*----------------------------------------------------------------------*
REPORT yj_interactive_alv_oops.
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*--Double-click control
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column es_row_no.
PRIVATE SECTION.
ENDCLASS. "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION .
*--Handle Double Click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column es_row_no .
ENDMETHOD . "handle_double_click
ENDCLASS . "lcl_event_handler IMPLEMENTATION
DATA : o_cust TYPE REF TO cl_gui_custom_container,
o_alv TYPE REF TO cl_gui_alv_grid,
it_mara TYPE TABLE OF mara,
wa_mara TYPE mara,
gt_fcat TYPE lvc_t_fcat,
gs_layo TYPE lvc_s_layo,
ok_code TYPE sy-ucomm.
DATA gr_event_handler TYPE REF TO lcl_event_handler .
DATA : t_mat LIKE mara-matnr,
variant TYPE disvariant,
gv_matnr type matnr.
Select-OPTIONS : s_matnr for gv_matnr.
START-OF-SELECTION.
PERFORM data_fetch.
CALL SCREEN 102.
" DATA_FETCH
FORM data_fetch .
SELECT * FROM mara INTO TABLE it_mara WHERE matnr IN s_matnr.
variant-report = sy-repid.
variant-username = sy-uname.
ENDFORM.
" STATUS_0100 OUTPUT
MODULE status_0102 OUTPUT.
SET PF-STATUS 'STATUS1'.
SET TITLEBAR 'TITLE1'.
ENDMODULE.
" DISPLAY OUTPUT
MODULE display_alv OUTPUT.
CREATE OBJECT o_cust
EXPORTING
container_name = 'CUSTOM1'.
CREATE OBJECT o_alv
EXPORTING
i_parent = o_cust.
PERFORM create_fcat CHANGING gt_fcat.
PERFORM create_layout CHANGING gs_layo.
CALL METHOD o_alv->set_table_for_first_display
EXPORTING
is_variant = variant
is_layout = gs_layo
i_save = 'A'
* i_structure_name =
CHANGING
it_outtab = it_mara
it_fieldcatalog = gt_fcat.
CREATE OBJECT gr_event_handler .
SET HANDLER gr_event_handler->handle_double_click FOR o_alv .
ENDMODULE.
" USER_COMMAND_0100 INPUT
MODULE user_command_0102 INPUT.
CASE ok_code.
WHEN 'BACK' .
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
FORM create_fcat CHANGING pt_fcat TYPE lvc_t_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
* ls_fcat-coltext = 'Radio Button'.
* ls_fcat-fieldname = 'RADIO'.
** ls_fcat-ref_table = 'gt_emp'.
* ls_fcat-icon = 'X'. "Icons
* ls_fcat-hotspot = 'X'. "Hotspot(Hand Symbol)
* ls_fcat-col_pos = '1'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-coltext = 'Material'.
ls_fcat-outputlen = 18.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'MEINS'.
ls_fcat-coltext = 'Base Unit'.
ls_fcat-outputlen = 4.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'MTART'.
ls_fcat-coltext = 'Material Type'.
ls_fcat-outputlen = 4.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'MBRSH'.
ls_fcat-coltext = 'Industry Sector'.
ls_fcat-outputlen = 2.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'ERSDA'.
ls_fcat-coltext = 'Created on'.
ls_fcat-outputlen = 8.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'ERNAM'.
ls_fcat-coltext = 'Name of person'.
ls_fcat-outputlen = 12.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-coltext = 'Material Group'.
ls_fcat-outputlen = 10.
ls_fcat-edit = 'X'.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ENDFORM.
FORM create_layout CHANGING ps_layo TYPE lvc_s_layo.
ps_layo-zebra = 'X'.
ENDFORM.
FORM handle_double_click USING i_row TYPE lvc_s_row
i_column TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
READ TABLE it_mara INTO wa_mara INDEX is_row_no-row_id .
IF sy-subrc = 0 .
SET PARAMETER ID 'MAT' FIELD wa_mara-matnr.
CASE i_column.
WHEN 'MATNR'.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
WHEN 'MBLNR'.
CALL TRANSACTION 'MIGO' AND SKIP FIRST SCREEN..
WHEN OTHERS.
ENDCASE.
ENDIF.
ENDFORM . "handle_double_click
Flow logic of screen 102
PROCESS BEFORE OUTPUT.
MODULE STATUS_0102.
MODULE display_alv.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0102.
REPORT yj_interactive_alv_oops.
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*--Double-click control
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column es_row_no.
PRIVATE SECTION.
ENDCLASS. "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION .
*--Handle Double Click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column es_row_no .
ENDMETHOD . "handle_double_click
ENDCLASS . "lcl_event_handler IMPLEMENTATION
DATA : o_cust TYPE REF TO cl_gui_custom_container,
o_alv TYPE REF TO cl_gui_alv_grid,
it_mara TYPE TABLE OF mara,
wa_mara TYPE mara,
gt_fcat TYPE lvc_t_fcat,
gs_layo TYPE lvc_s_layo,
ok_code TYPE sy-ucomm.
DATA gr_event_handler TYPE REF TO lcl_event_handler .
DATA : t_mat LIKE mara-matnr,
variant TYPE disvariant,
gv_matnr type matnr.
Select-OPTIONS : s_matnr for gv_matnr.
START-OF-SELECTION.
PERFORM data_fetch.
CALL SCREEN 102.
" DATA_FETCH
FORM data_fetch .
SELECT * FROM mara INTO TABLE it_mara WHERE matnr IN s_matnr.
variant-report = sy-repid.
variant-username = sy-uname.
ENDFORM.
" STATUS_0100 OUTPUT
MODULE status_0102 OUTPUT.
SET PF-STATUS 'STATUS1'.
SET TITLEBAR 'TITLE1'.
ENDMODULE.
" DISPLAY OUTPUT
MODULE display_alv OUTPUT.
CREATE OBJECT o_cust
EXPORTING
container_name = 'CUSTOM1'.
CREATE OBJECT o_alv
EXPORTING
i_parent = o_cust.
PERFORM create_fcat CHANGING gt_fcat.
PERFORM create_layout CHANGING gs_layo.
CALL METHOD o_alv->set_table_for_first_display
EXPORTING
is_variant = variant
is_layout = gs_layo
i_save = 'A'
* i_structure_name =
CHANGING
it_outtab = it_mara
it_fieldcatalog = gt_fcat.
CREATE OBJECT gr_event_handler .
SET HANDLER gr_event_handler->handle_double_click FOR o_alv .
ENDMODULE.
" USER_COMMAND_0100 INPUT
MODULE user_command_0102 INPUT.
CASE ok_code.
WHEN 'BACK' .
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
FORM create_fcat CHANGING pt_fcat TYPE lvc_t_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
* ls_fcat-coltext = 'Radio Button'.
* ls_fcat-fieldname = 'RADIO'.
** ls_fcat-ref_table = 'gt_emp'.
* ls_fcat-icon = 'X'. "Icons
* ls_fcat-hotspot = 'X'. "Hotspot(Hand Symbol)
* ls_fcat-col_pos = '1'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-coltext = 'Material'.
ls_fcat-outputlen = 18.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'MEINS'.
ls_fcat-coltext = 'Base Unit'.
ls_fcat-outputlen = 4.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'MTART'.
ls_fcat-coltext = 'Material Type'.
ls_fcat-outputlen = 4.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'MBRSH'.
ls_fcat-coltext = 'Industry Sector'.
ls_fcat-outputlen = 2.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'ERSDA'.
ls_fcat-coltext = 'Created on'.
ls_fcat-outputlen = 8.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'ERNAM'.
ls_fcat-coltext = 'Name of person'.
ls_fcat-outputlen = 12.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-coltext = 'Material Group'.
ls_fcat-outputlen = 10.
ls_fcat-edit = 'X'.
APPEND ls_fcat TO pt_fcat.
Clear ls_fcat.
ENDFORM.
FORM create_layout CHANGING ps_layo TYPE lvc_s_layo.
ps_layo-zebra = 'X'.
ENDFORM.
FORM handle_double_click USING i_row TYPE lvc_s_row
i_column TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
READ TABLE it_mara INTO wa_mara INDEX is_row_no-row_id .
IF sy-subrc = 0 .
SET PARAMETER ID 'MAT' FIELD wa_mara-matnr.
CASE i_column.
WHEN 'MATNR'.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
WHEN 'MBLNR'.
CALL TRANSACTION 'MIGO' AND SKIP FIRST SCREEN..
WHEN OTHERS.
ENDCASE.
ENDIF.
ENDFORM . "handle_double_click
Flow logic of screen 102
PROCESS BEFORE OUTPUT.
MODULE STATUS_0102.
MODULE display_alv.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0102.
No comments:
Post a Comment