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

ALV

madan_ullasa
Contributor
0 Likes
1,401

Hi frnds,.

Can we run a ALV report in background?

rgds,

Madan..

1 ACCEPTED SOLUTION
Read only

Former Member

Hi frnds,.

Can we run a ALV report in background?

rgds,

Madan..

12 REPLIES 12
Read only

Former Member
0 Likes
1,211

yeah, you can

if you are using alv classes then you need to use

this code..

CALL METHOD cl_gui_alv_grid=>offline
                RECEIVING e_offline = off.
    IF off IS INITIAL.
      CREATE OBJECT g_custom_container
             EXPORTING container_name = g_container.
    ENDIF.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,211

Yes, are you using the CL_GUI_ALV_GRID? If so, you can do it like this. I have BOLDED the important parts.



REPORT ZRICH_0006 .

* Tables
TABLES: MARA.

* Output internal table
DATA: ITAB TYPE TABLE OF MARA.

* ALV Grid
<b>DATA: R_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: R_CONTROL TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: G_DOCK TYPE REF TO CL_GUI_DOCKING_CONTAINER.</b>

* Other Data Declaration
DATA: OKCODE(4) TYPE C.

* Selection screen
SELECTION-SCREEN BEGIN OF BLOCK ONE WITH FRAME.
SELECT-OPTIONS: SO_MATNR FOR MARA-MATNR.
SELECTION-SCREEN END OF BLOCK ONE.

START-OF-SELECTION.

  SELECT * FROM MARA INTO TABLE ITAB 
                 WHERE MATNR IN SO_MATNR.

  CALL SCREEN 100.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.

  SET PF-STATUS 'LISTOUT1'.
  SET TITLEBAR 'LIST1'.

  IF R_CONTROL IS INITIAL.
<b>* Check whether the program is run in batch or foreground
    IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
* Run in foreground
      CREATE OBJECT R_CONTROL EXPORTING CONTAINER_NAME = 'CONTAINER_1'.
      CREATE OBJECT R_GRID EXPORTING I_PARENT = R_CONTROL.
    ELSE.
* Run in background
      CREATE OBJECT R_GRID EXPORTING I_PARENT = G_DOCK.
    ENDIF.</b>

* Structure ZBA_MARA1 is defined in DDIC as linetype
    CALL METHOD R_GRID->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
    I_STRUCTURE_NAME = 'MARA'
    CHANGING
    IT_OUTTAB = ITAB.
  ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
  CASE OKCODE.
    WHEN 'BACK'.
      SET SCREEN 0.
  ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT


Regards,

Rich Heilman

Read only

0 Likes
1,211

Hi ,

Could you please tell me after making these changes. How do i need to run the ALV Program. Can you please specify step by step.

With Best Regards

Mamatha.B

Read only

0 Likes
1,211

hi Mamatha,

open a new thread because this thread was already answered so no one is going to watch it

Naveen

Read only

madan_ullasa
Contributor
0 Likes
1,211

frnds,

if im not using any classes.... just the FM 'ALV_REUSE_GRID_DISPLAY'....

regrds,

Madan...

Read only

0 Likes
1,211

then in that case , it work well, no need to do any thing...

vijay

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,211

Also, if you are using the function module ALV grid, then this will be handled for you automatically, no need to do anything special. It will generate the list in background.

Regards,

Rich Heilman

Read only

0 Likes
1,211

Hi Rich,

Congrats,...crossed 10K

vijay

Read only

Former Member
Read only

0 Likes
1,211

Thanks Vijay.

Happy New Year,

Rich

Read only

0 Likes
1,211

Hi Rich,

Thanks,

I wish you the Same..

Vijay

Read only

0 Likes
1,211

Does this work for ALV_LIST_DISPLAY as well ?