Skip to Content
Author's profile photo Former Member

Dependent Batch Jobs Scheduling

Scenario:


Let consider the scenario where your Transaction Jobs are dependent on your Master Jobs and you have to schedule your transaction jobs such that without completion of master it won’t get executed.Scenario is based on daily execution of both job.

To achieve this follow the below steps –

1) Batch File Export: Take export of batch file for your transaction jobs.

      How:

  • Log into Data Services Management Console.
  • On the left panel, click Administrator > Batch.
  • Select repository name.
  • Click ‘Batch Job Configuration’ tab.
  • Click ‘Export Execution Command’ for the job in question.
  • Optional: Uncheck the ‘Use password file’ option. (Then no password file will be created, the      password will be encrypted into the bat file.)
  • Click Export.

2) Global Variable Declaration: Open your transaction job and add create following global variable.

$STATUS_JOB_DIM datatype as varchar(1)

$JOB_STATUS datatype as varchar(1)


global variable.png

3) Job Modification: Add one script and conditional as follow.

job design.png

4) Job Status Script: In script use the following command

$STATUS_JOB_DIM = sql(‘DS_SQL_ANYWHERE’,’select status from abc.al_history where service = \’JOB_DIM\’ and  END_TIME in (select max(END_TIME) from abc.al_history where service = \’JOB_DIM\’)  and convert(varchar(8),start_time)=convert(varchar(8),getdate())’);

### use repo name in place of abc.

print($STATUS_JOB_DIM);

if($STATUS_JOB_DIM=’D’)

       begin

$JOB_STATUS=’D’;               

       end

else

       begin

                       $JOB_STATUS=’E’;

       end

5) Conditional: Put your Transaction workflow in ELSE clause of conditional and put a Script in THEN clause.

/wp-content/uploads/2016/04/5_935178.png

IF Condition:  ($JOB_STATUS = ‘E’ or $JOB_STATUS is NULL)

6) Conditional Script: Within script put the following command:

print(‘Master tables are not populated yet, Cannot Initiate’||$G_JOB_NAME );

#### create a global variable $G_JOB_NAME or Hard code your job name ###

sleep(‘600000’);  ### A pause of 10 min ###

print(exec( ‘Your batch file path,”,8));   ### Provide your exported batch file location ###

7) Job Scheduling: Now go to DS management console and schedule your transaction job. At time of execution it will first check the Master Job status if Master Job not completed yet then job will take a pause and re execute itself after 10 min.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.