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: 

Find overlapping dates in transportation lanes

Former Member
0 Kudos

I need to locate transportation lane records where a Receiver location is assigned to multiple Source locations. The internal table contains the fields: material, source location, Receiver location, 'From' date, and 'To' date.

For example,

Material Source Receiver From date To date

12345 XX01 XX02 1/1/1999 5/31/2006

12345 XX03 XX02 5/1/2006 12/31/9999

I need to flag that material 12345 is assigned to two Source locations for the 5/1/2006-5/31/2006 period. Does anyone have any ideas on an efficient way of finding these situations?

Thanks and best regards,

Sandy

1 ACCEPTED SOLUTION

former_member186741
Active Contributor
0 Kudos

If your table is declared something like below I think my code will be pretty efficient. If the table is not sorted and has a lot of entries the code will be slow:

data itab type sorted table of xyz with non-unique key

material source receiver.

field-symbols:

<prime> type xyz,

<duplicate> type xyz.

loop at itab assigning <prime>.

loop at itab assigning <duplicate>

where material = <prime>-material

and source = <prime>-source

and receiver = <prime>-receiver.

if <duplicate>-from between <prime>-from

and <prime>-to

or <duplicate>-to between <prime>-from and <prime>-to.

write:/ 'bingo!'........"etc

endif.

endloop.

endloop.

2 REPLIES 2

former_member186741
Active Contributor
0 Kudos

If your table is declared something like below I think my code will be pretty efficient. If the table is not sorted and has a lot of entries the code will be slow:

data itab type sorted table of xyz with non-unique key

material source receiver.

field-symbols:

<prime> type xyz,

<duplicate> type xyz.

loop at itab assigning <prime>.

loop at itab assigning <duplicate>

where material = <prime>-material

and source = <prime>-source

and receiver = <prime>-receiver.

if <duplicate>-from between <prime>-from

and <prime>-to

or <duplicate>-to between <prime>-from and <prime>-to.

write:/ 'bingo!'........"etc

endif.

endloop.

endloop.

Former Member
0 Kudos

Try TB_TIME_INTERVAL_OVERLAP.

Rob