2014 Jun 06 5:36 AM
Hi friends,
set_table_for_first_display using display interactive reports.
My task: When am i select Some row in First Display and Execut My Second display have same related records data.
I have idea how to do Using Function Modules. I should use Class&Methods.
Please give idea about that.
Redards,
Thrimu
2014 Jun 06 5:48 AM
Hi Thrimu,
This is achievable. What you have to do is to make the relevant field of the first ALV as hotspot. Then you should create an event handler class to handle the HOTSPOT_CLICK event of CL_GUI_ALV_GRID. In that class you have to create a method to handle this event. Within this method you will be getting the Row ID, Column ID & Row No. that you select. Based on this you will be able to select the related data for your second ALV. Then display this by calling another screen.
Please have a look at the following SCN contants:
USING ALV EVENT HANDLER FOR ALL INSTANCES - Code Gallery - SCN Wiki
Regards,
Abijith
2014 Jun 06 5:50 AM
Hi Thrimu,
You have to trap the events using Event Handler Class and binding the event double click to the same for the ALV for showing the result on the next display.
Pl refer following code as a reference:
http://wiki.scn.sap.com/wiki/display/ABAP/ALV+Grid+Report+-+with+Object+Oriented+SALV+Classes
Hope this helps.
Regards,
Naveen
2014 Jun 06 7:53 AM
Hi Naveen,
actully in my first display i select multiple records and selected records key field data give the input of second display. ( using class and method only).
please see bellow screen short you get a idea.
Kindly replay back.
2014 Jun 06 8:27 AM
Hi Thrimu,
Ok. So what you want is to show related data to all the records selected on the first ALV. In this case, you need to create an additional button on the ALV toolbar using the event handler class. After you select multiple records, you can click on this button to show th second ALV.
Declare your event handler class as follows:
CLASS lcl_alv1_handler DEFINITION.
PUBLIC SECTION.
"To handle adding buttons to toolbar
METHODS handle_toolbar_set FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive.
"To handle button click of newly added buttons
METHODS handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS.
CLASS lcl_alv1_handler IMPLEMENTATION.
METHOD handle_toolbar_set.
CLEAR wa_button.
wa_button-function = '&SHOW'.
wa_button-icon = '@10@'.
wa_button-butn_type = '0'.
wa_button-quickinfo = 'Second ALV'.
APPEND wa_button TO e_object->mt_toolbar.
ENDMETHOD.
METHOD handle_user_command.
CASE e_ucomm.
WHEN '&SHOW'.
"Please make your selections here based on the selected records from the first
"ALV. The selected records can be identified based on CHECKBOX = 'x'.
"Then call your second ALV.
ENDCASE.
ENDMETHOD.
ENDCLASS.
Then before you call the set_table_for_first_display method of CL_GUI_ALV_GRID, you need create an object for the above event handler class and register the events. Can be done as follows.
CREATE OBJECT o_container1
EXPORTING
container_name = 'CUSTCON1'
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 o_alv1
EXPORTING
i_parent = o_container1
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
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 o_alv1_handler.
SET HANDLER : o_alv1_handler->handle_toolbar_set FOR o_alv1,
o_alv1_handler->handle_user_command FOR o_alv1.
CALL METHOD o_alv1->set_table_for_first_display
EXPORTING
is_layout = wa_layo
it_toolbar_excluding = gt_excl_toolbar
CHANGING
it_outtab = gt_final
it_fieldcatalog = gt_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
I think you have got a basic idea on how this can be achieved. Please check & revert back.
Regards,
Abijith