Application Development 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: 

can we join MCHA and MCHB tables

Former Member
0 Kudos

Hi all,

Can we join MCHA and MCHB tables based on matnr,werks,charg?

actually i am using for all entries like below...

   SELECT  matnr werks charg bwtar
               FROM mcha CLIENT SPECIFIED
                INTO TABLE it_mcha
      FOR ALL ENTRIES IN it_mara
               WHERE mandt = sy-mandt
                 AND matnr = it_mara-matnr
                 AND werks IN s_werks.

   SELECT matnr werks lgort charg clabs cspem
           FROM mchb CLIENT SPECIFIED
           INTO TABLE it_data
           FOR ALL ENTRIES IN it_mcha
           WHERE mandt = sy-mandt
             AND matnr = it_mcha-matnr
             AND werks = it_mcha-werks
             AND lgort IN s_lgort
             AND charg = it_mcha-charg.

So it is taking lot of time for execution...

Can i use join like this below?

   SELECT mchb~matnr
           mchb~werks
           mchb~lgort
           mchb~charg
           mchb~clabs
           mchb~cspem
           mcha~bwtar
      INTO TABLE it_data
      FROM mchb AS mchb
      INNER JOIN mcha AS mcha
      ON mcha~matnr EQ mchb~matnr
      AND mcha~werks EQ mchb~werks
      AND mcha~charg EQ mchb~charg
      FOR ALL ENTRIES IN it_mara
      WHERE mcha~matnr = it_mara-matnr
      AND mcha~werks IN s_werks
      AND lgort IN s_lgort.

Please advise me?

Regards

Ram

5 REPLIES 5

prakashjasti
Contributor
0 Kudos

Hi,

As all the three fields of selection were available in mchb you can fetch directly from MCHB

You can remove the batches with stock zero if required and then if some of the

fields were needed from MCHA then go for MCHA by using for all entries in MCHB

so that the execution time will be reduced.

Regards,

Prakash.

Prakash J

former_member194152
Contributor
0 Kudos

Yes you can join, are u facing any issue in join?

0 Kudos

No Problem is facing in joins..

For the performance wise which one is better...and also i want the execution time to come down..

Regards

Ram

0 Kudos

Why don't you try this yourself and compare the runtimes?

Results can vary greatly based on data present in each system, so you better compare it in your own landscape.

Thomas

0 Kudos

Hi Thomas,

I used joins instead of FAE.

Retreving data is faster than the FAE.

Thanks to all.

I am closing this thread.

Regards

Ram