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

join tables

Former Member
0 Likes
1,129

how to join 3-4 tables with good performance with coding

reply me soon.......

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
830

hi

you can achieve it using internal tables. select 1st table and move it to internal table.

now use one more select with 'for all entries' in the internal table . make sure you dont write ur code with nested loop.

regards

Manoharan

5 REPLIES 5
Read only

Former Member
0 Likes
830

You can do it in two ways:

1. Use inner joins to select the data from each of these tables together. But you need to be careful and sure about he joining conditions.

2. Select serially from one table and use for all entries in the next select statement.

This will also work.

- Guru

Reward points if useful

Read only

Former Member
0 Likes
830

Joining 3 tables is not suggested by SAP.

First try to fetch all the Master entries into an Internal table.

Use a Join for the remaining 2 tables with a FOR ALL ENTRIES condition on the Master Internal table.

Don't forget to put sy-subrc checks, DELETE Duplicates..., SORT, READ, etc. before for all Entries.

Hope this helps

Regards

Vinayak

Read only

Former Member
0 Likes
830

hi,

by apply inner join condition.

select irecdv icdiff iitime iidate ivlcod ipoint imdtxt imdocm mobjnr mswerk eeqktx tatinn e~equnr into CORRESPONDING FIELDS OF table it

from imrg as i

inner join imptt as t on ipoint = tpoint

inner join mcipmis as m on mobjnr = tmpobj

inner join eqkt as e on eequnr = mequnr

where m~swerk in swerk

and i~idate in idate

and t~atinn in ('0000000058' , '0000000151' , '0000000152')

and i~cancl <> 'X'.

use this type of condition in your program

reward point if helpful.

regards,

pankaj

Read only

ak_upadhyay
Contributor
0 Likes
830

Hi Ashwani,

Check this report....


*&---------------------------------------------------------------------*
*& Report  ZCUSTOMER_DETAIL                                            *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZCUSTOMER_DETAIL                        .

TABLES : KNA1, VBAK, VBAP, LIPS, VBRP, VBRK, KNKK.

PARAMETERS : KUNNR LIKE KNA1-KUNNR.

DATA : BEGIN OF IT OCCURS 0,
       KUNNR LIKE KNA1-KUNNR,
       NAME1 LIKE KNA1-NAME1,
       FKDAT LIKE VBRK-FKDAT,
       KLIMK LIKE KNKK-KLIMK,
       KKBER LIKE KNKK-KKBER,
       END OF IT.

    SELECT SINGLE
                KNA1~KUNNR
                KNA1~NAME1
                VBRK~FKDAT
                KNKK~KLIMK
                KNKK~KKBER
                INTO IT FROM KNA1 INNER JOIN VBAK ON
                KNA1~KUNNR = VBAK~KUNNR
                INNER JOIN KNKK ON
                KNA1~KUNNR = KNKK~KUNNR
                INNER JOIN VBAP ON
                VBAK~VBELN = VBAP~VBELN
                INNER JOIN LIPS ON
                VBAP~VBELN = LIPS~VGBEL
                INNER JOIN VBRP ON
                LIPS~VBELN = VBRP~VGBEL
                INNER JOIN VBRK ON
                VBRP~VBELN = VBRK~VBELN
                WHERE KNA1~KUNNR = KUNNR.

    APPEND IT.

   LOOP AT IT.

   WRITE :/ IT-KUNNR,
            IT-NAME1,
            IT-FKDAT,
            IT-KLIMK,
            IT-KKBER.
   ENDLOOP.

Reward points if useful....

Regards

AK

Read only

Former Member
0 Likes
831

hi

you can achieve it using internal tables. select 1st table and move it to internal table.

now use one more select with 'for all entries' in the internal table . make sure you dont write ur code with nested loop.

regards

Manoharan