‎2006 Nov 29 1:34 PM
Hello,
I have a ztable with two fields: from , to.
I have to validate the entries, so that the intervals shouldn't overlap.
Example:
I have the entries:
from to
1 7
12 15
Entry allowed: from: 8 to: 11
Entry denied: from: 13 to: 14
What is the easiest way of doing this?
Thank you!
‎2006 Nov 29 1:42 PM
Hi George
Are you taking the values from user and updating them into ztable? Or are you reading from ztable and validating?
For the first case if you use SELECT-OPTIONS the system itself will provide you the validation. You no need to bother.
In the second case, retrieve both from the ztable;
IF FROM > TO
Message -
.
ENDIF.
Regards
Surya.
‎2006 Nov 29 1:42 PM
Hi George
Are you taking the values from user and updating them into ztable? Or are you reading from ztable and validating?
For the first case if you use SELECT-OPTIONS the system itself will provide you the validation. You no need to bother.
In the second case, retrieve both from the ztable;
IF FROM > TO
Message -
.
ENDIF.
Regards
Surya.
‎2006 Nov 29 1:43 PM
depends how you enter the values. if you make a screen with SE51 you can build the logic in there. if you use SM30 you can create an event
with SE11 select the table and change
menu utilities -> table maintenance generator ->
new screen
menu Environment -> modification -> events
you can enter an event or in this case a check before save there
kind regards
arthur
‎2006 Nov 29 1:48 PM
hi George,
Please try the following logic.
Data:
itab type table of ztable with header line.
wa type ztable. "this has the new value for from and to.
sort itab by from to.
loop at itab.
if itab-from < wa-from and itab-to > wa_to.
{ set flag eror}
exit.
endif.
endloop.
Hope this helps.
Sajan.
‎2006 Nov 29 2:14 PM
Doesn't work, because field type is char, and the sorting is not working as it should...
‎2006 Nov 29 2:16 PM
hi,
sample:
*check Überlappung / overlap
LOOP AT ztab WHERE mahns = ztab-mahns
AND hkont = ztab-hkont
AND sp1 = ztab-sp1
AND sp2 = ztab-sp2
AND ( new_from_date BETWEEN ztab-from_date and ztab-to_date
or new_to_date between ztab-from_date AND ztab-to_date ).
ENDLOOP.
IF sy-subrc = 0.
MESSAGE e001(00) WITH text-e02.
endif.A.