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

Running Report as Background Process

Former Member
0 Likes
2,993

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.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,072

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

8 REPLIES 8
Read only

Former Member
0 Likes
2,072

Hi

check the thread which will give some information in using background programing.

http://scn.sap.com/thread/805457

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,073

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

Read only

0 Likes
2,072

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

Read only

0 Likes
2,072

Before changing ucomm, add a check


IF sy-batch IS INITIAL.

Else that will trigger the pop-ups for print parameter and jobs scheduling, in background

Regards,

Raymond

Read only

0 Likes
2,072

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.

Read only

0 Likes
2,072

Not with this trick, you would then have to code in the PAI/AT SELECTION-SCREEN

  1. Extract current selection-screen parameters with RS_REFRESH_FROM_SELECTOPTIONS (and with RS_REFRESH_FROM_DYNAMICAL_SEL if logical database)
  2. Fillm the print structure with GET_PRINT_PARAMETERS (setting NO_DIALOG parameter)
  3. Open a job with JOB_OPEN
  4. SUBMIT the report with options, WITH SELECTION-TABLE rspar (WITH FREE SELECTIONS texpr if logical database) , SPOOL PARAMETERS pri_params and VIA JOB job NUMBER n
  5. Schedule job for immediate execution with JOB_CLOSE
  6. Get back to selection  screen (e.g. LEAVE TO CURRENT TRANSACTION or clear ucomm)

Regards,

Raymond

Read only

ThomasZloch
Active Contributor
0 Likes
2,072

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

Read only

Former Member
0 Likes
2,072

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.