简体   繁体   English

手动设置SELECT-OPTIONS?

[英]Setting SELECT-OPTIONS manually?

I have a program that, among other things, retrieves data from table RESB based on the bdter field, a DATS type.我有一个程序,除其他外,它根据bdter字段(一种 DATS 类型)从表RESB检索数据。 On the selection screen the user either specifies a range or a standard range (start of month - today) is used.在选择屏幕上,用户指定范围或使用标准范围(月初 - 今天)。

However, if I try to re-use the select-option I created for date in those cases where it isn't filled (the user entered no date range), my changes to this work area don't seem to be recognized when I use it in my select statement.但是,如果我尝试在未填写日期的情况下(用户未输入日期范围)尝试重新使用我为日期创建的选择选项,则我对该工作区的更改似乎无法识别在我的选择语句中使用它。

Relevant code segments follow.相关代码段如下。 After some testing I've concluded that:经过一些测试,我得出结论:

  • if s_bdter is not modified by the user and subsequently set in code, no records are filtered如果s_bdter没有被用户修改并随后在代码中设置,则不会过滤任何记录

  • if s_bdter is modified by the user, records are correctly filtered如果s_bdter被用户修改,记录被正确过滤

  • if s_bdter is modified by the user and subsequently modified in code, records are correctly filtered如果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.

Is this known and documented behaviour?这是已知并记录在案的行为吗? I resolved it by creating my own RANGE table, is this what you're always supposed to do?我通过创建自己的RANGE表解决了这个问题,这是你应该做的吗? Is there then no way to re-use unset select-options to prevent code duplication?那么有没有办法重新使用 unset select-options 来防止代码重复?

You only fill the header line of s_bdter .您只需填写s_bdter的标题行。 You must also append it:您还必须附加它:

" 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

With this, you don't check, if it isn't filled.有了这个,你不检查,如果它没有被填满。 This check must be done explicit:此检查必须明确进行:

" 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.

I hope my code has the correct syntax and sy-tfill is the correct value.我希望我的代码具有正确的语法并且 sy-tfill 是正确的值。 I can't check it actual.我无法检查它的实际情况。 But the principle should be clear.但是原理应该是清楚的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM