Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

HELP IN SMALL QUERY

Hi all,

I have a variable type c and want to know whether it contains only numericals are not.

Lets say

test(5) type c.

test = '12345'.

if test co '0123456789'.

write : 'only numericals'.

elseIF NOT TEST = SPACE.

write : 'ALPHA numericals'.

ELSE.

write : 'SPACE'.

ENDIF.

tHIS WORKS FINE FOR INPUT 12345

SOMETIMES MY INPUT IS LIKE THIS

test = '345 '. OR test = ' 345'.

HERE THE OUTPUT SHOULD BE ONLY NUMERICALS.

IN ORDER TO ACHEIVE THIS I DID CHANGED THIS

if test co '0123456789'.

TO if test co '0123456789 '.: NOTE AFTER 9 I ADDED A SPACE

NOW IT WORKS FINE FOR THIS CODE .

THE ONLY PROBLEM WITH CODE IS

EVEN IF TEST = ' '.

IT GIVES ME A OUT PUT SAYING ONLY NUMERICALS

IN THIS CASE I WANT O/P AS SPACE

CAN ANYONE TELL ME HOW TO ACHEIVE THIS

THANKS

Tags:
Former Member
Former Member replied

Hi preety .

Try in this way...

test(5) type c.

test = '12345'.

<b>if test co '0123456789 ' and test NE ' '.</b>

write : 'only numericals'.

ELSEif test = SPACE.

write : 'SPACE'.

elseIF NOT TEST = SPACE.

write : 'ALPHA numericals'.

else.

write : 'Other'.

endif.

ENDIF.

<b>Reward Points if it is helpful.</b>

Let me know if you need more help.

Thanks & Regards

ilesh 24x7

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question