2007 Aug 13 5:52 AM
hi friends ,
I have written the code for telephone number validation for the formats XXX-XXX-XXXX
and XXXXXXXXXX.
IF <fl_ship>-telf13(1) EQ '-' AND <fl_ship>-telf17(1) EQ '-' .
IF <fl_ship>-telf1 CO '0123456789-'.
write sy-fdpos..
li_ship_to-telf1 = <fl_ship>-telf1.
ELSE.
li_ship_to-telf1 = ' '.
ENDIF.
ELSEIF <fl_ship>-telf1 CO '0123456789'.
write sy-fdpos.
li_ship_to-telf1 = <fl_ship>-telf1.
ELSE.
li_ship_to-telf1 = ' '.
ENDIF.
this is not working for XXX-XXX-XXXX also for XXXXXXXXXX can any body can say why its not working . I have tested with 123-456-7890 also for 1234567890 ...
hi friends ,
I have written the code for telephone number validation for the formats XXX-XXX-XXXX
and XXXXXXXXXX.
IF <fl_ship>-telf13(1) EQ '-' AND <fl_ship>-telf17(1) EQ '-' .
IF <fl_ship>-telf1 CO '0123456789-'.
write sy-fdpos..
li_ship_to-telf1 = <fl_ship>-telf1.
ELSE.
li_ship_to-telf1 = ' '.
ENDIF.
ELSEIF <fl_ship>-telf1 CO '0123456789'.
write sy-fdpos.
li_ship_to-telf1 = <fl_ship>-telf1.
ELSE.
li_ship_to-telf1 = ' '.
ENDIF.
this is not working for XXX-XXX-XXXX also for XXXXXXXXXX can any body can say why its not working . I have tested with 123-456-7890 also for 1234567890 ...
2007 Aug 13 6:00 AM
Hi,
Unfortunetly SAP is not in front of me. Otherwise i could have coded for you.
You can use like,
split <fl_ship>-telf1 into str1 str2 str3 using '-' (check syntax)
then check sy-subrc
if sy-subrc = 0.
" Splitted
if str1 CO '0123456789' or str2 CO '0123456789' or str3 CO '0123456789'.
perform action
else.
perform action.
endif.
else.
" Not Splitted
if <fl_ship>-telf1 CO '0123456789'
perform action.
else.
perform action.
endif.
endif.
Reward if useful!
2007 Aug 13 8:56 AM
Hi..
<b>Observe the changes in BOLD</b>
You have to include the SPACE ( ' ' ) also while comparing with CO.
Otherwise if the String contains a SPACE it will not match the condition.
Now try the code below.
It works.
<b>IF <fl_ship>-telf1 CO '0123456789- '. "Add SPACE character also</b>
write sy-fdpos.
IF <fl_ship>-telf13(1) EQ '-' AND <fl_ship>-telf17(1) EQ '-' .
li_ship_to-telf1 = <fl_ship>-telf1.
ELSE.
li_ship_to-telf1 = ' '.
ENDIF.
<b>ELSEIF <fl_ship>-telf1 CO '0123456789 '. "Add a space also</b>
write sy-fdpos.
li_ship_to-telf1 = <fl_ship>-telf1.
ELSE.
li_ship_to-telf1 = ' '.
ENDIF.
<b>Reward if Helpful</b>