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

need help

Former Member
0 Likes
507

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.

3 REPLIES 3
Read only

Former Member
0 Likes
489

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

Read only

Former Member
0 Likes
489

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.

Read only

Former Member
0 Likes
489

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.