2006 Dec 19 8:06 AM
HI All,
I am having a requirement where i need to join two database tables where there is only one field on which i can put an inner join, objnr from one table and valuestrng from other and last 5 digits of objnr can be compared with valuestrng, in a select query how can we get last 5 digits of 22 digit number.can anybody suggest the query please.
2006 Dec 19 8:11 AM
hi,
pls close multiple thread, the same question is answered
so another way
data: last_5(5) type c.
last_5 = v_data + 16(5).
rgds
Anver
2006 Dec 19 8:23 AM
Hi Shilpa ,
You cannot use offset in select statment , so the solution i would suggest select the data saperately , insted of using joins.
Regards
Arun
2006 Dec 19 8:36 AM
if u compare it in join itself it will give syntax error like,
filed is not defined in the DATA .
if u work with for all entries in, then also it wil give syntax error like, the two fileds to be compared should have same type and length.
so its better to take the data in an internal table, and compare with loop and can store into another internal table.
2006 Dec 19 8:44 AM
DATA : TVALUESTRING(5).
TVALUESTRING = OBJNR+16(5).
IN YOUR SELECT QRY
SELECT .....FROM <DBTAB> INTO.....WHERE VALUESTRING LIKE TVALUESTRING.
IF OBJNR VALUE IS NOT FIXED.
THEN USE STRLEN TO FIND OUT THE LENGTH OF OBJNR AND SUBTRACT 5 FROM THAT NOW TAKE THAT VALUE FROM OBJNR TO TVALUESTRING
REGARDS
SHIBA DUTTA
2006 Dec 19 8:48 AM
data: val(5).
val = variable+16(5).
select ........... from... into...... where objnr = val.
Cheers.
2006 Dec 19 9:00 AM
Hi shilpa,
In select statement you can not apply offset.
So select the 2 queries seperately.