
Introduction:
The class CL_SALV_TABLE in ABAP (Advanced Business Application Programming) is used to create ALV (ABAP List Viewer) reports. One of the features of ALV reports is the ability to handle user actions like double clicking on a row of the report. This is achieved using the CL_SALV_TABLE class. To implement the double click functionality, you need to first create an instance of the CL_SALV_TABLE class and then get the event object for the table using the GET_EVENT( ) method. Once you have the event object, you can register a handler method for the double click event.
let’s take a requirement.
Requirement :-
Sollution :-
So, we will write the rest logic into our method to display the output. :
REPORT zsi_sales_order_double_click.
TYPES : BEGIN OF ty_vbak,
vbeln TYPE vbeln_va,
erdat TYPE erdat,
erzet TYPE erzet,
ernam TYPE ernam,
vbtyp TYPE vbtypl,
END OF ty_vbak.
TYPES : BEGIN OF ty_vbap,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
matnr TYPE matnr,
END OF ty_vbap.
DATA : lt_vbak TYPE TABLE OF ty_vbak,
lt_vbap TYPE TABLE OF ty_vbap.
DATA : lv_vbeln TYPE vbeln_va.
SELECT-OPTIONS : s_vbeln FOR lv_vbeln.
DATA : row TYPE salv_de_row,
column TYPE salv_de_column.
CLASS local DEFINITION.
PUBLIC SECTION.
METHODS handle FOR EVENT double_click OF cl_salv_events_table IMPORTING row column.
ENDCLASS.
CLASS local IMPLEMENTATION.
METHOD handle.
READ TABLE lt_vbak INTO DATA(ls_vbak) INDEX row.
IF sy-subrc EQ 0.
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE lt_vbap
WHERE vbeln = ls_vbak-vbeln.
IF lt_vbap IS NOT INITIAL.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = DATA(lo_obj2)
CHANGING
t_table = lt_vbap.
CATCH cx_salv_msg.
ENDTRY.
lo_obj2->display( ).
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
SELECT vbeln erdat erzet ernam vbtyp
FROM vbak
INTO TABLE lt_vbak
WHERE vbeln IN s_vbeln.
IF lt_vbak IS NOT INITIAL.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
* r_container =
* container_name =
IMPORTING
r_salv_table = DATA(lo_object)
CHANGING
t_table = lt_vbak.
CATCH cx_salv_msg.
ENDTRY.
CALL METHOD lo_object->get_event
RECEIVING
value = DATA(lo_event).
DATA(lo_local) = NEW local( ).
SET HANDLER lo_local->handle FOR lo_event.
lo_object->display( ).
ENDIF.
Execute the Code :-
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 | |
1 |