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

Character Comparison

Former Member
0 Likes
856

hi All,

Can any one provide me the code for character comparison?

I need to check the data in one field ZDATA and pass the value to ZDATA1

If ZDATA is a char or blank then ZDATA1 = 0

else

Move the number value of ZDATA to ZDATA1.

\[removed by moderator\]

Thanks in advance!

Edited by: Jan Stallkamp on Aug 25, 2008 4:36 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
828

Hi,

IF zdata CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' OR zdata EQ space.

MOVE 0 to zdata1

else.

MOVE zdata to zdata1

endif.

5 REPLIES 5
Read only

Former Member
0 Likes
828

Hi,

Try this.

Use CA for comparing.

If zdata CA '0123456789'.

<as per your requirement>

else.

zdata = 0.

endif.

Sharin.

Read only

Former Member
0 Likes
829

Hi,

IF zdata CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' OR zdata EQ space.

MOVE 0 to zdata1

else.

MOVE zdata to zdata1

endif.

Read only

Former Member
0 Likes
828

find strlen(zdata) into variable i.

do i times.

if not zdata(i) in r_numbers.

zdata1(i) = '0'.

else.

zdata1(i) = zdata(i).

enddo.

hope it helps....

Read only

Former Member
0 Likes
828

If ZDATA cn sy-abcde or ZDATA eq ''.

ZDATA1 = 0

else.

CALL FUNCTION 'NUMERIC_CHECK'

EXPORTING

STRING_IN = ZDATA

IMPORTING

STRING_OUT = ZDATA

type = type

IF type NE 'NUMC'.

zdata1 = zdata

endif

endif.

Read only

Former Member
0 Likes
828

Hi,

Try like this:

if zdata CA sy-abcde OR zdata EQ ''.

zdata1 = 0.

write:/ zdata1.

else.

move zdata to zdata1.

write:/ zdata1.

endif.

Regards,

Bhaskar