ABAP 的搜索幫助有不少種方法,掌握下面的幾種基本差很少了html
*&---------------------------------------------------------------------*
*& Report ZTEST1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*app
REPORT ZTEST1.post
tables: mara.spa
DATA:ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm..net
parameters: l_matnr type matnr matchcode object zmara. " 第1種-簡單的彈出對話框code
PARAMETERS:l_ebeln type ebeln matchcode object ZEKKO. " 第2種-selectio-method 是 view。htm
* 第3種,上下兩個是關聯在一塊的。工廠和庫存地點。
PARAMETERS:l_werks type zwerks_logrt-werks.
PARAMETERS:l_logrt type zwerks_logrt-logrt.blog
* 第4種,selection screen 中的 :日期類型的search help。這種方法要注意在dialogue screen 中,要在元素清單中reference中 l_data添加DATS,
*按鈕纔會出來,不然要按F4,才能出來幫助按鈕。
PARAMETERS:l_data type dats.get
* 第5種:dialogue screen 中的 屏幕下拉框。input
data l_date type dats." dialogue screen 中的日期類型的search help 建立。
call screen '0100'.
data l_ver type char10.
Module drop_down_list output.
TYPE-POOLS vrm.
DATA :name TYPE vrm_id,
List TYPE vrm_values,
Value LIKE LINE OF list.
Name = 'L_VER'. "屏幕上綁定的下拉框也是這個名字。
REFRESH list.
Value-key = 'A'.
Value-text = '西海岸'.
APPEND value TO list.
Value-key = 'B'.
Value-text = '東海岸'.
APPEND value TO list.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
ENDMODULE. "drop_down_list OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '0100'.
SET TITLEBAR '0100'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
SAVE_OK = OK_CODE .
clear:OK_CODE.
case:SAVE_OK.
when 'BACK' or 'EXIT' or 'CACEL'.
leave to screen 0.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUT
*****************************************************
module value_z005 input.
data: fields like table of help_value with header line,
select_value type string
.
data: begin of valuetab occurs 0,
value(40),
end of valuetab.
data: ls_vbak like vbak.
clear: valuetab, valuetab[], fields[], fields.
*填寫顯示的列
fields-tabname = 'VBAK'.
fields-fieldname = 'VBELN'.
fields-selectflag = 'X'.
append fields.
fields-tabname = 'VBAK'.
fields-fieldname = 'ERDAT'.
fields-selectflag = ''.
append fields.
fields-tabname = 'VBAK'.
fields-fieldname = 'VKORG'.
fields-selectflag = ''.
append fields.
fields-tabname = 'VBAK'.
fields-fieldname = 'Z006'.
fields-selectflag = ''.
append fields.
*按照上面的順序填寫數據
select * from vbak into ls_vbak where kunnr = vbak-kunnr
and auart in ('Z002','Z025','Z026')
and z001 > 0.
valuetab = ls_vbak-vbeln.
append valuetab.
valuetab = ls_vbak-erdat.
append valuetab.
valuetab = ls_vbak-vkorg.
append valuetab.
valuetab = ls_vbak-z001.
condense valuetab.
append valuetab.
endselect.
call function 'HELP_VALUES_GET_WITH_TABLE'
importing
select_value = select_value "選中的值
tables
fields = fields "顯示的列
valuetab = valuetab "每列的數據
exceptions
field_not_in_ddic = 1
more_then_one_selectfield = 2
no_selectfield = 3
others = 4
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
vbak-z005 = select_value.
endif.
endmodule. " VALUE_Z005 INPUT