ABAP 选择屏幕搜索帮助自动带出其它字段

2023-10-13 19:26:44 浏览数 (2)

代码语言:javascript复制
1 TYPES: shlp_descr_t TYPE shlp_descr .
 2 DATA: BEGIN OF itab OCCURS 0 ,
 3         matnr LIKE mara-matnr,
 4         maktx LIKE makt-maktx,
 5       END OF itab.
 6 DATA: return_tab TYPE ddshretval OCCURS 0 .
 7 
 8 PARAMETERS: p_matnr LIKE itab-matnr,
 9             p_maktx LIKE itab-maktx.
10 
11 INITIALIZATION.
12   SELECT matnr maktx INTO TABLE itab FROM makt UP TO 20 ROWS
13     WHERE spras = '1'.
14 
15 AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr .
16   PERFORM f4.
17 
18 FORM f4.
19   CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
20     EXPORTING
21       retfield         = 'MATNR'
22       dynpprog         = sy-repid
23       dynpnr           = sy-dynnr
24       dynprofield      = 'P_MATNR'
25       value_org        = 'S'
26       callback_program = sy-repid
27       callback_form    = 'CB_FORM'
28     TABLES
29       value_tab        = itab
30       return_tab       = return_tab
31     EXCEPTIONS
32       parameter_error  = 1
33       no_values_found  = 2
34       OTHERS           = 3.
35 ENDFORM.                    "f4"
36 
37 FORM cb_form TABLES record_tab STRUCTURE seahlpres
38               CHANGING shlp TYPE shlp_descr_t
39               callcontrol LIKE ddshf4ctrl.
40   DATA: interface LIKE LINE OF shlp-interface.
41   READ TABLE shlp-interface INTO interface INDEX 1.
42   "表示把搜索帮助中的第二列,放入P_MAKTX中去。
43   interface-shlpfield 4(1) = '2'. "注意点解析"
44   interface-valfield = 'P_MAKTX'.
45   APPEND interface TO shlp-interface.
46 ENDFORM.                    "bo_callback_form

0 人点赞