2007 Nov 17 10:53 AM
HI experts,
Can v use BSEG and BKPF table in inner join.
thanks.
Khan
2007 Nov 17 11:04 AM
since BSEG is a cluster table you can not use inner join . Here you have to use For all entries option
like
tables : bkpf , bseg.
data : ibkpf like bkpf occurs 0 with header line.
data : ibseg like bseg occurs 0 with header line.
select * into table ibkpf from bkpf up to 10 rows.
if not ibkpf[] is initial.
select * from bseg into table ibseg for all entries in ibkpf where
bukrs = ibkpf-bukrs and
belnr = ibkpf-belnr.
endif.
regards
shiba dutta
HI experts,
Can v use BSEG and BKPF table in inner join.
thanks.
Khan
2007 Nov 17 11:03 AM
2007 Nov 17 11:04 AM
hi,
no u cant use join with BSEG as it is cluster table so u need to first fetch data from it and have to use for all entries.
Reward if useful.
2007 Nov 17 11:04 AM
since BSEG is a cluster table you can not use inner join . Here you have to use For all entries option
like
tables : bkpf , bseg.
data : ibkpf like bkpf occurs 0 with header line.
data : ibseg like bseg occurs 0 with header line.
select * into table ibkpf from bkpf up to 10 rows.
if not ibkpf[] is initial.
select * from bseg into table ibseg for all entries in ibkpf where
bukrs = ibkpf-bukrs and
belnr = ibkpf-belnr.
endif.
regards
shiba dutta
2007 Nov 17 11:08 AM
rather u can check the views related to bseg and bkpf:
V_VBSEGD
V_VBSEGK
V_VBSEGS
2007 Nov 17 12:22 PM
HI ,
hOW CAN i POPULATE A VIEW AT RUNTIME AND HOW DO I THEN FETCH THE DATA.
MY INPUT FIELDS ON SELECTION SCREEN ARE
P_BUKRS LIKE BSEG-BUKRS.
S_DATE FOR BKPF-BUDAT
S_KUNNR FOR BSEG-KUNNR
plz help.
thaNKS.
KHAN
2007 Nov 17 5:53 PM
Check this BLOG:
<a href="/people/rob.burbank/blog/2007/11/12/quickly-retrieving-fi-document-data-from-bseg">Quickly Retrieving FI document Data from BSEG</a>
Rob
2007 Nov 17 2:40 PM
Hi Khan,
Need to do this way because u can't join cluster and pooled tables...
1. FOR ALL ENTRIES.
2. It is recommended that
first select entries from only one table
(say, BKPF),
3. After that, using the internal table,
FOR ALL ENTRIES, and BSEG table,
select the relevant entries from BSEG table.
4. Performance wise, this will be very fast.
See the Below example and modify ur it according to ur requirement ...
data: begin of tbl_bkpf occurs 0,
bukrs like bkpf-bukrs,
belnr like bkpf-belnr,
gjahr like bkpf-gjahr,
end of tbl_bkpf.
data: begin of tbl_bseg occurs 0,
bukrs like bkpf-bukrs,
belnr like bkpf-belnr,
gjahr like bkpf-gjahr,
end of tbl_bseg.
select bukrs belnr gjahr
into table tbl_bkpf
from bkpf
where belnr in s_belnr. "Insert parameters here
check sy-subrc eq 0.
select belnr
into table tbl_bseg
from bseg
for all entries in table tbl_bkpf
where bukrs = tbl_bkpf-bukrs and
belnr = tbl_bkpf-belnr and
gjahr = tbl_bkpf-gjahr.
sort tbl_bseg by bukrs belnr gjahr.
loop at tbl_bkpf.
read table tbl_bseg with key bukrs = tbl_bkpf-bukrs
belnr = tbl_bkpf-belnr
gjahr = tbl_bkpf-gjahr
binary search.
if sy-subrc ne 0.
** ur logic here
endif.
endloop.
This method hits the DB twice only, and using the BINARY SEARCH is a very efficient way to search a SORTED Internal Table.
Hope it will solve your problem..
<b>Reward points if useful..</b>
Thanks & Regards
ilesh 24x7