‎2008 Jan 11 5:34 AM
Hi all.
I have two table MAEX other Ztable.
MAEX have key field: MATNR, ALAND, and GEGRU.
ZTABLE have key field: Delivery, delivery item but MATNR is INDEX field.
I need to fetch ALNUM from MAEX. remaining fields i need to fetch from ZTABLE .Pls help me.shall I use Index as Key field?
To be reward all helpful answers.
Regards.
JNJ
‎2008 Jan 11 5:40 AM
select <fields>
into table <itab>
from MAEX as a inner join Ztab as b
on amatnr = bmatnr
where <condition>
Madhavi
‎2008 Jan 11 5:41 AM
Hi,
From performance point of view its always better to have key fields in the where clause of select statement and if you dont have any key field in where clause the second best option is to have a field which have index in the table.
regards,
Pankaj
‎2008 Jan 11 5:45 AM
hi
since matnr is your index field so matnr will not match directly to your standard table matnr.
so do one thing when you are fetching the record from z table then first fetch the record in internal table then convert the data type of your indexed matnr to your standard one, then match the record by read table and fill in final one/
regards
vijay
‎2008 Jan 11 5:45 AM
Hi JNJ,
you can use select following statment :
select maexalnum ztablefield1 field2....
into table itab from maex
inner join ztable on maexmatnr = ztablematnr
where ...
Syed Tayab Shah
‎2008 Jan 11 6:22 AM
Hi,
It may be helpful to you...
TYPES: BEGIN OF ty_maex,
matnr TYPE maex-matnr,
alnum TYPE maex-alnum,
END OF ty_vbak.
TYPES: BEGIN OF ty_ztable,
matnr TYPE ztable-matnr,
delivery TYPE ztable-delivery,
delivery_item TYPE ztable-delivery_item,
END OF ty_vbap.
TYPES: BEGIN OF ty_final,
matnr TYPE maex-matnr,
alnum TYPE maex-alnum,
delivery TYPE ztable-delivery,
delivery_item TYPE ztable-delivery_item,
END OF ty_final.
--
DATA: wa_maex TYPE ty_maex,
wa_ztable TYPE ty_ztable,
wa_final TYPE ty_final.
--
DATA: it_maex TYPE TABLE OF ty_maex,
it_ztable TYPE TABLE OF ty_ztable,
it_final TYPE TABLE OF ty_final.
SELECT matnr alnum
FROM maex INTO TABLE it_maex WHERE matnr in s_matnr(selection screen field).
SORT it_maex BY matnr.
IF it_maex[] IS NOT INITIAL.
SELECT matnr delivery delivery_item
FROM ztable INTO TABLE it_ztable
FOR ALL ENTRIES IN it_maex
WHERE matnr = it_maex-matnr.
ENDIF.
LOOP AT it_ztable INTO wa_ztable.
READ TABLE it_maex INTO wa_maex WITH KEY matnr = wa_ztable-matnr.
wa_final-matnr = wa_ztable-matnr.
wa_final-alnum = wa_maex-alnum.
wa_final-delivery = wa_ztable-delivery.
wa_final-delivery_item = wa_ztable-delivery_item.
APPEND wa_final TO it_final.
ENDLOOP.
Regards,
Sayak... ..."reward if it is helpful"