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

Comparision

Former Member
0 Likes
1,038

I have 2 character fields , Lenght 10

1 is havin data as d1 = '00000000001' and other d2 = '1' .Mathematically they are equal. How can i compare them to get resuly as equal.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
964

refer this demo code -

data: d1(10),

d2(10),

c1 type i,

c2 type i,

d3(10) type n.

d1 = '0000000001'.

d2 = '1'.

c2 = strlen( d2 ).

d3 = '0000000000'.

c1 = strlen( d3 ) - c2.

d3+c1(c2) = d2.

if d1 = d3 .

write 'Equal'.

else.

write 'not equal'.

endif.

9 REPLIES 9
Read only

Former Member
0 Likes
965

refer this demo code -

data: d1(10),

d2(10),

c1 type i,

c2 type i,

d3(10) type n.

d1 = '0000000001'.

d2 = '1'.

c2 = strlen( d2 ).

d3 = '0000000000'.

c1 = strlen( d3 ) - c2.

d3+c1(c2) = d2.

if d1 = d3 .

write 'Equal'.

else.

write 'not equal'.

endif.

Read only

rahulkavuri
Active Contributor
0 Likes
964

use conversion_exit_alpha_output FM to remove leading zeroes.

suppose your variable contains '00000000001'.

data: var(10).

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

INPUT = var

IMPORTING

OUTPUT = var.

now u can do comparison as all the leading zeroes are removed.

mark helpful answers

Read only

Former Member
0 Likes
964

Cast/assign them temporarily to integer variables. Then compare those integer variables.

data: i1 type i, i2 type i.

i1 = d1.

i2 = d2.

if i1 eq i2.

...

endif.

Manoj

Read only

Former Member
0 Likes
964

data: d1(10),

d2(10),

d3(10) type n.

d1 = '0000000001'.

d2 = '1'.

d3 = d2.

if d1 = d3 .

write 'Equal'.

else.

write 'not equal'.

endif.

Read only

0 Likes
964

<b>CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = d2

IMPORTING

OUTPUT = d2.

now compare

d1 and d2</b>

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
964

Hi,

Assign them to two data variables of type 'N' and then assign them to type I.

Then you can compare.

DATA: var1(10) type N value '0000000001'.

DATA: var2 type N value '1'.

DATA: var3 type I,

var4 type I.

var3 = var1.

var4 = var2.

if var3 = var4.

endif.

Regards,

Sesh

Read only

Former Member
0 Likes
964

conversion_exit_alpha_output

Read only

Former Member
0 Likes
964

I dont think FM CONVERSION_EXIT_ALPHA_INPUT is useful in this case. U need to use FM CONVERSION_EXIT_ALPHA_OUTPUT which converts any number with zeroes right into a simple integer

Import parameters Value

INPUT 0000000001

Export parameters Value

OUTPUT 1

Then you can compare both the values.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

Former Member
0 Likes
964

Hi,

use CONVERSION_EXIT_ALPHA_OUTPUT

and pass the value of D1 and the leading zeroes will be removed.

then compare

regards

Shiva