<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FTP_R3_TO_SERVER error  issue command error 2 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818102#M2026053</link>
    <description>&lt;P&gt;Thanks alot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2024 17:42:18 GMT</pubDate>
    <dc:creator>pashasapcha</dc:creator>
    <dc:date>2024-01-04T17:42:18Z</dc:date>
    <item>
      <title>FTP_R3_TO_SERVER error  issue command error 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818097#M2026048</link>
      <description>&lt;P&gt;Hi, gurus, &lt;/P&gt;
  &lt;P&gt;I am using the STANDARD FM FTP_R3_TO_SERVER and I am getting command error and data is not getting pushed. Kindly please help as it is&lt;/P&gt;
  &lt;P&gt;in production. Thanks in advance.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt; SET EXTENDED CHECK OFF.&amp;lt;br&amp;gt; lv_slen = strlen( lv_pwd ).&lt;/CODE&gt;&lt;/PRE&gt; 
  &lt;PRE&gt;&lt;CODE&gt; CALL FUNCTION 'HTTP_SCRAMBLE'
  &amp;lt;br&amp;gt; EXPORTING
  &amp;lt;br&amp;gt; source = lv_pwd
  &amp;lt;br&amp;gt; sourcelen = lv_slen
  &amp;lt;br&amp;gt; key = lv_key
  &amp;lt;br&amp;gt; IMPORTING
  &amp;lt;br&amp;gt; destination = lv_pwd.
  &amp;lt;br&amp;gt; CALL FUNCTION 'FTP_CONNECT'
  &amp;lt;br&amp;gt; EXPORTING
  &amp;lt;br&amp;gt; user = lv_user
  &amp;lt;br&amp;gt; password = lv_pwd
  &amp;lt;br&amp;gt; host = lv_host
  &amp;lt;br&amp;gt; rfc_destination = lv_dest
  &amp;lt;br&amp;gt; IMPORTING
  &amp;lt;br&amp;gt; handle = lv_hdl
  &amp;lt;br&amp;gt; EXCEPTIONS
  &amp;lt;br&amp;gt; not_connected = 1.
  &amp;lt;br&amp;gt; IF sy-subrc IS INITIAL.
  &amp;lt;br&amp;gt; IF lv_cmd1 NE ' '.
  &amp;lt;br&amp;gt; CONCATENATE 'cd' lv_val2 INTO lv_cmd1 SEPARATED BY space.
  &amp;lt;br&amp;gt; CALL FUNCTION 'FTP_COMMAND'
  &amp;lt;br&amp;gt; EXPORTING
  &amp;lt;br&amp;gt; handle = lv_hdl
  &amp;lt;br&amp;gt; command = lv_cmd1
  &amp;lt;br&amp;gt; compress = lv_compress
  &amp;lt;br&amp;gt; TABLES
  &amp;lt;br&amp;gt; data = lt_text1
  &amp;lt;br&amp;gt; EXCEPTIONS
  &amp;lt;br&amp;gt; command_error = 1
  &amp;lt;br&amp;gt; tcpip_error = 2.
  &amp;lt;br&amp;gt; LOOP AT result.
  &amp;lt;br&amp;gt; WRITE AT / result-line.
  &amp;lt;br&amp;gt; ENDLOOP.
  &amp;lt;br&amp;gt; REFRESH result.
  &amp;lt;br&amp;gt; ENDIF.
  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;* READ TABLE it_sales_data INTO ls_sales_data INDEX 1.
  &amp;lt;br&amp;gt; LOOP AT it_sales_data INTO ls_sales_data WHERE supp_gstin IS NOT INITIAL.
  &amp;lt;br&amp;gt; IF ls_sales_data-supp_gstin IS NOT INITIAL.
  &amp;lt;br&amp;gt; EXIT.
  &amp;lt;br&amp;gt; ENDIF.
  &amp;lt;br&amp;gt; ENDLOOP.
  &amp;lt;br&amp;gt; IF ls_sales_data-supp_gstin IS NOT INITIAL.
  &amp;lt;br&amp;gt; CONCATENATE sy-datum sy-uzeit INTO lv_time.
  &amp;lt;br&amp;gt; IF sy-sysid = 'PDR' OR sy-sysid = 'PQR'.
  &amp;lt;br&amp;gt; CONCATENATE '/GSTR1/TEST/INPUT/UNPROCESSED/GSTR1_ALL_'
  &amp;lt;br&amp;gt; ls_sales_data-supp_gstin '_' lv_time '_62a9726934d95e258be1' '.csv' INTO lv_file.
  &amp;lt;br&amp;gt; ELSEIF sy-sysid = 'PPR'.
  &amp;lt;br&amp;gt; CONCATENATE '/GSTR1/PRODUCTION/INPUT/UNPROCESSED/GSTR1_ALL_'
  &amp;lt;br&amp;gt; ls_sales_data-supp_gstin '_' lv_time '_62a9726934d95e258be1' '.csv' INTO lv_file.
  &amp;lt;br&amp;gt; ENDIF.
  &amp;lt;br&amp;gt;* CONCATENATE 'GSTR1_ALL_' ls_sales_data-supp_gstin '_' lv_time '_62a9726934dca95e258be17d' '.csv' INTO lv_file.
  &amp;lt;br&amp;gt; CALL FUNCTION 'FTP_R3_TO_SERVER'
  &amp;lt;br&amp;gt; EXPORTING
  &amp;lt;br&amp;gt; handle = lv_hdl
  &amp;lt;br&amp;gt; fname = lv_file
  &amp;lt;br&amp;gt;* BLOB_LENGTH =
  &amp;lt;br&amp;gt; character_mode = 'X'
  &amp;lt;br&amp;gt; TABLES
  &amp;lt;br&amp;gt;* BLOB =
  &amp;lt;br&amp;gt; text = lt_text
  &amp;lt;br&amp;gt; EXCEPTIONS
  &amp;lt;br&amp;gt; tcpip_error = 1
  &amp;lt;br&amp;gt; command_error = 2
  &amp;lt;br&amp;gt; data_error = 3
  &amp;lt;br&amp;gt; OTHERS = 4.
  
********************************facing error sy-subrc = 2 command error*************************************&amp;lt;br&amp;gt; IF sy-subrc &amp;lt;&amp;gt; 0.&amp;lt;br&amp;gt;* Implement suitable error handling here&lt;/CODE&gt;&lt;/PRE&gt; 
  &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt; ELSE.&lt;BR /&gt; CLEAR lt_staging_data.&lt;BR /&gt; LOOP AT it_sales_data INTO ls_sales_data.&lt;BR /&gt; MOVE-CORRESPONDING ls_sales_data TO ls_staging_data.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;BR /&gt;
  &lt;PRE&gt;&lt;CODE&gt; READ TABLE lt_header INTO ls_header WITH KEY bukrs = ls_staging_data-bukrs&lt;BR /&gt; belnr = ls_staging_data-belnr&lt;BR /&gt; gjahr = ls_staging_data-gjahr.&lt;BR /&gt; IF sy-subrc IS INITIAL.&lt;BR /&gt; ls_staging_data-invoice_value = ls_header-invoice_value.&lt;BR /&gt; ls_staging_data-taxable_value = ls_header-taxable_value.&lt;BR /&gt; ls_staging_data-igst_amount = ls_header-igst_amount.&lt;BR /&gt; ls_staging_data-cgst_amount = ls_header-cgst_amount.&lt;BR /&gt; ls_staging_data-sgst_amount = ls_header-sgst_amount.&lt;BR /&gt; ls_staging_data-cess_amount = ls_header-cess_amount.&lt;BR /&gt; ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;BR /&gt;
  &lt;PRE&gt;&lt;CODE&gt; ls_staging_data-ftp_status = 'Y'.&lt;BR /&gt; ls_staging_data-valid_flag = 'Y'.&lt;BR /&gt; ls_staging_data-filename = lv_file.&lt;BR /&gt; ls_staging_data-ftp_date = sy-datum.&lt;BR /&gt; ls_staging_data-ernam = sy-uname.&lt;BR /&gt; ls_staging_data-erdat = sy-datum.&lt;BR /&gt; CLEAR:ls_staging_data-response_date,ls_staging_data-reverse_filename,&lt;BR /&gt; ls_staging_data-aenam, ls_staging_data-aedat.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;BR /&gt;
  &lt;PRE&gt;&lt;CODE&gt; APPEND ls_staging_data TO lt_staging_data.&lt;BR /&gt; CLEAR ls_staging_data.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;BR /&gt;* Item details
  &lt;BR /&gt; MOVE-CORRESPONDING ls_sales_data TO ls_staging_itm.
  &lt;BR /&gt; ls_staging_itm-ernam = sy-uname.
  &lt;BR /&gt; ls_staging_itm-erdat = sy-datum.
  &lt;BR /&gt; CLEAR:ls_staging_itm-aenam,ls_staging_itm-aedat, ls_staging_itm-error.
  &lt;BR /&gt; APPEND ls_staging_itm TO lt_staging_itm.
  &lt;BR /&gt; CLEAR ls_staging_itm.
  &lt;BR /&gt;
  &lt;BR /&gt; ENDLOOP.
  &lt;BR /&gt;
  &lt;BR /&gt; IF lt_staging_data IS NOT INITIAL.
  &lt;BR /&gt; MODIFY ztreco_sales_det FROM TABLE lt_staging_data.
  &lt;BR /&gt; MODIFY ztreco_sales_itm FROM TABLE lt_staging_itm.
  &lt;BR /&gt; ENDIF.
  &lt;BR /&gt; et_staging_data = lt_staging_data.
  &lt;BR /&gt; et_staging_itm = lt_staging_itm.
  &lt;BR /&gt;
  &lt;BR /&gt;
  &lt;BR /&gt; ENDIF. 
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; CALL FUNCTION 'FTP_DISCONNECT'&amp;lt;br&amp;gt; EXPORTING&amp;lt;br&amp;gt; handle = lv_hdl.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;BR /&gt; CALL FUNCTION 'RFC_CONNECTION_CLOSE' &lt;BR /&gt; EXPORTING &lt;BR /&gt; destination = lv_dest &lt;BR /&gt; EXCEPTIONS &lt;BR /&gt; OTHERS = 1. &lt;BR /&gt; ENDIF. &lt;BR /&gt; &lt;BR /&gt; ELSE. &lt;BR /&gt; &lt;BR /&gt; MESSAGE 'FTP connection error' TYPE 'I'. &lt;BR /&gt; &lt;BR /&gt; ENDIF. &lt;BR /&gt;* ENDIF. &lt;BR /&gt; ENDIF. &lt;BR /&gt;* &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;ENDFUNCTION.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 14:19:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818097#M2026048</guid>
      <dc:creator>pashasapcha</dc:creator>
      <dc:date>2024-01-04T14:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: FTP_R3_TO_SERVER error  issue command error 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818098#M2026049</link>
      <description>&lt;P&gt;Plz help  me as it is in production.&lt;BR /&gt;what possible r the reasons for few documents getting transferred and few others not getting transferred.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 14:44:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818098#M2026049</guid>
      <dc:creator>pashasapcha</dc:creator>
      <dc:date>2024-01-04T14:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: FTP_R3_TO_SERVER error  issue command error 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818099#M2026050</link>
      <description>&lt;P&gt;Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 15:12:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818099#M2026050</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2024-01-04T15:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: FTP_R3_TO_SERVER error  issue command error 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818100#M2026051</link>
      <description>&lt;P&gt;Please edit your question (Actions&amp;gt;Edit), select your code and press the button [CODE], which makes the code appear colored/indented, it'll be easier for people to look at it. Thanks! &lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 15:13:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818100#M2026051</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2024-01-04T15:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: FTP_R3_TO_SERVER error  issue command error 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818101#M2026052</link>
      <description>&lt;P&gt;Now it's worse, you really have a problem with editing.&lt;/P&gt;&lt;P&gt;Here is the code well formatted to help anybody who wants to answer.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SET EXTENDED CHECK OFF.
lv_slen = strlen( lv_pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
  EXPORTING source      = lv_pwd
            sourcelen   = lv_slen
            key         = lv_key
  IMPORTING destination = lv_pwd.
CALL FUNCTION 'FTP_CONNECT'
  EXPORTING  user            = lv_user
             password        = lv_pwd
             host            = lv_host
             rfc_destination = lv_dest
  IMPORTING  handle          = lv_hdl
  EXCEPTIONS not_connected   = 1.
IF sy-subrc IS INITIAL.
  IF lv_cmd1 NE ' '.
    CONCATENATE 'cd' lv_val2 INTO lv_cmd1 SEPARATED BY space.
    CALL FUNCTION 'FTP_COMMAND'
      EXPORTING  handle        = lv_hdl
                 command       = lv_cmd1
                 compress      = lv_compress
      TABLES     data          = lt_text1
      EXCEPTIONS command_error = 1
                 tcpip_error   = 2.
    LOOP AT result.
      WRITE AT / result-line.
    ENDLOOP.
    REFRESH result.
  ENDIF.
  " read table it_sales_data into ls_sales_data index 1.
  LOOP AT it_sales_data INTO ls_sales_data WHERE supp_gstin IS NOT INITIAL.
    IF ls_sales_data-supp_gstin IS NOT INITIAL.
      EXIT.
    ENDIF.
  ENDLOOP.
  IF ls_sales_data-supp_gstin IS NOT INITIAL.
    CONCATENATE sy-datum sy-uzeit INTO lv_time.
    IF sy-sysid = 'PDR' OR sy-sysid = 'PQR'.
      CONCATENATE '/GSTR1/TEST/INPUT/UNPROCESSED/GSTR1_ALL_'
      ls_sales_data-supp_gstin '_' lv_time '_62a9726934d95e258be1' '.csv' INTO lv_file.
    ELSEIF sy-sysid = 'PPR'.
      CONCATENATE '/GSTR1/PRODUCTION/INPUT/UNPROCESSED/GSTR1_ALL_'
      ls_sales_data-supp_gstin '_' lv_time '_62a9726934d95e258be1' '.csv' INTO lv_file.
    ENDIF.
    CALL FUNCTION 'FTP_R3_TO_SERVER'
      EXPORTING  handle         = lv_hdl
                 fname          = lv_file
                 character_mode = 'X'
      TABLES     text           = lt_text
      EXCEPTIONS tcpip_error    = 1
                 command_error  = 2
                 data_error     = 3
                 OTHERS         = 4.

    " facing error sy-subrc = 2 command error************************************* 
    IF sy-subrc &amp;lt;&amp;gt; 0.
      " Implement suitable error handling here

    ELSE.
      CLEAR lt_staging_data.
      LOOP AT it_sales_data INTO ls_sales_data.
        MOVE-CORRESPONDING ls_sales_data TO ls_staging_data.
        READ TABLE lt_header INTO ls_header WITH KEY bukrs = ls_staging_data-bukrs
                                                     belnr = ls_staging_data-belnr
                                                     gjahr = ls_staging_data-gjahr.
        IF sy-subrc IS INITIAL.
          ls_staging_data-invoice_value = ls_header-invoice_value.
          ls_staging_data-taxable_value = ls_header-taxable_value.
          ls_staging_data-igst_amount   = ls_header-igst_amount.
          ls_staging_data-cgst_amount   = ls_header-cgst_amount.
          ls_staging_data-sgst_amount   = ls_header-sgst_amount.
          ls_staging_data-cess_amount   = ls_header-cess_amount.
        ENDIF.
        ls_staging_data-ftp_status = 'Y'.
        ls_staging_data-valid_flag = 'Y'.
        ls_staging_data-filename   = lv_file.
        ls_staging_data-ftp_date   = sy-datum.
        ls_staging_data-ernam      = sy-uname.
        ls_staging_data-erdat      = sy-datum.
        CLEAR:ls_staging_data-response_date,ls_staging_data-reverse_filename,
        ls_staging_data-aenam, ls_staging_data-aedat.
        APPEND ls_staging_data TO lt_staging_data.
        CLEAR ls_staging_data.
        " Item details
        MOVE-CORRESPONDING ls_sales_data TO ls_staging_itm.
        ls_staging_itm-ernam = sy-uname.
        ls_staging_itm-erdat = sy-datum.
        CLEAR:ls_staging_itm-aenam,ls_staging_itm-aedat, ls_staging_itm-error.
        APPEND ls_staging_itm TO lt_staging_itm.
        CLEAR ls_staging_itm.

      ENDLOOP.

      IF lt_staging_data IS NOT INITIAL.
        MODIFY ztreco_sales_det FROM TABLE lt_staging_data.
        MODIFY ztreco_sales_itm FROM TABLE lt_staging_itm.
      ENDIF.
      et_staging_data = lt_staging_data.
      et_staging_itm = lt_staging_itm.

    ENDIF.
    CALL FUNCTION 'FTP_DISCONNECT'
      EXPORTING handle = lv_hdl.

    CALL FUNCTION 'RFC_CONNECTION_CLOSE'
      EXPORTING  destination = lv_dest
      EXCEPTIONS OTHERS      = 1.
  ENDIF.

ELSE.

  MESSAGE 'FTP connection error' TYPE 'I'.

ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jan 2024 17:40:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818101#M2026052</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2024-01-04T17:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: FTP_R3_TO_SERVER error  issue command error 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818102#M2026053</link>
      <description>&lt;P&gt;Thanks alot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 17:42:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/12818102#M2026053</guid>
      <dc:creator>pashasapcha</dc:creator>
      <dc:date>2024-01-04T17:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: FTP_R3_TO_SERVER error  issue command error 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/13742877#M2028752</link>
      <description>&lt;P&gt;any solution to this?&lt;BR /&gt;Background job getting failed with error - Invalid FTP handle&lt;BR /&gt;we have WINSCP in place, and Foreground is working fine.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 07:07:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/ftp-r3-to-server-error-issue-command-error-2/m-p/13742877#M2028752</guid>
      <dc:creator>Ajain</dc:creator>
      <dc:date>2024-06-26T07:07:16Z</dc:date>
    </item>
  </channel>
</rss>

