Skip to Content
0
Former Member
Feb 10, 2011 at 09:59 AM

Launch 2 jobs, one after another

77 Views

Hi,

my requirement is very simple, in ABAP i need to launch 2 jobs, one after another. The job 1 is launched and once completed the job 2 is launched.

My problem is that the two jobs are launched at the same ; i tried some parameters but no solution.

REPORT  z_erca_job_create.

DATA: w_job1 LIKE tbtcjob-jobcount,
      w_job2 LIKE tbtcjob-jobcount.

**********************************************************************
* 1er job
**********************************************************************
CALL FUNCTION 'JOB_OPEN'
  EXPORTING
    jobname          = 'ZERCA_JOB_TEST'
  IMPORTING
    jobcount         = w_job1
  EXCEPTIONS
    cant_create_job  = 1
    invalid_job_data = 2
    jobname_missing  = 3
    OTHERS           = 4.

SUBMIT zpr_0098
VIA JOB 'ZERCA_JOB_TEST' NUMBER w_job1
        WITH pmolga EQ '06'
        WITH pperiod EQ '201101'
        WITH psacha EQ '201'
        WITH psbmod EQ 'FRAL'
        WITH ptest EQ space
        AND RETURN.

CALL FUNCTION 'JOB_CLOSE'
  EXPORTING
    jobcount             = w_job1
    jobname              = 'ZERCA_JOB_TEST'
    strtimmed            = 'X'
  EXCEPTIONS
    cant_start_immediate = 1
    invalid_startdate    = 2
    jobname_missing      = 3
    job_close_failed     = 4
    job_nosteps          = 5
    job_notex            = 6
    lock_failed          = 7
    invalid_target       = 8
    OTHERS               = 9.

**********************************************************************
* 2ème job
**********************************************************************
CALL FUNCTION 'JOB_OPEN'
  EXPORTING
    jobname          = 'ZERCA_JOB_TEST2'
  IMPORTING
    jobcount         = w_job2
  EXCEPTIONS
    cant_create_job  = 1
    invalid_job_data = 2
    jobname_missing  = 3
    OTHERS           = 4.

SUBMIT zpr_0104
VIA JOB 'ZERCA_JOB_TEST2' NUMBER w_job2
        WITH pperiod EQ '201101'
        WITH psacha EQ '201'
        WITH psbmod EQ 'FRAL'
        WITH ptest EQ space
        AND RETURN.

CALL FUNCTION 'JOB_CLOSE'
  EXPORTING
*   AT_OPMODE                         = ' '
*   AT_OPMODE_PERIODIC                = ' '
*   CALENDAR_ID                       = ' '
*   EVENT_ID                          = ' '
*   EVENT_PARAM                       = ' '
*   EVENT_PERIODIC                    = ' '
    jobcount                          = w_job2
    jobname                           = 'ZERCA_JOB_TEST2'
*   laststrtdt                        = NO_DATE
*   LASTSTRTTM                        = NO_TIME
*   PRDDAYS                           = 0
*   PRDHOURS                          = 0
*   PRDMINS                           = 0
*   PRDMONTHS                         = 0
*   PRDWEEKS                          = 0
   predjob_checkstat                 = 'X'
   pred_jobcount                     = w_job1
   pred_jobname                      = 'ZERCA_JOB_TEST'
*   sdlstrtdt                         = NO_DATE
*   SDLSTRTTM                         = NO_TIME
*  STARTDATE_RESTRICTION             = 'X'
    strtimmed                         = 'X'
*   TARGETSYSTEM                      = ' '
*   START_ON_WORKDAY_NOT_BEFORE       = SY-DATUM
*   START_ON_WORKDAY_NR               = 0
*   WORKDAY_COUNT_DIRECTION           = 0
*   RECIPIENT_OBJ                     =
*   TARGETSERVER                      = ' '
*   DONT_RELEASE                      = ' '
*   TARGETGROUP                       = ' '
   direct_start                      = 'X'
* IMPORTING
*   JOB_WAS_RELEASED                  =
* CHANGING
*   RET                               =
 EXCEPTIONS
   cant_start_immediate              = 1
   invalid_startdate                 = 2
   jobname_missing                   = 3
   job_close_failed                  = 4
   job_nosteps                       = 5
   job_notex                         = 6
   lock_failed                       = 7
   invalid_target                    = 8
   OTHERS                            = 9.

Thanks for your help.