TYPE-POOLS:slis. CLASS lcl_event_receiver DEFINITION DEFERRED. DATA: gt_fcat TYPE lvc_t_fcat, gs_fcat TYPE lvc_s_fcat, gt_f4 TYPE lvc_t_f4, gs_f4 TYPE lvc_s_f4, gs_event TYPE slis_alv_event, gt_event TYPE slis_t_event, gs_layout TYPE lvc_s_layo, gs_glay TYPE lvc_s_glay. DATA: event_receiver TYPE REF TO lcl_event_receiver, go_grid TYPE REF TO cl_gui_alv_grid. DATA: BEGIN OF gs_data , pernr TYPE persno, nachn TYPE nachn, gesch TYPE gesch, END OF gs_data, gt_data LIKE TABLE OF gs_data. DATA: BEGIN OF gs_f4value, gesch TYPE gesch, ztext TYPE text, END OF gs_f4value, gt_f4value LIKE TABLE OF gs_f4value. *————————————————————————————————————————* * CLASS LCL_EVENT_RECEIVER DEFINITION *———————————————————————————————————————-* CLASS lcl_event_receiver DEFINITION. PUBLIC SECTION. METHODS: handle_f4 FOR EVENT onf4 OF cl_gui_alv_grid IMPORTING e_fieldname e_fieldvalue es_row_no er_event_data et_bad_cells e_display. ENDCLASS. *———————————————————————————————————————-* * CLASS LCL_EVENT_RECEIVER IMPLEMENTATION *———————————————————————————————————————-* CLASS lcl_event_receiver IMPLEMENTATION. METHOD handle_f4. PERFORM f_f4_help USING e_fieldname es_row_no. er_event_data->m_event_handled = ‘x‘ . PERFORM refresh_table_alv. ENDMETHOD. ENDCLASS. START-OF-SELECTION. PERFORM f_get_data. PERFORM f_show_data. FORM f_get_data . SELECT pernr nachn FROM pa0002 INTO CORRESPONDING FIELDS OF TABLE gt_data WHERE begda LE sy-datum AND endda GE sy-datum. CLEAR gs_f4value. gs_f4value-gesch = 1. gs_f4value-ztext = ‘男‘. APPEND gs_f4value TO gt_f4value. CLEAR gs_f4value. gs_f4value-gesch = 2. gs_f4value-ztext = ‘女‘. APPEND gs_f4value TO gt_f4value. ENDFORM. FORM f_show_data . DEFINE %%fcat. CLEAR gs_fcat. gs_fcat-fieldname = &1. gs_fcat-scrtext_l = &2. IF &1 = ‘GESCH‘. gs_fcat-edit = ‘X‘. gs_fcat-f4availabl = ‘X‘. ENDIF. APPEND gs_fcat TO gt_fcat. END-OF-DEFINITION. %%fcat: ‘PERNR‘ ‘人员编号‘, ‘NACHN‘ ‘姓名‘, ‘GESCH‘ ‘性别‘. gs_event-name = ‘CALLER_EXIT‘. gs_event-form = ‘F_CALLER_EXIT‘. APPEND gs_event TO gt_event. gs_glay-edt_cll_cb = ‘X‘. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC‘ EXPORTING i_callback_program = sy-cprog i_callback_pf_status_set = ‘PF_STATUS_SET‘ it_fieldcat_lvc = gt_fcat it_events = gt_event i_grid_settings = gs_glay TABLES t_outtab = gt_data. ENDFORM. FORM f_caller_exit USING e_grid TYPE slis_data_caller_exit. gs_f4-fieldname = ‘GESCH‘. gs_f4-register = ‘X‘. * gs_f4-getbefore = ‘X‘. * gs_f4-chngeafter = ‘X‘. INSERT gs_f4 INTO TABLE gt_f4. CALL FUNCTION ‘GET_GLOBALS_FROM_SLVC_FULLSCR‘ IMPORTING e_grid = go_grid. CREATE OBJECT event_receiver. SET HANDLER event_receiver->handle_f4 FOR go_grid. CALL METHOD go_grid->register_f4_for_fields EXPORTING it_f4 = gt_f4[]. ENDFORM. FORM f_f4_help USING e_fieldname TYPE lvc_fname es_row_no TYPE lvc_s_roid. DATA: lt_ddshretval TYPE STANDARD TABLE OF ddshretval, ls_ddshretval TYPE ddshretval. CHECK e_fieldname = ‘GESCH‘. REFRESH lt_ddshretval. CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST‘ EXPORTING retfield = ‘GESCH‘ " dynpprog = sy-repid dynpnr = sy-dynnr dynprofield = ‘GESCH‘ value_org = ‘S‘ callback_program = sy-repid callback_form = 'FM_CB_FORM'
TABLES value_tab = gt_f4value return_tab = lt_ddshretval EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc = 0 AND lt_ddshretval IS NOT INITIAL . CLEAR ls_ddshretval. READ TABLE lt_ddshretval INTO ls_ddshretval INDEX 1. IF ls_ddshretval-fieldval IS NOT INITIAL. CLEAR gs_data. READ TABLE gt_data INTO gs_data INDEX es_row_no-row_id. gs_data-gesch = ls_ddshretval-fieldval. MODIFY gt_data FROM gs_data INDEX es_row_no-row_id TRANSPORTING gesch. ENDIF. ENDIF. ENDFORM. FORM refresh_table_alv . DATA: ls_stbl TYPE lvc_s_stbl. ls_stbl-row = ‘X‘." ls_stbl-col = ‘X‘. CALL METHOD go_grid->refresh_table_display EXPORTING is_stable = ls_stbl. ENDFORM. FORM pf_status_set USING rt_extab TYPE slis_t_extab. SET PF-STATUS ‘STATUS_ALV‘. ENDFORM.
*&---------------------------------------------------------------------* *& Form FM_CB_FORM *&---------------------------------------------------------------------* FORM fm_cb_form TABLES record_tab STRUCTURE seahlpres CHANGING shlp TYPE shlp_descr_t callcontrol LIKE ddshf4ctrl. DATA: interface LIKE LINE OF shlp-interface. READ TABLE shlp-interface INTO interface INDEX 1. interface-shlpfield+4(1) = '1'. interface-valfield = 'DOC_LAYOUT'. APPEND interface TO shlp-interface. DELETE shlp-interface INDEX 1. ENDFORM. "bo_callback_form