‎2008 May 16 8:39 AM
hi all,
i have developed a simple report with follwing 2 select statements.
but the problem is as recommended to use join for these 2 select statement .
please help me how to write code for join and do i need to make any changes in the following loop statement to pass the fields to final internal table..
SELECT ebeln
ebelp
matnr
from ekpo
into table gt_ekpo
where ebeln in s_ebeln.
check gt_ekpo[] is not initial.
SELECT matnr
bismt
from mara
into table gt_mara
FOR ALL ENTRIES IN gt_ekpo
where matnr eq gt_ekpo-matnr.
LOOP AT gt_ekpo WHERE ebeln NE ' ' AND matnr NE ' '.
MOVE gt_ekpo-ebeln TO gt_final-ebeln.
MOVE gt_ekpo-matnr TO gt_final-matnr.
READ TABLE gt_mara WITH KEY matnr = gt_ekpo-matnr BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_mara-bismt TO gt_final-bismt.
ENDIF.
please help.
thanks in advance.
‎2008 May 16 8:47 AM
SELECT aebeln aebelp amatnr bbismt
from ekpo as a inner join mara as b
on amatnr = bmatnr
into table gt_final
where a~ebeln in s_ebeln.
Best Regards,
Vibha
Please mark all the helpful answers
‎2008 May 16 8:49 AM
Hi,
Try with the below code.
tables ekpo.
select-options: s_ebeln for ekpo-ebeln.
data: begin of itab occurs 0,
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
bismt like mara-bismt,
end of itab.
select aebeln aebelp amatnr bbismt into table itab from ekpo as a inner join mara as b
on amatnr = bmatnr
where a~ebeln in s_ebeln.
‎2008 May 16 8:55 AM
Hi,
Something like that :
SELECT eebln eeblp ematnr mbismt
INTO TABLE gt_table
FROM ekpo AS e INNER JOIN mara AS m
ON ematnr = mmatnr
WHERE e~matnr <> ' '
AND e~ebeln <> ' '
AND e~ebeln IN s_ebeln.