Skip to Content

"Left Outer Join" with "For All Entries" condition

Hello,

Maybe you can help me.

I want to do an Select like this:

SELECT a~matnr c~werks a~wrkst a~groes c~ekgrp INTO CORRESPONDING FIELDS OF TABLE lt_data_info FROM mara AS a left OUTER JOIN marc AS c ON a~matnr = c~matnr FOR ALL ENTRIES IN ct_data_info WHERE a~matnr = ct_data_info-matnr AND c~werks = ct_data_info-werks.

But this does not work.

So I tried this:

SELECT a~matnr c~werks a~wrkst a~groes c~ekgrp INTO CORRESPONDING FIELDS OF TABLE lt_data_info FROM mara AS a left OUTER JOIN marc AS c ON a~matnr = c~matnr AND c~werks = ct_data_info-werks FOR ALL ENTRIES IN ct_data_info WHERE a~matnr = ct_data_info-matnr.

It does not work.

So how can I do such Select.

Thanks,

Pascal

Sorry for my bad English, here the German version.

Entschuldigung für mein schlechtes Englisch, hier die deutsche Version.

Hallo,

Vielleicht könnt ihr mir ja helfen.

Ich möchte einen Select wie diesen machen.

SELECT a~matnr c~werks a~wrkst a~groes c~ekgrp INTO CORRESPONDING FIELDS OF TABLE lt_data_info FROM mara AS a left OUTER JOIN marc AS c ON a~matnr = c~matnr FOR ALL ENTRIES IN ct_data_info WHERE a~matnr = ct_data_info-matnr AND c~werks = ct_data_info-werks.

Allerdings funktioniert der so nicht.

Daher habe ich folgendes probiert, welches allerdings auch nicht funktioniert hat.

SELECT a~matnr c~werks a~wrkst a~groes c~ekgrp INTO CORRESPONDING FIELDS OF TABLE lt_data_info FROM mara AS a left OUTER JOIN marc AS c ON a~matnr = c~matnr AND c~werks = ct_data_info-werks FOR ALL ENTRIES IN ct_data_info WHERE a~matnr = ct_data_info-matnr.

Diese Überlegung hat auch nichts gebracht.

Ich hoffe, dass ihr mir weiterhelfen könnt.

Mit freundlichen Grüßen,

Pascal

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Sep 15, 2016 at 01:52 PM

    hi pascal,

    you can not use JOINS with for all entries satatement...

    Add a comment
    10|10000 characters needed characters exceeded

    • Pascal Lammers wrote:

      So no Left outer Join with For all Entries.

      Of course, this sentence is valid only in your context, as it's generally possible to use left outer join with for all entries, but you can join the FAE table with only the left table before 7.40. So the answer by Jasper Debie is fully correct (both OpenSQL), and the answer by Amit Kumar is the answer to your question (use 2 SELECT).

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2016 at 01:57 PM

    Hi Pascal,

    You can use 'inner join' if you need those records which must be present in MARC. otherwise, you can use separate select statement for mara and marc.

    Regards,

    Amit Kumar

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 15, 2016 at 02:20 PM

    Why do you use a LEFT join, you cannot use the field of such joined (right) table in a WHERE statement so MUST use them in the ON statement, and there are millions of threads on google on difference between result of an ON on WHERE clause.

    Can you elaborate: In which case do you want to get a MARA record data for which there is no data in MARC with full key.

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.