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 in ABAP

Former Member
0 Kudos
call function 'FTP_CONNECT'
  exporting
    user            = user
    password        = pwd
    host            = host
    rfc_destination = dest
  importing
    handle          = hdl.

<b>What is Handle ?</b>

 call function 'FTP_COMMAND'
    exporting
      handle        = hdl
      command       = cmd1
      compress      = compress
    tables
      data          = result
    exceptions
      command_error = 1
      tcpip_error   = 2.
  loop at result.
    write at / result-line.
  endloop.
  refresh result.

<b>What is result? Why do we display it?</b>

Could some one explain me exception handling. I am new to ABAP and dont quite understand how to call function modules. What does command_error = 1 and tcpip_error = 2 mean?

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

<b>Handle</b>

This handle is a pointer to an instance of FTP that we started via the FTP_CONNECT. So we get reconnected to the same FTP session with each command we issue.

<b>Result</b>

Depend on the comand your issued

<b>Exception</b>

Function modlure return an error code (in Abap, look at ERROR RAISING or RAISE)

You then check the value returned in sy-subrc.

<b>Documentation</b>

Look at this OSS <a href="https://service.sap.com/sap/support/notes/130106">Note 130106 - Using SAPFTP for data transfer</a>

Look at this Blog <a href="/people/thomas.jung3/blog/2004/11/15/performing-ftp-commands-from-abap FTP Commands From ABAP</a>

Regards

2 REPLIES 2

raymond_giuseppi
Active Contributor
0 Kudos

<b>Handle</b>

This handle is a pointer to an instance of FTP that we started via the FTP_CONNECT. So we get reconnected to the same FTP session with each command we issue.

<b>Result</b>

Depend on the comand your issued

<b>Exception</b>

Function modlure return an error code (in Abap, look at ERROR RAISING or RAISE)

You then check the value returned in sy-subrc.

<b>Documentation</b>

Look at this OSS <a href="https://service.sap.com/sap/support/notes/130106">Note 130106 - Using SAPFTP for data transfer</a>

Look at this Blog <a href="/people/thomas.jung3/blog/2004/11/15/performing-ftp-commands-from-abap FTP Commands From ABAP</a>

Regards

Former Member
0 Kudos

Typically when you call a function module, you will see the section exceptions (not all function modules have these). These are error conditions raised within the logic of the function module. So for example, in the FTP_COMMAND function module you see that it is issuing two exceptions 'command_error' and 'tcpip_error'. These are just descriptive names for the errors. But the actual message may be transferred to the system variables SY-MSGVI, SY-MSGV2, etc. So after the call function, you will check for errors by adding the following lines.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

The 1, and 2 that you see in the exceptions is the non-zero number that you can assign for your own handling. This is the number that SY-SUBRC will be set to when that exception is raised. So I can also handle the errors as follows

CASE SY-SUBRC.

WHEN 1.

MESSAGE e208(00) WITH 'Invalid FTP command.'.

WHEN 2.

MESSAGE e208(00) WITH 'TCP-IP error, cannot connect'.

WHEN OTHERS.

ENDCASE.