메뉴 건너뛰기

SAP 한국 커뮤니티

FTP 호출 프로그램 예제

sapjoy 2014.11.28 09:43 조회 수 : 5619

report rsftp002.

parametersuser(30type lower case,
            pwd(30type lower case,
            host(64type lower case,
            cmd1(80type lower case,
            cmd2(80type lower case,
            cmd3(80type lower case,
            dest like rfcdes-rfcdest default 'SAPFTP',
            compress type default 'N'.

datahdl type i,
      key type value 26101957,
      slen type i.

databegin of result occurs 0,
      line(100type c,
      end of result.

set extended check off.
slen strlenpwd ).

AUTHORITY-CHECK OBJECT 'S_ADMI_FCD'
         ID 'S_ADMI_FCD'
         FIELD 'SFTP'.
IF sy-subrc <> 0.
  MESSAGE 'no_authorization' type 'E'.
  exit.
*     Keine Berechtigung zum Ändern der Aktivierung einer ID
ENDIF.

CALL FUNCTION 'HTTP_SCRAMBLE'
  exporting
    source      pwd
    sourcelen   slen
    key         key
  importing
    destination pwd.

call function 'FTP_CONNECT'
  exporting
    user            user
    password        pwd
    host            host
    rfc_destination dest
  importing
    handle          hdl.

if cmd1 ne ' '.
  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.
endif.

if cmd2 ne ' '.
  call function 'FTP_COMMAND'
    exporting
      handle        hdl
      command       cmd2
    tables
      data          result
    exceptions
      command_error 1
      tcpip_error   2.
  loop at result.
    write at / result-line.
  endloop.
  refresh result.
endif.

if cmd3 ne ' '.
  call function 'FTP_COMMAND'
    exporting
      handle        hdl
      command       cmd3
    tables
      data          result
    exceptions
      command_error 1
      tcpip_error   2.
  loop at result.
    write at / result-line.
  endloop.
  refresh result.
endif.

call function 'FTP_DISCONNECT'
  exporting
    handle hdl.

call function 'RFC_CONNECTION_CLOSE'
  exporting
    destination dest
  exceptions
    others 1.

* password not visible

at selection-screen output.

  loop at screen.
    if screen-name 'PWD'.
      screen-invisible '1'.
      modify screen.
    endif.
  endloop.