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

Sample code to have ALV Grid in Background

Former Member
0 Likes
6,422

Hi All,

I am currently working on the ALV Grid that should be in background? How can I make this? Can anyone of you can provide me a sample code of a program that generates ALV Grid in background?

Thank you very much in advance!

1 ACCEPTED SOLUTION
Read only

dani_mn
Active Contributor
0 Likes
1,353

HI,

If you are using function module technique then there is

no difference. it will be displayed in background in list format.

For oops this function do the trick.

<b>cl_gui_alv_grid=>offline( ) IS INITIAL.</b>

For OOPs technique use the following code.

<b>


data: g_custom_container type ref to cl_gui_custom_container.
data: G_DOCK TYPE REF TO CL_GUI_DOCKING_CONTAINER.

if g_custom_container is initial.

    IF cl_gui_alv_grid=>offline( ) IS INITIAL.

      create object g_custom_container
             exporting container_name = g_container.

      create object grid1
             exporting i_parent = g_custom_container.

    ELSE.
* If it is in backround:
      CREATE OBJECT grid1
             EXPORTING i_parent = G_DOCK.
    ENDIF.


    call method grid1->set_table_for_first_display
                  exporting
                   is_print         = gs_print
                   is_layout        = gs_layout
                   is_variant       = gs_variant
                   i_save           = 'A'
                   i_default        = 'X'


          changing   it_fieldcatalog = ITAB_C[]
                     it_outtab        = itab[].


  endif.

</b>

Regards,

10 REPLIES 10
Read only

Former Member
0 Likes
1,353

Hi Jason,

Please refer this thread :

Best regards,

Prashant

Read only

0 Likes
1,353

i don't think it is not possible

Read only

Former Member
0 Likes
1,353

hi Jason,

Check this out

Regards,

Santosh

Read only

Laxmana_Appana_
Active Contributor
0 Likes
1,353

Hi,

Check this code :

Data : o_container TYPE REF TO cl_gui_custom_container.

DATA : o_dockingcontainer_1 TYPE REF TO cl_gui_docking_container .

DATA: grid1 TYPE REF TO cl_gui_alv_grid.

  IF NOT sy-batch = 'X'.
    CREATE OBJECT o_container
            EXPORTING
                  container_name = 'CONTAINER'.
    CREATE OBJECT grid1
            EXPORTING
                  i_parent = o_container.
  ELSE.
    CREATE OBJECT grid1
      EXPORTING
     i_parent = o_dockingcontainer_1.
    IF sy-subrc NE 0.
    ENDIF.
  ENDIF.

Regards

Appana

Read only

0 Likes
1,353

This message was moderated.

Read only

dani_mn
Active Contributor
0 Likes
1,354

HI,

If you are using function module technique then there is

no difference. it will be displayed in background in list format.

For oops this function do the trick.

<b>cl_gui_alv_grid=>offline( ) IS INITIAL.</b>

For OOPs technique use the following code.

<b>


data: g_custom_container type ref to cl_gui_custom_container.
data: G_DOCK TYPE REF TO CL_GUI_DOCKING_CONTAINER.

if g_custom_container is initial.

    IF cl_gui_alv_grid=>offline( ) IS INITIAL.

      create object g_custom_container
             exporting container_name = g_container.

      create object grid1
             exporting i_parent = g_custom_container.

    ELSE.
* If it is in backround:
      CREATE OBJECT grid1
             EXPORTING i_parent = G_DOCK.
    ENDIF.


    call method grid1->set_table_for_first_display
                  exporting
                   is_print         = gs_print
                   is_layout        = gs_layout
                   is_variant       = gs_variant
                   i_save           = 'A'
                   i_default        = 'X'


          changing   it_fieldcatalog = ITAB_C[]
                     it_outtab        = itab[].


  endif.

</b>

Regards,

Read only

Former Member
0 Likes
1,353

I'm considering using this code, but I'm not sure what the output looks like. Right now I'm gettting my ALV to output in batch, but some of the colums get cut off... I wanted to try this to see if that corrects the issue. Does the method allow what you see in the spool like a regular ALV table or is it a regualr print format?

Thanks for the help!

Eric Glenn

Read only

Former Member
0 Likes
1,353

Hi Jason,

If your are running the pgm in background mode. You can only use LIST DISPLAY METHOD of ALV.

Regards

Saurabh

Read only

Former Member
0 Likes
1,353

Thanks for all!

Read only

0 Likes
1,353

Hi ,

if you are on Higher versions then ALV Grid works well in Background.

But if you are using the ALV Class CL_GUI_ALV_GRID then you have to use the Logic mentioned in H R A 's Post.

Regards

Vijay