Skip to Content
author's profile photo Former Member
Former Member

Join Tables

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 !!!

.....

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Apr 12, 2008 at 06: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 .....

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 12, 2008 at 06: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.