Application Development and Automation 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: 
Read only

Execute multiple Jobs in Parallel.

Former Member
0 Likes
3,451

I have a z1 program which submits a job in background. I want to execute this program multiple times in parallel. I have designed one Z2 wrapper program which reads the internal table and submits this program in a loop. But Is this parallel processing because when I say submit the execution of program shifts to Z1 program and returns only after it has executed z1 completely, What I want to achieve is parallel processing. Is there a better way to do the same?

Regards,

Ankur Bhandari

I have a z1 program which submits a job in background. I want to execute this program multiple times in parallel. I have designed one Z2 wrapper program which reads the internal table and submits this program in a loop. But Is this parallel processing because when I say submit the execution of program shifts to Z1 program and returns only after it has executed z1 completely, What I want to achieve is parallel processing. Is there a better way to do the same?

Regards,

Ankur Bhandari

18 REPLIES 18
Read only

Former Member
Read only

Former Member
0 Likes
2,406

Hi Ankur,

Check the above link, in that sample program <b>PARAJOB</b> check it , it may help you.

thanks

vijay

Read only

Former Member
0 Likes
2,406

Hi,

1. How are u using submit ?

2. use like this :

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = jobname

IMPORTING

jobcount = jobcount

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4

-


Submit

SUBMIT Z1

VIA JOB jobname NUMBER jobcount AND RETURN

TO SAP-SPOOL

WITHOUT SPOOL DYNPRO

-


CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = jobcount

jobname = jobname

strtimmed = '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

.

regards,

amit m.

Read only

0 Likes
2,406

I think I didn’t make my self clear. This is what I am doing , but when the program execution reaches submit then it continues in Z1, I want a scenario where in when I say submit it should execute Z1 but not wait till its execution. Any pointers on how do I do this?

Z1 program. Is something like this.

Get parameter/variables which are passed from recording from wrapper program using export commands.

Bdc recording of transaction SARA.

Call transaction SARA.( which internally creates jobs in background)

Z2 wrapper program

Reads a z table and creates an internal table.

Loops at internal table.

Import to memory ids

Submit program z1.

Endloop.

Read only

0 Likes
2,406

Hi again,

1. I already understood what u said.

2.

Reads a z table and creates an internal table.

Loops at internal table.

Import to memory ids

Submit program z1. <----


Endloop

Instead of just 1 line of submit,

write the below code :

The purpose is that Even Z1 should

be treated and submited as background job.

(Simple submit won't do)

3.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = jobname

IMPORTING

jobcount = jobcount

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4

-


Submit

SUBMIT Z1

VIA JOB jobname NUMBER jobcount AND RETURN

TO SAP-SPOOL

WITHOUT SPOOL DYNPRO

-


CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = jobcount

jobname = jobname

strtimmed = '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

regards,

amit m.

Read only

0 Likes
2,406

Thanks Amit for the response. But just before I use this approach. Would like to know Are there any other approaches? Is this the best approach ? Some responses mentioned about using the function module with "NEW TASK" but I am not sure whether I can use that in my scenario.In case some one has previous experience in doing the same and can thrwo some lights on these issues.

Regards,

Ankur Bhandari

Read only

0 Likes
2,406

Hi Ankur,

1. I have also used the same approach.

2. This is the BEST PRACTICAL approach.

3. function module with "NEW TASK

This funda is used for FUNCTION MODULES.

But since your is a Program, we

have to use Submit and background process funda.

Even New task does more or less the same thing.

4. Morever, benefit of using background is,

we can MONITOR,VIEW the background job log

and check if anything has gone wrong.

Moreover we can Capture the spool for further

purpose.

5. Hence, the approach is perfectly fantastic. !!!

regards,

amit m.

Read only

0 Likes
2,406

Hi Amit,

When I submit the program using job, Although the job is created and released , no further processing happens. Is there a way I can find out what could be the problem.Is there a sample program which I could recheck to figure out the problem ?

Ankur Bhandari

p.s I am attaching a part of the code which i am doing right now. Any problems you see ?

_________________________________________________________

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = gv_jobname

IMPORTING

jobcount = gv_jobcount.

  • EXCEPTIONS

  • CANT_CREATE_JOB = 1

  • INVALID_JOB_DATA = 2

  • JOBNAME_MISSING = 3

  • OTHERS = 4.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

SUBMIT zhre_arc_tab_pcalc USING SELECTION-SCREEN gc_snum

WITH SELECTION-TABLE gt_par_tab

TO SAP-SPOOL WITHOUT SPOOL DYNPRO

VIA JOB gv_jobname NUMBER gv_jobcount AND RETURN.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = gv_jobcount

jobname = gv_jobname

STRTIMMED = gc_x

EXCEPTIONS

  • CANT_START_IMMEDIATE = 1

  • INVALID_STARTDATE = 2

  • JOBNAME_MISSING = 3

  • JOB_CLOSE_FAILED = 4

job_nosteps = 5.

Read only

0 Likes
2,406

Hi Ankur,

The code looks OK.. How are you confirmig that the job is released? Did you check under SM37?

Regards,

Suresh

Read only

0 Likes
2,406

HI ankur,

1. There are two things :

2. Using submit :

USING SELECTION-SCREEN gc_

do not use selection-screen

use :

USING SELECTION-SET variant

3. while closing u have not passed the parameter

for event

DATA : eventparm LIKE tbtcjob-eventparm.

eventparm = jobname.

eventparm+32 = jobcount.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = jobcount_sen

jobname = jobname_sen

predjob_checkstat = ''

event_id = 'SAP_END_OF_JOB'

event_param = eventparm

  • PRED_JOBCOUNT = jobcount

  • PRED_JOBNAME = jobname

  • strtimmed = 'X'

I hope it helps.

regards,

amit m.

Read only

0 Likes
2,406

Amit,

Does that mean the program won't work with selection-screen and if I dont pass the event parameter or are they optional.

Ankur bhandari

Read only

0 Likes
2,406

Hi again,

1. sorry for the extra information

for the eventparam

(this is not required in your case, pls ignore it)

2.

SUBMIT (report)

WITH SELECTION-TABLE rsparams

USING SELECTION-SET variant

VIA JOB jobname NUMBER jobcount AND RETURN

TO SAP-SPOOL

WITHOUT SPOOL DYNPRO

Do not use selection-screen,

instead u can use VARIANT

OR

u can pass the parameters

using SELECTION-TABLE rsparams

(see above)

regards,

amit m.

Read only

0 Likes
2,406

Hi Group,

One fundamental question. I am trying to execute transaction PU22 in background using the submit program. My question is this program has tree control in the left hand side of the screen. Can this program be called in background.Cos now I am getting the exceptions related to tree controls.

Regards,

Ankur Bhandari

Read only

0 Likes
2,406

hi,

it will give problems, you need to use

similar to alv (OO) you need to do something similar to below.

CALL METHOD cl_gui_alv_grid=>offline
                RECEIVING e_offline = off.
    IF off IS INITIAL.
      CREATE OBJECT g_custom_container
             EXPORTING container_name = g_container.
    ENDIF.

regards

vijay

Read only

0 Likes
2,406

Hi ankur,

1. It cannot be programmed

since tree control is based on CONTROLS

technology !

regards,

amit m.

Read only

0 Likes
2,406

Does that mean any transactions which uses controls technology we will be unable to execute them in background ?

Ankur Bhandari

Read only

0 Likes
2,406

you need to use some code to prevent the exceptions, some thing similar to OO ALV.

regards

vijay

Read only

0 Likes
2,406

hi,

for doing parallel jobs

Call <fn_module> starting new task.

give the extension "starting new task " at the end of "call <fn>" statement. If we give that addition, the fn module will be executed parallelly.

regards

hyma