cancel
Showing results for 
Search instead for 
Did you mean: 

Hi All, I am facing problem in executing the batch files in parallel

Former Member
0 Kudos

Please find the clear explanation below:

The execution command should not wait to go next line until the running job status got completed.

  • There are BODS batch files for 20 jobs in the path and the actual jobs are in different repo’s.
  • By maintaining sequence number, we are triggering the jobs parallelly with scripting.
  • EX: sequence 1 will have 5 jobs and sequence 2 will have 7 jobs, for sequence 1 all five jobs will trigger in parallel and once sequence 1 is completed sequence 2 will start and all 7 jobs will get executed in parallel.
  • The below script is using for triggering the jobs for particular sequence.
  • Script:
  • ##Getting the count of jobs for a sequence(Dependancy field in Job_info table)
  • $max_i = SQL('DS_GDB_ETL_STG','SELECT count(*) FROM dbo.JOB_INFO where dependancy = \'' ||$D || '\' AND SOURCE = \'' || [$$SOURCE] || '\'');
  • $i = 1;
  • While( $i <= $max_i )
  • Begin
  • ##Getting path of the batch file
  • $G_BatFilePath = SQL('DS_GDB_ETL_STG','SELECT BAT_FILE_PATH FROM (SELECT a.*,RANK () over (partition by dependancy,SOURCE order by sno) rn FROM dbo.JOB_INFO a where dependancy = ' || $D || ') a where rn = \'' ||$i || '\' AND SOURCE = \'' || [$$SOURCE] || '\'');
  • print($G_BatFilePath);
  • ##Getting name of the batch file
  • $G_BatFileName = SQL('DS_GDB_ETL_STG','SELECT BAT_FILE_NAME FROM (SELECT a.*,RANK () over (partition by dependancy,SOURCE order by sno) rn FROM dbo.JOB_INFO a where dependancy = ' || $D || ') a where rn = \'' ||$i || '\' AND SOURCE = \'' || [$$SOURCE] || '\'');
  • Print($G_BatFileName);
  • ##Concatenating path and file for execution
  • $G_BatFile = $G_BatFilePath || $G_BatFileName;
  • print($G_BatFile);
  • ##Executing the batch file
  • EXEC($G_BatFile,8);
  • $i = $i+1;
  • END
  • The exact issue is for most of the jobs script is waiting near the EXEC statement and not going to the next line until the triggered jobs gets completed.

Note: ideally the script will run in series and actual jobs should trigger with out the dependency of the previous job completion.

Reference discussions: https://archive.sap.com/discussions/thread/3719533

Accepted Solutions (0)

Answers (0)