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

Need to execute a program in background

Hello,

I have a report program that has a checkbox option to 'Execute in background'. This should also generate a spool file in SAP. I would just like to ask for options on how to do about this.

I have thought of using the SUBMIT command and I read that this command can also generate a spool file. So it is like calling the program itself. Is this possible? Or do I need to make a cloned program and call submit the parameters to the cloned program?

Is there a function module that does this?

I'd appreciate your help on this. Thanks in advance!

Regards,

Kristine

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Feb 17, 2005 at 03:41 AM

    Hello,

    To create a Job Step, the FM 'JOB_OPEN' could be used.

    To add a JOBSTEP, In your case an ABAP program, "SUBMIT" could be used.

    To close the job step, use FM "JOB_CLOSE".

    SAMPLE Code:

    CALL FUNCTION 'JOB_OPEN'

    EXPORTING

    • DELANFREP = ' '

    • JOBGROUP = ' '

    jobname = 'XYZ'

    sdlstrtdt = sy-datum "Current date

    sdlstrttm = sy-uzeit

    IMPORTING

    jobcount = g_jobcount

    EXCEPTIONS

    cant_create_job = 1

    invalid_job_data = 2

    jobname_missing = 3

    OTHERS = 4

    .

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    -


    SUBMIT z_PROGRAM AND RETURN

    USER sy-uname " User for runtime authorizations

    WITH p_para EQ p_para

    "..... Selection screen parameters

    VIA JOB g_jobname NUMBER g_jobcount

    " Job name and job number

    " from JOB_OPEN

    TO SAP-SPOOL " Print and archiving options from

    " GET_PRINT_PARAMETERS

    " Both sets of options come from

    " GET_PRINT_PARAMETERS

    SPOOL PARAMETERS g_s_user_print_params

    ARCHIVE PARAMETERS g_s_user_arc_params

    WITHOUT SPOOL DYNPRO.

    -


    CALL FUNCTION 'JOB_CLOSE'

    EXPORTING

    • AT_OPMODE = ' '

    • AT_OPMODE_PERIODIC = ' '

    • CALENDAR_ID = ' '

    • EVENT_ID = ' '

    • EVENT_PARAM = ' '

    • EVENT_PERIODIC = ' '

    jobcount = g_jobcount

    jobname = g_jobname

    • LASTSTRTDT = NO_DATE

    • LASTSTRTTM = NO_TIME

    • PRDDAYS = 0

    • PRDHOURS = 0

    • PRDMINS = 0

    • PRDMONTHS = 0

    • PRDWEEKS = 0

    • PREDJOB_CHECKSTAT = ' '

    • PRED_JOBCOUNT = ' '

    • PRED_JOBNAME = ' '

    sdlstrtdt = g_datum

    sdlstrttm = g_uzeit

    • STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS

    • STRTIMMED = ' '

    • TARGETSYSTEM = ' '

    • START_ON_WORKDAY_NOT_BEFORE = SY-DATUM

    • START_ON_WORKDAY_NR = 0

    • WORKDAY_COUNT_DIRECTION = 0

    • RECIPIENT_OBJ =

    • TARGETSERVER = ' '

    IMPORTING

    job_was_released = g_job_released

    EXCEPTIONS

    cant_start_immediate = 1

    invalid_startdate = 2

    jobname_missing = 3

    job_close_failed = 4

    job_nosteps = 5

    job_notex = 6

    lock_failed = 7

    OTHERS = 8

    .

    You can get the Print Parameters from FM: 'GET_PRINT_PARAMETERS'.

    All the above FMs have detailed documentation which will help you.

    Hope this helps you.

    Regards, Murugesh AS

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 17, 2005 at 01:56 AM

    hi kristine,

    there are a couple of ways to do that - try reading the SAP help file - follow this link:

    http://help.sap.com/saphelp_46c/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm

    and click on ABAP User Dialogs -> Lists -> Printing Lists

    and yes, you can SUBMIT the current running program - but it might be better if you had a generic print program that you submit your list to.

    sorry if i'm not too specific... but i'll assist you if you need some more help.

    ryan.

    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.