‎2007 Aug 15 5:40 PM
Hi Gurus,
I need to select all the records from Z_tab to it_tab that meet below conditions:
mode = a or b
amount1 < amount2
and for this I have written the following code
select * into table it_tab
from z_tab
for all entries in it_temp
where mode = 'A' or mode = 'B'
and amount1 < amount2.
but its showing me an error that field amount2 is unkown, although this field is defined in my z_tab table.
please help me out.
Thanks
Rajeev Gupta
‎2007 Aug 15 5:44 PM
Hi,
Hope your Ztab contains amount1 and amount2 fields.
For that select using
select * into table it_tab
from z_tab
for all entries in it_temp
where mode = 'A' or mode = 'B'.
delete it_itab where amount2 ge amount1.
finally you will have the required values in it_itab.
Regards,
Baburaj
‎2007 Aug 15 5:48 PM
HI,
In this select you are trying to compare the two database table fields which is not possible. rather do this.
select * from z_tab into table itab where mode in ('A','B').
if sy-subrc eq 0.
delete itab where amont1 > amount2.
endif.
Y are u using the for all entris in it_Temp does this table contains amount2?
if yes
then use this.
select * from z_tab for all enteris in it_temp into table itab where mode in ('A','B') and amount1 < it_temp-amount2..
Thanks
mahesh
‎2007 Aug 15 5:50 PM
You cannot do that in one single select statement. Easiest will be to get all the records (include the columns amount1 and amount2 as well to your itab) just based on mode and then loop at the itab. delete the record if amount1 < amount2.
‎2007 Aug 16 4:00 AM
‎2007 Aug 16 4:30 AM
Hi..
The error is coming bcoz amount1 is not a field in ur Table zTab.
You have to change the query like this:
select * into table it_tab
from z_tab
for all entries in it_temp
where mode = 'A' or mode = 'B'
and amount2 > amount1.
<b>Reward if Helpful</b>
‎2007 Aug 16 4:49 AM
use tablename.ammount2 it wil remove ur error
use the tablename to wich amnt2 is associated