Skip to Content
author's profile photo Former Member
Former Member

how to use FM: SXPG_CALL_SYSTEM

Hi all.

i used the FM SXPG_CALL_SYSTEM as below

w_ext_cmd = 'ZREMSH'.

w_params = 'HARP -L BATCHMGR LS -L ~ORDER_BOOKING/PMAIL/DV4/*.TXT'.

CALL FUNCTION 'SXPG_CALL_SYSTEM'

EXPORTING

commandname = w_ext_cmd

additional_parameters = w_params

.....

.......

ZHREMSH was already added by BASIS.

the output was ERROR:

18 permission denied.

44 External program terminated with exit code 1

i loggen in into my user Account.

can u please provide me the process how i can execute it successfully. If possible with a sample program.

thanks,

Ajay

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Sep 08, 2010 at 02:20 PM

    Try this kind of report

          CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
               EXPORTING
                    commandname                   = lv_command
                    additional_parameters         = lv_parameters
               IMPORTING
                    exitcode                      = exitcode
               TABLES
                    exec_protocol                 = lt_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.
          CALL FUNCTION 'DB6_SHOW_SXPG_ERROR'
               EXPORTING
                    commandname                   = lv_command
                    additional_parameters         = lv_parameters
                    server        = sy-host
                    return_code   = sy-subrc
                    exitcode      = exitcode
               TABLES
                    exec_protocol = lt_protocol
               EXCEPTIONS
                    OTHERS        = 0.

    You may then analyze the errors, which are not always related to the Abap code.

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2010 at 02:15 PM

    Hi Ajay,

    Refer below code snippet :

    
    DATA: DIR_PREFIX(40) TYPE C VALUE '/usr/sap/trans/SID/BACCHUS',
            FROM_FILE(125) TYPE C,
            TO_FILE(125) TYPE C,
            W_MESS_AREA LIKE TSL1D-AREA VALUE 'LC',
            W_MESS_AREA_SUB LIKE TSL1D-SUBID VALUE '0',
            W_CMD    LIKE SXPGCOLIST-NAME,           "cmd name
            W_STATUS LIKE BTCXP3-EXITSTAT, "cmd exit status
            W_PARM   LIKE SXPGCOLIST-PARAMETERS.           "cmd parameters
    
      DATA:  RTAB LIKE BTCXPM OCCURS 20 WITH HEADER LINE.
    
    * Logical command name
      MOVE: COMMAND TO W_CMD,
            IN_FILE TO FROM_FILE,
            OUT_FILE TO TO_FILE.
    
    * Check directory prefix
      REPLACE 'SID' WITH SY-SYSID INTO DIR_PREFIX.
      CONDENSE DIR_PREFIX NO-GAPS.
    
      IF FROM_FILE(24) NE DIR_PREFIX(24) OR
           TO_FILE(24) NE DIR_PREFIX(24).
        MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 107 WITH FROM_FILE(24).
      ENDIF.
    
      CONCATENATE FROM_FILE
                  TO_FILE
                  INTO
                  W_PARM
                  SEPARATED BY SPACE.
    
      CALL FUNCTION 'SXPG_CALL_SYSTEM'
           EXPORTING
                COMMANDNAME                = W_CMD
                ADDITIONAL_PARAMETERS      = W_PARM
           IMPORTING
                STATUS                     = W_STATUS
    *           EXITCODE                   =
           TABLES
                EXEC_PROTOCOL              = RTAB
           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
                OTHERS                     = 12.
    
      IF SY-SUBRC NE 0.
        IF SY-SUBRC EQ 4.
          MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 105 WITH SY-SUBRC
                                                            FROM_FILE.
        ELSE.
          MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 106 WITH SY-SUBRC
                                                            TO_FILE.
        ENDIF.
      ELSE.
    
        IF W_STATUS EQ 'O'.
    *     Command executed
          READ TABLE RTAB INDEX 1.
          IF RTAB-MESSAGE CO '1234567890 '.
          ELSE.
    *       Executed command came back with an error
            MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 108 WITH RTAB-MESSAGE.
          ENDIF.
        ELSE.
    *     Command not executed
    *     MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 109 WITH w_status
    *                                                       to_file.
        ENDIF.
    
      ENDIF.
    
    ENDFORM.                               " MOVE_FILE
    

    Regards

    Abhii

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.