Application Development and Automation 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: 
Read only

Problem with data fetching

Former Member
0 Likes
659

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

5 REPLIES 5
Read only

Former Member
0 Likes
603

Can you please post your Code of Select statement

Read only

Former Member
0 Likes
603

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.

Read only

MarcinPciak
Active Contributor
0 Likes
603

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

Read only

Former Member
0 Likes
603

cant you use select distinct if there are duplicate entries

??

Read only

Former Member
0 Likes
603

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.