Hi All,
My requirement is to do validation on a certain field.
Consider,
Field -- ZVARASTO-VARASTO.
Rule-- 1. Field given must be in 5 digit format ( only numbers ).
2. No leading zeros.
I have implemented code for checking 5 digits.
Following is the code.
var = STRLEN( zvarasto-varasto ).
IF var NE 5 .
MESSAGE e003(zmlo_msg).
LEAVE TO SCREEN 100.
ENDIF.
Im not able to proceed ahead with how to check non numeric values and leading zeros
Kindly help with the same.
Thanx in advance,
Amruta.
Hi
Use the String Compareing commands like CS (contains string) CN (contains not string)
data: v_str(9) type c value '123456789'.
if ZVARASTO-VARASTO CN v_str.
message ' field contains non numeric digits'.
endif.
for eliminate leading zeros move it to TYPE I field and can use.
Regards
anji
hi Amruta,
IF ZVARASTO-VARASTO(5) CO '0123456789'.
5 five chars only numbers
ELSE.
5 five chars not only numbers
ENDIF.
IF ZVARASTO-VARASTO(1) EQ '0'.
Leading zero
ELSE.
Not leading zero
ENDIF.
hope this helps
ec
parameters: ch(10) type c.
data: ch1(5) type c.
data: ty type DD01V-DATATYPE.
if strlen( ch ) > 5.
write: 'not perfect'.
exit.
endif.
*deleting leading zeros.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = ch
IMPORTING
OUTPUT = ch1.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
STRING_IN = ch1
IMPORTING
STRING_OUT = ch1
HTYPE = ty.
.
if ty = 'NUMC'.
WRITE:' perfect'.
else.
write: 'not perfect'.
endif.
<b>*delete leading zeros.... </b>
data: str type string.
str = '00000000000000654654'.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = str
IMPORTING
OUTPUT = str.
write:/ str.
<b>* only 5 digit output</b>
NUMC is the datatype which allows only digits.
ex: parameters: str(5) type NUMC.
Hi,
parameters fname(5). " Length five is only allowed
AT SELECTION-SCREEN ON fname.
IF fname ca sy-abcde.
message e000(zz) with 'alphabets'. "alphabets will be tracked
ENDIF.
start-of-selection.
pack fname to fname."Leading zeros will be ignored
write fname.
Add a comment