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: 

how to join two tables?

Former Member
0 Kudos

can anyone tell me the code "how to create a report to display material number and sales order using two tables MARA and VBAP?"

points will be rewarded for correct answer.

6 REPLIES 6

Former Member
0 Kudos

To display material number and sales order using two tables MARA and VBAP

u can get like this.

DATA:matnr like mara-matnr.

select aMATNR INTO matnr from mara AS a INNER JOIN vbap as b on amatnr = b~matnr

endselect.

Reward Points if useful.

0 Kudos

can u plese tell the code.i am new to ABAP.

0 Kudos

>data: begin of itab occurs 0,

> vbeln type vbak-vbeln,

> posnr type vbap-posnr,

> matnr type vbap-matnr,

> end of itab.

>

>select-options: so_vbeln for vbap-vbeln.

>

>select vbeln posnr matnr from vbap

> into table Itab

> where vbeln eq so_vbeln.

OR

> selct avbeln aposnr bmatnr bwerks

> from vbap as a

> join mara as b

> on amatnr = bmatnr

> into table itab ( create a stru related to it)

> where vbeln in so_vbeln.

Award points if helpful

Edited by: jackandjay on Dec 25, 2007 12:19 AM

0 Kudos

can u tell me the code in detail.i am new to sap abap.

points will be rewarded for correct answer.

Former Member
0 Kudos

Hi Ashwini,

Just a suggestion, since you are new to ABAP, i feel you can obtain the results using SQVI. Here you can insert the tables you want, join the fields & in the layout mode, select the fields you want to be displayed & also select the respective input fields.

For your report, i feel a Join between MARC-VBAP would be better, as you will be able to get the report for a specific plant. The reason for suggestion is, MARA table contains all materials & not specific to a plant & if you run the report, it will take a very long time.

Hope i was able to provide you with some inputs.

Regards,

Vivek

dhruv_shah3
Active Contributor
0 Kudos

Hi,

Assume that you have 2 tables Mara and Makt

First fire select query on Mara Table.

i.e select matnr from mara into table it_mara

Now fire query on Makt table

Select matnr maktx from Makt into table it_makt

for all entries in it_mara

where matnr = it_mara-matnr.

here we have joined tables using the For All Entries....

Regards,

DS