Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Waiting Jobs to end

Former Member
0 Kudos

Hi guys,

I have a program that generates a file of +500.000 registers (with a lot of info ecah) to the server. I have splitted the program in multiple jobs to make it performant,and after that I managed the program continues to create one single file from a Z table (which is filled by the Jobs).

The questions are:

1 - Do I have to Lock the table when doing the insert command in each job?

2 - The program needs to wait until all jobs are finished. How can I programm that?

Here an example of the code implemented to create multiple jobs:

DATA: L_CANT_REG TYPE RSEUMOD-TBMAXSEL.

CONSTANTS: DC_SIGN TYPE CHAR1 VALUE 'I',

DC_OPTION TYPE CHAR2 VALUE 'EQ'.

CLEAR: RA_BPCONTACT. REFRESH RA_BPCONTACT.

LOOP AT I_BCONT INTO R_BCONT.

RA_BPCONTACT-SIGN = DC_SIGN.

RA_BPCONTACT-OPTION = DC_OPTION.

RA_BPCONTACT-LOW = R_BCONT-BPCONTACT.

APPEND RA_BPCONTACT.

DESCRIBE TABLE RA_BPCONTACT LINES L_CANT_REG.

IF L_CANT_REG EQ P_CANREG.

PERFORM F_EJECUTAR_JOB.

CLEAR: L_CANT_REG, RA_BPCONTACT.

REFRESH RA_BPCONTACT.

ENDIF.

ENDLOOP.

IF RA_BPCONTACT IS NOT INITIAL.

PERFORM F_EJECUTAR_JOB.

CLEAR: L_CANT_REG, RA_BPCONTACT.

REFRESH RA_BPCONTACT.

ENDIF.

Many thanks in advance!!!

LUCAS

4 REPLIES 4

mgbernardo
Participant
0 Kudos

Hi mate,

You don't need to block the table. It's already blocked with that command.

Talking about the last job... Do you have a determined number of parallel jobs? Or it varies depending on the work load?

Guessing you have a fixed number of paralel jobs, you can make them to mark a flag on a Z table whenever they finishes. Then schedule a report (the one who joins the files) for all the jobs to execute when the job finishes.

Inside that report check those table flags. In case they are all filled then proceed to join the files, otherwise do nothing.

That should do the trick

Regards

Former Member
0 Kudos

Hi Lucas,

after that I managed the program continues to create one single file from a Z table (which is filled by the Jobs).

Do you mean to say that each job will be updating a Z table with the actual data that will be later downloaded into a file?

1 - Do I have to Lock the table when doing the insert command in each job?

Depends how you build your Z table, i would suggest something like below,

MANDT - Key Field

JOBNO - Key Field

followed by the fields that contain actual data

Jobno will be a unique number for every "PERFORM F_EJECUTAR_JOB." call that you make and will be passed from your main program. This will make sure that duplicate entries are not overwritten and you don't have to worry about locking the table.

2 - The program needs to wait until all jobs are finished. How can I programm that?

Like i said in my previous post, you will have to use the "PERFORM ON END OF TASK" construct when you are calling the FM in parallel. Could you post the code inside "PERFORM F_EJECUTAR_JOB." so that you can get more inputs on how you could do this.

Check the below links too fore more inputs on parallel processing

http://help.sap.com/saphelp_nw04/helpdata/en/22/0425c6488911d189490000e829fbbd/frameset.htm

http://wiki.sdn.sap.com/wiki/display/ABAP/Parallel+Processing

Regards,

Chen

Former Member
0 Kudos

Thanks for the answers.

What I did, is to create an internal table with all the related Job Status. I programmed a DO and a LOOP in the DO, which deletes the Jobs from the Internal table which are finished or cancelled. When the lines of the internal table is equal to zero, the program exits the DO, and contunes wth the file download.

Best regards,

0 Kudos

But that way you are checking everytime the jobs status. Not a good performance I guess.

Regards