‎2012 Sep 05 7:34 AM
Hi Experts,
I have few reports that need to be run in both foreground and background as per the user wants.
At selection screen, there has to be a Checkbox for background process, which if the user checks and Executes (F8) then the program should run in the background and after its finished the output (Smartform/Mail/ALVgrid) should be displayed/sent accordingly.
Now I have searched alot but have not found proper solution for this exact problem.
So please help me with this..
Thanks,
Vishal.
‎2012 Sep 05 8:07 AM
Without too much code you could try in PAI (AT SELECTION-SCREEN)
TABLES: sscrfields.
PARAMETERS p_backgr AS CHECKBOX.
AT SELECTION-SCREEN.
IF ( sscrfields-ucomm EQ 'ONLI' OR sscrfields-ucomm EQ 'PRIN' )
AND p_backgr IS NOT INITIAL.
sscrfields-ucomm = 'SJOB'.
ENDIF.
If you don't want the background information pop-up, code a JOB_OPEN/SUBMIT VIA JOB/JOB_CLOSE in the START-OF-SELECTION. (Samples at cheduling a Job: Full-Control Method) You can pass parameters in the SUBMIT with option WITH SELECTION-TABLE where the internal table is provided by FM RS_REFRESH_FROM_SELECTOPTIONS.
Regards,
Raymond
‎2012 Sep 05 7:41 AM
Hi
check the thread which will give some information in using background programing.
‎2012 Sep 05 8:07 AM
Without too much code you could try in PAI (AT SELECTION-SCREEN)
TABLES: sscrfields.
PARAMETERS p_backgr AS CHECKBOX.
AT SELECTION-SCREEN.
IF ( sscrfields-ucomm EQ 'ONLI' OR sscrfields-ucomm EQ 'PRIN' )
AND p_backgr IS NOT INITIAL.
sscrfields-ucomm = 'SJOB'.
ENDIF.
If you don't want the background information pop-up, code a JOB_OPEN/SUBMIT VIA JOB/JOB_CLOSE in the START-OF-SELECTION. (Samples at cheduling a Job: Full-Control Method) You can pass parameters in the SUBMIT with option WITH SELECTION-TABLE where the internal table is provided by FM RS_REFRESH_FROM_SELECTOPTIONS.
Regards,
Raymond
‎2014 Jan 03 10:06 AM
Thank you Raymond for ur reply.
I tried ur solution in my code but as soon as the Background job starts,
It directly gets CANCELLED.
So what could be the reason for this ?
my code is as below.
===========================================
INITIALIZATION.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : so_no FOR vbak-vbeln ,
c_name FOR vbpa-kunnr,
so_date FOR itab-edatu.
PARAMETERS : backg AS CHECKBOX DEFAULT ' ' USER-COMMAND e2.
PARAMETERS : p_mail AS CHECKBOX DEFAULT ' ' USER-COMMAND e1.
SELECTION-SCREEN: END OF BLOCK b1.
AT SELECTION-SCREEN.
IF ( sscrfields-ucomm EQ 'ONLI' OR sscrfields-ucomm EQ 'PRIN' )
AND backg IS NOT INITIAL.
sscrfields-ucomm = 'SJOB'.
ENDIF.
START-OF-SELECTION.
PERFORM fetch_data.
END-OF-SELECTION.
IF p_mail = ' '.
IF itab[] IS NOT INITIAL.
PERFORM field_catalog.
PERFORM display.
ELSE.
PERFORM field_catalog.
PERFORM display.
ENDIF.
ELSEIF backg = 'X'.
PERFORM prepare_summary.
ELSEIF p_mail = 'X'.
PERFORM prepare_summary.
ENDIF.
Thanks,
Vishal
‎2014 Jan 03 10:15 AM
‎2014 Jan 03 11:26 AM
Thanks Raymond,
Its working now.
But before adding IF sy-batch IS INITIAL. the printer and job schedule popups were coming.
and even after adding, both the popups still come.
So is there anyway they can be suppressed or run in background so the user doesn't have to click few times on the popups in order to start the background job ??
Regards,
Vishal.
‎2014 Jan 03 12:07 PM
Not with this trick, you would then have to code in the PAI/AT SELECTION-SCREEN
Regards,
Raymond
‎2012 Sep 05 11:41 AM
On the selection screen, the user can hit F8 for online and F9 for background processing. Why is there a need for additional development?
Thomas
‎2012 Sep 05 11:46 AM
Hi
yes you can go with function keys and select foreground and background insted of writing code seperatly.
try using F8 and F9 function keys as explained in above thread.