Tuesday, September 16, 2014

ABAP TIP - External Command


ABAP TIP - External Command


You can register the UNIX command as a external command in sap system.
SAP 시스템에서 UNIX 서버의 외부 명령어를 등록하여, 실행할 있다.









1. Let’s execute T-CODE:SM49, SM69 and register external command.  Press ‘create’ icon.
2. If you want to register shell script, you should describe all directory path including shell script file. In case of UNIX command, you can write like below.
3. It’s also possible to use external command you created in T-CODE:SM36 and call external command in abap program like below example.


CONSTANTS: c_extcom    TYPE sxpgcolist-name VALUE 'ZCOMMAND,
           c_oper      TYPE syopsys VALUE 'UNIX'.

DATA: v_dir_input      TYPE sxpgcolist-parameters.  " Input Directory
DATA: t_result         TYPE STANDARD TABLE OF btcxpm.

v_dir_input = '/sapmmt'.

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  EXPORTING
    commandname                   = c_extcom
    additional_parameters         = v_dir_input
    operatingsystem               = c_oper
  TABLES
    exec_protocol                 = t_result
  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.




No comments:

Post a Comment