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

Problem with left outer join + table AUSP

Former Member
0 Likes
1,077

Hello,

I was trying to do a SELECT statement reading data from mara and AUSP. Therefore I want to use a left outer join. The problem is that it doesn't want to accept the on clause using the OBJEK attribut in AUSP. The Strange thing is that I know that I could access it in another programm.

TABLES: ausp, mara.

* temporary table to work with
DATA:
BEGIN OF line,
* Attributes from AUSP
atwrt TYPE AUSP-atwrt,
ATINN TYPE AUSP-ATINN,
OBJEK TYPE AUSP-OBJEK,
* Attributes from MARA
mbrsh TYPE mara-mbrsh,
MANDT TYPE mara-MANDT,
MATNR TYPE mara-MATNR,
* ...
END OF line,
itab LIKE SORTED TABLE OF line
                WITH NON-UNIQUE KEY MATNR.
* Put the requested values in temporary table
SELECT 
ausp-atwrt
ausp-ATINN 
ausp-OBJEK
mara-mbrsh
mara-MANDT
mara-MATNR
* ...
into corresponding fields of table  itab
FROM mara LEFT OUTER JOIN ausp
ON AUSP-OBJEK = MATNR.

There must be a syntax error I don't understand. Can you find it?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
841

Hi Daniel,

Here Main problem is that you have to replace - (hyphens) with ~ (Tide's), as well as no need of using INTO CORRESPONDING FIELDS OF ( as it degrades PERFORMANCE )as shown below:

DATA:
  BEGIN OF line,
*   Attributes from AUSP
    atwrt TYPE AUSP-atwrt,
    ATINN TYPE AUSP-ATINN,
    OBJEK TYPE AUSP-OBJEK,
*   Attributes from MARA
    mbrsh TYPE mara-mbrsh,
    MANDT TYPE mara-MANDT,
    MATNR TYPE mara-MATNR,
*   ...
  END OF line,
  
  itab LIKE SORTED TABLE OF line
                  WITH NON-UNIQUE KEY MATNR.
* Put the requested values in temporary table
SELECT ausp~atwrt
        ausp~ATINN 
        ausp~oBJEK
        mara~mbrsh
        mara~MANDT
        mara~MATNR
* ...
into table itab
FROM mara LEFT OUTER JOIN ausp
ON AUSP~OBJEK = mara~MATNR.

Regards,

Sunil

5 REPLIES 5
Read only

Former Member
0 Likes
841

you do an array fetch into a sorted table

it´s a wonder that the syntax checker doesnt even whine.

use a standard table and it will work

Read only

0 Likes
841

hm unfortunatley no effect about that, I changed the code like that and same error:

itab LIKE STANDARD TABLE OF line
                WITH NON-UNIQUE KEY MATNR.

Read only

Former Member
0 Likes
842

Hi Daniel,

Here Main problem is that you have to replace - (hyphens) with ~ (Tide's), as well as no need of using INTO CORRESPONDING FIELDS OF ( as it degrades PERFORMANCE )as shown below:

DATA:
  BEGIN OF line,
*   Attributes from AUSP
    atwrt TYPE AUSP-atwrt,
    ATINN TYPE AUSP-ATINN,
    OBJEK TYPE AUSP-OBJEK,
*   Attributes from MARA
    mbrsh TYPE mara-mbrsh,
    MANDT TYPE mara-MANDT,
    MATNR TYPE mara-MATNR,
*   ...
  END OF line,
  
  itab LIKE SORTED TABLE OF line
                  WITH NON-UNIQUE KEY MATNR.
* Put the requested values in temporary table
SELECT ausp~atwrt
        ausp~ATINN 
        ausp~oBJEK
        mara~mbrsh
        mara~MANDT
        mara~MATNR
* ...
into table itab
FROM mara LEFT OUTER JOIN ausp
ON AUSP~OBJEK = mara~MATNR.

Regards,

Sunil

Read only

Former Member
0 Likes
841

Hi I have another problem here. When I try to print the values to screen, I get the error that there is a headline missing.

LOOP AT itab.

WRITE: / itabOBJEK, itabATINN, itab~atwrt.

ENDLOOP.

Read only

0 Likes
841

Yes, with this kind of tables you need a hear (workarea).

Your workarea in that case is the line structure. You must do your loop like this:

LOOP AT itab into line.

WRITE: / lineOBJEK, lineATINN, line~atwrt.

ENDLOOP.

I hope it helps.

Artur.