‎2007 Jan 22 11:41 AM
I have three table eban, ebkn, anla.
eban has four fields,
ebkn has one fields,
anla has one fields to retreive,
I hv created one structure for that.
Now I am in confusion that hw i will write select statement......
plz tell me hw to write select statement for that...
thanks....
‎2007 Jan 22 11:55 AM
Hi,
You can use the Inner join and also use the For all entries ....
select EBAN-Field1 EBAN-Fiel2 EBAN-Fiel3 EBAN-Field4
EBKN-FIELD1 EBKN-FIELD2 EBKN-FIELD3
ANLA-FIELD1 ANLA-FIELD2 ANLA-FIELD3 ANLA-FIELD4
into it_lista
from EBAN inner join EBKN
on EBAN-Field1 = EBKN-FIELD1
and EBKN-FIELD2 = EBKN-FIELD2
inner join ANLA
on EBAN-Field1 = EBAN-Field1
where ANLA-FIELD4 = '04'.
Regards
Sudheer
‎2007 Jan 22 11:55 AM
Hi,
You can use the Inner join and also use the For all entries ....
select EBAN-Field1 EBAN-Fiel2 EBAN-Fiel3 EBAN-Field4
EBKN-FIELD1 EBKN-FIELD2 EBKN-FIELD3
ANLA-FIELD1 ANLA-FIELD2 ANLA-FIELD3 ANLA-FIELD4
into it_lista
from EBAN inner join EBKN
on EBAN-Field1 = EBKN-FIELD1
and EBKN-FIELD2 = EBKN-FIELD2
inner join ANLA
on EBAN-Field1 = EBAN-Field1
where ANLA-FIELD4 = '04'.
Regards
Sudheer
‎2007 Jan 22 12:00 PM
Hi,
You can use the following selects for better performance
select fld1 fld2 from itab_eban
where....
if sy-subrc = 0.
select fld 1 ..
from ebkn
for all entries in itab_eban
where banfn =itab_eban-banfn
and bnfpo = itab_eban-bnfpo
endif.
... similarly with the rest of the tables
Please reward it it helps
Regards
‎2007 Jan 22 12:01 PM
select ff1 ff2 ff3 ff4 gf5 hf6 into table itab from eban as f inner join ebkn as g on eban-abcd = ebkn-abcd inner join enla as h on ebkn-abcd = enla-abcd.
wher abcd are the common fields in the given tables.
Cheers.
‎2007 Jan 22 12:06 PM
Hi Chang,
You may use JOINS in this case, using the keys BANFN and BNFPO to relate the tables EBAN & EBKN. Coming to ANLA, you will have to look for the relevant PK/FK to relate it with these tables.
samlpe code using joins
select
eban~f1
eban~f2
eban~f3
eban~f4
ebkn~f1
ebkn~f2
ebkn~f3
from eban as eban
inner join ebkn as ebkn
for all entries in <comparision tab>
where <your where condition>.
if sy-subrc = 0.
Check if the SELECT is successful
endif.
Please Close this thread.. when your problem is solved
Reward if Helpful
Regards
Karthik