Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to delete DELETE lt_infty_0001 where begda GT sy-datum AND endda LT sy-datum.

0 Kudos

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.
1 ACCEPTED SOLUTION

mateuszadamus
Active Contributor

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,
Mateusz
6 REPLIES 6

mateuszadamus
Active Contributor

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,
Mateusz

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

tom_wan
Contributor
0 Kudos

Hi himansu.gyala


Can you show us the content of lt_infty_0001?

Thanksℜgards

Tom

former_member736527
Active Participant

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.

Thanks farosht1 and mateuszadamus to provide the correct solution and the way it should write. Thanks both for help

raymond_giuseppi
Active Contributor
0 Kudos

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

  • sy-datum can be lower than begda - first check is false so whole check is false
  • sy-datum can be between begda and enddat - both checks are false so whole check is false
  • sy-datum can be greater than endda - second check is false so whole check is false

If you actually want to remove intevals that don't contain sy-datum, you could

  • Call for help
  • Ask Ben Kenobi
  • Replace AND with OR

Also you could use parameter BEGDA and ENDDA of HR_READ_INFOTYPE passing sy-datum value.