‎2009 Mar 06 6:44 AM
Hi All,
I need to fetch data of a fiedl BSTNK (Customer Purch.order no) from table VBAK using an inner join with table VBAP. Now this INNER JOIN works at times and doesnt at other times.
Can someone explain what is the problem with the same.
CLEAR: g_bstnk.
SELECT SINGLE k~bstnk FROM vbak AS k INNER JOIN vbap AS p
ON kvbeln EQ pvbeln
INTO g_bstnk
WHERE k~auart EQ 'ZC'
AND k~kunnr EQ vbdkl-kunnr
AND k~vkorg EQ vbdkl-vkorg
AND k~guebg LE likp-fkdat
AND k~gueen GE likp-fkdat
AND p~matnr EQ tvbdpl-matnr
AND p~werks EQ tvbdpl-werks.
‎2009 Mar 06 6:48 AM
probably you are not hitting the Key fields in Select query which wil result duplicate values. Can you explain abou the values in vbdkl, llikp and tvbdkl. Are you calling this in Loop ?
‎2009 Mar 06 6:48 AM
probably you are not hitting the Key fields in Select query which wil result duplicate values. Can you explain abou the values in vbdkl, llikp and tvbdkl. Are you calling this in Loop ?
‎2009 Mar 06 6:55 AM
Hi Phanendra,
Yes I am using this code within a loop,
Actuallly I manually went to se11 and tried to see whether I get a common data and I could find the
same but when I run the code it doesnt show up the result.
A snapshot of the contents of these fields at run time is as below
vbdkl-kunnr = 0000002411
vbdkl-vkorg = FR01
likp-lfdat = somedate ()
tvbdpl-matnr = 5851097-22
tvbdpl-werks = FR01
‎2009 Mar 06 6:53 AM
put vbeln in where condition ..
kvbeln EQ pvbeln
SELECT SINGLE k~bstnk FROM vbak AS k INNER JOIN vbap AS p
ON kvbeln EQ pvbeln
INTO g_bstnk
WHERE k~vbeln = p_vebln (p_vebln or s_vbeln from selection screen)
AND k~auart EQ 'ZC'
AND k~kunnr EQ vbdkl-kunnr
AND k~vkorg EQ vbdkl-vkorg
AND k~guebg LE likp-fkdat
AND k~gueen GE likp-fkdat
AND p~matnr EQ tvbdpl-matnr
AND p~werks EQ tvbdpl-werks.