ABAP 的搜索帮助有很多种方法,掌握下面的几种基本差不多了
*&---------------------------------------------------------------------*
*& Report ZTEST1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST1.
tables: mara.
DATA:ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.
parameters: l_matnr type matnr matchcode object zmara. " 第1种-简单的弹出对话框
PARAMETERS:l_ebeln type ebeln matchcode object ZEKKO. " 第2种-selectio-method 是 view。
* 第3种,上下两个是关联在一块的。工厂和库存地点。
PARAMETERS:l_werks type zwerks_logrt-werks.
PARAMETERS:l_logrt type zwerks_logrt-logrt.
* 第4种,selection screen 中的 :日期类型的search help。这种方法要注意在dialogue screen 中,要在元素清单中reference中 l_data添加DATS,
*按钮才会出来,否则要按F4,才能出来帮助按钮。
PARAMETERS:l_data type dats.
* 第5种:dialogue screen 中的 屏幕下拉框。
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