08-19-2010 3:06 PM
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
08-19-2010 3:40 PM
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
08-19-2010 3:11 PM
How is the table keyed...going to have a problem there, aren't you?
08-19-2010 3:40 PM
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
08-26-2010 1:03 PM