Application Development 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: 

Container ALV not working in background

Former Member
0 Kudos

Hi all,

I created an ALV grid, which runs fine foreground. In the background however the spool is created but cancelled.

REATE OBJECT g_custom_container

EXPORTING

container_name = 'G_CUSTOM_CONTAINER'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6.

IF sy-subrc <> 0.

  • Error in custom container instantiation. ALV cannot be displayed

MESSAGE e000 WITH text-015.

ENDIF.

CREATE OBJECT g_dyndoc_id

EXPORTING

style = 'ALV_GRID'.

  • Create a splitter and split the container for

  • the two parts of ALV contents

CREATE OBJECT g_splitter

EXPORTING

parent = g_custom_container

rows = 2

columns = 1.

  • Get container for top half of the report

CALL METHOD g_splitter->get_container

EXPORTING

row = 1

column = 1

RECEIVING

container = g_container_top.

  • Set the height of container for top half of the report

CALL METHOD g_splitter->set_row_height

EXPORTING

id = 1

height = 20.

  • Get Container for bottom half of the report

CALL METHOD g_splitter->get_container

EXPORTING

row = 2

column = 1

RECEIVING

container = g_container_grid.

  • Instantiate ALV grid main report

CREATE OBJECT g_grid

EXPORTING

i_parent = g_container_grid

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • Error in grid instantiation. ALV caanot be displayed

MESSAGE e000 WITH text-016.

ENDIF.

  • Build field catalogue

PERFORM build_field_cat.

  • Inatntiate Top-of-Page event

CREATE OBJECT g_events.

SET HANDLER g_events->handle_top_of_page FOR g_grid.

    • IF it_comparednomatch[] IS INITIAL.

    • MESSAGE s000 with text-003.

    • EXIT.

    • ELSE.

  • Print ALV Contents of first half of report

g_grid->set_table_for_first_display( EXPORTING i_default = 'X'

CHANGING it_outtab = it_comparednomatch

it_fieldcatalog = it_fldctdrl

EXCEPTIONS invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4 ).

IF sy-subrc <> 0.

  • Error in displaying ALV

MESSAGE e000 WITH text-017.

ENDIF.

  • ENDIF.

ENDIF.

      • Call top-Of-Page

CALL METHOD g_grid->list_processing_events

EXPORTING

i_event_name = 'TOP_OF_PAGE'

i_dyndoc_id = g_dyndoc_id.

Please help me out.

19 REPLIES 19

Former Member
0 Kudos

Hi ,

When you run in background if you use ALV grid output comes as ALV list ,so the container wouldn't work .

Mostly OOPS grid is for foreground .

Please reward if useful.

vinod_vemuru2
Active Contributor
0 Kudos

Hi Shilpi,

OOPS ALV and GRID display using FMs will not work in back ground since they need interactions with front end which is not possible when u run in back ground.

Best solution is convert ur OOPs ALV to List display using FMs REUSE_ALV_LIST_DISPLAY. It works fine.

I think there is no other way to run ur code in background.

Check the error log of ur job. It could have tried to make interaction with front end.

Thanks,

Vinod.

Former Member
0 Kudos

Hi Shilpi,

For background ALV processing, don't use OOPS! U can use this fm : REUSE_ALV_GRID_DISPLAY.

Reward if useful!

Tarick.

Former Member
0 Kudos

Hi

If you need to run a program with ALV grid in background mode, u should set the parameter IS_PRINT-PRINT = 'X' in order to generate the spool only.

Max

former_member188685
Active Contributor
0 Kudos

For background program or Foreground it works very well. you dont need to change any thing. Just check this small sample code.

REPORT  ztest_oo_a.

DATA: it_flight TYPE sflight_tab1.
DATA: dock TYPE REF TO cl_gui_docking_container,
      grid TYPE REF TO cl_gui_alv_grid.

SELECT *
  FROM sflight
  INTO TABLE it_flight
  UP TO 20 ROWS.

CALL SCREEN 100.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SATR'.


  CREATE OBJECT dock
    EXPORTING
      repid     = sy-repid
      dynnr     = '100'
      extension = '1500'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      OTHERS                      = 6
      .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  CREATE OBJECT grid EXPORTING i_parent = dock.

  CALL METHOD grid->set_table_for_first_display
    EXPORTING
      i_structure_name              = 'SFLIGHT'
    CHANGING
      it_outtab                     = it_flight
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE ucomm.

    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

Flow Logic..

PROCESS BEFORE OUTPUT.
 MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_0100.

and Don't create any control on the screen. just create an empty screen. thats all. run Foreground and background. both will give you the respective output.

0 Kudos

Hi Vijay,

It is working but i have different problem in my report i am displaying two alv on one page so with your solution how can two alvs be managed on single screen without using the container approach.

0 Kudos

We can do that without having any problem.

We can split the Docking container and proceed. i will give you the sample .

0 Kudos

Hi

In this case u can try to use the ALV list and print the second ALV in the event END_OF_LIST of the the first ALV:

TYPE-POOLS: SLIS.

DATA: BEGIN OF ITAB1 OCCURS 0,
        LIFNR LIKE LFA1-LIFNR,
        NAME1 LIKE LFA1-NAME1,
      END   OF ITAB1.

DATA: BEGIN OF ITAB2 OCCURS 0,
        KUNNR LIKE KNA1-KUNNR,
        NAME1 LIKE KNA1-NAME1,
      END   OF ITAB2.

DATA: GT_FIELDCAT1 TYPE  SLIS_T_FIELDCAT_ALV,
      GT_FIELDCAT2 TYPE  SLIS_T_FIELDCAT_ALV,
      GT_EVENTS    TYPE  SLIS_T_EVENT WITH HEADER LINE,
      GT_REPORT    TYPE  SY-REPID,
      LT_LAYOUT    TYPE  SLIS_LAYOUT_ALV.

START-OF-SELECTION.

  SELECT LIFNR NAME1 UP TO 10 ROWS FROM LFA1 INTO ITAB1.
    APPEND ITAB1.
  ENDSELECT.

  SELECT KUNNR NAME1 UP TO 10 ROWS FROM KNA1 INTO ITAB2.
    APPEND ITAB2.
  ENDSELECT.

END-OF-SELECTION.

  GT_REPORT = SY-REPID.

* Catalog first ALV:
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            I_PROGRAM_NAME     = GT_REPORT
            I_INTERNAL_TABNAME = 'ITAB1'
            I_INCLNAME         = GT_REPORT
       CHANGING
            CT_FIELDCAT        = GT_FIELDCAT1.

* Catalog second ALV:
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            I_PROGRAM_NAME     = GT_REPORT
            I_INTERNAL_TABNAME = 'ITAB2'
            I_INCLNAME         = GT_REPORT
       CHANGING
            CT_FIELDCAT        = GT_FIELDCAT2.

* Set events
  GT_EVENTS-NAME = 'END_OF_LIST'.
  GT_EVENTS-FORM = 'END_OF_LIST'.
  APPEND GT_EVENTS.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM = GT_REPORT
            IT_FIELDCAT        = GT_FIELDCAT1
            IT_EVENTS          = GT_EVENTS[]
       TABLES
            T_OUTTAB           = ITAB1.

*---------------------------------------------------------------------*
*       FORM end_of_list                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM END_OF_LIST.
  LT_LAYOUT-LIST_APPEND = 'X'.
* Second ALV
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM = GT_REPORT
            IS_LAYOUT          = LT_LAYOUT
            IT_FIELDCAT        = GT_FIELDCAT2
       TABLES
            T_OUTTAB           = ITAB2.
ENDFORM.

Or you can use the ALV block in order to print the ALVs dispalyed in a single page by alv grid

Max

0 Kudos

Hi Vijay ,

send me the sample code of two alvs on the same screen .You forgot the code in the last reply.

0 Kudos

Hi,

I want to display in Grid only because of req.

0 Kudos

Hi

U need to use two different calls:

- One of on-line mode: here u use the GRID;

- One of background mode: here u can't use the grid if you wan't to print boths ALV, in this case u can produce the spool only.

Max

0 Kudos

Hi,

Even we cant display in list in background process.

former_member188685
Active Contributor
0 Kudos

In Background only one ALV Print is coming, but the other one is giving not showing, This is not giving any Dump unlike previous case.

REPORT  ztest_oo_a.

DATA: it_flight TYPE sflight_tab1.
DATA: dock TYPE REF TO cl_gui_docking_container,
      split TYPE REF TO cl_gui_splitter_container,
      grid1 TYPE REF TO cl_gui_alv_grid,
      grid2 TYPE REF TO cl_gui_alv_grid,
      doc1 TYPE REF TO cl_gui_docking_container,
      con22 TYPE REF TO cl_gui_docking_container.

SELECT *
  FROM sflight
  INTO TABLE it_flight
  UP TO 20 ROWS.

CALL SCREEN 100.


*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SATR'.


  CREATE OBJECT dock
    EXPORTING
      repid     = sy-repid
      dynnr     = '100'
      extension = '600'
      side     = '1'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      OTHERS                      = 6
      .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CREATE OBJECT doc1
    EXPORTING
      repid     = sy-repid
      dynnr     = '100'
      extension = '1000'
      side     = '4'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      OTHERS                      = 6
      .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


  CREATE OBJECT grid1 EXPORTING i_parent = dock.


  CALL METHOD grid1->set_table_for_first_display
    EXPORTING
      i_structure_name              = 'SFLIGHT'
    CHANGING
      it_outtab                     = it_flight
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CREATE OBJECT grid2 EXPORTING i_parent = doc1.


  CALL METHOD grid2->set_table_for_first_display
    EXPORTING
      i_structure_name              = 'SFLIGHT'
    CHANGING
      it_outtab                     = it_flight
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE sy-ucomm.

    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.


ENDMODULE.                 " USER_COMMAND_0100  INPUT

0 Kudos

Hi

Just as I said in my previuos answer, I believe the grid ALV can't print both ALVs (displayed in a single screen), so it need to force the print using the ALV list.

If it needs to print two ALV or it tryes to use my solution (with event END_OF_LIST) or it use ALV block.

So:

- use ALV grid in ON-LINE mode;

- use ALV list in background mode

Max

0 Kudos

Hi Vijay,

It is displaying only one list in spool.

0 Kudos

Hi ,

I need to display 2 Alv's in background display using Docking.. But it displays only first screen in background output.. Is there any way of doing that??

0 Kudos

You will have to have 2 separate logics for foreground and background, use ALV list as block in background if you need to see 2 ALVs in spool.

Former Member
0 Kudos

This message was moderated.

former_member228514
Participant
0 Kudos

This message was moderated.