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

FTP open file

Former Member
0 Likes
2,073

Hi,

I have to open a file from a server and use the FM CALL FUNCTION 'FTP_COMMAND' to reach to directory, anyone know the command ftp to open the file in directory.

Thanks and Regards,

Eduardo Paiva

1 ACCEPTED SOLUTION
Read only

RahulKeshav
Active Contributor
0 Likes
1,658

Hi,

you can reach to FTP server..i dont think there is any command avaliable to open the file.

if you want to edit that file then jst copy it, edit it and dump it back to the ftp server.

Thnkx

Rahul

Hi,

you can reach to FTP server..i dont think there is any command avaliable to open the file.

if you want to edit that file then jst copy it, edit it and dump it back to the ftp server.

Thnkx

Rahul

8 REPLIES 8
Read only

RahulKeshav
Active Contributor
0 Likes
1,659

Hi,

you can reach to FTP server..i dont think there is any command avaliable to open the file.

if you want to edit that file then jst copy it, edit it and dump it back to the ftp server.

Thnkx

Rahul

Read only

Former Member
0 Likes
1,658

Hi,

you can use this code to do the FTP, feild UNIXCOMMAND will hold the name of the UNIX command from sm69. This command is linked to the shell script you create. You can use this link to show you know to create the FTP shell script.

http://datadictionary.blogspot.com/2006/08/unix-shell-script-to-transfer-files.html

The shell script has to be located in the appropriate run folder on UNIX by your basis team so that the script runs.

** These commands must be set up in transaction SM69 first **
  DATA: STATUS LIKE BTCXP3-EXITSTAT.

  DATA: BEGIN OF EXEC_PROTOCOL OCCURS 0.
          INCLUDE STRUCTURE BTCXPM.
  DATA: END OF EXEC_PROTOCOL.

  CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
       EXPORTING
            COMMANDNAME                   = UNIXCOMMAND
            TERMINATIONWAIT               = 'X'
            ADDITIONAL_PARAMETERS         = UNIXPARAMS
       IMPORTING
            STATUS                        = STATUS
       TABLES
            EXEC_PROTOCOL                 = EXEC_PROTOCOL
       EXCEPTIONS
            NO_PERMISSION                 = 1
            COMMAND_NOT_FOUND             = 2
            PARAMETERS_TOO_LONG           = 3
            SECURITY_RISK                 = 4
            WRONG_CHECK_CALL_INTERFACE    = 5
            PROGRAM_START_ERROR           = 6
            PROGRAM_TERMINATION_ERROR     = 7
            X_ERROR                       = 8
            PARAMETER_EXPECTED            = 9
            TOO_MANY_PARAMETERS           = 10
            ILLEGAL_COMMAND               = 11
            WRONG_ASYNCHRONOUS_PARAMETERS = 12
            CANT_ENQ_TBTCO_ENTRY          = 13
            JOBCOUNT_GENERATION_ERROR     = 14
            OTHERS                        = 15.


  IF SY-SUBRC NE 0 OR STATUS = 'E'.
    RAISE NOTEXECUTED.
  ENDIF.

thanks.

JB

Read only

Former Member
0 Likes
1,658

Hi,

The server that i have to reach isn't a server SAP, i can use FM CALL FUNCTION 'SXPG_COMMAND_EXECUTE' ?

I have a user FTP to logon into the server and with this function a can't logon put the user and password.

Thanks and Regards

Eduardo Paiva

Read only

venkat_o
Active Contributor
0 Likes
1,658

Hi, <li>Command should be GET . <li>Try this way.


 "Call FTP_CONNECT function module to open 
 DATA:cmd(120) type C.
 cmd = 'get d:\temp\test.txt'. "GET is command to Copy a file from the remote system to the local system
 CALL FUNCTION 'FTP_COMMAND'
    EXPORTING
      handle        = mi_handle
      command       = cmd
    TABLES
      data          = it_data
    EXCEPTIONS
      tcpip_error   = 1
      command_error = 2
      data_error    = 3
      OTHERS        = 4.
 "Call FTP_DISCONNECT to close FTP connection
Thanks Venkat.O

Read only

Former Member
0 Likes
1,658

You can do this using the functions below:

CALL FUNCTION 'FTP_CONNECT' EXPORTING user = user password = pass host = host rfc_destination = p_rfc IMPORTING handle = ftphandle EXCEPTIONS not_connected = 1 OTHERS = 2. CALL FUNCTION 'FTP_COMMAND' EXPORTING handle = ftphandle command = 'set passive on' TABLES data = lines EXCEPTIONS tcpip_error = 1 command_error = 2 data_error = 3. CALL FUNCTION 'FTP_SERVER_TO_R3' EXPORTING handle = ftphandle fname = gt_fname-fname IMPORTING blob_length = blen TABLES blob = blob_orj. CALL FUNCTION 'FTP_DISCONNECT' EXPORTING handle = ftphandle. CLEAR ftphandle.

Read only

Former Member
0 Likes
1,658

{

}
Code Here
{

}

Read only

Former Member
0 Likes
1,658
 try 33 
Read only

Former Member
0 Likes
1,658
 last
try