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

SQ02 Left Join

Former Member
0 Likes
4,044

Hello,

I made a query inculding mara, marc and mard tables.

mara left joins marc and marc inner joins mard.(I tried marc to left join mard but it doesn't allow it because of the previous(mara-marc) left-join)

I tried to make the query in a way, even if only basic data is maintained query would bring rows from marc and mard empty.

But unfortunately for me, it doesn't work that way and only the maintained data for all tables are returning as results.

What am I doing wrong?

Thanks,

Arda

1 ACCEPTED SOLUTION
Read only

jogeswararao_kavala
Active Contributor
0 Likes
3,315

Hi Arda,

Have you tried the other way of joins?

ie., MARA to MARC inner and MARC to MARD left.

Jogeswara Rao K

16 REPLIES 16
Read only

jogeswararao_kavala
Active Contributor
0 Likes
3,316

Hi Arda,

Have you tried the other way of joins?

ie., MARA to MARC inner and MARC to MARD left.

Jogeswara Rao K

Read only

0 Likes
3,315

Hello Jogeswara,

Yes I did but if MARA inner joins MARC unmaintained data for WERKS will not return in query.

Read only

0 Likes
3,314

Hi Arda,

Actually, my difficulty is to understand the requirement, so that I could simulate and cross-check. My senses say your requirement is well within the reach, because it is not a complex join at all.

For the present issue, you may explore the feature documented here.

For other features of Infoset Queries you may refer to this document also

Jogeswara Rao K

Read only

0 Likes
3,314

By referring to the 'Alias Tables' I am hinting at creating an alias table for MARC or MARD as per your requirement (by the name MARC1 or MARD1) and use this table parallelly.

Jogeswara Rao K.

Read only

0 Likes
3,314

Jogeswara,

I thought it worked correctly but I missed a spot.

If only MARA table is maintained my query doesn't return any result.

How can I solve this? I can create an ABAP program but I want to fix this issue within SAP query limits.

Thanks.

Read only

0 Likes
3,314

Unable to understand

Read only

0 Likes
3,314

If a material is not maintained in MARC and MARD, my query doesn't return result.

I mean, let's say I maintained only basic data of material, then my query won't show that material.

Read only

0 Likes
3,314

Naturally. How there could be any solution for such case?

Read only

0 Likes
3,314

If I could do the following join,

MARA left join ( MARC left join MARD )

Wouldn't I be able to  receive this report?

MARAMARAMARCMARD
Maintainance StatusMATNRMATKLWERKSLGORT
Only basic data10000A01
Only basic data10001A02
Plant and basic data10002A03PLNT1
Plant and basic data10002A03PLNT2
Plant and basic data10003A04PLNT1
Plant and basic data10003A04PLNT2
Strg, plant and basic data10004A05PLNT1STRG1
Strg, plant and basic data10005A06PLNT1STRG2
Strg, plant and basic data10005A06PLNT2STRG3
Strg, plant and basic data10006A07PLNT2STRG4
Read only

0 Likes
3,314

I understood the issue

Try this join. This should work

If the above does not work, switch to Infoset Query.(If you are using SQVI).  In the infoset use one table MARA and MARC with LOJ. Have MARD fields as Additional fields and get values through Select statements in the Code section of these additional fields.

Best of Luck

Jogeswara Rao K

Read only

0 Likes
3,314

Well in theory this join condition is wrong, because it will multiply MARD data for each MARC plant even if I did not maintain those MARD data regarding MARC plant.( as in the tables below )

But we maintain each material for only 1 plant so this should work as long as people do not make mistake and maintain same material for multiple plants.

Thanks again.

Real data
MARAMARCMARD
10000PLNT1STRG1
10000PLNT1STRG2
10000PLNT2
Query result would be like
MARAMARCMARD
10000PLNT1STRG1
10000PLNT1STRG2
10000PLNT2STRG1
10000PLNT2STRG2
Read only

0 Likes
3,314

In fact I've not worked with these tables. On the other hand when issues are there, I believe there is no harm in trying things do not fall under theories. One more thing you can do is to remove(delete) WERKS join in the original configuration.

Read only

Former Member
0 Likes
3,314

Hi Arda,

Please try

Regards

Boris

Read only

0 Likes
3,314

Hi Boris,

It doesn't work as I intended.

I want MARC and MARD fields to return null even if they are not maintained.

And inner join doesn't allow this.

Read only

0 Likes
3,314

MARA----------MARC----left join---MARD worked for me.

Thanks everyone

Read only

Former Member
0 Likes
3,314

This message was moderated.