ABAP:F4 F4IF_INT_TABLE_VALUE_REQUEST

1 篇文章 0 订阅

ABAP:F4
F4IF_INT_TABLE_VALUE_REQUEST

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
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.
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值