Skip to Content
Author's profile photo Praveer Kumar Sen

Run in Background and Get in ALV Format

Hello,

Some of the customize reports, which takes more time to execute in foreground and after some time it gives the time out error.

and we suggest users to execute the report in background.

But then after they get the information in list view format.

For these, they go through with the customize T-code and then SM37, there they have to find the related report background job.

And execute the same for the final result.

To overcome the issues faced by the users, I have come-up with a solution in the customize report,

where i have added two more option, as show below.

1. Background Process: –

I have created a Function Module, which executes the program directly in background with auto generated job id.

In this function module, a programmer needs to create a logic, where they have to pass only those input field information’s

which contains the values.

I have used one of my created program, with that user can fetch the field combination information’s between SAP tables.

http://scn.sap.com/docs/DOC-48837

Screen Logic: –

SELECTION-SCREEN:   BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT001.

  SELECTION-SCREEN:    BEGIN OF LINE,
    PUSHBUTTON 2(20) BTN_BACK USER-COMMAND BTTN_BACK.
  SELECTION-SCREEN:    END OF LINE.

  SELECTION-SCREEN:    BEGIN OF LINE.
  SELECTION-SCREEN:    END OF LINE,
   PUSHBUTTON 2(20) BTN_DISP USER-COMMAND BTTN_DISP.
SELECTION-SCREEN:   END OF BLOCK B2.

DATA:   GIT_SCR TYPE STANDARD TABLE OF RSPARAMS,
         GFL_SCR LIKE LINE OF GIT_SCR.


AT SELECTION-SCREEN.
   CASE SYUCOMM.
     WHEN ‘BTTN_BACK’.
       REFRESH: GIT_SCR.
       PERFORM SUB_UPDATE_SCREEN_INFO USING ‘P_FLDNM’ ‘P’ ‘I’ ‘EQ’ P_FLDNM .
       IF S_DATELMLOW NE SPACE.
         PERFORM SUB_UPDATE_SCREEN_INFO USING ‘S_DATELM’ ‘S’ ‘I’ ‘EQ’ S_DATELMLOW .
       ENDIF.
       IF S_WIDFLLOW NE SPACE.
         PERFORM SUB_UPDATE_SCREEN_INFO USING ‘S_WIDFL’  ‘S’ ‘I’ ‘EQ’ S_WIDFLLOW .
       ENDIF.
       IF S_CLASSLOW NE SPACE.
         PERFORM SUB_UPDATE_SCREEN_INFO USING ‘S_CLASS’  ‘S’ ‘I’ ‘EQ’ S_CLASSLOW .
       ENDIF.
       CALL FUNCTION ‘ZPRV_BACKGROUND_PROCESS’
         EXPORTING
           G_PROG              = SYREPID
         TABLES
           VARI_CONTENTS       = GIT_SCR.

     WHEN OTHERS.
   ENDCASE.

If the function module executes successfully, then a pop will display, “Program Executed Successfully!’.

2. Display Output

To display the all background jobs of the respective report.

Create a program with refer to below blog.

http://scn.sap.com/docs/DOC-48984

And write the below code for Display Output option.


     WHEN ‘BTTN_DISP’.
       DATA: L_BTCJOB  TYPE BTCJOB.
       CONCATENATE SYREPID ‘*’ INTO L_BTCJOB.
       SUBMIT ZPRV_DISPLAY_BACKGROUND WITH P_JOB = L_BTCJOB.

Here the ZPRV_DISPLAY_BACKGROUND is the program name, which created with refer the http://scn.sap.com/docs/DOC-48984  blog.

If the Display Output option is selected, then if any background job exists based on the customize report, it will display the job information’s in ALV grid.

By double clicking on any one of the records, the respective list information will display in formatted ALV Grid.

Thanks & Regards.

Praveer Kumar Sen

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Shakeeluddin Khaja
      Shakeeluddin Khaja

      Thanks for sharing Praveen.

      Regards,

      Shakeel.

      Author's profile photo Former Member
      Former Member

      Thanks Praveer..