文章目录
- 需求
- 解析
- 1-DYNP_GET_STEPL
- 2-F4IF_INT_TABLE_VALUE_REQUEST
- 3-获取返回值
- 4-把相应字段更新到内表
- 5-DYNP_VALUES_UPDATE
- 代码
需求
如图,当我点击责任工序的搜说帮助时,
同时会把责任人员的描述带出来.
解析
1-DYNP_GET_STEPL
这个方法就是获取当前的循环步骤
2-F4IF_INT_TABLE_VALUE_REQUEST
这个函数就是搜索帮助功能的函数,这里主要说一下这个参数RETURN_TAB
返回值,
他会返回你所想要的字段值.
3-获取返回值
这个红框中就是我想要这个字段的具体内容,然后通过这个字段值我来获取责任人员的数据.
4-把相应字段更新到内表
这个就是你要把那些值带到屏幕上去,可以带出多个字段,一直加就行了.
5-DYNP_VALUES_UPDATE
这个函数的作用就是更新字段的, 把刚才你添加的那两个字段更新到屏幕上去.
欢迎大佬前来补充
代码
MODULE f4_help_4_zzrgx INPUT.
DATA:BEGIN OF ls_oper,
vornr TYPE zsmsjkz-vornr,
arbpl TYPE zsmsjkz-arbpl,
ktext TYPE crhd_v1-ktext,
END OF ls_oper.
DATA:lt_oper LIKE STANDARD TABLE OF ls_oper.
DATA:lt_return TYPE STANDARD TABLE OF ddshretval.
DATA:lt_zsmsjkz TYPE STANDARD TABLE OF zsmsjkz.
DATA:lv_sname TYPE string."责任人 文本
DATA:lv_zzrgx TYPE shvalue_d.
DATA:lvx_row LIKE sy-tabix,
lt_systems TYPE STANDARD TABLE OF dynpread.
FIELD-SYMBOLS:<fs_systems> TYPE dynpread.
FIELD-SYMBOLS:<fs_return> TYPE ddshretval.
CLEAR: lv_bj,lv_bj2,lv_bj3.
IF gs_authorization-conform NE 'X'.
EXIT.
ENDIF.
CLEAR: lt_oper,ls_oper .
SELECT
zsmsjkz~vornr,
zsmsjkz~arbpl,
zsmsjkz~tarbpl,
crhd_v1~ktext
INTO TABLE @DATA(lt_zsm)
FROM zsmsjkz
LEFT JOIN crhd_v1 ON zsmsjkz~arbpl = crhd_v1~arbpl
WHERE aufnr = @gs_data-aufnr
AND crhd_v1~werks = '1000'.
SORT lt_zsm BY vornr.
IF sy-subrc = 0 .
LOOP AT lt_zsm INTO DATA(ls_zsm) .
IF ls_zsm-tarbpl <> ''.
SELECT ktext INTO @DATA(lv_tarbpl) FROM crhd_v1 WHERE arbpl = @ls_zsm-tarbpl .ENDSELECT.
ls_zsm-arbpl = ls_zsm-tarbpl .
ls_zsm-ktext = lv_tarbpl .
ENDIF.
CLEAR ls_oper .
ls_oper-vornr = ls_zsm-vornr.
ls_oper-arbpl = ls_zsm-arbpl.
ls_oper-ktext = ls_zsm-ktext .
APPEND ls_oper TO lt_oper.
CLEAR ls_zsm.
ENDLOOP.
ENDIF.
CALL FUNCTION 'DYNP_GET_STEPL'
IMPORTING
povstepl = lvx_row.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ZZRGX' "lt内表里面的字段
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'LS_OPER-ARBPL' "画面上绑定字段
value_org = 'S'
window_title = '责任工序选择'
callback_program = sy-repid
display = 'F'
* MULTIPLE_CHOICE = 'X' "X:支持多选,space:单选
* callback_form = 'CALLBACK_F4'
TABLES
value_tab = lt_oper "需要显示帮助的值内表
return_tab = lt_return "返回值
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc = 0.
READ TABLE lt_return ASSIGNING <fs_return> INDEX 1.
IF sy-subrc = 0.
CLEAR: lv_zzrgx,lv_sname.
lv_zzrgx = z_tct_interface_util=>replace_char_in_string( iv_str = <fs_return>-fieldval iv_old_char = '/' iv_new_char = '-' ).
READ TABLE lt_oper INTO ls_oper WITH KEY ktext = lv_zzrgx.
SELECT
zyggh~ygmc
INTO lv_sname
FROM zyggh
INNER JOIN zsmsjl ON zyggh~rgm = zsmsjl~rgm
WHERE zsmsjl~arbpl = ls_oper-arbpl
AND zsmsjl~aufnr = gs_data-aufnr
AND zsmsjl~OPERTP = '2'.
ENDSELECT.
APPEND INITIAL LINE TO lt_systems ASSIGNING <fs_systems>.
<fs_systems>-fieldname = 'GS_DATA-ZZRGX'.
<fs_systems>-stepl = lvx_row.
<fs_systems>-fieldvalue = lv_zzrgx.
APPEND INITIAL LINE TO lt_systems ASSIGNING <fs_systems>.
<fs_systems>-fieldname = 'GS_DATA-ZZRXR'.
<fs_systems>-stepl = lvx_row.
<fs_systems>-fieldvalue = lv_sname.
*
* APPEND INITIAL LINE TO lt_systems ASSIGNING <fs_systems>.
* <fs_systems>-fieldname = 'GS_DATA-ZGZZX'.
* <fs_systems>-stepl = lvx_row.
* <fs_systems>-fieldvalue = lv_sname2.
* APPEND INITIAL LINE TO lt_systems ASSIGNING <fs_systems>.
* <fs_systems>-fieldname = 'GS_DATA-ZZRBM'.
* <fs_systems>-stepl = lvx_row.
* <fs_systems>-fieldvalue = lv_sname3.
*
* IF lv_zzrgx NE '其它' AND gs_data-werks = '1000'. "ADD BY CHY 2021.03.23
* APPEND INITIAL LINE TO lt_systems ASSIGNING <fs_systems>.
* <fs_systems>-fieldname = 'GS_DATA-DEPARTMENTID'.
* <fs_systems>-stepl = lvx_row.
* <fs_systems>-fieldvalue = ''.
*
* APPEND INITIAL LINE TO lt_systems ASSIGNING <fs_systems>.
* <fs_systems>-fieldname = 'GS_DATA-DEPARTMENTDNM'.
* <fs_systems>-stepl = lvx_row.
* <fs_systems>-fieldvalue = ''.
* ENDIF.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = '100'
TABLES
dynpfields = lt_systems
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.
ENDMODULE.