ABAP Program of FTP Function Module

A sample ABAP program for understanding how to program with FTP function Module in ABAP.

FUNCTION Y_FTP.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(USER)
*" VALUE(PWD)
*" VALUE(HOST)
*" TABLES
*" COMMANDS
*" EXCEPTIONS
*" NO_SUCH_FILE
*"----------------------------------------------------------------------

DATA: W_USER(12) TYPE C ,
W_PWD(20) TYPE C ,
W_HOST(64) TYPE C.

DATA: HDL TYPE I,
KEY TYPE I VALUE 26101957,
DSTLEN TYPE I.

DATA: BEGIN OF RESULT OCCURS 0,
LINE(100) TYPE C,
END OF RESULT.

DESCRIBE FIELD PWD LENGTH DSTLEN.

CALL 'AB_RFC_X_SCRAMBLE_STRING'
ID 'SOURCE' FIELD PWD ID 'KEY' FIELD KEY
ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD PWD
ID 'DSTLEN' FIELD DSTLEN.

CALL FUNCTION 'FTP_CONNECT'
EXPORTING
USER = USER
PASSWORD = PWD
HOST = HOST
RFC_DESTINATION = 'SAPFTP'
IMPORTING
HANDLE = HDL.

LOOP AT COMMANDS.
IF COMMANDS NE ' '.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = HDL
COMMAND = COMMANDS
TABLES
DATA = RESULT
EXCEPTIONS
COMMAND_ERROR = 1
TCPIP_ERROR = 2.
LOOP AT RESULT.
WRITE AT / RESULT-LINE.
IF RESULT CS 'error'.
RAISE NO_SUCH_FILE.
ENDIF.
ENDLOOP.
REFRESH RESULT.
ENDIF.
ENDLOOP.

CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
HANDLE = HDL.




ENDFUNCTION.

Most readed SAP Tutorials

Latest Added SAP documents

Custom Search
ABAP Tutorials ABAP Syntax BAPI SAP Jobs SAP Glossary SAP Netweaver SAP XI SAP Download SAP Interview questions

Complete SAP Study materials | SAP JOBS | PDF Tutorials   List of SAP Companies India

Google-Translate-Chinese (Simplified) BETA Google-Translate-English to French Google-Translate-English to German Google-Translate-English to Italian Google-Translate-English to Japanese BETA Google-Translate-English to Korean BETA Google-Translate-English to Russian BETA Google-Translate-English to Spanish

All of the product names here are trademarks of their respective companies. The site sapbrainsonline.com no way affiliated with SAP AG. Use information on this site at your own risk. Information furnished in the site is collected from various sites and posts from users. This site does not host any files on its server. If any compliants about the posts please contact us at sapbrain.support@gmail.com

Sitemap
web counter