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

VALIDATION CODE

Former Member
0 Likes
755

I have to write a validation code...for validating the serial number.It has 9 digits...( the first digit can be 5,7,9, the next two number will be yr 07 for 2007 , next two will be month 01 for Jan, last four number will be 0000-9999).

Check validation like sernr+0(1) = first digit

sernr1(2) = sy-datum2(2).

sernr3(2) = sy-datum0(2).

sernr+5(4) = last four digits.

How can i change the code to validate the number

3 REPLIES 3
Read only

Former Member
0 Likes
551

Hi Alexander,

IF ( SERNR0(1) = '5' OR SERNR0(1) = '7' OR SERNR+0(1) = '9' ) AND

SERNR1(2) = SY-DATUM2(2) AND

SERNR3(2) = SY-DATUM4(2) AND

( SERNR5(4) >= '0000' AND SERNR5(4) <= '9999' ).

>>Code as per requirement

ENDIF.

Thanks,

Vinay

Message was edited by:

Vinaykumar G

Read only

0 Likes
551

So the final code is

CHECK VALIDATION LIKE SERNR0(1) = '2' OR SERNR0(1) = '3' OR SERNR+0(1) = '6'

AND SERNR1(2) = SY-DATUM2(2) AND

SERNR3(2) = SY-DATUM4(2) AND

SERNR+ 5(4) >= '0000' AND SERNR+5(4) <= '9999'

Read only

Former Member
0 Likes
551

Hi Alexander,

Below code should give you an idea :

v_num = '507013333'.

if v_num(1) co '579'.

write 'first digit validated'.

else.

write 'first digit false'.

endif.

if v_num+5 co '0123456789'.

write 'last digits validated'.

else.

write 'last digits false'.

endif.

Cheers,

Vikram

Pls reward for helpful replies!!