sap 表格控件字段增加搜索帮助,首先要先取到当前行信息,然后依据当前行数据,查询数据,显示搜索帮助。
1. 设置POV
2. POV实现
3. 实现代码
FORM frm_charg_f4 .
DATA: lt_return_tab TYPE TABLE OF ddshretval.
DATA: lv_line TYPE i.
* 检查输入t-code
CHECK ( gs_selection-tcode = 'ZGSPZH01' OR gs_selection-tcode = 'ZGSPZH02' ).
* 获取索引
GET CURSOR LINE lv_line.
* 获取当前行数据
READ TABLE gt_prod_list INTO DATA(ls_prod_list) INDEX lv_line.
CHECK ls_prod_list-werks IS NOT INITIAL.
CHECK ls_prod_list-matnr IS NOT INITIAL.
* 物料转内码
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = ls_prod_list-matnr
IMPORTING
OUTPUT = ls_prod_list-matnr.
* 按当前的工厂、物料查询批次信息
SELECT werks,
matnr,
charg
FROM mcha
INTO TABLE @DATA(lt_mcha)
WHERE werks = @ls_prod_list-werks
AND matnr = @ls_prod_list-matnr.
IF sy-subrc <> 0.
EXIT.
ENDIF.
REFRESH: lt_return_tab.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CHARG' "指定要返回屏幕参数的在内表中的field
dynpprog = sy-repid "指定屏幕参数所在的程序名称
dynpnr = sy-dynnr "指定参数所在的屏幕编号
value_org = 'S'
dynprofield = 'GS_PROD_LIST-CHARG'
TABLES
value_tab = lt_mcha
return_tab = lt_return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
* IF sy-subrc = 0.
* READ TABLE lt_return_tab INTO DATA(ls_return) INDEX 1.
* IF sy-subrc = 0.
* ls_prod_list-charg = ls_return-fieldval.
*
* READ TABLE gt_prod_list ASSIGNING FIELD-SYMBOL(<ls_prod_list>) INDEX lv_line.
* IF sy-subrc = 0.
* <ls_prod_list>-charg = ls_return-fieldval.
* ENDIF.
* ENDIF.
* ENDIF.
ENDFORM.