Transferring Data from SAP to Other Systems
The Function module GUI_DOWNLOAD is used to download the data into presentation server and Dataset concepts to download the data into Application server. Sometimes we may require to download the data into other system (3rd Party System) from SAP.
In such scenarios, the concept of FTP commands comes into picture through which data (internal table data) from SAP can be transffered to other system.
This scenarios can be achieved through SAP using the FTP Commands which are available within SAP. The data gets transferred to other systems. The concept is that the internal table data will be placed as a file in other systems using the FTP concept.
The various FTP commands which are needed for this prupose are HTTP_SCRAMBLE, FTP_CONNECT, FTP_R3_TO_SERVER, FTP_DISCONNECT, RFC_CONNECTION_CLOSE function modules.
HTTP_SCRAMBLE: This is used to scramble the password provided into a format which is been recognized by SAP.
l_pwd = p_pwd.
l_slen = STRLEN(
l_pwd ).
CALL FUNCTION
‘HTTP_SCRAMBLE’
exporting
source = l_pwd
sourcelen = l_slen
key = c_key
importing
destination = l_pwd.
FTP_CONNECT :
This is used to connect to other system from SAP with the help of Userid & amp;
scrambled password & Host string & destination (default ‘SAPFTP’).
* To Connect to the Server using FTP
CALL FUNCTION ‘FTP_CONNECT’
EXPORTING
user = p_user
password = l_pwd
host = p_host
rfc_destination = c_dest
IMPORTING
handle = w_hdl
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
FTP_R3_TO_SERVERThis is used to transfer the
internal table data as a file to other system in the character mode.
CALL FUNCTION ‘FTP_R3_TO_SERVER’
EXPORTING
handle = w_hdl
fname =
character_mode = ‘X’
TABLES
text =
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING invalid_output_file.
ENDIF.
FTP_DISCONNECT: This is used to disconnect the
connection between SAP and other system.
* To disconnect the FTP
CALL FUNCTION ‘FTP_DISCONNECT’
EXPORTING
handle = w_hdl.
RFC_CONNECTION_CLOSE: This is used to disconnect the RFC connection between SAP and other system.
CALL FUNCTION ‘RFC_CONNECTION_CLOSE’
EXPORTING
destination = c_dest
EXCEPTIONS
OTHERS = 1.
New NetWeaver Information at SAP.com
Very Helpfull