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

Urgent:Doubt on Validation

Former Member
0 Likes
466

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 ...

2 REPLIES 2
Read only

Former Member
0 Likes
436

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!

Read only

varma_narayana
Active Contributor
0 Likes
436

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>