我创建了一些动态选择选项。在我的桌子上,我希望预定义一个参数,而不能为用户更改。我在事件中使用回调表单进行了改变:
data: LS_EVENTS type RSDSEVENTS,
LT_EVENTS type standard table of RSDSEVENTS.
LS_EVENTS-EVENT = 'O'. "at selection screen output §§§
LS_EVENTS-PROG = SY-REPID.
LS_EVENTS-FORM = 'AT_SELECTION_SCREEN_OUT'.
append LS_EVENTS to LT_EVENTS.
call function 'FREE_SELECTIONS_INIT'
exporting
KIND = 'F' "
importing
SELECTION_ID = GV_SELECTION_ID
tables
TABLES_TAB = GT_TABLE
FIELDS_TAB = GT_FIELDSTAB
EVENTS = LT_EVENTS
exceptions
...
others = 20.
现在回调表单如下所示:
form AT_SELECTION_SCREEN_OUT tables
LT_RSSELDYN "selections
LT_RSFLDNUM. "dynpro info
field-symbols <FS_LINE> type ANY.
field-symbols <FS_FIELD> type ANY.
read table LT_RSFLDNUM assigning <FS_LINE> with key
('TABLENAME') = 'MyTab' ('FIELDNAME') = 'MyField' .
if <FS_LINE> is assigned.
assign component 'GROUP1' of structure <FS_LINE> to <FS_FIELD>.
if <FS_FIELD> is assigned. "Group1 ausgelesen
loop at screen.
if SCREEN-GROUP1 = <FS_FIELD>.
"Eingabe deaktiviert
SCREEN-INPUT = '0'.
"Ausblenden unnötiger Felder
if SCREEN-GROUP3 = 'TOT'
or SCREEN-GROUP3 = 'HGH'
or SCREEN-GROUP3 = 'VPU'.
SCREEN-INVISIBLE = 1.
endif.
modify screen."änderungen auf Screen speichern
endif.
endloop.
endif.
endif.
unassign: <FS_FIELD>, <FS_LINE>.
有效。它设置了正确的值,不可变。在第一个表中,如文档所述,保存当前值。但如果我改变它们,那就行不通了。
read table LT_RSSELDYN assigning <FS_LINE> with key
('TABLENAME') = 'MyTab' ('FIELDNAME') = 'MyField' .
if <FS_LINE> is assigned.
"<>-low = 'MyValue', <>-sign = 'I', <>-option = 'EQ'
assign component 'LOW' of structure <FS_LINE> to <FS_FIELD>.
if <FS_FIELD> is assigned.
<FS_FIELD> = 'MyValue'.
endif.
unassign <FS_FIELD>.
assign component 'SIGN' of structure <FS_LINE> to <FS_FIELD>.
if <FS_FIELD> is assigned.
<FS_FIELD> = 'I'.
endif.
unassign <FS_FIELD>.
assign component 'OPTION' of structure <FS_LINE> to <FS_FIELD>.
if <FS_FIELD> is assigned.
<FS_FIELD> = 'EQ'.
endif.
unassign <FS_FIELD>.
endif.
unassign: <FS_FIELD>, <FS_LINE>.
endform.
是否有可能限制这些值的变化?我只是希望它们显示在Selectoptions中,如果它们在那里。
答案 0 :(得分:0)
作为一个选项,您可以隐藏用户不希望更改的字段,并填充表达式,然后手动隐藏选项卡。对于此tabfields_not_display
参数存在。
DATA: table TYPE string,
ev_expressions TYPE rsds_texpr,
ev_field_ranges TYPE rsds_trange,
ev_number_of_active_fields LIKE sy-tfill,
lt_field_tab TYPE TABLE OF rsdsfields,
lt_tabfields_not_display TYPE TABLE OF rsdsfields.
DATA: table_tab TYPE TABLE OF rsdstabs,
selid TYPE rsdynsel-selid,
cond_tab TYPE rsds_twhere.
table = 'USR02'.
table_tab = VALUE #( ( prim_tab = table ) ).
APPEND VALUE rsdsfields( tablename = 'USR02' fieldname = 'BNAME' ) TO lt_tabfields_not_display.
APPEND VALUE rsdsfields( tablename = 'USR02' fieldname = 'GLTGV' ) TO lt_tabfields_not_display.
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
kind = 'T'
IMPORTING
selection_id = selid
TABLES
tables_tab = table_tab
tabfields_not_display = lt_tabfields_not_display
EXCEPTIONS
OTHERS = 4.
CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
EXPORTING
selection_id = selid
title = 'Free Selection'
as_window = ' '
IMPORTING
where_clauses = cond_tab
expressions = ev_expressions
field_ranges = ev_field_ranges
number_of_active_fields = ev_number_of_active_fields
TABLES
fields_tab = lt_field_tab
EXCEPTIONS
OTHERS = 4.
APPEND VALUE rsds_expr( tablename = table
expr_tab = VALUE rsds_expr_tab(
( logop = 'AND' arity = '2' )
( arity = '0' fieldname = 'BNAME' option = 'EQ' low = 'my_user' )
( arity = '0' fieldname = 'GLTGV' option = 'EQ' low = '20190503' ) )
) TO ev_expressions.
APPEND VALUE rsds_where( tablename = table
where_tab = VALUE rsds_where_tab(
( line = ` ( BNAME EQ 'my_user' ) ` )
( line = ` AND ( GLTGV EQ '20190503' ) ` ) )
) TO cond_tab.