Skip to Content

Running a batch file kept on the server

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 ??

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Dec 22, 2008 at 03:18 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 20, 2008 at 02:09 PM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 20, 2008 at 02:11 PM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

    • 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..

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 04:38 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 22, 2008 at 04:46 AM

    The question is amswered

    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.