report ztest_sc_2 no standard page heading.
*Types & data: For dropdownlist
type-pools : vrm .
tables:sscrfields.
parameters : p_list1(4) as listbox visible length 20 ,
p_list2 type rmmg1-mtart as listbox visible length 28,
p_list3 type rmmg1-berty as listbox visible length 15,
p_list4 type c as listbox visible length 10 user-command p4.
* Initialization
initialization.
"Set the value list
perform value_list using 'p_list1'.
perform value_list using 'p_list4'.
* at selection-screen output
at selection-screen output.
"Set the default key of value list
perform value_list_default.
* at selection-screen
at selection-screen.
"Check the PAI event of value-list
perform value_list_pai.
* start of selection
start-of-selection.
*&———————————————————————*
*& Form VALUE_LIST
*&———————————————————————*
* Create the Dropdown list
*———————————————————————-*
form value_list using i_name type c.
data:
lv_name type vrm_id,
lt_list type vrm_values,
ls_list type vrm_value.
clear:ls_list,lt_list.
if i_name = 'p_list1'.
* For the items: p_list1
clear:ls_list.
ls_list-key = 'MM01'.
ls_list-text = 'Create Material'.
append ls_list to lt_list.
clear:ls_list.
ls_list-key = 'MM02'.
ls_list-text = 'Change Material'.
append ls_list to lt_list.
clear:ls_list.
ls_list-key = 'MM03'.
ls_list-text = 'Display Material'.
append ls_list to lt_list.
elseif i_name = 'p_list4'.
* For the items: p_list4
clear:ls_list.
ls_list-key = 'A'.
ls_list-text = 'Character A'.
append ls_list to lt_list.
clear:ls_list.
ls_list-key = 'B'.
ls_list-text = 'Character B'.
append ls_list to lt_list.
endif.
* Set the value list
lv_name = i_name.
call function 'VRM_SET_VALUES'
exporting
id = lv_name
values = lt_list
exceptions
id_illegal_name = 1
others = 2.
if sy-subrc <> 0.
"For the item list error!
message 'For the item list error!' type 'E'.
endif.
endform. " VALUE_LIST
*&———————————————————————*
*& Form VALUE_LIST_DEFAULT
*&———————————————————————*
* Set the default key of value list
*———————————————————————-*
form value_list_default .
*Note:
* For dropdownlist, it will use ”Key-match” to determine the selected.
* if no match, for exmaple,if you enter such as ”MM04″, then the item
* 'MM04' will be added in the below of the value-list automatically.
*1. For p_list1
p_list1 = 'MM02'. " Key-match
*2. For p_list2
p_list2 = 'No KEY'. " No Key-match and cast
*3. For p_list3
p_list3 = '3'. " Key-match
endform. " VALUE_LIST_DEFAULT
*&———————————————————————*
*& Form VALUE_LIST_PAI
*&———————————————————————*
* Check the PAI event of value-list
*———————————————————————-*
form value_list_pai .
*1. For p_list1 : Should be triggered by ENTER or F-code
case p_list1.
when 'MM01'.
message 'You have selected ”MM01” item.' type 'I'.
when 'MM02'.
message 'You have selected ”MM02” item.' type 'I'.
when 'MM03'.
message 'You have selected ”MM03” item.' type 'I'.
when others.
message 'No relevant transaction maintained!' type 'W'.
endcase.
*2. For p_list4 : Triggered automatically when state changed
if sscrfields-ucomm = 'P4'. "Only when change the item in List 'P4'
case p_list4.
when 'A'.
message 'You have selected ”A” Character.' type 'I'.
when 'B'.
message 'You have selected ”B” Character.' type 'I'.
endcase.
endif.
endform. " VALUE_LIST_PAI
*-------------------------------------------------------
REPORT."调用模板
PARAMETERS: p_out(4) AS LISTBOX VISIBLE LENGTH 20.
TYPE-POOLS vrm .
TABLES sscrfields.
DATA: lv_name TYPE vrm_id,
lt_list TYPE vrm_values,
ls_list TYPE vrm_value.
INITIALIZATION.
CLEAR: ls_list, lt_list.
ls_list-key = 'ZLD0'.
ls_list-text = '交货单打印'.
APPEND ls_list TO lt_list.
CLEAR:ls_list.
ls_list-key = 'ZLD1'.
ls_list-text = '出库单打印'.
APPEND ls_list TO lt_list.
CLEAR:ls_list.
ls_list-key = 'ZLDX'.
ls_list-text = '全部打印'.
APPEND ls_list TO lt_list.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_OUT' "p_out可以取lt_list-key中的任一值
values = lt_list
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
评论