其他分享
首页 > 其他分享> > ABAP 下拉框

ABAP 下拉框

作者:互联网

 ALV列表下拉框

DATA: I_DDVAL TYPE LVC_T_DRAL, "LVC_T_DROP, "存储下拉列表的数据
WA_DDVAL TYPE LVC_S_DRAL, "LVC_S_DROP,
I_DDVAL1 TYPE LVC_T_DROP, "存储下拉列表的数据
WA_DDVAL1 TYPE LVC_S_DROP.

*下拉数据填充
*call function生成报表的情况下,
*caller_exit能帮助你在标准屏幕中实现部分自定义屏幕PAI的功能。
*如写一个自适应的搜索帮助等。。。其本质类似于弱化版的user_exit。
FORM F_CALLER_EXIT USING LS_DATA TYPE SLIS_DATA_CALLER_EXIT.
DATA: L_REF_ALV TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_REF_ALV1 TYPE REF TO CL_GUI_ALV_GRID.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = L_REF_ALV. "这个方法设置下拉框的值改变时,把值更新到内表中
CALL METHOD L_REF_ALV->SET_DROP_DOWN_TABLE "设置下拦选项的内表
EXPORTING
IT_DROP_DOWN = I_DDVAL1
IT_DROP_DOWN_ALIAS = I_DDVAL.


ENDFORM.


*下拉框数据
FORM F_CREATE_DROPDOWN_LIST .
SELECT BEDAE FROM T459A INTO WA_DDVAL-VALUE.
WA_DDVAL-HANDLE = 1.
APPEND WA_DDVAL TO I_DDVAL.
ENDSELECT.

SELECT PLANT WERKS FROM ZPLANT INTO (WA_DDVAL-VALUE,WA_DDVAL-INT_VALUE).
WA_DDVAL-HANDLE = 2.
WA_DDVAL-VALUE = WA_DDVAL-INT_VALUE && '-' && WA_DDVAL-VALUE.
APPEND WA_DDVAL TO I_DDVAL.
ENDSELECT.
SELECT BEZEI FROM TVM4T INTO WA_DDVAL-VALUE.
WA_DDVAL-HANDLE = 3.
APPEND WA_DDVAL TO I_DDVAL.
ENDSELECT.

ENDFORM.

DATA: GT_FCAT TYPE LVC_T_FCAT,
GW_FCAT TYPE LVC_S_FCAT,
GW_LAYO TYPE LVC_S_LAYO.
DATA: LR_GRID TYPE REF TO CL_GUI_ALV_GRID.

DEFINE SET_FCAT. "列显示定义
gv_step = gv_step + 1.
clear gw_fcat.
gw_fcat-col_pos = gv_step.
gw_fcat-fieldname = &1.
if &1 = 'CHK'.
gw_fcat-checkbox = 'X'.
gw_fcat-EDIT = 'X'.
endif.
if &1 = 'BEDAE'.
gw_fcat-drdn_field = 'DD_HANDLE'. "设置下拉菜单
endif.
if &1 = 'PLANT'.
GW_FCAT-drdn_hndl = 2.
ENDIF.
if &1 = 'MVGR4'.
GW_FCAT-drdn_hndl = 3.
endif.

gw_fcat-ref_table = &2.
gw_fcat-ref_field = &3.
gw_fcat-scrtext_l = &4.
gw_fcat-scrtext_m = &4.
gw_fcat-scrtext_s = &4.
gw_fcat-reptext = &4.
append gw_fcat to gt_fcat.
END-OF-DEFINITION.


屏幕下拉框
1.LISTBOX
PARAMETERS: P_BSART LIKE EKKO-BSART AS LISTBOX VISIBLE LENGTH 20 OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK B2.

AT SELECTION-SCREEN OUTPUT.
REFRESH LIST1.
NAME1 = 'P_BSART'.
VALUE1-KEY = 'ZEB'.
VALUE1-TEXT = '配送转储采购订单'.
APPEND VALUE1 TO LIST1.
VALUE1-KEY = 'ZCB'.
VALUE1-TEXT = '非生产材料领料单'.
APPEND VALUE1 TO LIST1.
VALUE1-KEY = 'ZPB'.
VALUE1-TEXT = '生产领料单'.
APPEND VALUE1 TO LIST1.
VALUE1-KEY = 'ZXB'.
VALUE1-TEXT = '计划直传转储采购订单'.
APPEND VALUE1 TO LIST1.

CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = NAME1
VALUES = LIST1.


2. F4IF_INT_TABLE_VALUE_REQUEST

 

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ZWLH' "lt内表里面的字段
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'ZWLH' "画面上绑定字段
value_org = 'S'
callback_program = sy-repid
* MULTIPLE_CHOICE = 'X' "X:支持多选,space:单选
callback_form = 'CM_FORM'
TABLES
value_tab = gt_list1 "需要显示帮助的值内表
return_tab = lt_return "返回值
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.

IF sy-subrc = 0.
READ TABLE lt_return INTO ls_return INDEX 1.
ENDIF.
 

标签:gw,fcat,WA,DDVAL,ABAP,VALUE1,TYPE,下拉框
来源: https://www.cnblogs.com/liu1838998131/p/16469416.html