Application Development 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: 

ftp_command

Former Member
0 Kudos
153

hello,

i want to transfer the content of my file in the program to remote server how it should be done using FTP command. and what are the Commands to be passed to FTP_Connect Function MOdule .

chhers

2 REPLIES 2

Former Member
0 Kudos
100

Use RSFTP002 and RSFTP004.

That will solve.

Thanks & Regards,

Ankur

0 Kudos
100

Hi,

check this code...

REPORT ztest_ftp.
SELECTION-SCREEN BEGIN OF BLOCK FRM_FILES WITH FRAME TITLE TEXT-001.
PARAMETERS: HOST(64) TYPE C LOWER CASE OBLIGATORY,
            FTPCMD(10) TYPE C LOWER CASE OBLIGATORY,
            SOURCE(128) TYPE C LOWER CASE,
            TARGET(128) TYPE C LOWER CASE.
SELECTION-SCREEN ULINE.
PARAMETERS: USER(12) TYPE C LOWER CASE,
            PWD(20) TYPE C LOWER CASE.
SELECTION-SCREEN END OF BLOCK FRM_FILES.

DATA: COUNT    TYPE I VALUE 1,
      CMD1(266) TYPE C,
      DIRCHG(131) TYPE C,
*     user(12) TYPE c,
*      pwd(20) TYPE c,
*      cmd2(80) TYPE c,
      DEST LIKE RFCDES-RFCDEST VALUE 'ZSAPFTP'.

DATA: HDL TYPE I,
      INDX TYPE I,
      KEY TYPE I VALUE 26101957,
      DSTLEN TYPE I,
      TXT(80) TYPE C.

DATA: C1(4) TYPE C,
      C2(4) TYPE C,
      PERCENT TYPE I.

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

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF SCREEN-NAME(3) = 'PWD'.
      MOVE '1' TO SCREEN-INVISIBLE.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.

START-OF-SELECTION.

  CONCATENATE FTPCMD SOURCE TARGET INTO CMD1 SEPARATED BY SPACE.

  IF USER = SPACE.
    USER = 'ftpuser'.
    PWD = 'xfer2u'.
  ENDIF.

  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 = DEST
       IMPORTING
            HANDLE          = HDL.
  CALL FUNCTION 'FTP_COMMAND'
       EXPORTING
            HANDLE  = HDL
            COMMAND = 'prompt'
       TABLES
            DATA    = RESULT.

  INDX = 0.
  WRITE AT / TEXT-001. WRITE INDX. INDX = INDX + 1.
  WRITE AT / CMD1.

  WRITE INDX TO C1. WRITE COUNT TO C2.
  CONCATENATE 'FTP: ' C1 ' from ' C2 INTO TXT.
  PERCENT = INDX * 100 / COUNT.

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
            PERCENTAGE = PERCENT
            TEXT       = TXT.


  CALL FUNCTION 'FTP_COMMAND'
       EXPORTING
            HANDLE        = HDL
            COMMAND       = CMD1
*            verify        = 'Y'
       TABLES
            DATA          = RESULT
       EXCEPTIONS
            TCPIP_ERROR   = 1
            COMMAND_ERROR = 2.

  LOOP AT RESULT.
    WRITE AT / RESULT-LINE.
  ENDLOOP.
  REFRESH RESULT.

  CALL FUNCTION 'FTP_DISCONNECT'
       EXPORTING
            HANDLE = HDL.

regards

vijay