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: 

passing and reading the one container data to another container in Split containers in using CL_SALV

karthikganti
Explorer
0 Kudos

Dears,

We have a requirement where we need to display multiple ALV's on single screen. User will select the line item from first grid and few items from 4th grid. Based on the selected items from both the containers, an order to be created.

We have a button on first container , upon clicking we identify the item selected from container 1 using below code.

lr_selections1 = o_salv_table4->get_selections( ).
lt_rows1 = lr_selections1->get_selected_rows( ).

Similarly we wanted to read the data which is selected in 4th container when button is pressed in first container only. As the instances are different, 4th container selected data is not visible in the first container.

Attaching document has the the sample output which we are expecting.

Is it possible to to read the containers data in other container ?

Can anyone share the ideas on how to achieve the same?

PS : We have an alternative approach where we are displaying 3grids on first screen and upon submission 4th grid on different screen. However we would like to display 4 grids on one ALV screen so that user will able to view complete details at one go.

Thank you.

5 REPLIES 5

Sandra_Rossi
Active Contributor
0 Kudos

Of course it's possible. I don't understand what issue you have.

For instance: when the button is pressed in 1st container, raise a custom event that has a method handler in your main controller application (the one which initiates the 4 ALV grids), which then selects lines from the 4th ALV grid.

"4 grids on one ALV screen"? You mean "4 ALV grids on one screen"?

gdey_geminius
Contributor
0 Kudos

I believe it's possible using "CL_ALV_GRID_DISPLAY". What you have to do is, when button is pressed in ALV1, you have to call the "CHECK_CHANGED_DATA" method on the object of ALV4. Then if you read the selected row, you will be able to read the selected row from ALV4. I didn't find the similar possibility using "CL_SALV_TABLE". I believe we cannot do the same using "CL_ALV_TABLE".

Thanks,

Gourab

karthikganti
Explorer
0 Kudos

Dear Sandra,

Thank you for the response. We have already tried the option you suggested, but did not work out unfortunately.

karthikganti
Explorer
0 Kudos

Dear Gourab,

Thanks for the response.

Currently we have an alternate approach which we have gone with.

As rework is needed, I will work on the approach suggested and will keep posted .

Thank you.

YorRombaut
Participant
0 Kudos

Hi Karthik,

As Sandra states, this is perfectly possible..

Are you using classes CL_GUI_ALV_GRID and CL_GUI_CUSTOM_CONTAINER, to create instances of your tables and containers? If so, you should be able to get the selections using the method: CL_GUI_ALV_GRID->GET_SELECTED_ROWS( IMPORTING et_index_rows = DATA(lt_index_rows1) ). from any ALV on the screen..

Also make sure that you have instantiated the ALV with the correct layout selection parameters ("lvc_s_layo-sel_mode"), else he cannot know which lines were selected.

kr

Yor

Check this sample code where I get the selected lines from both ALV's:

REPORT ztest_yr.
DATA:
  go_alv_container1 TYPE REF TO cl_gui_custom_container,
  go_alv_grid1      TYPE REF TO cl_gui_alv_grid,
  go_alv_container2 TYPE REF TO cl_gui_custom_container,
  go_alv_grid2      TYPE REF TO cl_gui_alv_grid,
  gt_table1         TYPE TABLE OF zbc_int4,
  gt_table2         TYPE TABLE OF zbc_char20,
  gs_table1         TYPE zbc_int4,
  gs_table2         TYPE zbc_char20.
gs_table1-int4 = 1.
APPEND gs_table1 TO gt_table1.
gs_table1-int4 = 2.
APPEND gs_table1 TO gt_table1.
gs_table1-int4 = 3.
APPEND gs_table1 TO gt_table1.
gs_table2-char20 = 'a'.
APPEND gs_table2 TO gt_table2.
gs_table2-char20 = 'b'.
APPEND gs_table2 TO gt_table2.
gs_table2-char20 = 'c'.
APPEND gs_table2 TO gt_table2.

CALL SCREEN 1100.

*----------------------------------------------------------------------*
***INCLUDE ZTEST_YR_PAI.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_1100 INPUT.
  IF sy-ucomm EQ 'PRESS'.
    go_alv_grid1->get_selected_rows( IMPORTING et_index_rows = DATA(lt_index_rows1) ).
    go_alv_grid2->get_selected_rows( IMPORTING et_index_rows = DATA(lt_index_rows2) ).
  ENDIF.
ENDMODULE.
*----------------------------------------------------------------------*
***INCLUDE ZTEST_YR_PBO.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_1100 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_1100 OUTPUT.
  DATA:
      ls_layout TYPE lvc_s_layo.
    ls_layout-sel_mode = 'D'.
    ls_layout-info_fname = 'LINECOLOR'.
  " Create container object
    CREATE OBJECT go_alv_container1
      EXPORTING
        container_name = 'CONTAINER1'.
    " Create grid object
    CREATE OBJECT go_alv_grid1
      EXPORTING
        i_parent = go_alv_container1.
    go_alv_grid1->set_table_for_first_display( EXPORTING
                                                  is_layout = ls_layout
                                                  i_structure_name = 'ZBC_INT4'
                                               CHANGING
                                                 it_outtab = gt_table1 ).
    " Create container object
    CREATE OBJECT go_alv_container2
      EXPORTING
        container_name = 'CONTAINER2'.
    " Create grid object
    CREATE OBJECT go_alv_grid2
      EXPORTING
        i_parent = go_alv_container2.
    go_alv_grid2->set_table_for_first_display( EXPORTING
                                                  is_layout = ls_layout
                                                  i_structure_name = 'ZBC_CHAR20'
                                               CHANGING
                                                 it_outtab = gt_table2 ).
ENDMODULE.