‎2010 Mar 16 5:18 AM
Hi everyone,
I have an requirement to schedule a report in background . the report is executing in foreground but i have a button when the report is displayed "post all " so i have to post all the data to the database . so my requirement is when the user will click that "post all" button only then the report should run in background . I tried this in sm35 and sm36 but it did'nt worked .
thanks in advance
nikhil.
‎2010 Mar 16 5:24 AM
Hi,
try to right the logic in the event AT USER COMMAND.
1. when Post all button is pressed by user in the AT user command event check the fcode.
2. use the function modules JOB_OPEN , JOB_SUBMIT and JOB_CLOSE function module to schedule the required report in background.
‎2010 Mar 16 6:09 AM
Thanks Niraj ,
where should i write this code in PAI module , because when i click 'post all' button it will trigger PAI right .
i tried the code given by you in AT USER COMMAND but it is not working i think not running the report in background .
and one more quetion how u will i get to know that after pressing the post all button it is scheduled in background .
‎2010 Mar 16 6:24 AM
Hi,
1. yes you need to write this in to PAI module and check the sy-ucomm.
2. you will able to see the schedule backgound job in SM37 transaction
‎2010 Mar 16 6:49 AM
Hi niraj,
thanks , i have written that code in PAI but it is not working .
WHEN 'POSTALL'.
PERFORM postall.
IF majd = 'ADJUST ADVANCE'.
PERFORM adjdis.
ENDIF.
PERFORM upddistbl.
endcase.this is my code but i am confused that whether to write the background function module before the performs or after it .
do you have any idea .
‎2010 Mar 16 5:31 AM
Hi,
If the user want to post the records without getting displayed you can try,
Call Transaction in Mode 'N'. "By this it will update the tables without displaying it to the user
Hope it helps
Regrds
Mansi
‎2010 Mar 16 5:37 AM
Hi Mansi ,
Thanks for the reply but my requirement is not to call a transaction , its like i have huge amount of data to be posted or modify the Z tables .
when the user will click then i want it to be scheduled in background because in foreground it will show a dump saying 'time limit exceeded' .
Thanks .
‎2010 Mar 16 6:05 AM
hi nikhil
for your requirement just look into the below
case sy-ucomm
when 'postall'
use this link http://help.sap.com/erp2005_ehp_04/helpdata/EN/fa/096d67543b11d1898e0000e8322d00/frameset.htm
hope it works
cheers
s.janagar
‎2010 Mar 16 9:08 AM
Hi Nikhilarya
I assume that in your case you have two program lets say ZFOREGROUND and ZBACKGROUND (Called inside zforeground using submit statement)
zforeground has :
1. a input field to browse excel sheet or some file at the selection screen, and
2. button 'post all' to determine the background processing.
Now your requirement is such that you want zbackground to get scheduled as background job when post all button is clicked.
So, within the event AT USER-Command, check the sy-ucomm as that of post all button, if so write the following code to schedule the job:
DATA: jobname LIKE tbtcjob-jobname.
DATA :jobcount LIKE tbtcjob-jobcount,
host LIKE msxxlist-host.
DATA: BEGIN OF starttime.
INCLUDE STRUCTURE tbtcstrt.
DATA: END OF starttime.
DATA: starttimeimmediate LIKE btch0000-char1.
DATA: gv_job_dt TYPE sy-datum,
gv_job_tm TYPE sy-uzeit.
jobname = 'EXCLUSION_LISTING'.
gv_job_dt = sy-datum.
gv_job_tm = sy-uzeit.
Job open
CALL FUNCTION 'JOB_OPEN'
EXPORTING
delanfrep = ' '
jobgroup = ' '
jobname = jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
IMPORTING
jobcount = jobcount
EXCEPTIONS
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03.
IF sy-subrc NE 0.
"error processing
ENDIF.
Insert process into job
SUBMIT ZBACKGROUND AND RETURN
WITH p_file1 = gv_file_cust_exc "<----
Parameters which you want to pass to report zbackground from the report
WITH p_file2 = gv_file_win_deal "------zforeground
USER sy-uname
VIA JOB jobname
NUMBER jobcount.
IF sy-subrc ne 0.
"error processing
ENDIF.
Close job
starttime-sdlstrtdt = gv_job_dt.
starttime-sdlstrttm = gv_job_tm.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
event_id = starttime-eventid
event_param = starttime-eventparm
event_periodic = starttime-periodic
jobcount = jobcount
jobname = jobname
laststrtdt = starttime-laststrtdt
laststrttm = starttime-laststrttm
prddays = 1
prdhours = 0
prdmins = 0
prdmonths = 0
prdweeks = 0
sdlstrtdt = starttime-sdlstrtdt
sdlstrttm = starttime-sdlstrttm
strtimmed = starttimeimmediate
targetsystem = host
EXCEPTIONS
cant_start_immediate = 01
invalid_startdate = 02
jobname_missing = 03
job_close_failed = 04
job_nosteps = 05
job_notex = 06
lock_failed = 07
OTHERS = 99.
IF sy-subrc EQ 0.
WRITE:/1 'JOB' COLOR 3,
jobname COLOR COL_GROUP,
'Scheduled in Background' COLOR 3. "error processing
gv_time = starttime-sdlstrttm.
gv_date = starttime-sdlstrtdt.
ENDIF.
Above code will schedule the report zbackground in background.
Note:
the program schduled in background will not be able to access any data present on your presentation server. data should be provided either by the program schhedulling it in foreground or it has to be thr in application server.
Thanks
Ankit Attrish