‎2014 Jun 06 2:30 PM
Hi,
Can someone please help me with this one:
I'm doing an OOP with the use of CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY and I want to use similar functionality of 'REUSE_ALV_GRID_DISPLAY'->I_CALLBACK_USER_COMMAND. Since the CALL METHOD doesn't have I_call_back functionality. The alternative is to code it using classes, particularly SET_HANDLER.
Can someone please give me a working code for this? I'm still new with this type of class programming.
Thanks a lot.
‎2014 Jun 06 2:45 PM
‎2014 Jun 06 2:46 PM
Hi,
Try like this ,
Declare screen, custom container, methods etc like,
first declare data : IT_rec_Fcat TYPE lvc_T_fcat,
WA_rec_Fcat TYPE lvc_s_fcat,
ob_custom TYPE REF TO cl_gui_custom_container ,
ob_grid1 TYPE REF TO cl_gui_alv_grid .
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODs : handle_double_click FOR EVENT double_click OF cl_gui_alv_grid IMPORTING e_row e_column.
ENDCLASS.
DATA : v_event_receiver TYPE REF TO lcl_event_receiver.
perform build_fcat.
CALL SCREEN 9000 .
within that screen's OUTPUT part>
* This will create a container
CREATE OBJECT ob_custom
EXPORTING
container_name = 'CONTAINER' .
CREATE OBJECT : v_event_receiver.
SET HANDLER v_event_receiver->handle_double_click FOR Ob_grid1.
CALL METHOD ob_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'IT_REC_FCAT'
CHANGING
it_outtab = it_OUT_REC
IT_FIELDCATALOG = IT_REC_FCAT[] .
>>
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
READ TABLE it_out_rec INTO wa_out_rec INDEX e_row-index TRANSPORTING kunnr.
SUBMIT RFITEMAR with DD_KUNNR-LOW = wa_out_rec-kunnr
WITH X_AISEL = 'X'
with SO_BUDAT in s_budat
* WITH %%DYN011-LOW = '1300000032'
AND RETURN .
ENDMETHOD.
DO NOT forget to create other part & declaration.
Hope this code will help you.
Try like that.
Thanks.
‎2014 Jun 06 2:49 PM
‎2014 Jun 06 3:23 PM
You'll need to have a local class+object to handle a EVENT the ALV Class will trigger.
Start with the ALV OO examples you can find in SCN, but don't just Copy+Paste. Try to understand what you're doing by learning about OO concepts.
Regards!