Often you need to execute command of operating system from ABAP Program, the purpose may be for encrypt or decrypt file and compres or decompress file, and also you need supply user input to OS Commnands.

In ABAP you can use two method, the difference from both ways is just on the security system. but if you are consent you can choose the method that SAP is recommended.

1.Using SXPT Function Group to execute OS Command from ABAP Program

First you need to define command in SM69, the function module will check user authorization before execute the command, there are three function modules available to execute OS Command.

  • SXPG_CALL_SYSTEM

this function module will execute os command on the locally.

  • SXPG_COMMAND_EXECUTE

this function module will execute os command on the target host

  • SXPG_COMMAND_EXECUTE_LONG 

this function module will execute os command on the target host but support longer list of parameter.

This method is SAP recommended, because it function module also consent about security.

 

2.Using CALL System function call to execute OS Command.

You can execute OS command using CALL system function call to execute OS Command, the cons using this method it is not consent about security and you can run most of OS command without any restriction.

Most of SAP Basis always deactivate this function by setting system profile rdisp/call_system to ‘0’.

For example we want to encrypt string using openssl Linux OS Program from ABAP Program and get the result.