SAP FTP技术

   SAP与外部系统异常之间可以采用FTP技术进行文件的交换处理,达到信息共享的目的, ftp技术的调如方式如下:


REPORT zfiletest .

DATA: p_prg LIKE sy-repid.

DATA:  com(100) ,
       t_name(40),
       t_cnt TYPE i,
       t_typ(3).

DATA:  BEGIN OF tabl OCCURS 100,
           line(255),
         END OF tabl.
data: begin of commands occurs 0,
       cmd(100) type c,
      end of commands.
data: hdl type i,
      key type i value 26101957,
      dstlen type i,
      nlen type i.

data: begin of result occurs 0,
        line(100) type c,
        end of result.
data: CNS_DIR(40) TYPE C .  "VALUE 'MAS'.

start-of-selection.
p_prg = sy-repid.

 call function 'FTP_CONNECT'
       EXPORTING
            user            = 'ftp'
            password        = 'ftp'
            host            = '10.0.4.85'
            rfc_destination = 'SAPFTPA'
       IMPORTING
            handle          = hdl.


   move 'lcd /usr/sap/tmp' to commands-cmd.
  call function 'FTP_COMMAND'
           EXPORTING
                handle        = hdl
                command       = commands-cmd
           TABLES
                data          = result
           EXCEPTIONS
                command_error = 1.


    REFRESH RESULT.
   move 'cd  MAS' to commands-cmd.
    call function 'FTP_COMMAND'
           EXPORTING
                handle        = hdl
                command       = commands-cmd
           TABLES
                data          = result
           EXCEPTIONS
                command_error = 1.

move 'mget *.txt' to commands-cmd.
    call function 'FTP_COMMAND'
           EXPORTING
                handle        = hdl
                command       = commands-cmd
           TABLES
                data          = result
           EXCEPTIONS
                command_error = 1.

 CNS_DIR  =  '/usr/sap/tmp'.
* cns_dir  =  '/MAS'.

CONCATENATE 'ls' cns_dir  INTO com SEPARATED BY space.

REFRESH tabl.
SET BLANK LINES ON.
CALL 'SYSTEM' ID 'COMMAND' FIELD com
              ID 'TAB' FIELD tabl-*sys*.

IF tabl[] IS INITIAL.
  MESSAGE w398(00) WITH '没有所需的文件'.
ENDIF.

SORT tabl BY line DESCENDING.

LOOP AT tabl.
  WRITE tabl-line.
ENDLOOP.


*&Directory Handle Part.
  clear : cns_dir, tabl.
  refresh tabl.
  set blank lines on.
  cns_dir = '/usr/sap/trans/public/order'.

*&no 1.
  CONCATENATE 'mkdir' cns_dir  INTO com SEPARATED BY space.
 CALL 'SYSTEM' ID 'COMMAND' FIELD com
              ID 'TAB' FIELD tabl-*sys*.
*&no 2.
 CONCATENATE 'chmod 777' cns_dir  INTO com SEPARATED BY space.
 CALL 'SYSTEM' ID 'COMMAND' FIELD com
              ID 'TAB' FIELD tabl-*sys*.

*&no 3.
 CONCATENATE 'chown qasadm: sapsys' cns_dir  INTO com SEPARATED BY
space
.
 CALL 'SYSTEM' ID 'COMMAND' FIELD com
              ID 'TAB' FIELD tabl-*sys*.



*&end.


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值