03-11-2009 10:06 AM
Hi all,
With respect to one of my previous question ,I have searched the forum , but could not find the answer.
I have two reports(executable programs).
I am executing the report1 and getting a specific output ,say it is be a case
if its case 1:
report 2 must be executed in the background(probably using submit)
If case 2:
report 2 must be executed in fore ground.
Hope you get my query.
Regards,
K.Sibi
03-11-2009 10:12 AM
HI,
Try this,
Scheduling a submitable program as a background task with the number number in a background request name. After scheduling, the background task is completed by function module JOB_CLOSE and released immediately providing the user has the relevant authorization.
DATA: number TYPE tbtcjob-jobcount,
name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
print_parameters TYPE pri_params.
...
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT submitable TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB name NUMBER number
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
...
ENDIF.
ENDIF.
ENDIF.
regards,
Venkatesh
03-11-2009 10:12 AM
HI,
Try this,
Scheduling a submitable program as a background task with the number number in a background request name. After scheduling, the background task is completed by function module JOB_CLOSE and released immediately providing the user has the relevant authorization.
DATA: number TYPE tbtcjob-jobcount,
name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
print_parameters TYPE pri_params.
...
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT submitable TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB name NUMBER number
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
...
ENDIF.
ENDIF.
ENDIF.
regards,
Venkatesh
03-11-2009 10:20 AM
Hello venkatesh,
Thanks for the reply.
So , you mean to tell that
1.Use the below code for adding the report no 2 in backgroubnd for execution
2.To use the SUBMIT for adding it in foreground execution.
Regards,
K.Sibi
03-11-2009 10:31 AM
hi,
Yes, this is correct. If it is foreground u can use the SUBMIT statement
other wise if it is in back ground, u need to use those function modules.
you can check it with sy-batch value
if sy-batch = 'X'.
this is back ground. here u need to use those function modules as said in my previous reply.
else.
this is fore ground.
sumbit zprogram via selection-screen and return.
endif.
Regards,
Venkatesh
03-11-2009 10:12 AM
just call ue report2 depending on conditions like this:
when u need to run it in foreground, use SUBMIT
when in background use these fms
JOB_OPEN u2013 Creates a background job
JOB_SUBMIT u2013 Adds a step (program) to a background job
JOB_CLOSE u2013 Schedules a background job .
кu03B1ятu03B9к
03-11-2009 10:14 AM
03-11-2009 10:16 AM
HI,
1) Report 1-->Use Submit Report2 and Export (Export Statement) the case result to the 2nd report.
2) Report2->Import (Import statement) the case result->Use Conditions.
If case 1.
job_open.
job_submit
job_close -->to run the program in background.
Else.
Run in foreground.
Endif.
Regards,
Gurpreet
03-11-2009 10:41 AM