Search code examples
abapalv

Display two tables on one screen with CL_SALV_TABLE


I would like to ask if it is possible to display two related tables (e.g., by PO number) on one screen by using the class CL_SALV_TABLE.

If not, what other class would work?

Thank you in advance!


Solution

  • As Sandra correctly said it is impossible. You need to change the approach: set up split container and display your tables/grids in it. The template steps for such displaying would be following:

    * creating splitter
    DATA(split) = NEW cl_gui_splitter_container( parent = cl_gui_container=>screen0
                                                 no_autodef_progid_dynnr = abap_true
                                                 rows = 1
                                                 columns = 2 ).
    
    * marking container
    DATA(spl_left) = split->get_container( row = 1 column = 1 ).
    DATA(spl_right) = split->get_container( row = 1 column = 2 ).
    
    * grid 1
    cl_salv_table=>factory( EXPORTING
                                r_container    = spl_right
                              IMPORTING
                                r_salv_table   = o_salv
                              CHANGING
                                t_table        = it_salv_itab1 ).
    
    * grid 2
    cl_salv_table=>factory( EXPORTING
                                r_container    = spl_left
                              IMPORTING
                                r_salv_table   = o_salv
                              CHANGING
                                t_table        = it_salv_itab2 ).
    

    Check this page for a comprehensive example https://codezentrale.de/abap-gui-simple-tree-und-salv-grid-in-split-container-ohne-dynpro-anzeigen-eventhandling/