Skip to Content

<p>The Function module <b>GUI_DOWNLOAD</b> is used to download the data into <b>presentation server</b> and <b>Dataset</b> concepts to download the data into <b>Application server</b>. Sometimes we may require to download the data into other system (<b>3rd Party System</b>) from SAP.

In such scenarios, the concept of <b>FTP</b> commands comes into picture through which data (<b>internal table data</b>) from SAP can be transffered to other system.</p>

<p>This scenarios can be achieved through SAP using the <b>FTP</b> 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.</p>

<p>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.</p>

<p><b>HTTP_SCRAMBLE</b>: This is used to scramble the password provided into a format which is been recognized by SAP.</p>

<p>l_pwd = p_pwd.</p>

<p>l_slen = STRLEN(

l_pwd ).</p>

<p>CALL FUNCTION

‘HTTP_SCRAMBLE'</p>

<p>exporting</p>

<p>source = l_pwd</p>

<p>sourcelen = l_slen</p>

<p>key = c_key</p>

<p>importing</p>

<p>destination = l_pwd.</p>

<p><b>FTP_CONNECT</b> :

This is used to connect to other system from SAP with the help of Userid & amp;

scrambled password & Host string & destination (default ‘SAPFTP’).</p>

<p>* To Connect to the Server using FTP</p>

<p>CALL FUNCTION ‘FTP_CONNECT'</p>

<p>EXPORTING</p>

<p>user = p_user</p>

<p>password = l_pwd</p>

<p>host = p_host</p>

<p>rfc_destination = c_dest</p>

<p>IMPORTING</p>

<p>handle = w_hdl</p>

<p>EXCEPTIONS</p>

<p>OTHERS = 1.</p>

<p>IF sy-subrc <> 0.</p>

<p>MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno</p>

<p>WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.</p>

<p>ENDIF.</p>

<p><b>FTP_R3_TO_SERVER</b>This is used to transfer the

internal table data as a file to other system in the character mode.</p>

<p>CALL FUNCTION ‘FTP_R3_TO_SERVER'</p>

<p>EXPORTING</p>

<p>handle = w_hdl</p>

<p>fname = <file path of destination system></p>

<p>character_mode = ‘X'</p>

<p>TABLES</p>

<p>text = <internal table data></p>

<p>EXCEPTIONS</p>

<p>tcpip_error = 1</p>

<p>command_error = 2</p>

<p>data_error = 3</p>

<p>OTHERS = 4.</p>

<p>IF sy-subrc <> 0.</p>

<p>MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno</p>

<p>WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4</p>

<p>RAISING invalid_output_file.</p>

<p>ENDIF.</p>

<p><b>FTP_DISCONNECT:</b> This is used to disconnect the

connection between SAP and other system.</p>

<p>* To disconnect the FTP</p>

<p>CALL FUNCTION ‘FTP_DISCONNECT'</p>

<p>EXPORTING</p>

<p>handle = w_hdl.</p>

<p><b>RFC_CONNECTION_CLOSE</b>: This is used to disconnect the RFC connection between SAP and other system.</p>

<p>CALL FUNCTION ‘RFC_CONNECTION_CLOSE'</p>

<p>EXPORTING</p>

<p>destination = c_dest</p>

<p>EXCEPTIONS</p>

<p>OTHERS = 1.</p>

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Rashid Javed
    Brief and to the point coverage of FTP function modules. Just want to add that you should also mention FTP_COMMAND function module. This comes in handy if after connecting to FTP server, you need to change directories or transfer mode etc.
    I hope in your future blogs you will cover other methods also such as calling a script from R/3 using SM49 commands or RFC_ECECUTE function module. Also with the introduction of SAP WEB AS we can use other techniques such as web services, http connection etc.

    Cheers

    (0) 
  2. Dagfinn Parnas
    Nice to see you start blogging.

    It would be someone compare the different methods available(FTP, XI, ETL tools,++)  for exporting data to non-SAP systems.

    (0) 
      1. Michael Nicholls
        Hi Dagfinn

        One of the reasons that FTP and other non-XI (whoops non-PI) mechanisms are often not used is because it can be difficult to handle problems. For example, if I kick off an FTP command to a remote site that is down, then I need to a) handle the error gracefully and b) remember to send it later on and c) probably tell someone.

        Once you start making use of a guaranteed delivery mechanism, such as XI, the sending application just has to kick off a generic send and XI will take care of error handling, trying multiple times etc.

        Cheers

        (0) 
        1. Anonymous
          Yes that is true. If remote system is not online the FTP fails and a error is shown. One can check the same (the people monitoring the system) and can re-execute the same once the system is online. This is one of the problem.
          (0) 

Leave a Reply