1、需求:选择屏幕中的“库存类型”字段的搜索帮助按照自定义的要求显示,如下效果:
关键代码:
SELECT-OPTIONS: s_insmk FOR mseg-insmk NO INTERVALS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_insmk-low.PERFORM frm_request_f4_insmk USING 'S_INSMK-LOW'.
*&---------------------------------------------------------------------*
*& Form FRM_REQUEST_F4_INSMK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_request_f4_insmk USING pv_field TYPE help_info-dynprofld.DEFINE lm_modify_insmk.LS_VALUE_TAB-INSMK = &1.LS_VALUE_TAB-INSMKT = &2.APPEND LS_VALUE_TAB TO Lt_VALUE_TAB.CLEAR LS_VALUE_TAB.END-OF-DEFINITION.DATA: BEGIN OF ls_value_tab,insmk TYPE mseg-insmk,insmkt TYPE dd07t-ddtext,END OF ls_value_tab.DATA: lt_value_tab LIKE TABLE OF ls_value_tab.lm_modify_insmk 'U' text-r03. " Unrestrictedlm_modify_insmk 'B' text-r04. " Blockedlm_modify_insmk 'Q' text-r05. " Quality inspectionlm_modify_insmk 'T' text-r06. " Transfer stock between storage locationlm_modify_insmk 'P' text-r07. " Transfer stock between plantCALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'EXPORTINGretfield = 'INSMK'dynpprog = sy-repiddynpnr = sy-dynnrdynprofield = pv_fieldvalue_org = 'S'TABLESvalue_tab = lt_value_tabEXCEPTIONSparameter_error = 1no_values_found = 2OTHERS = 3.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.ENDFORM.
2、需求:搜索帮助显示列表ALV的列名显示成用户指定的名称。
关键代码:
*&---------------------------------------------------------------------*
*& Form FRM_REQUEST_F4_INSMK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_request_f4_insmk USING pv_field TYPE help_info-dynprofld.DEFINE lm_modify_insmk.LS_VALUE_TAB-INSMK = &1.LS_VALUE_TAB-INSMKT = &2.APPEND LS_VALUE_TAB TO Lt_VALUE_TAB.CLEAR LS_VALUE_TAB.END-OF-DEFINITION.DATA: BEGIN OF ls_value_tab,insmk TYPE mseg-insmk,insmkt TYPE dd07t-ddtext,END OF ls_value_tab.DATA: ls_field_tab TYPE dfies.DATA: lt_value_tab LIKE TABLE OF ls_value_tab,lt_field_tab LIKE TABLE OF ls_field_tab.DATA: lv_retfield TYPE dfies-fieldname,lv_tabix TYPE sy-tabix.lv_retfield = 'INSMK'.lm_modify_insmk 'U' text-r03. " Unrestrictedlm_modify_insmk 'B' text-r04. " Blockedlm_modify_insmk 'Q' text-r05. " Quality inspectionlm_modify_insmk 'T' text-r06. " Transfer stock between storage locationlm_modify_insmk 'P' text-r07. " Transfer stock between plantPERFORM get_fields_of_value_tab(saplsdhi) TABLES lt_value_tablt_field_tabCHANGING lv_retfield.LOOP AT lt_field_tab INTO ls_field_tab.lv_tabix = sy-tabix.CASE ls_field_tab-fieldname.WHEN 'F0001'.ls_field_tab-reptext = text-r01. " Stock typeWHEN 'F0002'.ls_field_tab-reptext = text-r02. " Stock type descriptionENDCASE.MODIFY lt_field_tab FROM ls_field_tab INDEX lv_tabix TRANSPORTING reptext.CLEAR ls_field_tab.ENDLOOP.CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'EXPORTINGretfield = lv_retfielddynpprog = sy-repiddynpnr = sy-dynnrdynprofield = pv_fieldvalue_org = 'S'TABLESvalue_tab = lt_value_tabfield_tab = lt_field_tabEXCEPTIONSparameter_error = 1no_values_found = 2OTHERS = 3.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.ENDFORM.
注:如有疏漏之处,还请不吝赐教!