ABAP 在選擇螢幕中獲取螢幕欄位建立搜尋幫助
常用的螢幕邏輯流有PBO和PAI,還有不常用的POV和POH,POV就是
PROCESS ON VALUE-REQUEST.
FIELD FIELD_NAME MODULE F4_MODULE. "當用戶按下查詢幫助按鍵時(或按下F4)被觸發,事件結束後將繼續處理當前螢幕。
我們要根據螢幕欄位的輸入值來判斷加入的搜尋幫助的值,所以要先獲取螢幕欄位
CLEAR: dynpfields, dynpfields[].
dynpfields-fieldname = 'name'. "填入需要讀值的欄位名
APPEND dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
translate_to_upper = 'X'
TABLES
dynpfields = dynpfields
EXCEPTIONS
OTHERS = 9.
IF sy-subrc = 0.
READ TABLE dynpfields WITH KEY fieldname = 'name'.
name = dynpfields-fieldvalue. "備註
ENDIF.
根據上述函式獲取到需要的螢幕欄位的值name
CLEAR: lt_tescdy[]. 搜尋幫助值的內表
IF name = '1'.
SELECT * FROM z10tescdy
INTO CORRESPONDING FIELDS OF TABLE lt_tescdy
WHERE zscbh LIKE '%B'
AND zstat EQ '1'.
ELSE.
SELECT * FROM z10tescdy
INTO CORRESPONDING FIELDS OF TABLE lt_tescdy
WHERE zscbh LIKE '%N'
AND zstat EQ '1'.
ENDIF.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = 'ZSCBH'
* PVALKEY = ' '
DYNPPROG = sy-repid
DYNPNR = sy-dynnr
DYNPROFIELD = 'ZBANH'
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
VALUE_ORG = 'S'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* MARK_TAB =
* IMPORTING
* USER_RESET =
tables
value_tab = lt_tescdy[]
* FIELD_TAB =
* RETURN_TAB =
* DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
通過上述函式建立自定義搜尋幫助。