Skip to Content
0
Former Member
Oct 18, 2012 at 08:36 AM

can we join MCHA and MCHB tables

543 Views

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