data: first_number type I,
num type I,
counter type I,
s type I,
r type I,
rr type I,
i type I.
clear: x_stcd1_Str , x_stcd1_Len .
x_stcd1_Str = i_lfa1-stcd1.
SHIFT x_stcd1_Str LEFT DELETING LEADING space.
CONDENSE x_stcd1_Str NO-GAPS.
first_number = SUBSTRING( VAL = x_stcd1_Str OFF = 0 LEN = 1 ) .
do 9 times.
num = SUBSTRING( VAL = x_stcd1_Str OFF = sy-index - 1 LEN = 1 ) .
if num = first_number .
counter = counter + 1.
endif.
s = s + num * ( 11 - sy-index ).
enddo.
r = s Mod 11 .
If r > 1 .
r = 11 - r .
endif.
rr = SUBSTRING( VAL = x_stcd1_Str OFF = 9 LEN = 1 ) .
If r = rr And counter < 9 .
MESSAGE 'National Code is valid !' TYPE 'I'.
else.
MESSAGE 'National Code is not valid !' TYPE 'E'.
endif.
num type I,
counter type I,
s type I,
r type I,
rr type I,
i type I.
clear: x_stcd1_Str , x_stcd1_Len .
x_stcd1_Str = i_lfa1-stcd1.
SHIFT x_stcd1_Str LEFT DELETING LEADING space.
CONDENSE x_stcd1_Str NO-GAPS.
first_number = SUBSTRING( VAL = x_stcd1_Str OFF = 0 LEN = 1 ) .
do 9 times.
num = SUBSTRING( VAL = x_stcd1_Str OFF = sy-index - 1 LEN = 1 ) .
if num = first_number .
counter = counter + 1.
endif.
s = s + num * ( 11 - sy-index ).
enddo.
r = s Mod 11 .
If r > 1 .
r = 11 - r .
endif.
rr = SUBSTRING( VAL = x_stcd1_Str OFF = 9 LEN = 1 ) .
If r = rr And counter < 9 .
MESSAGE 'National Code is valid !' TYPE 'I'.
else.
MESSAGE 'National Code is not valid !' TYPE 'E'.
endif.
No comments:
Post a Comment