F4IF_FIELD_VALUE_REQUEST 和 F4IF_INT_TABLE_VALUE_REQUEST的不同
F4IF_FIELD_VALUE_REQUEST主要功能是将表里的字段对应的search help引入到屏幕上来,从而打开对话框,当然也可以任意指定某个search help。
F4IF_INT_TABLE_VALUE_REQUEST支持字定义内表,但是不能通过指定search help的方式打开对话框。
1.F4IF_FIELD_VALUE_REQUEST的应用实例
TYPES: BEGIN OF type_carrid,
carrid TYPE spfli-carrid,
connid type spfli-connid,
carrname TYPE scarr-carrname,
END OF type_carrid.
DATA itab_carrid TYPE STANDARD TABLE OF type_carrid.
parameters airline(2) type c.
*&---------------------------------------------------------------------*
*& Processing Blocks called by the Runtime Environment *
*&---------------------------------------------------------------------*
* Event Block AT SELECTION-SCREEN ON VALUE-REQUEST FOR
at selection-screen on value-request for airline.
perform frm_f4_help.
* Form for generating F4 HELP for parameter AIRLINE
form FRM_F4_HELP .
SELECT carrid carrname
FROM scarr
INTO CORRESPONDING FIELDS OF TABLE itab_carrid.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
TABNAME = 'SPFLI' "指定stucture,必须的
fieldname = 'CARRID' "指定structure中的field
dynpprog = sy-repid "指定屏幕参数所在的程序名称
dynpnr = sy-dynnr "指定参数所在的屏幕编号
dynprofield = 'AIRLINE'. "指定屏幕参数的名称
IF sy-subrc <> 0.
...
ENDIF.
endform. " FRM_F4_HELP
2.F4IF_INT_TABLE_VALUE_REQUEST的应用实例
TYPES: BEGIN OF type_carrid,
carrid TYPE spfli-carrid,
connid type spfli-connid,
carrname TYPE scarr-carrname,
END OF type_carrid.
DATA itab_carrid TYPE STANDARD TABLE OF type_carrid.
* Selection Screen
parameters airline(2) type c.
* Event Block AT SELECTION-SCREEN ON VALUE-REQUEST FOR
at selection-screen on value-request for airline.
perform frm_f4_help.
* Form for generating F4 HELP for parameter AIRLINE
form FRM_F4_HELP .
SELECT carrid carrname
FROM scarr
INTO CORRESPONDING FIELDS OF TABLE itab_carrid.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CARRID' "指定要返回屏幕参数的在内表中的field
value_org = 'S' "S代表structure
dynpprog = sy-repid "指定屏幕参数所在的程序名称
dynpnr = sy-dynnr "指定参数所在的屏幕编号
dynprofield = 'AIRLINE'"指定屏幕参数的名称
TABLES
value_tab = itab_carrid "内表
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
...
ENDIF.
endform. " FRM_F4_HELP
完整例子:
DATA: BEGIN OF wa_help ,
ebeln TYPE ebeln,
aedat TYPE erdat,
END OF wa_help.
DATA: it_help LIKE TABLE OF wa_help.
DATA: it_return LIKE TABLE OF ddshretval WITH HEADER LINE.
DATA: BEGIN OF wa_data.
INCLUDE STRUCTURE ztable_line.
DATA: maktx(40),
rowcolor(4),
END OF wa_data.
DATA: it_data LIKE TABLE OF wa_data WITH HEADER LINE.
DATA: it_data_tmp LIKE TABLE OF wa_data WITH HEADER LINE.
DATA:BEGIN OF it_maktx OCCURS 0,
matnr TYPE matnr,
maktx(40),
END OF it_maktx.
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_ebeln FOR g_ebeln OBLIGATORY.
SELECT-OPTIONS: s_bukrs FOR g_bukrs .
SELECTION-SCREEN END OF BLOCK bl1.
INITIALIZATION.
CLEAR:it_help, wa_help.
SELECT ebeln aedat
INTO TABLE it_help
FROM ekko
UP TO 100 ROWS.
AT SELECTION-SCREEN.
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ebeln.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_ebeln-low.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'EBELN'
value_org = 'S'
TABLES
value_tab = it_help
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF it_return[] IS NOT INITIAL.
READ TABLE it_return INDEX 1.
IF sy-subrc = 0.
s_ebeln-low = it_return-fieldval .
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_ebeln-high.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'EBELN'
value_org = 'S'
TABLES
value_tab = it_help
return_tab = it_return