SAP ABAP发送文件到SFTP服务器 SXPG_COMMAND_EXECUTE
经过今天在ERP系统的测试及在SAP官方网站查询相关的资料,发现SAP可以直接访问FTP服务,但不能直接访问SFTP服务器。如需访问SFTP服务器,需要在SFTP客户端及服务端安装相关的软件,详情见附件SAP NOTE795131。实现步骤;1.SAP ABAP发送文件到SAP应用服务器指定目录2.BASIS部署脚本并配置SM69命令SFTP.SH#!/bin/shHOST=XXXX.XX.XX.
经过今天在ERP系统的测试及在SAP官方网站查询相关的资料,发现SAP可以直接访问FTP服务,但不能直接访问SFTP服务器。
如需访问SFTP服务器,需要在SFTP客户端及服务端安装相关的软件,详情见附件SAP NOTE 795131 。
实现步骤;
1.SAP ABAP发送文件到SAP应用服务器指定目录
2.BASIS部署脚本并配置SM69命令
SFTP.SH
#!/bin/sh
HOST=XXXX.XX.XX.XX
USER=用户名
PASS=密码
lftp -u ${USER},${PASS} sftp://${HOST} <<EOF
lcd /usr/sap/trans/sd
cd TEST/IN
put $1
bye
EOF
3.调用函数驱动应用服务器脚本发送数据到SFTP .
SXPG_COMMAND_EXECUTE
FORM FRM_SEND_CSV_TO_SFTP USING LV_FILE_NAME TYPE STRING
CHANGING LV_FLAG TYPE CHAR01
LV_MESSA TYPE STRING .
DATA:LT_EXEC_PROTOCOL TYPE TABLE OF BTCXPM .
DATA:
LV_COMMANDNAME LIKE SXPGCOLIST-NAME,
LV_ADDITIONAL_PARAMETERS LIKE SXPGCOLIST-PARAMETERS,
LV_OPERATINGSYSTEM LIKE SXPGCOLIST-OPSYSTEM.
data:
lv_status type EXTCMDEXEX-STATUS ,
lv_exitcode type EXTCMDEXEX-EXITCODE .
DATA:LV_MESSAGE TYPE STRING .
IF P_TRAIN IS INITIAL .
LV_COMMANDNAME = 'ZFTP' . "待确定
ELSE .
LV_COMMANDNAME = 'ZFTP' .
ENDIF .
LV_OPERATINGSYSTEM = 'Linux' . "待确定
LV_ADDITIONAL_PARAMETERS = LV_FILE_NAME .
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = LV_COMMANDNAME
ADDITIONAL_PARAMETERS = LV_ADDITIONAL_PARAMETERS
OPERATINGSYSTEM = LV_OPERATINGSYSTEM "SY-OPSYS
* TARGETSYSTEM = ''
* DESTINATION =
* STDOUT = 'X'
* STDERR = 'X'
* TERMINATIONWAIT = 'X'
* TRACE =
* DIALOG =
IMPORTING
STATUS = lv_status
EXITCODE = lv_exitcode
TABLES
EXEC_PROTOCOL = LT_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 <> 0 or lv_exitcode ne 0 .
LV_FLAG = 'X' .
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = SY-MSGID
MSGNR = SY-MSGNO
MSGV1 = SY-MSGV1
MSGV2 = SY-MSGV2
MSGV3 = SY-MSGV3
MSGV4 = SY-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = LV_MESSAGE.
ELSE .
ENDIF.
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)