‎2008 Aug 28 11:10 AM
Hi,
Can we use offset in select statement. I was trying to compare the year and month of MBEWH table with the LINV table. MBEWH has seperate fields for year and month but LINV table has a date field.
TYPES:BEGIN OF TY_MBEWH,
lfgja type lfgja,
lfmon type lfmon,
END OF TY_MBEWH.
Data: T_MBEWH TYPE TABLE OF TY_MBEWH,
WA_MBEWH TYPE TY_MBEWH.
Select MBEWHLFGJA MBEWHLFMON
INTO TABLE T_MBEWH FROM MBEWH INNER JOIN LINV
ON MBEWHMATNR = LINVMATNR
where MBEWHBWKEY = LINVWERKS
and MBEWHLFGJA >= *LINVIDATU(4)*
and MBEWH~LFMON > LINV.IDATU+4(2).
When I execute the above code Iam getting "Field LINV~IDATU is unknown. It is neither in one of the specified tables nor defined by a DATA statement.
Best Regards
Suresh
‎2008 Aug 28 11:20 AM
Hi Suresh,
Try it this way:
W_YEAR = LINV-IDATU+0(4).
W_MONTH = LINV-IDATU+4(2).
Select MBEWH~LFGJA MBEWH~LFMON
INTO TABLE T_MBEWH FROM MBEWH INNER JOIN LINV
ON MBEWH~MATNR EQ LINV~MATNR
where MBEWH~BWKEY EQ LINV~WERKS
and MBEWH~LFGJA GE W_YEAR
and MBEWH~LFMON GT W_MONTH.With luck,
Pritam.
‎2008 Aug 28 11:12 AM
well you can do that offset actiojn BEFORE yourselect into another variable.
then use this variable in your select.
‎2008 Aug 28 11:13 AM
Hi,
For this error, declare in the top of the program as TABLES: LINV.We have to define the tables used in the program. Hope this will solve the issue.
‎2008 Aug 28 11:18 AM
>
> Hi,
> For this error, declare in the top of the program as TABLES: LINV.We have to define the tables used in the program. Hope this will solve the issue.
Not in any recent version of SAP you don't.
‎2008 Aug 28 11:15 AM
Hi,
Whenever you use offset in select query both the fields length(comparing fields after off setting) should be same.
in your case MBEWHLFMON length should equal to the length of LINVIDATU+4(2). then it works.
Regards,
Sathish Reddy.
‎2008 Aug 28 11:17 AM
Hi
Select MBEWHLFGJA MBEWHLFMON
INTO TABLE T_MBEWH FROM MBEWH INNER JOIN LINV
ON MBEWHMATNR = LINVMATNR
where MBEWHBWKEY = LINVWERKS
and MBEWHLFGJA >= LINVIDATU(4)
and MBEWH~LFMON > LINV.IDATU+4(2).
i think this "LINV.IDATU4(2)" instead should be LINV~IDATU4(2).
‎2008 Aug 28 11:18 AM
No we cannot use offset in select query.
take this LINV~IDATU(4) in some other variable and use that variable in query.
Amit.
‎2008 Aug 28 11:20 AM
Hi Suresh,
Try it this way:
W_YEAR = LINV-IDATU+0(4).
W_MONTH = LINV-IDATU+4(2).
Select MBEWH~LFGJA MBEWH~LFMON
INTO TABLE T_MBEWH FROM MBEWH INNER JOIN LINV
ON MBEWH~MATNR EQ LINV~MATNR
where MBEWH~BWKEY EQ LINV~WERKS
and MBEWH~LFGJA GE W_YEAR
and MBEWH~LFMON GT W_MONTH.With luck,
Pritam.
‎2008 Aug 28 11:23 AM
Hi ,
Right hand side of select query should contain some variable or constants. As said in the previous reply first keep the data LINV~IDATU(4) in some variable and use this variable in the select statement.
Regards,
Swarna Munukoti
Edited by: Swarna Munukoti on Aug 28, 2008 12:25 PM
‎2008 Aug 28 12:42 PM
Hi,
I cant take the field LINV~IDATU(4) into a variable as this field is used in inner joins. Iam comparing two table fields using joins.
Also LINV is declared in tables statement.
Best Regards
Suresh
Edited by: mariosuresh on Aug 28, 2008 1:43 PM
‎2008 Aug 28 12:53 PM
Mario,
First write a select only for LINV table and get the data of field IDATU in some itab-IDATU than use offset of IDATU(4) and take in itab-temp and use this itab-temp varibale in your join ferther.
Amit.
‎2008 Aug 28 12:45 PM