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

Fetching data from 3 tables

Hi All,

I trying to fetch values from 3 tables and pass the values into an internal table.

Code

SELECT KNA1KTOKD KNA1KUNNR KNB1BUKRS KNVVVKORG KNVVVTWEG KNVVSPART KNVV~LOEVM

INTO

(ITAB-KTOKD,ITAB-KUNNR,ITAB-BUKRS, ITAB-VKORG,ITAB-VTWEG,ITAB-SPART, ITAB-LOEVM)

FROM ( ( KNA1

INNER JOIN KNB1

ON KNA1KUNNR = KNB1KUNNR)

KNA1

INNER JOIN KNVV

ON KNA1KUNNR = KNVVKUNNR ) .

I am getting an error message.

"The Format of the Field Specificatio "KNB1~KUNNR" is not supported.

What is the problem here?

Regards

Aby

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Jan 18, 2008 at 12:17 PM

    Hi,

    check this program..

    DATA:BEGIN OF ITAB OCCURS 0,

    KTOD LIKE KNA1-KTOKD,

    KUNNR LIKE KNA1-KUNNR,

    BUKRS LIKE KNB1-BUKRS,

    VKORG LIKE KNVV-VKORG,

    VTWEG LIKE KNVV-VTWEG,

    SPART LIKE KNVV-SPART,

    LOEVM LIKE KNVV-LOEVM,

    END OF ITAB.

    SELECT KNA1KTOKD KNA1KUNNR KNB1BUKRS KNVVVKORG KNVVVTWEG KNVVSPART

    KNVV~LOEVM

    INTO TABLE ITAB

    FROM KNA1

    INNER JOIN KNB1

    ON KNA1KUNNR = KNB1KUNNR

    INNER JOIN KNVV

    ON KNA1KUNNR = KNVVKUNNR .

    LOOP AT ITAB.

    WRITE:/ ITAB-KTOD,ITAB-KUNNR,ITAB-BUKRS,ITAB-VKORG,ITAB-VTWEG,ITAB-SPART

    ,ITAB-LOEVM.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 12:29 PM

    Hi Aby,

    Take a look at th ebold line. . You nee dto switch 'KNA1KUNNR' and ' KNB1KUNNR' .

    I also used aliases just to be sure (optional here i think)

    -


    SELECT kktokd kkunnr bbukrs vvkorg vvtweg vspart v~loevm

    INTO

    (itab-ktokd,itab-kunnr, itab-bukrs, itab-vkorg,itab-vtweg,itab-spart, itab-loevm)

    FROM ( ( kna1 AS k

    INNER JOIN knb1 AS b ON bkunnr = kkunnr )

    INNER JOIN knvv AS v ON vkunnr = kkunnr ) .

    ENDSELECT.

    -


    Please also refer to this example from help.sap.com:

    PARAMETERS: p_cityfr TYPE spfli-cityfrom,

    p_cityto TYPE spfli-cityto.

    DATA: BEGIN OF wa,

    fldate TYPE sflight-fldate,

    carrname TYPE scarr-carrname,

    connid TYPE spfli-connid,

    END OF wa.

    DATA itab LIKE SORTED TABLE OF wa

    WITH UNIQUE KEY fldate carrname connid.

    SELECT ccarrname pconnid f~fldate

    INTO CORRESPONDING FIELDS OF TABLE itab

    FROM ( ( scarr AS c

    INNER JOIN spfli AS p ON pcarrid = ccarrid

    AND p~cityfrom = p_cityfr

    AND p~cityto = p_cityto )

    INNER JOIN sflight AS f ON fcarrid = pcarrid

    AND fconnid = pconnid ).

    LOOP AT itab INTO wa.

    WRITE: / wa-fldate, wa-carrname, wa-connid.

    ENDLOOP.

    Regards, and reward if usefull please.

    Joris

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 12:31 PM

    hi

    good

    instead of using the table name try to use the reference names for the respective table names and than try, apart from this check with your join statement again.

    thanks

    mrutyun^

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 12:38 PM

    Hi,

    It should be:

    FROM ( ( KNA1

    INNER JOIN KNB1

    ON KNA1KUNNR = KNB1KUNNR

    INNER JOIN KNVV

    ON KNA1KUNNR = KNVVKUNNR ) .

    Regards,

    John.

    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.