Application Development 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: 

waht is the best way to comapre 2 fields in a select statement

Former Member
0 Kudos

I am using a select statment to pull data back but the 2 fields that I compare are of differnt lengths and just the last 8 characters should match. I tried using an offset but it won't work in the select statement. Basically here is what I want to do but can't

loop at data into table2

select * from table1 where

field(4)+8 = table2-field

modify data from table2

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

U can use LIKE

loop at data into table2

VALUE = '%&%'.

REPLACE '&' WITH table2-field INTO VALUE.

select * from table1 where field like VALUE.

  • Anyway you should still check if the value is correct:

if table1-field(4)+8 = table2-field.

.............

endif.

Max

Max

Message was edited by:

max bianchi

7 REPLIES 7

Former Member
0 Kudos

Hi

U can use LIKE

loop at data into table2

VALUE = '%&%'.

REPLACE '&' WITH table2-field INTO VALUE.

select * from table1 where field like VALUE.

  • Anyway you should still check if the value is correct:

if table1-field(4)+8 = table2-field.

.............

endif.

Max

Max

Message was edited by:

max bianchi

former_member181962
Active Contributor
0 Kudos

loop at data into table2

concatenate '%' table2-field into v_field.

select * from table1 where

field like v_field.

modify data from table2

0 Kudos

is this putting a wild card in front of the field? How does it know though to match on the last 8 characters only?

0 Kudos

Should I be doing a select witih a loop or should I put in an internal talbe. the talbe it selects form is a SAP table that is pretty large

Former Member
0 Kudos

hi,

try like this...

loop at data into table2

cancatenate '%' table2-field into lv_field.

select * from table1

where field like lv_field.

modify data from table2.

Regards,

Satya.

Former Member
0 Kudos

i think u cannot use offset at the left hand side , try this out

select * from table1 into table itab2.

loop at data into table2
  read table itab2  with key field1 = table2-field1.
   if itab2-field1+8 = table2-field1.
     * write ur code here
   endif.
endloop.

Former Member
0 Kudos

hi,

loop at table1.

read table table2 with key...

if field(4)+8 = table2-field.

modify table2 from table1.

endif.

endloop.

regards,

keerthi