2008 Jun 25 11:28 AM
Hello Everyone ,
I am developing an oops alv , i need some help like in the output list if i select particular row and press a push button it has to do some operation.
Is there any Method which captures the selected row by the user.
Thanks,
Srinu.
Hello Everyone ,
I am developing an oops alv , i need some help like in the output list if i select particular row and press a push button it has to do some operation.
Is there any Method which captures the selected row by the user.
Thanks,
Srinu.
2008 Jun 25 11:43 AM
Hi Vaasu,
check the code below.....
Use GET_SELECTED_ROWS method to get the selected row...
*----------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
DATA: wa_toolbar TYPE stb_button,
utilities TYPE REF TO cl_gui_frontend_services.
METHODS : toolbar_handle FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object
e_interactive,
ucomm_handle FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
METHOD toolbar_handle.
MOVE 3 TO wa_toolbar-butn_type.
APPEND wa_toolbar TO e_object->mt_toolbar.
MOVE : 0 TO wa_toolbar-butn_type,
'$PUSH' TO wa_toolbar-function,
'@0V@' TO wa_toolbar-icon.
APPEND wa_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "toolbar_handle
METHOD ucomm_handle.
CHECK e_ucomm EQ '$PUSH'.
PERFORM on_push_button_click.
ENDMETHOD. "ucomm_handle
ENDCLASS. "lcl_event_handler IMPLEMENTATION
DATA : container TYPE REF TO cl_gui_custom_container,
grid TYPE REF TO cl_gui_alv_grid,
event TYPE REF TO lcl_event_handler,
it_display TYPE TABLE OF mara,
wa_display TYPE mara.
START-OF-SELECTION.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'BASIC'.
PERFORM build_it_display.
PERFORM create_objects.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'EXIT'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'CANC'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form build_it_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_it_display .
SELECT * FROM mara UP TO 15 ROWS INTO TABLE it_display.
ENDFORM. " build_it_display
*&---------------------------------------------------------------------*
*& Form create_objects
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM create_objects .
IF container IS INITIAL.
CREATE OBJECT container
EXPORTING
container_name = 'CUSTOM'.
CREATE OBJECT event.
CREATE OBJECT grid
EXPORTING
i_parent = container.
SET HANDLER event->toolbar_handle FOR grid.
SET HANDLER event->ucomm_handle FOR grid.
CALL METHOD grid->set_table_for_first_display
EXPORTING
i_structure_name = 'MARA'
CHANGING
it_outtab = it_display.
ENDIF.
ENDFORM. " create_objects
*&--------------------------------------------------------------------*
*& Form on_push_button_click
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM on_push_button_click.
BREAK-POINT. " can be used to process the selected row
ENDFORM. "on_push_button_clickCheers,
Jose.
2008 Jun 25 11:45 AM
Hi Srinu,
This is the link where you can get the complete programe.
http://abapreports.blogspot.com/2008/06/oops-alv-sample-interactive-report.html
Please check this Method CALL METHOD W_GRID->GET_CURRENT_CELL
Cheers
Mohinder Singh Chauhan
2008 Jun 25 11:46 AM
Hi Vaasu,
Refer to the following link for sample code.
http://saptechnical.com/Tutorials/ALV/Interactive/oops.htm
Jaya Vani
2013 Sep 20 11:28 PM
Hello Former Member, sent you a links to a good example.
http://www.teamabap.com/2013/02/alv-using-class/
http://saptechnical.com/Tutorials/ALV/CustomTable/Page1.htm
Regards
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |