Skip to Content
author's profile photo Former Member
Former Member

left outer join for lips and vbap tables

Dear all;

I want to generate a report that shows me the whole content for the fileds:

LIPS-LFIMG

LIPS-KDAUF

VBAP-KWMENG

This is how my code looks like:

==================================================================================================================

REPORT ZDEMO_SELECT_LEFT_OUTER_JOIN2.

DATA: BEGIN OF wa,

LFIMG TYPE LIPS-LFIMG,

KDAUF TYPE LIPS-KDAUF,

KWMENG TYPE VBAP-kwmeng,

END OF wa,

itab LIKE SORTED TABLE OF wa WITH NON-UNIQUE KEY LFIMG KDAUF KWMENG.

SELECT p-LFIMG p-KDAUF f-kwmeng INTO CORRESPONDING FIELDS OF TABLE ITAB FROM LIPS AS q left OUTER JOIN VBAP AS f

ON q-vbeln = f-vbeln.

LOOP AT itab INTO wa.

WRITE: / wa-LFIMG, wa-KDAUF, wa-KWMENG.

ENDLOOP.

==================================================================================================================

when I check it, it gives me the following error:

files q-vbeln unknown

can you tell me please what is wrong with my code, and how can get the data from these two tables generated in a report.

I guess the connection condition between the two tables has be corrected

Best Regards

~Amal Aloun

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Aug 02, 2012 at 08:56 AM

    Hi amal aloun , you need to change the "-" symbol to "~" in case of joins.

    and need to change p to q in your code

    i.e

    report zdemo_select_left_outer_join2.



    data: begin of wa,
    lfimg type lips-lfimg,
    kdauf type lips-kdauf,
    kwmeng type vbap-kwmeng,
    end of wa,
    itab like sorted table of wa with non-unique key lfimg kdauf kwmeng.


    select q~lfimg
    q~kdauf
    f~kwmeng
    into corresponding fields of table itab
    from lips as q left outer join vbap as f
    on q~vbeln = f~vbeln.


    loop at itab into wa.
    write: / wa-lfimg, wa-kdauf, wa-kwmeng.
    endloop.

    Thanks & Regards,

    madhumahesh.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 02, 2012 at 07:39 AM

    Link between LIPS and VBAP is LIPS-VGBEL = VBAP-VBELN and LIPS-VGPOS = VBAP-POSNR

    So your select must be

    SELECT q-LFIMG " See in your code you gave p instead of q

    q-KDAUF " See in your code you gave p instead of q

    f-kwmeng

    INTO CORRESPONDING FIELDS OF TABLE itab

    FROM lips AS q LEFT OUTER JOIN vbap AS f

    ON q-vbelv = f-vbeln

    AND q-vgpos = f-posnr.

    Thanks & Regards

    Bala Krishna

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2012 at 08:24 AM

    Hi,

    check your code once again , write q-lfimg and q-kdauf instead of p-lfimg and p-kdauf.

    Regards,

    Venkat.

    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.