REPORT ZEXAMPLE.

DATA: BEGIN OF COMMAND_LIST OCCURS 0.

INCLUDE STRUCTURE SXPGCOLIST.

DATA: END OF COMMAND_LIST .

DATA: BEGIN OF EXEC_PROTOCOL OCCURS 0.

INCLUDE STRUCTURE BTCXPM.

DATA: END OF EXEC_PROTOCOL.

DATA: STATUS LIKE BTCXP3-EXITSTAT,

COMMANDNAME LIKE SXPGCOLIST-NAME VALUE '*',

SEL_NO LIKE SY-TABIX.

* GET LIST OF EXTERNAL COMMANDS

CALL FUNCTION 'SXPG_COMMAND_LIST_GET'

EXPORTING

COMMANDNAME = COMMANDNAME

OPERATINGSYSTEM = SY-OPSYS

TABLES

COMMAND_LIST = COMMAND_LIST

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC EQ 0.

CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'

EXPORTING

ENDPOS_COL = 100

ENDPOS_ROW = 20

STARTPOS_COL = 2

STARTPOS_ROW = 2

TITLETEXT = 'CHOOSE A COMMAND TO EXECUTE:'

IMPORTING

CHOISE = SEL_NO

TABLES

VALUETAB = COMMAND_LIST

EXCEPTIONS

BREAK_OFF = 1

OTHERS = 2.

IF SY-SUBRC EQ 0.

READ TABLE COMMAND_LIST INDEX SEL_NO.

* CHECK AUTHORIZATION

CALL FUNCTION 'SXPG_COMMAND_CHECK'

EXPORTING

COMMANDNAME = COMMAND_LIST-NAME

OPERATINGSYSTEM = SY-OPSYS

EXCEPTIONS

NO_PERMISSION = 1

COMMAND_NOT_FOUND = 2

PARAMETERS_TOO_LONG = 3

SECURITY_RISK = 4

WRONG_CHECK_CALL_INTERFACE = 5

X_ERROR = 6

TOO_MANY_PARAMETERS = 7

PARAMETER_EXPECTED = 8

ILLEGAL_COMMAND = 9

COMMUNICATION_FAILURE = 10

SYSTEM_FAILURE = 11

OTHERS = 12.

CASE SY-SUBRC.

WHEN 0.

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

COMMANDNAME = COMMAND_LIST-NAME

TABLES

EXEC_PROTOCOL = 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 EQ 0.

WRITE:/ COMMAND_LIST-NAME, 'RAN SUCCESSFULLY'.

ELSE.

WRITE:/ 'ERROR WITH COMMAND', COMMAND_LIST-NAME.

ENDIF.

WHEN 1.

WRITE:/'YOU ARE NOT AUTHORIZED TO RUN', COMMAND_LIST-NAME.

WHEN OTHERS.

WRITE:/'ERROR WITH FUNCTION WITH COMMAND', COMMAND_LIST-NAME.

ENDCASE.

ENDIF. "POPUP_WITH_TABLE_DISPLAY

ENDIF. "SXPG_COMMAND_LIST_GET