Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error in ftp file transfer

Former Member
0 Likes
1,999

Hi All,

  I am trying to populate pdf from sap server to different server. when  i am trying to open that pdf in target system , getting the error " root object is missing or invalid "  here is my code :

CALL FUNCTION 'HTTP_SCRAMBLE'

     EXPORTING

       source      = p_pwd

       sourcelen   = lv_pwd_len

       key         = lc_key

     IMPORTING

       destination = p_pwd.

* connect to FTP server

   CALL FUNCTION 'FTP_CONNECT'

     EXPORTING

       user                   = p_user

       password               = p_pwd

*   ACCOUNT                =

       host                   = p_ip

       rfc_destination        = lc_rfc_dest

*   GATEWAY_USER           =

*   GATEWAY_PASSWORD       =

*   GATEWAY_HOST           =

    IMPORTING

      handle                 = lv_handle

* EXCEPTIONS

*   NOT_CONNECTED          = 1

*   OTHERS                 = 2

             .

   IF sy-subrc <> 0.

     l_fail = 'X'.

     WRITE : / 'FTP Connection failed'.

     EXIT.

   ENDIF.

   CALL FUNCTION 'FTP_COMMAND'

     EXPORTING

      handle                = lv_handle

       command               = 'cd /Payadvice         '"lv_cmd

       compress              = 'N'

*   RFC_DESTINATION       = lc_rfc_dest     "sapftpa

*   VERIFY                =

* IMPORTING

*   FILESIZE              =

*   FILEDATE              =

*   FILETIME              =

     TABLES

       data                  = it_output

    EXCEPTIONS

      tcpip_error           = 1

      command_error         = 2

      data_error            = 3

      OTHERS                = 4

             .

   IF sy-subrc NE 0.

     l_fail = 'X'.

     EXIT.

   ENDIF.

   CLEAR l_fail.

CALL FUNCTION 'FTP_COMMAND'

   EXPORTING

    HANDLE                = lv_handle

     command               = 'binary'

   tables

     data                  = it_lines

  EXCEPTIONS

    TCPIP_ERROR           = 1

    COMMAND_ERROR         = 2

    DATA_ERROR            = 3

    OTHERS                = 4

           .

IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.

   CLEAR wa_result.

   CONCATENATE  v_name '.pdf' INTO wa_result.

   DATA: l_count TYPE i.

   CALL FUNCTION 'FTP_R3_TO_SERVER'

     EXPORTING

       handle         = lv_handle

       fname          = wa_result

*      blob_length    = l_count

       character_mode = 'X'

     TABLES

*       BLOB           =

       text           = it_lines"it_tmp

     EXCEPTIONS

       tcpip_error    = 1

       command_error  = 2

       data_error     = 3

       OTHERS         = 4.

   IF sy-subrc NE 0.

     l_fail = 'X'.

     EXIT.

     endif.

   clear insfile.

     CONCATENATE 'put' wa_result INTO insfile SEPARATED BY space.

     CALL FUNCTION 'FTP_COMMAND'

       EXPORTING

        HANDLE                = lv_handle

         command               = insfile

*       COMPRESS              = 'N'

*       RFC_DESTINATION       =

*       VERIFY                =

*     IMPORTING

*       FILESIZE              =

*       FILEDATE              =

*       FILETIME              =

       tables

         data                  = it_lines

      EXCEPTIONS

        TCPIP_ERROR           = 1

        COMMAND_ERROR         = 2

        DATA_ERROR            = 3

        OTHERS                = 4 .

   IF sy-subrc NE 0.

     l_fail = 'X'.

     EXIT.

   ELSE.

     UPDATE zwork_to_sapvenp SET flag1 = 'X' WHERE inv_act_doc = lv_name.

     IF sy-subrc = 0.

     ENDIF.

   ENDIF.

*ftp disconnect

   CALL FUNCTION 'FTP_DISCONNECT'

     EXPORTING

       handle = lv_handle.

   CALL FUNCTION 'RFC_CONNECTION_CLOSE'

    EXPORTING

      destination                = lc_rfc_dest

*   TASKNAME                   =

* EXCEPTIONS

*   DESTINATION_NOT_OPEN       = 1

*   OTHERS                     = 2

             .

   IF sy-subrc <> 0.

* Implement suitable error handling here

   ENDIF.

here  "put" command is not working properly getting command error .  please help.

4 REPLIES 4
Read only

former_member201275
Active Contributor
0 Likes
1,267

Please post the data declaration for your variables: insfile & it_lines.

Also, there is a sap standard program RSFTP003 which is a demo for this PUT command so maybe go thru this code and see how it is done.

Hope this helps.

Read only

0 Likes
1,267

it_lines    TYPE STANDARD TABLE OF tline WITH HEADER LINE.

   insfile          TYPE text ,

Read only

0 Likes
1,267

I think something wrong with your declarations, try same as std program i sent you.

Read only

0 Likes
1,267

I tried as the standard prog but still put command is not working.