2006 Nov 09 6:48 PM
I am displaying one ALV and on the basis of rows selected and user command, I need to display another ALV.
I am using method 'set_table_for_first_display' to call the second ALV.
But rather then displaying second ALV, it is coming out of the execution mode.
Kindly help.
I am displaying one ALV and on the basis of rows selected and user command, I need to display another ALV.
I am using method 'set_table_for_first_display' to call the second ALV.
But rather then displaying second ALV, it is coming out of the execution mode.
Kindly help.
2006 Nov 09 6:52 PM
Hi
U should call a new screen where you display the second ALV.
Max
2006 Nov 09 6:54 PM
2006 Nov 09 7:01 PM
For first ALV>>
*******
MODULE create_objects OUTPUT.
CREATE OBJECT g_alv_container
EXPORTING
container_name = 'YVASS_GRID'."screen
CREATE OBJECT g_alv_grid
EXPORTING
i_parent = g_alv_container .
ENDMODULE. " CREATE_OBJECTS OUTPUT
********
MODULE call_grid_object OUTPUT.
ALV control: Layout structure
DATA: gs_layout TYPE lvc_s_layo.
gs_layout-sel_mode = 'A'.
CALL METHOD g_alv_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = t_itab[]
it_fieldcatalog = structure_report
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDMODULE. " CALL_GRID_OBJECT
*******
FOR SECOND ALV
*******
FORM error_alv_display .
DATA: gs_layout_err TYPE lvc_s_layo.
CALL METHOD g_alv_grid->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_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.
*
CLEAR: g_alv_grid.
PERFORM get_field_catalog.
gs_layout_err-sel_mode = 'A'.
CALL METHOD g_alv_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout_err
CHANGING
it_outtab = t_yvasstk_err_desc_all[]
it_fieldcatalog = structure_report_all
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDFORM. " Error_ALV_display
***********
When I use method <Free> then it is giving me a dump.
2006 Nov 09 7:05 PM
2006 Nov 09 7:04 PM
Hello Ashish
I have already developed several reports containing multiple ALV lists that have to communicate with each other.
You should apply the following logic:
(1) Use a splitter container having two cells (for the two ALV lists)
(2) Use the first cell (e.g. the top cell) as parent for your main ALV list (first list).
(3) Use the second cell (e.g. the bottom cell) as parent for your detail ALV list.
How do you link both ALV lists together? When the user has selected a row in the main ALV list and pushes, for example, button "Display Details" then you use the values of the selected entry as filter for the detailed ALV list.
You have to use the grid method SET_FILTER_CRITERIA. After setting the new filter criteria you must refresh (method <detail ALV grid>-REFRESH_TABLE_DISPLAY) the ALV list.
Regards
Uwe
2006 Nov 09 9:28 PM
Hello Ashish
Here is a simple report demonstrating the communication between a "header" and a corresponding "position" ALV list.
The dynpro '0100' does not contain any elements and has the following flow logic:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.And here is the report. The first ALV list displays all customers of a company code. If you select one customer and push the button 'DETAIL' then the sales areas of the customer are displayed in the second ALV list.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_TWO_ALV_GRIDS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_two_alv_grids.
DATA:
gd_okcode TYPE ui_func,
*
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_knvv TYPE STANDARD TABLE OF knvv.
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
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 splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_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.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
EXCEPTIONS
OTHERS = 5.
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 go_grid2
EXPORTING
i_parent = go_cell_bottom
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
<b>* Display data</b>
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
CHANGING
it_outtab = gt_knb1
EXCEPTIONS
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.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNVV'
CHANGING
it_outtab = gt_knvv " empty !!!
EXCEPTIONS
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.
<b>* Link the docking container to the target dynpro</b>
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
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.
CALL SCREEN '0100'.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
<b>* Refresh display of detail ALV list</b>
CALL METHOD go_grid2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
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.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
<b>* User has pushed button "Display Details"</b>
WHEN 'DETAIL'.
PERFORM entry_show_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form ENTRY_SHOW_DETAILS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM entry_show_details .
* define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM knvv INTO TABLE gt_knvv
WHERE kunnr = ls_knb1-kunnr.
ENDFORM. " ENTRY_SHOW_DETAILSRegards
Uwe
2006 Nov 09 7:08 PM
Hi Ashish,
Are you using single container for both the ALVs..? I think you should use separate containers for both.
If you are using FREE method, then it will free the object and the reference variable will be null as there is nothing which it can point to.That is why it is giving you dump.
Use two containers and I think it should not cause any problem.
Regards,
SP.
2006 Nov 09 7:46 PM
Thanks for the response...
But my problem is still not fully solved. I have created a new screen with new container and grid object. But when i am calling method 'set_table_for_first_display' with new grid object, it is not displaying any data. But the layout is correct (catalogue is showing new fields.)
2006 Nov 09 7:52 PM
2006 Nov 09 7:57 PM
Yes I have the data in internal table which I am passing in method 'set_table_for_first_display'.
2006 Nov 09 8:00 PM
2006 Nov 09 8:00 PM
Hi Ashish,
Try to debug the program. Check if the internal table is getting populated with data to be sent to ALV Grid. If possible , can you just give the code so that we can analyse where the problem lies..
Regards,
SP.
2006 Nov 09 8:03 PM
Rich: you are right I am getting blank ALV with correct field headings.
SP: Here is the code for second ALV..
FORM error_alv_display .
ALV control: Layout structure
DATA: gs_layout_err TYPE lvc_s_layo.
CALL METHOD g_alv_grid->FREE
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_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.
*
CLEAR: g_alv_grid.
PERFORM get_field_catalog.
gs_layout_err-sel_mode = 'A'.
CALL METHOD g_alv_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout_err
CHANGING
it_outtab = t_yvasstk_err_desc_all[]
it_fieldcatalog = structure_report_all
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CREATE OBJECT event_receiver_err.
SET HANDLER event_receiver_err->handle_top_of_page FOR g_alv_grid.
SET HANDLER event_receiver_err->handle_end_of_list FOR g_alv_grid.
ENDFORM. " Error_ALV_display
*
*
*&----
**& Form get_field_catalog
*&----
FORM get_field_catalog .
PERFORM add_row USING 'ycorpcust' 'yvasstk_err_desc' 'ycorpcust'.
PERFORM add_row USING 'yfilenmbr' 'yvasstk_err_desc' 'yfilenmbr'.
PERFORM add_row USING 'yrecnmbr' 'yvasstk_err_desc' 'yrecnmbr'.
PERFORM add_row USING 'yrecsub' 'yvasstk_err_desc' 'yrecsub'.
PERFORM add_row USING 'yconsnmbr' 'yvasstk_err_desc' 'yconsnmbr'.
PERFORM add_row USING 'yerror' 'yvasstk_err_desc' 'yerror'.
PERFORM add_row USING 'yerrorline' 'yvasstk_err_desc' 'yerrorline'.
ENDFORM. " get_field_catalog
*
*&----
**& Form ADD_ROW
*&----
Filling a catalog by passing a value of field table-name
and fieldname
*----
FORM add_row USING p_ref_field
p_ref_table
p_fieldname.
CLEAR wa_structure_report.
wa_structure_report-ref_field = p_ref_field.
wa_structure_report-ref_table = p_ref_table.
wa_structure_report-fieldname = p_fieldname.
APPEND wa_structure_report TO structure_report_all.
ENDFORM. " add_row
2006 Nov 09 8:06 PM
Hi
But g_alv_grid is the grid for the first ALV, isn't it?
U should use a new object g_alv_grid_2 for example.
Max
2006 Nov 09 8:13 PM
2006 Nov 09 8:13 PM
Hi Ashish,
What I can find out from your program is in the field catalog, you are using lower case values to the field names and other fields. Try giving it in upper case, always.
Also I assume that you have created two reference variables for the containers and using as per that.
For eg:
data: container_name1 type ref to cl_gui_custom_container, " for first ALV
container_name2 type ref to cl_gui_custom_container. " for second ALV
Regards,
SP.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |