‎2009 May 19 10:22 AM
Hi,
I am facing the problem while fetching the data from COEP table.The scenario is as follows:
1) For the projects entered on selection screen,fetch BEDID from AFKO. (PRONR = Project def.)
2) Based on value of BEDID,fetch OBJNR from AFVC.
3) Based on value of OBJNR, fetch WOGBTR from COEP and sum it up.
I am facing problem with step 3 as WHERE clause in the select query is based on nonkey field of the table.Same is the case while fetching data from AFKO and AFVC.
Please suggest the better alternative
‎2009 May 19 10:29 AM
‎2009 May 19 10:37 AM
Hi,
Try like this.
select BEDID from AFKO into table it_afko where PRONR = Project def.
if sy-subrc is initial.
select OBJNR
BEDID from AFVC into table it_afvc
for all entries in it_afko
where bedid = it_afko-bedid.
endif.
if not it_afvc is initial.
select OBJNR
WOGBTR from coep into table it_coep
for all entries in it_afko
where objnr = it_afko-objnr
endif.
‎2009 May 19 10:38 AM
Hi,
In WHERE clause you can use non key fields. The important is that on the left side it must be a column from LEFT table i.e.
select ... from AFVC as A inner join COEP as C on
a~column1 = c~column1 and
...
where a~non_key_column = .... "here on the left must be a left table column provided, but non key field is allowed
Regards
Marcin
‎2009 May 19 10:40 AM
‎2009 May 19 11:09 AM
Hai,
I think you should find the primary key field common to all the tables which you are using and use that field in the WHERE clause.