2006 Jan 07 8:20 AM
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
2006 Jan 07 8:25 AM
Hi,
Check this sap Help link..
http://help.sap.com/saphelp_45b/helpdata/en/fa/096e92543b11d1898e0000e8322d00/content.htm
Vijay
2006 Jan 07 8:27 AM
Hi Ankur,
Check the above link, in that sample program <b>PARAJOB</b> check it , it may help you.
thanks
vijay
2006 Jan 07 8:28 AM
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.
2006 Jan 07 8:47 AM
I think I didnt 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.
2006 Jan 07 8:50 AM
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.
2006 Jan 07 9:00 AM
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
2006 Jan 07 9:06 AM
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.
2006 Jan 12 4:19 AM
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.
2006 Jan 12 4:26 AM
Hi Ankur,
The code looks OK.. How are you confirmig that the job is released? Did you check under SM37?
Regards,
Suresh
2006 Jan 12 4:42 AM
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.
2006 Jan 12 5:00 AM
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
2006 Jan 12 5:22 AM
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.
2006 Jan 12 6:52 AM
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
2006 Jan 12 7:00 AM
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
2006 Jan 12 7:01 AM
Hi ankur,
1. It cannot be programmed
since tree control is based on CONTROLS
technology !
regards,
amit m.
2006 Jan 12 7:05 AM
Does that mean any transactions which uses controls technology we will be unable to execute them in background ?
Ankur Bhandari
2006 Jan 12 7:07 AM
you need to use some code to prevent the exceptions, some thing similar to OO ALV.
regards
vijay
2006 Jan 12 7:35 AM
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
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |