我有一个程序,除其他外,根据RESB
字段(DATS类型)从表bdter
检索数据。在选择屏幕上,用户指定范围或标准范围(月初 - 今天)。
但是,如果我尝试重新使用我为日期创建的select-option而未填写的选项(用户没有输入日期范围),我对此工作区的更改不会当我在select语句中使用它时似乎被识别出来。
相关的代码段如下。经过一些测试后,我得出结论:
s_bdter
并随后在代码中设置,则不会过滤任何记录s_bdter
,则会正确过滤记录如果用户修改了s_bdter
并随后在代码中进行了修改,则会正确过滤记录
SELECT-OPTIONS: s_bdter FOR ls_itab-bdter MODIF ID sbd.
START-OF-SELECTION.
" Set the interval.
s_bdter-sign = 'I'.
s_bdter-option = 'BT'.
s_bdter-low = lc_bdter_start.
s_bdter-high = sy-datum + 30.
" This select doesn't filter on bdter unless the selection parameter was set by the user.
SELECT r~aufnr p~psphi
FROM resb AS r
INNER JOIN afpo AS o ON o~aufnr = r~aufnr
INNER JOIN prps AS p ON p~pspnr = o~projn
INTO TABLE lt_resb_ss
WHERE r~bdter IN s_bdter.
这是已知的和记录在案的行为吗?我通过创建自己的RANGE
表来解决它,这是你一直应该做的吗?那么有没有办法重新使用未设置的select-options来防止代码重复?
答案 0 :(得分:4)
您只填写s_bdter
的标题行。你还必须追加它:
" Set the interval.
s_bdter-sign = 'I'.
s_bdter-option = 'BT'.
s_bdter-low = lc_bdter_start.
s_bdter-high = sy-datum + 30.
append s_bdter. "<- this was missing
有了这个,你不检查,如果没有填写。 必须明确地进行此检查:
describe table s_bdter.
if sy-tfill = 0.
" Set the interval.
s_bdter-sign = 'I'.
s_bdter-option = 'BT'.
s_bdter-low = lc_bdter_start.
s_bdter-high = sy-datum + 30.
append s_bdter. "<- this was missing
endif. " sy-tfill = 0.
我希望我的代码具有正确的语法,并且sy-tfill是正确的值。我无法检查它是否真实。但原则应该是明确的。