ABAP--编写应用服务器执行外部命令的程序示例

1、相关Package
SBTC

2、相关T-CODE
SM69:
SM49

3、SXPG_CALL_SYSTEM函数说明
 

Use this function module to do the following:
·         Check a user’s authorization to run a command
·         Carry out the command.
To determine the system on which the command should be carried out, the function module takes by default the user’s current host system and the operating system type. 
Since the function module is RFC-capable, you can use RFC (the remote function call interface) to carry run the function module at another SAP application server. The external command is then carried out on the host system on which the destination server is running. See CALL FUNCTION... DESTINATION in the ABAP syntax documentation or User’s Guide for more information.
SXPG_CALL_SYSTEM checks the command that is specified in the call before carrying it out. The function module follows these rules in performing this check:
·         It checks for a command definition that has the same operating system type as in the system field SY-OPSYS. If found, then this command definition is used to run the command.
·         If the first check fails, then the function module looks to see if the command has been defined with an operating system type that belongs to the same syntax group as the SY-OPSYS operating system. A syntax group is an SAP construct that groups together OS’s that share the same command and file name syntax. Example: the various flavors of UNIX belong to a syntax group. 
If found, then this command definition is used to run the command. Example: If SY-OPSYS shows HP-UX as the OS, then a command definition for Sun UNIX would also be acceptable for carrying out the command. 
·         If the second check also fails, then the function modules looks for the command with the operating system type ANYOS. ANYOS indicates that a command definition can be carried out on all supported host operating systems.
If found, then this command definition is used to run the command.
Syntax:
CALL FUNCTION ‘SXPG_CALL_SYSTEM’
     IMPORTING                                                
        COMMANDNAME   = <Name of command to run> “ Default '*'
        ADDITIONAL_PARAMETERS    = <Argument string> “ Default <space>        
     EXPORTING                                                
        STATUS        = <Exit status of command>                  
      TABLES                                                   
        EXEC_PROTOCOL = <Log> “ In structure BTCXPM. Can
                               “ contain STDOUT, STDERR

      EXCEPTIONS                                               
        NO_PERMISSION “ Command rejected by user exit auth.
                      “ check

        COMMAND_NOT_FOUND  “ Command not defined in SAP database
        PARAMETERS_TOO_LONG  “ Complete parameter string exceeds
                             “ 128 characters

        SECURITY_RISK “ Security check failed
        WRONG_CHECK_CALL_INTERFACE “ Problem with function
                                    “ module for additional
                                    “ security check

        PROGRAM_START_ERROR “ Error while starting program                               
        PROGRAM_TERMINATION_ERROR
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值