[英]ABAP SQL capture records of a date range of active employees
Record in pa0000 / pa0001 has two records as follows: pa0000/pa0001中的记录有如下两条记录:
Begda Endda贝格达恩达
[03.07.2017 - 31.12.9999] [03.07.2017 - 31.12.9999]
[03.01.2017 - 02.07.2017] [03.01.2017 - 02.07.2017]
Selection screen has the date range: Low: 01/07/2017 and High: 31/07/2017选择屏幕具有日期范围:低:01/07/2017 和高:31/07/2017
ABAP Code has written as follows: ABAP代码写成如下:
Select data from Pa0001 table
SELECT PERNR
ENDDA
BEGDA
PERSG
PERSK
FROM PA0001
INTO TABLE T_PA0001
WHERE PERNR IN S_PERNR[] AND
BEGDA <= S_BUDAT-LOW AND
ENDDA >= S_BUDAT-HIGH AND
PERSG IN S_EMPGR[] AND
PERSK IN S_EMPSG[] AND
GSBER IN S_WERKS AND
BTRTL = 'FURC' .
The aforesaid two records are not captured.上述两条记录没有被捕获。
I would like to re-write the code by using the method "Exclude all wrong options" instead of present method "enlist all acceptable options", as follows.我想通过使用“排除所有错误选项”的方法而不是当前方法“列出所有可接受的选项”来重新编写代码,如下所示。
WHERE NOT ( pa0001-begda > s_budat-high or pa0001-endda < s_budat-low)
Any help in this regard will be highly appreciated.在这方面的任何帮助将不胜感激。
It probably does not work because S_BUDAT
is a header of the internal table with header line S_BUDAT[]
so in other words it is a structure.它可能不起作用,因为
S_BUDAT
是带有标题行S_BUDAT[]
的内部表的标题,因此换句话说,它是一个结构。 You should rather split select option S_BUDAT
to two parameters eg.您应该将选择选项
S_BUDAT
为两个参数,例如。 P_LOW
and P_HIGH
and rephrase your query. P_LOW
和P_HIGH
并重新P_HIGH
您的查询。
The other option would be to write simply NOT IN S_BUDAT[]
.另一种选择是简单地写
NOT IN S_BUDAT[]
。
The selection you have now will only match employees that are active on all the days from S_BUDAT-LOW to S_BUDAT-HIGH.您现在的选择将只匹配从 S_BUDAT-LOW 到 S_BUDAT-HIGH 的所有日子都处于活动状态的员工。 From your question it looks like you actually want to select all employees that have at least one day in that range.
从您的问题看来,您实际上想要选择在该范围内至少有一天的所有员工。 To get the last selection you can use:
要获得最后一个选择,您可以使用:
BEGDA LE S_BUDAT-HIGH AND
ENDDA GE S_BUDAT-LOW
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.