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

Background Execution Problem-Docking Container with 2 ALV Grids in one scre

Former Member
0 Likes
2,725

Hi Friends,

I have created 2 ALV Grids in one screen - one below another using DOCKING CONTAINER.

The objects are 'g_dock_cont' and 'g_dock_cont1'.

I am getting the foreground output as expected with 2 ALV Grids.

While executing in background (F9), I am getting only output of first ALV grid. Second ALV is not getting displayed in BACKGROUND(F9) mode.

How to solve this.

FORM create_objects.
* Materials with data
  IF   g_dock_cont IS INITIAL.
   IF sy-batch NE 'X'.
*CREATE THE OBJECT FOR DOCKING CONTAINER
    CREATE OBJECT g_dock_cont
      EXPORTING
        side                  = cl_gui_docking_container=>dock_at_top
        extension             = 300.
    ENDIF.
*CREATE THE OBJECT FOR ALV GRID
    CREATE OBJECT g_alvgrid
           EXPORTING i_parent = g_dock_cont.
    wa_layout-grid_title =
          'Materials with Data'.
  ENDIF.
*
IF NOT I_DETAIL[] IS INITIAL.
CALL METHOD g_alvgrid->set_table_for_first_display
  EXPORTING
    IS_VARIANT                    = WA_VARIANT_STX
    IS_LAYOUT                     = wa_layout
  CHANGING
    it_outtab                     = I_DETAIL
    IT_FIELDCATALOG               = LIT_FIELDCATALOG[]
  EXCEPTIONS
    INVALID_PARAMETER_COMBINATION = 1
    PROGRAM_ERROR                 = 2
    TOO_MANY_LINES                = 3
    others                        = 4
        .
IF sy-subrc <> 0.
ENDIF.
ENDIF.
*MATERIALS WITHOUT DATA
  IF   g_dock_cont1 IS INITIAL.
   IF sy-batch NE 'X'.
*CREATE THE OBJECT FOR DOCKING CONTAINER
    CREATE OBJECT g_dock_cont1
      EXPORTING
        side                  = cl_gui_docking_container=>dock_at_bottom
        extension             = 300.
   ENDIF.
*CREATE THE OBJECT FOR ALV GRID
    CREATE OBJECT g_alvgrid1
           EXPORTING i_parent = g_dock_cont1.
    wa_layout1-grid_title =
          'Materials without Data'.
  ENDIF.
*
IF NOT I_MARA[] IS INITIAL.
CALL METHOD g_alvgrid1->set_table_for_first_display
  EXPORTING
    IS_LAYOUT                     = wa_layout1
  CHANGING
    it_outtab                     = I_MARA
    IT_FIELDCATALOG               = i_fieldcat[]
  EXCEPTIONS
    INVALID_PARAMETER_COMBINATION = 1
    PROGRAM_ERROR                 = 2
    TOO_MANY_LINES                = 3
    others                        = 4
        .
IF sy-subrc <> 0.
ENDIF.
ENDIF.

ENDFORM.                    " create_objects

Regards,

Viji.

10 REPLIES 10
Read only

Former Member
0 Likes
1,617

Hi,

ALV Grids by default do not work in the background mode.

You have to use the method: cl_gui_alv_grid=>offline( ) for background processing.

Check the code here:

http://www.sapfans.com/forums/viewtopic.php?t=83243

Regards,

ravi

Read only

0 Likes
1,617

Hi Ravi,

I have used the code as suggested by you.

But still I am getting the FIRST ALV GRID while executing in BACKGROUND.

Code pasted for your reference.

Regards,

Viji.

  IF   g_dock_cont IS INITIAL.
    IF cl_gui_alv_grid=>offline( ) IS INITIAL.

      CREATE OBJECT g_dock_cont
      EXPORTING
        side                  = cl_gui_docking_container=>dock_at_top
        extension             = 300.

      CREATE OBJECT g_alvgrid
             EXPORTING i_parent = g_dock_cont.

    ELSE.
* If it is in backround:
      CREATE OBJECT g_alvgrid
             EXPORTING i_parent = g_dock_cont.
    ENDIF.
IF NOT I_DETAIL[] IS INITIAL.
CALL METHOD g_alvgrid->set_table_for_first_display
  EXPORTING
    IS_LAYOUT                     = wa_layout
  CHANGING
    it_outtab                     = I_DETAIL
    IT_FIELDCATALOG               = LIT_FIELDCATALOG[]
  EXCEPTIONS
    INVALID_PARAMETER_COMBINATION = 1
    PROGRAM_ERROR                 = 2
    TOO_MANY_LINES                = 3
    others                        = 4.
       IF sy-subrc <> 0.
       ENDIF.
ENDIF.
ENDIF.
*****************************************
  IF   g_dock_cont1 IS INITIAL.
    IF cl_gui_alv_grid=>offline( ) IS INITIAL.

      CREATE OBJECT g_dock_cont1
      EXPORTING
        side                  = cl_gui_docking_container=>dock_at_BOTTOM
        extension             = 300.

      CREATE OBJECT g_alvgrid1
             EXPORTING i_parent = g_dock_cont1.

    ELSE.
* If it is in backround:
      CREATE OBJECT g_alvgrid1
             EXPORTING i_parent = g_dock_cont1.
    ENDIF.
IF NOT I_MARA[] IS INITIAL.
CALL METHOD g_alvgrid1->set_table_for_first_display
  EXPORTING
    IS_LAYOUT                     = wa_layout1
  CHANGING
    it_outtab                     = I_MARA
    IT_FIELDCATALOG               = i_fieldcat[]
  EXCEPTIONS
    INVALID_PARAMETER_COMBINATION = 1
    PROGRAM_ERROR                 = 2
    TOO_MANY_LINES                = 3
    others                        = 4.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.

Read only

0 Likes
1,617

Hi Friends,

Is there any other ways to get both grids in BACKGROUND execution.

Regards,

Viji

Read only

0 Likes
1,617

Hi Friends,

Anyone encountered this scenario.

Regards

Viji

Edited by: VijayaLakshmi Krishnaswamy on May 6, 2009 3:01 PM

Read only

0 Likes
1,617

Hi,

There is always a problem with the ALV in background if u use Containers / Grid to display more than one List at a time.

As a workaround solution u can try this

Inside the perform where you are displaying the ALVs check for the background mode ( SY-BATCH = 'X' ) and then call REUSE_ALV_LIST_DISPLAY one after another with the data you need to display.

Something like this:

IF SY-BATCH EQ 'X'.

PERFORM LIST_DISPLAY1.

PERFORM LIST_DISPLAY2.

ENDIF.

Inside the LIST_DISPLAY1 & LIST_DISPLAY2 call REUSE_ALV_LIST_DISPLAY to display the data.

You can control the SPOOL with IS_PRINT parameter of REUSE_ALV_LIST_DISPLAY.

Thanks,

Abhishek

Read only

0 Likes
1,617

Hello,

I experienced a similar if not exact problem.

I was displaying one ALV grid, handling a button click(or in background just executing the appropriate form) and then displaying a second ALV grid.

When I ran this job in background the job log showed only one spool list had been created and it contained only the output from one of the ALV grids. However, if I went to sp02/sp01 from the link in the job log I found that there were actually 2 spool lists created. One for each of the ALV grids.

Hope that helps a bit.

Regards

Greg Kern

Read only

0 Likes
1,617

Hi Abhishek,

I have checked the same using SY-BATCH NE 'X'.

But I am getting only one GRID in the OUTPUT. Another GRID is missing.

Is there any other way to get this done.

Regards,

Viji

Read only

0 Likes
1,617

Hi,

What i was saying is that you need to code again for background mode of execution.

AT END OF SELECTION.

IF SY-BATCH EQ 'X'.

PERFORM DISPLAY1.

PERFORM DISPLAY2.

In DISPLAY1 use REUSE_ALV_LIST_DISPLAY to display data from outtab1.

In DISPLAY2 use REUSE_ALV_LIST_DISPLAY to display data from outtab2.

-


For example : execute this report in background mode.this will not execute in online mode.

After execution you will get two spools one for KNA1 and one for LFA1 data. Spool can be controlled via IS_PRINT structure.

report zrbackground.

data gt_lfa1 type standard table of lfa1.

data gt_kna1 type standard table of kna1.

start-of-selection.

select * from lfa1 into table gt_lfa1 up to 10 rows.

select * from kna1 into table gt_kna1 up to 20 rows.

end-of-selection.

if sy-batch eq 'X'.

perform display_lfa1.

perform display_kna1.

endif.

&----


*& Form DISPLAY_LFA1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_lfa1 .

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = sy-repid

i_structure_name = 'LFA1'

tables

t_outtab = gt_lfa1

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " DISPLAY_LFA1

&----


*& Form DISPLAY_KNA1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_kna1 .

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = sy-repid

i_structure_name = 'KNA1'

tables

t_outtab = gt_kna1

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " DISPLAY_KNA1

Please let me know if its not clear or you need more info.

Thanks,

Abhishek

Edited by: abhishek sinha on May 8, 2009 7:42 PM

Edited by: abhishek sinha on May 8, 2009 8:45 PM

Read only

Former Member
0 Likes
1,617

Used download option for the Second grid.

Read only

0 Likes
1,617

Hi VijayaLakshmi,

I am facing the same trouble, how have you got the solution.. Please share..