04-12-2008 6:51 PM
Hi all,
I have a scenario where I have got three tables two std ones and the third one is the custom one bseg,bkpf and ztest, and based on three fields i.e. belnr, blart and bukrs( which is in all the three tables )to join these tables and need to retreive the following the data from each table:
From BSEG - - -> saknr,kostl
From BKPF- - - - > blart,bldat
and
From Ztest -
> co_num, co_name
So can you please tell me how can I achieve this.
Thanks,
Rajeev !!!
.....
04-12-2008 7:03 PM
types: begin of ty_itab,
saknr type ..
kostl type ...
blart type ....
co_num type ....
co_name type...
types: end of ty_itab.
data: itab type table of ty_itab.
select BSEG~saknr
BSEG~kostl
BKPF~blart
BKPF~bldat
ztest~co_num
ztest~co_name
from bseg inner join
bkpf
on bsegbelnr = bkprbelnr
and bsegblart = bkpfblart
and bsegbukrs = bkpfbukrs inner join
ztest on ztestbelnr = bsegbelnr
and ztestblart = bsegblart
and ztestbukrs = bsegbukrs
into table itab
where .....
04-12-2008 7:10 PM
Hi,
You can do as below:
First get all the data from BKPF for the fields belnr, blart, bldat and bukrs into one internal table as this is the header table for document .
select bukrs belnr blart bldat budat from bkpf into table gt_bkpf where <condition>.
"Then go to BSEG table using BKPF details
select bukrs belnr blart saknr kostl from bseg into table gt_bseg for all entries of gt_bkpf where <condition>.
"Then go to ZTable using the details of BSEG gt_bseg using for all entries .
select co_num, co_name from ztable into table gt_table where <condition>.
"You can use the gt_table for the output.
Please use the fields depends upon your requirement.
Thanks,
Sriram Ponna.