Application Development and Automation 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: 
Read only

Dates Agregation with gaps between days

stepniake73
Explorer
0 Likes
1,136

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?

3 REPLIES 3
Read only

FredericGirod
Active Contributor
1,091

Code it yourself, it is not so difficult

Read only

shantraj6
Explorer
0 Likes
1,091

Sort the table and delete the adjacent duplicates.

Sort Itab by PERNR begda endda.
Delete Adjacent Duplicate from ITAB Comparing pernr begda endda.
Read only

0 Likes
1,091

not working 01.12.2022 - 01.12.2022 and 02.12.2022 02.12.2022 should give you 01.12.2022 - 02.12.2022