Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Running a batch file kept on the server

anuj_srivastava
Active Participant
0 Kudos

Hi ,

I need to upload a file onto the application server then i have to call a batch file from my ABAP code kept on the same server .

The batch file takes 3 inputs the uploaded filename onto the server the new file name ( that can be any name ) and the delete flag parameter ( 0 or 1 ).

Is there any function module to do the same ??

1 ACCEPTED SOLUTION

former_member223537
Active Contributor
0 Kudos

Hi,

You will have to use FM 'SXPG_COMMAND_EXECUTE'.

Search with above FM name on SDN & you will get a sample program with necessary steps.

Best regards,

Prashant

6 REPLIES 6

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

This message was moderated.

0 Kudos

Hi Alok thanks for the reply...

Actually what i wanted to know was about the function module that will call the batch file stored on the server.

I was able to download the file from my ABAP code on the application server earlier but was not able to call the batch file.

I think my question gave you a wrong impression what i was looking for.

Anyways thx..

former_member223537
Active Contributor
0 Kudos

Hi,

You will have to use FM 'SXPG_COMMAND_EXECUTE'.

Search with above FM name on SDN & you will get a sample program with necessary steps.

Best regards,

Prashant

Former Member
0 Kudos

Hi,

Follow the steps:

1) Define external operating system command say zcopytm1 using SM69 by using the following parameters:

Command name Operating system Type

ZCOPYTM1 Windows NT Customer

Operating system command

e:\tm1out\tm1ph.bat

Parameters for operating system command

Leave this blank

tm1ph.bat is the batch file which it will execute.

2) First test it using SM49. Once satisfied use the following code to execute it thru ABAP:


DATA: BEGIN OF t_copy OCCURS 1.
        INCLUDE STRUCTURE btcxpm.
DATA: END OF t_copy.
DATA:      statusline LIKE btcxp3-exitstat.


  CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
         EXPORTING
            commandname            = 'zcopytm1'
            status                              = statusline
         TABLES
            exec_protocol                       = t_copy
         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
        .

  CASE sy-subrc.
    WHEN 0.
      MESSAGE s999 WITH 'File has been copied in G:\public\tm1ph'.
    WHEN 1.
      MESSAGE s999 WITH 'No_permission'.
    WHEN 2.
      MESSAGE s999 WITH 'Command_not_found'.
    WHEN 3.
      MESSAGE s999 WITH 'Parameters_too_long'.
    WHEN 4.
      MESSAGE s999 WITH 'Security_risk'.
    WHEN 5.
      MESSAGE s999 WITH 'Wrong_check_call_interface'.
    WHEN 6.
      MESSAGE s999 WITH 'Program_start_error'.
    WHEN 7.
      MESSAGE s999 WITH 'Program_termination_error'.
    WHEN 8.
      MESSAGE s999 WITH 'X_error'.
    WHEN 9.
      MESSAGE s999 WITH 'Parameter_expected'.
    WHEN 10.
      MESSAGE s999 WITH 'Too_many_parameters'.
    WHEN 11.
      MESSAGE s999 WITH 'Illegal_command'.
    WHEN 12.
      MESSAGE s999 WITH 'Wrong_asynchronous_parameters'.
    WHEN 13.
      MESSAGE s999 WITH 'Cant_enq_tbtco_entry'.
    WHEN 14.
      MESSAGE s999 WITH 'Jobcount_generation_error'.
  ENDCASE.
*

I hope this helps,

Regards

Raju Chitale

Edited by: Raju Chitale on Dec 22, 2008 5:38 AM

anuj_srivastava
Active Participant
0 Kudos

The question is amswered