Professional Documents
Culture Documents
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.
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.
1 REPORT Z_TEST_PING.
2
3 TYPES char255 TYPE c LENGTH 255.
4 PARAMETERS: pv_count TYPE i DEFAULT 5,
5 pv_targt TYPE char255 LOWER CASE.
6 DATA lt_result TYPE TABLE OF btcxpm WITH EMPTY KEY.DATA lv_line TYPE btcxpm.DATA lv_param TYPE
7 char255.
8 INITIALIZATION.
9 CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'SAPDBHOST'
10 ID 'VALUE' FIELD lv_param.
11 pv_targt = lv_param. ” get the db server as default target
12 AT SELECTION-SCREEN.
13 if pv_count < 1 OR
14 pv_count > 10.
15 MESSAGE ‘Please enter a number between 1 and 10.’ TYPE ‘E’.
16 ENDIF.
if pv_targt = ”.
17 MESSAGE 'pv_target: You need to specify a destination to ping.' TYPE 'E'.
18 ENDIF.
19 START-OF-SELECTION.
20 lv_param = |–c{ pv_count } { pv_targt }|. ” this only works on UNIX like ping this wayWrite :/ ‘now executing:
21 Z_MyPing with parameters: ‘ && lv_param.Write :/ .CALL FUNCTION ‘SXPG_CALL_SYSTEM’
22 EXPORTING
23 commandname = 'ZPING'
24 additional_parameters = lv_param
25 TABLES
26 exec_protocol = lt_result
27 EXCEPTIONS
28 no_permission = 1
29 command_not_found = 2
30 security_risk = 3
31 OTHERS = 4.
32 IF SY–SUBRC = 0.
33 LOOP at lt_result into lv_line.
34 Write :/ lv_line–message.
35 ENDLOOP.
36 ELSE.
37 MESSAGE 'Error, return code ' && sy–subrc TYPE 'E'.
ENDIF.
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.