SAP Bilgi Merkezi
Ana Sayfa  ABAP   FI   CO   MM   SD   PP   QM   HR   BW 
ABAP Destek
ABAP FTP Çağrısı
Abap tan bir servera ulaşıp ftp ile dosya göndermek veya almak gerekirse aşağıdaki fonksiyonları kullanabilirsiniz.

Program Satırları:
  IF p_rfc EQ 'SAPFTP'.
    p_rfc = 'SAPFTPA'.
  ENDIF.

  CALL FUNCTION 'FTP_CONNECT'
       EXPORTING
            user            = user
            password        = pass
            host            = host
            rfc_destination = p_rfc
       IMPORTING
            handle          = ftphandle
       EXCEPTIONS
            not_connected   = 1
            OTHERS          = 2.

  PERFORM ftp_error.
  CHECK sy-subrc IS INITIAL.
*------
  CALL FUNCTION 'FTP_COMMAND'
       EXPORTING
            handle        = ftphandle
            command       = 'set passive on'
       TABLES
            data          = lines
       EXCEPTIONS
            tcpip_error   = 1
            command_error = 2
            data_error    = 3.

  PERFORM ftp_error.
  CHECK sy-subrc IS INITIAL.

  IF NOT path IS INITIAL.
    cmd = 'cd '.
    cmd+3 = path.
    REFRESH lines.
    CALL FUNCTION 'FTP_COMMAND'
         EXPORTING
              handle        = ftphandle
              command       = cmd
         TABLES
              data          = lines
         EXCEPTIONS
              tcpip_error   = 1
              command_error = 2
              data_error    = 3
              OTHERS        = 4.
    IF sy-subrc <> 0.
      READ TABLE lines INDEX 2.
      MESSAGE i319(01) WITH 'FTP dizin değiştirmede hata:' lines.
      CALL FUNCTION 'FTP_DISCONNECT'
           EXPORTING
                handle = ftphandle.
      EXIT.
    ENDIF.
  ENDIF.

*------
  DESCRIBE TABLE objtxt_bin.
  DESCRIBE FIELD objtxt_bin LENGTH blob_length.
  blob_length = ( sy-tfill - 1 ) * blob_length.
  READ TABLE objtxt_bin INDEX sy-tfill.
  blob_length = blob_length + STRLEN( objtxt_bin ).

  CALL FUNCTION 'FTP_R3_TO_SERVER'
       EXPORTING
            handle      = ftphandle
            fname       = ftp_fname
            blob_length = blob_length
       TABLES
            blob        = objtxt_bin.

  IF sy-subrc <> 0.
    MESSAGE w398(00) WITH 'FTP' 'Gonderilemedi' '' ''.
  ELSE.
    MESSAGE s398(00) WITH 'FTP' 'Gonderildi' '' ''.
  ENDIF.

* Archive klasörü varsa orayada koy
  cmd = 'cd '.
  cmd+3 = 'Archive'.
  REFRESH lines.
  CALL FUNCTION 'FTP_COMMAND'
       EXPORTING
            handle  = ftphandle
            command = cmd
       TABLES
            data    = lines
       EXCEPTIONS
            OTHERS  = 4.
  IF sy-subrc EQ 0.
    CALL FUNCTION 'FTP_R3_TO_SERVER'
         EXPORTING
              handle      = ftphandle
              fname       = ftp_fname
              blob_length = blob_length
         TABLES
              blob        = objtxt_bin.
  ENDIF.

  CALL FUNCTION 'FTP_DISCONNECT'
       EXPORTING
            handle = ftphandle.
ABAP Destek
SAP Chain
SAP NetWeaver
ticket sistemimize katılın ve ücretsiz
10 adam gün kazanın >>
 Ana Sayfa  |  ABAP  |  FI  |  CO  |  MM  |  SD  |  PP  |  QM  |  HR  |  BW 
ykomut@gmail.com