Skip to Content
author's profile photo
Former Member

Background Job

Hi,

Lets say I am executing a report program. Now I would like to start a Background Job, which should start once this internal session is complete, is there any means of achieving the same.

Like in this case once the report is done, it should start executing the background job.

Regards,

Pavan

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • author's profile photo
    Former Member
    Apr 22, 2004 at 08:24 AM

    What is it you want to run as a background job, a report?

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Apr 22, 2004 at 09:14 AM

    Hi Pavan,

    Possibly you can set the background job to start after an event is triggered. You can Raise the event from your program. The job will be started when this event is triggered.

    regards,

    Tathagata

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Apr 23, 2004 at 03:53 AM

    Hi Pavan,

    In such a scenario possibly you can configure the two reports as two steps of the job. Completion of Step 1 would lead to Step 2. Just try configuring such a job in SM36.

    Possibly this could solve your problem.

    Regards,

    Tathagata

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Apr 23, 2004 at 12:34 PM

    Hi Pavan,

    there are function modules JOB_OPEN and JOB_CLOSE:

    CALL FUNCTION <b>'JOB_OPEN'</b>

    EXPORTING

    • DELANFREP = ' '

    • JOBGROUP = ' '

    jobname = <b>cl_jobname</b>

    • SDLSTRTDT = NO_DATE

    • SDLSTRTTM = NO_TIME

    IMPORTING

    jobcount = wl_jobcount

    EXCEPTIONS

    cant_create_job = 1

    invalid_job_data = 2

    jobname_missing = 3

    OTHERS = 4

    .

    IF sy-subrc <> 0.

    ...

    ENDIF.

    PERFORM get_print_parameters

    CHANGING sl_pri_params sl_arc_params wl_valid.

    IF wl_valid <> space.

    <b>SUBMIT</b> ztprprotokoll LINE-SIZE 200

    WITH a_trkorr = wf_trkorr

    TO SAP-SPOOL

    SPOOL PARAMETERS sl_pri_params

    ARCHIVE PARAMETERS sl_arc_params

    WITHOUT SPOOL DYNPRO

    USER wf_user+2 VIA JOB <b>cl_jobname</b> NUMBER wl_jobcount

    AND RETURN.

    ENDIF.

    • 2. Transportprotokoll ablegen ...

    • ... wenn Quellsystem C11!

    IF wf_trkorr(4) = 'C11K'.

    sl_arc_params-info = 'TP'.

    CONCATENATE 'Transportprotokoll' wf_trkorr INTO

    sl_arc_params-arctext SEPARATED BY space.

    PERFORM get_print_parameters

    CHANGING sl_pri_params sl_arc_params wl_valid.

    IF wl_valid <> space.

    <b>SUBMIT</b> rddprott WITH pv_korr = wf_trkorr

    TO SAP-SPOOL

    SPOOL PARAMETERS sl_pri_params

    ARCHIVE PARAMETERS sl_arc_params

    WITHOUT SPOOL DYNPRO

    USER wf_user+2 VIA JOB <b>cl_jobname</b> NUMBER wl_jobcount

    AND RETURN.

    ENDIF.

    ENDIF.

    CALL FUNCTION <b>'JOB_CLOSE'</b>

    EXPORTING

    • AT_OPMODE = ' '

    • AT_OPMODE_PERIODIC = ' '

    • CALENDAR_ID = ' '

    • EVENT_ID = ' '

    • EVENT_PARAM = ' '

    • EVENT_PERIODIC = ' '

    jobcount = wl_jobcount

    jobname = cl_jobname

    • LASTSTRTDT = NO_DATE

    • LASTSTRTTM = NO_TIME

    • PRDDAYS = 0

    • PRDHOURS = 0

    • PRDMINS = 0

    • PRDMONTHS = 0

    • PRDWEEKS = 0

    • PREDJOB_CHECKSTAT = ' '

    • PRED_JOBCOUNT = ' '

    • PRED_JOBNAME = ' '

    • SDLSTRTDT = NO_DATE

    • SDLSTRTTM = NO_TIME

    • STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS

    strtimmed = 'X'

    • TARGETSYSTEM = ' '

    • START_ON_WORKDAY_NOT_BEFORE = SY-DATUM

    • START_ON_WORKDAY_NR = 0

    • WORKDAY_COUNT_DIRECTION = 0

    • RECIPIENT_OBJ =

    • TARGETSERVER = ' '

    • IMPORTING

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

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Actually the work arounds are fine guys. I am completely happy with the work arounds, in fact we have also achieved a work around, using lock objects as indicated by martin.

      But what exactly i am looking for was, just like we could schedule a batch job on termination of another job. Is there some way we can identify the current session as well, and say that on the termination of this session start the next one.

      Regards,

      Pavan