Skip to Content
avatar image
Former Member

Select query for KONV and VBAK table

hy Experts.

Please Help me For this Query, i got error on it.

I wnt to take KONV-KBETR (RATE FIELD) for particular SO number. and i used following query but it gives error i cant relate VBAK & KONV table.

Please do needful

SELECT KBETR KNUMV FROM KONV INTO (ITAB-KBETR, ITAB-KNUMV) WHERE VBAK-KNUMV = KONV-KNUMV AND VBAK-VBELN IN VBELN.

Thnks

Bhavesh Panchal.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 08, 2009 at 09:04 AM

    Hi,

    try this:

    Select kbetr knumv

    from konv join vbak on vbakknumv = konvknumv

    into table itab

    where vbeln in vbeln.

    Regards,

    Leo.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hy

      thnks for reply

      but still i try ur query

      Select kbetr knumv

      from konv join vbak on vbakknumv = konvknumv

      into table itab

      where vbeln in vbeln

      but still i getting error VBK unknown.

      Tnks for Help

  • avatar image
    Former Member
    Apr 08, 2009 at 09:47 AM

    Try using tables KONH and KONP instead of KONV...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 08, 2009 at 09:39 AM

    Hi,

    We cannot join VBAK and KONV as one is a transparent table and other is a cluster table.

    We cannot write inner join between a cluster table and a transparent table. System will generate an error.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 08, 2009 at 09:08 AM

    if it_vbak is not initial.

    Select KBETR KNUMV From KONV into table it_konv for all entries in it_vbak where

    knumv = it_vbak-knumv.

    endif.

    You can even try like this..Hope it helps.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 08, 2009 at 09:11 AM

    modifY ur query like this:

    DATA: TEMP TYPE KONV-KBETR.

    SELECT VBELN KNUMV

    FROM VBAK

    INTO (ITAB1-VBELN ITAB1-KNUMV)

    WHERE VBELN IN VBELN

    SELECT KBETR KNUMV

    FROM KONV

    INTO (ITAB-KBETR, ITAB-KNUMV)

    WHERE KNUMV = VBAK-KNUMV

    TEMP = TEMP + ITAB-KBETR (instead of collect statement, we can use this to accumulate the rate for a particular SO)

    ENDSELECT.

    (BEFORE CLEARING temp, move these values, VBELN, KNUMV AND temp INTO DIFF. internal table)

    clear: temp

    ENDSELECT.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      You can proceed in the following manner for fetching rate for a particular sales order:

      Declare a internal table with required fields of KONV and VBAK. Also declare one internal table with required field for output e.g lt_out.

      SELECT vbeln knumv FROM vbak INTO TABLE lt_vbak

      WHERE vbeln IN s_vbeln.

      if sy-subrc EQ 0.

      SELECT knumv kposn kbetr FROM konv INTO lt_konv

      FOR ALL ENTERIES IN lt_vbak

      WHERE knumv = lt_vbak-knumv.

      ENDIF.

      LOOP AT lt_vbak INTO wa_vbak.

      READ TABLE lt_konv INTO wa_konv WITH KEY knumv = wa_vbak-knumv.

      if sy-subrc eq 0.

      wa_out-vbeln = wa_vbak-vbeln.

      wa_out-kbetr = wa_knumv-kbetr.

      APPEND wa_out TO lt_out.

      ENDLOOP.

      In this way both the tables can be linked. Field KNUMV is the link between both the tables.

      Hope this solves your problem.

      Regards,

      Brajvir