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

Query Question

Former Member
0 Likes
898

Hi,

How can i join a table with an internal table in Sap Query?

i have a base table (aufk) and i will be creating an internal table with code in an infoset. Then i need to join the internal table with aufk.

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
871

Hi Alper,

Here is the sample code for inner join.

SELECT mara~matnr

marc~werks

INTO TABLE t_material

FROM mara AS mara INNER JOIN marc AS marc

ON maramatnr = marcmatnr

WHERE mara~mtart = p_mtart.

here instead of a standard table use your internal table.

Hope it helps!

Much Regards,

Amuktha.

8 REPLIES 8
Read only

former_member582701
Contributor
0 Likes
871

SELECT *

FROM AUFK

INTO TABLE i_aufk

FOR ALL ENTRIES IN i_itab

WHERE field = i_itab-field.

Read only

0 Likes
871

Can you give more details?

i created an infoset with just aufk.

then where will i put this code? in additional fields? or where?

Thanks.

Read only

Former Member
0 Likes
871

Hi Alper

[Table Joins|http://help.sap.com/saphelp_nw04/helpdata/EN/50/a71ec8f65911d296390000e82de14a/content.htm]

Regards,

Sravanthi

Read only

Former Member
0 Likes
872

Hi Alper,

Here is the sample code for inner join.

SELECT mara~matnr

marc~werks

INTO TABLE t_material

FROM mara AS mara INNER JOIN marc AS marc

ON maramatnr = marcmatnr

WHERE mara~mtart = p_mtart.

here instead of a standard table use your internal table.

Hope it helps!

Much Regards,

Amuktha.

Read only

0 Likes
871

i was thinking about doing this on sq01 sap query,

from what you wrote i should understand that i need to create a seperate program for this?

Read only

0 Likes
871

Yes. sq01 is made to help querying out database tables, not doing some "complex" abap. In SQ01, can't you query a DB table instead of creating an internal table?

Read only

0 Likes
871

what i have is :

order no

1

2

order no---material no--reserved amount--

1--


1001
10
--


1--


1002
5
--


2--


1018
1
--


order no-material no


consumed amount

1--


1001
4
--


1--


1003
7
--


2--


1018
1
--


with these 3 tables, i want to get :

order no-material no


reservedconsumed--difference

1--


1001
10

4

6
--


1--


1002
3

0

3
--


1--


1003
0

7

(-7)
----

2--


1018
1

1

0
--


as you can see material numbers are unique lists for that order both from reservations and consumes.

Any hope?

Alper,

Read only

0 Likes
871

Thank you for the details, it's clear : I don't see how it can be done in only one query, so I guess you'd better create an abap program.