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 a Record a record with Overlap Period

Former Member
0 Kudos

Hi Experts,

I am developing a Module Pool Program to maintain the entries of a Z Table. My requirement is I should allow the User to create or Change the entry with Overlap Period. Below is Details.

Z Table Fields:

Company Code

Customer

Issue Date

Expiry Date

If there is an entry in the table with the below details

C001 20142 01/01/2010 01/01/2011

New Record

C001 20142 06/01/2010 12/31/2011

I should allow the user to create the second record as the record is having the Over Lap period . But he can create the record from 02/01/2011 to any date.

Please suggest how should be my SELECT statement.

Thanks in advance.

Regards,

Srinivas

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

You could try something like

* Actual record
* from...............to.............
* New record
* .........from............to.......
* Check if there is a record in database
* which overlap the new validity period
SELECT SINGLE * FROM ztable
  WHERE bukrs  EQ new_record-bukrs
    AND kunnr  EQ new_record-kunnr
    AND begdte LE new_record-begdte
    AND enddte GE new_record-begdte
    AND enddte LT new_record-enddte.

But which rule do you apply if there are already 2 or more records in database. (i suppose database table has keys mandt, bukrs, kunnr, begdte (or enddte)

Regards,

Raymond

3 REPLIES 3

Former Member
0 Kudos

How is the table keyed...going to have a problem there, aren't you?

raymond_giuseppi
Active Contributor
0 Kudos

You could try something like

* Actual record
* from...............to.............
* New record
* .........from............to.......
* Check if there is a record in database
* which overlap the new validity period
SELECT SINGLE * FROM ztable
  WHERE bukrs  EQ new_record-bukrs
    AND kunnr  EQ new_record-kunnr
    AND begdte LE new_record-begdte
    AND enddte GE new_record-begdte
    AND enddte LT new_record-enddte.

But which rule do you apply if there are already 2 or more records in database. (i suppose database table has keys mandt, bukrs, kunnr, begdte (or enddte)

Regards,

Raymond

0 Kudos

Thanks for all you help....

regards,

Srinivas