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

field validation

Former Member
0 Likes
677

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!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
645

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.

5 REPLIES 5
Read only

Former Member
0 Likes
646

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.

Read only

Former Member
0 Likes
645

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

Read only

Former Member
0 Likes
645

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.

Read only

0 Likes
645

Doesn't work, because field type is char, and the sorting is not working as it should...

Read only

andreas_mann3
Active Contributor
0 Likes
645

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.