Skip to Content
avatar image
Former Member

How to display two ALV grid display in a single page.

Hi All,

Can u please tell me how to add two ALV grid diaplay in a single page. I want to display Processed message as a title and below that list of processed messages.

and below this i want to show same for unprocessed messages.

columns for both are same.

Please help me out in this.

Regards,

Jayshree.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • avatar image
    Former Member
    Sep 01, 2008 at 12:35 PM

    Hello,

    Please see this: .

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 01, 2008 at 12:38 PM
    Add comment
    10|10000 characters needed characters exceeded

  • Sep 01, 2008 at 12:38 PM

    Hi Jayshree,

    I am not sure with classical ALV. But it is possible by OOPS ALV.

    Create a screen with 2 containers. Fill these containers with ur internal tables.

    Check below sample code.

    In PBO of the screen put this.

      CREATE OBJECT container1
      EXPORTING
        container_name    = 'CON'.
    
      CREATE OBJECT grid1
        EXPORTING
          i_parent          = container1.
    
      
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
    *   I_BUFFER_ACTIVE              =
         i_structure_name             = 'T_VBAP'
         i_client_never_display       = 'X'
         i_bypassing_buffer           = 'X'
        CHANGING
          ct_fieldcat                  = i_fieldcat
       EXCEPTIONS
         inconsistent_interface       = 1
         program_error                = 2
         OTHERS                       = 3
                .
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD grid->set_table_for_first_display
        EXPORTING
          i_bypassing_buffer            = 'X'
    *    I_BUFFER_ACTIVE               =
    *    I_CONSISTENCY_CHECK           =
          i_structure_name              = 'T_VBAP'
    *    IS_VARIANT                    =
    *    I_SAVE                        =
    *    I_DEFAULT                     = 'X'
        is_layout                     = wa_layout
    *    IS_PRINT                      =
    *    IT_SPECIAL_GROUPS             =
    *    IT_TOOLBAR_EXCLUDING          =
    *    IT_HYPERLINK                  =
    *    IT_ALV_GRAPHICS               =
    *    IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = i_vbap
          it_fieldcatalog               = i_fieldcat
          it_sort                       = i_sort
    *    IT_FILTER                     =
        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 container2
      EXPORTING
        container_name    = 'CON'.
    
      CREATE OBJECT grid2
        EXPORTING
          i_parent          = container2.
     CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
    *   I_BUFFER_ACTIVE              =
         i_structure_name             = 'T_VBAK'
         i_client_never_display       = 'X'
         i_bypassing_buffer           = 'X'
        CHANGING
          ct_fieldcat                  = i_fieldcat
       EXCEPTIONS
         inconsistent_interface       = 1
         program_error                = 2
         OTHERS                       = 3
                .
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
      CALL METHOD grid->set_table_for_first_display
        EXPORTING
          i_bypassing_buffer            = 'X'
    *    I_BUFFER_ACTIVE               =
    *    I_CONSISTENCY_CHECK           =
          i_structure_name              = 'T_VBAK'
    *    IS_VARIANT                    =
    *    I_SAVE                        =
    *    I_DEFAULT                     = 'X'
        is_layout                     = wa_layout
    *    IS_PRINT                      =
    *    IT_SPECIAL_GROUPS             =
    *    IT_TOOLBAR_EXCLUDING          =
    *    IT_HYPERLINK                  =
    *    IT_ALV_GRAPHICS               =
    *    IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = i_vbak
          it_fieldcatalog               = i_fieldcat
          it_sort                       = i_sort
    *    IT_FILTER                     =
        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.
    
    

    Thanks,

    Vinod.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 12:43 PM

    Hi,

    Yes it can be done using oops concept. The following explanation must help you.

    Where we use module pool screen to display the ALV screen. Here create two containers( choose 2nd from bottom icon in lay out design of module-pool screen ) .

    And follow the code below.

    TABLES:bsik,

    bsak.

    **Data decleration

    DATA: OK_CODE TYPE SY-UCOMM.

    types: begin of ty_open,

    bukrs like bsik-bukrs,

    augdt like bsik-augdt,

    gjahr like bsik-gjahr,

    belnr like bsik-belnr,

    dmbtr like bsik-dmbtr,

    wrbtr like bsik-wrbtr,

    saknr like bsik-saknr,

    end of ty_open.

    types: begin of ty_close,

    bukrs like bsak-bukrs,

    augdt like bsak-augdt,

    gjahr like bsak-gjahr,

    belnr like bsak-belnr,

    dmbtr like bsak-dmbtr,

    wrbtr like bsak-wrbtr,

    saknr like bsak-saknr,

    end of ty_close.

    data: wa_open type ty_open,

    wa_close type ty_close.

    data: it_open type standard table of ty_open,

    it_close type standard table of ty_close.

    data : wa_lay1 type lvc_s_layo,

    it_fieldcat1 type lvc_t_fcat ,

    ty_fieldcat1 type lvc_s_fcat ,

    c_alv1 type ref to cl_gui_alv_grid,

    c_cont1 type ref to cl_gui_custom_container.

    data : wa_lay2 type lvc_s_layo,

    it_fieldcat2 type lvc_t_fcat ,

    ty_fieldcat2 type lvc_s_fcat ,

    c_alv2 type ref to cl_gui_alv_grid,

    c_cont2 type ref to cl_gui_custom_container.

    **selection screen declaration

    SELECT-OPTIONS s_bukrs FOR bsik-bukrs.

    PARAMETERS: p_year LIKE bsik-gjahr.

    SELECT-OPTIONS s_docu FOR bsik-belnr.

    START-OF-SELECTION..

    **fetch data into table and field characteristics

    perform fetch_data.

    perform alv_output.

    &----


    *& Form fetch_data

    &----


    form fetch_data .

    **Retrieving open items corresponding to Vendor.

    SELECT bukrs

    augdt

    gjahr

    belnr

    dmbtr

    wrbtr

    saknr

    FROM bsiK

    INTO CORRESPONDING FIELDS OF TABLE it_open

    WHERE bukrs IN s_bukrs

    and ( augdt eq '00.00.0000' or augdt eq space )

    AND gjahr EQ p_year

    AND belnr IN s_docu.

    **Retrieving closed items corresponding to Vendor.

    SELECT bukrs

    augdt

    gjahr

    belnr

    dmbtr

    wrbtr

    saknr

    FROM bsak

    INTO TABLE it_close

    WHERE bukrs IN s_bukrs

    AND ( augdt ne space or augdt ne '00.00.0000' )

    AND gjahr EQ p_year

    AND belnr IN s_docu.

    endform. " fetch_data

    &----


    *& Form alv_output

    &----


    form alv_output .

    call screen '0100'.

    endform. " alv_output

    &----


    *& Module USER_COMMAND_0100 INPUT

    &----


    • text

    ----


    MODULE USER_COMMAND_0100 INPUT.

    CASE ok_code.

    when 'BACK'.

    LEAVE PROGRAM.

    ENDCASE.

    ENDMODULE. " USER_COMMAND_0100 INPUT

    &----


    *& Module STATUS_0100 OUTPUT

    &----


    • text

    ----


    MODULE STATUS_0100 OUTPUT.

    SET PF-STATUS 'RPM'.

    • SET TITLEBAR 'xxx'.

    create object c_cont1

    exporting

    container_name = 'CONT1' .

    if sy-subrc eq 0.

    *Creating object of alv.

    create object c_alv1

    exporting

    i_parent = c_cont1 .

    if sy-subrc eq 0.

    perform lay_out1.

    perform field_cat1.

    call method c_alv1->set_table_for_first_display

    EXPORTING

    is_layout = wa_lay1

    CHANGING

    it_outtab = it_OPEN

    it_fieldcatalog = it_fieldcat1.

    endif.

    endif.

    create object c_cont2

    exporting

    container_name = 'CONT2' .

    if sy-subrc eq 0.

    *Creating object of alv.

    create object c_alv1

    exporting

    i_parent = c_cont2 .

    if sy-subrc eq 0.

    perform lay_out2.

    perform field_cat2.

    call method c_alv1->set_table_for_first_display

    EXPORTING

    is_layout = wa_lay2

    CHANGING

    it_outtab = it_CLOSE

    it_fieldcatalog = it_fieldcat2.

    endif.

    endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    &----


    *& Form LAY_OUT1

    &----


    form lay_out1 .

    wa_lay1-grid_title = 'OPEN ITEMS'.

    wa_lay1-zebra = 'X'.

    • wa_lay1-no_toolbar = 'X'.

    wa_lay1-sel_mode = 'D'.

    endform. " LAY_OUT1

    &----


    *& Form FIELD_CAT1

    &----


    *bukrs like bsik-bukrs,

    • augdt like bsik-augdt,

    • gjahr like bsik-gjahr,

    • belnr like bsik-belnr,

    • dmbtr like bsik-dmbtr,

    • wrbtr like bsik-wrbtr,

    • saknr like bsik-saknr,

    form field_cat1 .

    clear ty_fieldcat1.

    ty_fieldcat1-row_pos = 1.

    ty_fieldcat1-col_pos = 1.

    ty_fieldcat1-fieldname = 'BUKRS'.

    ty_fieldcat1-tabname = 'BSIK'.

    ty_fieldcat1-coltext = 'COMPANY CODE'.

    ty_fieldcat1-outputlen = 12.

    append ty_fieldcat1 to it_fieldcat1.

    clear ty_fieldcat1.

    ty_fieldcat1-row_pos = 1.

    ty_fieldcat1-col_pos = 2.

    ty_fieldcat1-fieldname = 'AUGDT'.

    ty_fieldcat1-tabname = 'BSIK'.

    ty_fieldcat1-coltext = 'CLEARING DATE'.

    ty_fieldcat1-outputlen = 12.

    append ty_fieldcat1 to it_fieldcat1.

    clear ty_fieldcat1.

    ty_fieldcat1-row_pos = 1.

    ty_fieldcat1-col_pos = 3.

    ty_fieldcat1-fieldname = 'GJAHR'.

    ty_fieldcat1-tabname = 'BSIK'.

    ty_fieldcat1-coltext = 'FISCAL YEAR'.

    ty_fieldcat1-outputlen = 10.

    append ty_fieldcat1 to it_fieldcat1.

    clear ty_fieldcat1.

    ty_fieldcat1-row_pos = 1.

    ty_fieldcat1-col_pos = 4.

    ty_fieldcat1-fieldname = 'BSART'.

    ty_fieldcat1-tabname = 'EKKO'.

    ty_fieldcat1-coltext = 'DATE'.

    ty_fieldcat1-outputlen = 10.

    append ty_fieldcat1 to it_fieldcat1.

    endform. " FIELD_CAT1

    &----


    *& Form LAY_OUT2

    &----


    form lay_out2 .

    wa_lay2-grid_title = 'CLOSED ITEMS'.

    wa_lay2-zebra = 'X'.

    • wa_lay1-no_toolbar = 'X'.

    wa_lay2-sel_mode = 'D'.

    endform. " LAY_OUT1

    &----


    *& Form FIELD_CAT1

    &----


    form field_cat2 .

    clear ty_fieldcat2.

    ty_fieldcat2-row_pos = 1.

    ty_fieldcat2-col_pos = 1.

    ty_fieldcat2-fieldname = 'BUKRS'.

    ty_fieldcat2-tabname = 'BSAK'.

    ty_fieldcat2-coltext = 'COMPANY_CODE'.

    ty_fieldcat2-outputlen = 12.

    append ty_fieldcat2 to it_fieldcat2.

    clear ty_fieldcat2.

    ty_fieldcat2-row_pos = 1.

    ty_fieldcat2-col_pos = 2.

    ty_fieldcat2-fieldname = 'BUKRS'.

    ty_fieldcat2-tabname = 'EKKO'.

    ty_fieldcat2-coltext = 'COMP_CODE'.

    ty_fieldcat2-outputlen = 10.

    append ty_fieldcat2 to it_fieldcat2.

    clear ty_fieldcat2.

    ty_fieldcat2-row_pos = 1.

    ty_fieldcat2-col_pos = 3.

    ty_fieldcat2-fieldname = 'BSTYP'.

    ty_fieldcat2-tabname = 'EKKO'.

    ty_fieldcat2-coltext = 'CATEGORY'.

    ty_fieldcat2-outputlen = 10.

    append ty_fieldcat2 to it_fieldcat2.

    clear ty_fieldcat2.

    ty_fieldcat2-row_pos = 1.

    ty_fieldcat2-col_pos = 4.

    ty_fieldcat2-fieldname = 'BSART'.

    ty_fieldcat2-tabname = 'EKKO'.

    ty_fieldcat2-coltext = 'DATE'.

    ty_fieldcat2-outputlen = 10.

    append ty_fieldcat2 to it_fieldcat2.

    endform. " FIELD_CAT1

    With best wishes,

    Rama.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 12:43 PM

    Hi Jayashree,

    Check this sample code:

    [Two alv grids on single page|Two ALV Grids in a single screen;

    Regards,

    Chandra Sekhar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 12:44 PM

    create two container in same screen.

    attach one grid to one container

    and second grid to second container.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 04:47 AM

    Hi,

    The SAP program BALVBT01 provides an example of displying multiple ALV LIST reports on one page.

    Regards,

    Bhaskar

    Add comment
    10|10000 characters needed characters exceeded