Skip to Content
0
Jan 19, 2023 at 07:29 AM

Dates Agregation with gaps between days

45 Views

Hi, I have itab with 3 columns: pernr, begda, endda. I have also data in itab:

pernr | begda | endda

123 | 01.12.2022 | 01.12.2022
123 | 02.12.2022 | 02.12.2022

123 | 12.12.2022 | 12.12.2022
123 | 13.12.2022 | 13.12.2022
123 | 14.12.2022 | 14.12.2022
123 | 15.12.2022 | 15.12.2022
123 | 16.12.2022 | 16.12.2022

123 | 28.12.2022 | 28.12.2022
123 | 29.12.2022 | 29.12.2022
123 | 30.12.2022 | 30.12.2022

456 | 13.12.2022 | 13.12.2022

789 | 05.12.2022 | 05.12.2022
789 | 06.12.2022 | 06.12.2022
789 | 07.12.2022 | 07.12.2022
789 | 08.12.2022 | 08.12.2022
789 | 09.12.2022 | 09.12.2022

789 | 12.12.2022 | 12.12.2022

789 | 27.12.2022 | 27.12.2022
789 | 28.12.2022 | 28.12.2022
789 | 29.12.2022 | 29.12.2022
789 | 30.12.2022 | 30.12.2022

All i have to do, is to combine adjacent dates for every pernr.
Finally, ja have to get result as below:

123 | 01.12.2022 | 02.12.2022

123 | 12.12.2022 | 16.12.2022
123 | 28.12.2022 | 30.12.2022

456 | 13.12.2022 | 13.12.2022

789 | 05.12.2022 | 09.12.2022
789 | 12.12.2022 | 12.12.2022
789 | 27.12.2022 | 30.12.2022

I can`t find useful function module, or solution of similar problem.
How can i solve this task? Any suggestions?