03-26-2021 7:21 AM
Hi All below is the code, where trying to delete the entry. But below delete statement is not working in production, though the same code is working in testing and quality environment. Please help to fix the issue
DATA lt_infty_0001 TYPE STANDARD TABLE OF p0001.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
perner = iv_pernr
infty = cl_hrsfec_service_lib=>gc_infty_0001
TABLES
infty_tab = lt_infty_0001
EXCEPTIONS
infty_not_found = 1
OTHERS = 2
IF sy-subrc = 0.
DELETE lt_infty_0001 where begda GT sy-datum AND endda LT sy-datum.
ENDIF.
03-26-2021 7:34 AM
Hello himansu.gyala
What do you mean it does not work?
I don't see why you should have any records containing start date (BEGDA) greater than current date and end date (ENDDA) less than current data. Such records make no sense since they are never valid.
BEGDA > 20210326
ENDDA < 20210326
What is the validity period? None.
Unless you wanted to have OR instead of the AND in the DELETE statement?
Kind regards,03-26-2021 7:34 AM
Hello himansu.gyala
What do you mean it does not work?
I don't see why you should have any records containing start date (BEGDA) greater than current date and end date (ENDDA) less than current data. Such records make no sense since they are never valid.
BEGDA > 20210326
ENDDA < 20210326
What is the validity period? None.
Unless you wanted to have OR instead of the AND in the DELETE statement?
Kind regards,03-26-2021 7:46 AM
either that, or it should be
DELETE lt_infty_0001 where begda LT sy-datum AND endda GT sy-datum.
So that BEGDA < SY-DATUM < ENDDA
03-26-2021 7:35 AM
Hi himansu.gyala
Can you show us the content of lt_infty_0001?
Thanksℜgards
Tom
03-26-2021 7:41 AM
Can you show us the run time values in LT_INFTY_0001.
The DELETE statement seems to be wrong, because how can something begin at a later date (SY_DATUM) and end before that same date (SY-DATUM)?
The query boils down to
BEGDA > SY-DATUM > ENDDA
Maybe the query is supposed to be
DELETE lt_infty_0001 where begda LT sy-datum AND endda GT sy-datum.
03-30-2021 11:02 AM
Thanks farosht1 and mateuszadamus to provide the correct solution and the way it should write. Thanks both for help
03-26-2021 12:31 PM
Check the logic of 'where begda GT sy-datum AND endda LT sy-datum.'
one must always assert that the start date is before (less or equal) the end date
then
If you actually want to remove intevals that don't contain sy-datum, you could
Also you could use parameter BEGDA and ENDDA of HR_READ_INFOTYPE passing sy-datum value.