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

Compare two fields

Former Member
0 Likes
483

Hi

I have a table with 2 fields

ROW....FIELD1.......FIELD2

001.......XX_0020......XX_20

002.......XX_0002......XX_2

003.......XX_0200......XX_200

004.......XX_0201......XX_200

005.......XX_0037......XX_39

In select statement I would like to get only rows: 001, 002 and 003

because in these rows FIELD1 = FIELD2 if all zeros between "XX_" and first sign not equal "0" in FIELD1 are not taken into consideration.

Regards

PWnuk

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
458

hi check this..

select field1

field2

from dbtab

where field1 = s_field1 .

sort itab by field1 .

loop at itab .

if itab-field1 = itab-field2 .

write:/ itab-field1 , itab-field2 .

endif.

endloop.

regards,

venkat

3 REPLIES 3
Read only

Former Member
0 Likes
459

hi check this..

select field1

field2

from dbtab

where field1 = s_field1 .

sort itab by field1 .

loop at itab .

if itab-field1 = itab-field2 .

write:/ itab-field1 , itab-field2 .

endif.

endloop.

regards,

venkat

Read only

0 Likes
458

Hi venkat

THX for your reply.

Explain the "where" clause in more detail.

THX.

Read only

0 Likes
458

for simple demo check this...

data: begin of itab occurs 0,

field1 type i,

field2 type i,

end of itab .

itab-field1 = '10'.

itab-field2 = '0010'.

append itab .

itab-field1 = '20'.

itab-field2 = '0020'.

append itab .

itab-field1 = '30'.

itab-field2 = '0030'.

append itab .

loop at itab .

if itab-field1 = itab-field2 .

write:/ itab-field1 , itab-field2 .

endif.

endloop.