‎2009 Apr 16 9:17 AM
Hi All,
I am having a weird problem in my Select Query.
I am working in PM Module.
Select Query is as follows :
SELECT KOKRS GJAHR KSTAR WRTTP OBJNR PERIO WTGBTR
FROM COEP CLIENT SPECIFIED
INTO TABLE WT_COEP
FOR ALL ENTRIES IN WT_AUFK
WHERE MANDT EQ SY-MANDT
AND LEDNR EQ '00'
AND OBJNR EQ WT_AUFK-OBJNR
AND KOKRS EQ 'UB00'
AND KSTAR IN P_KSTAR
AND WRTTP EQ '04'
AND BEKNZ NE 'A'.
The problem is for the object number in table wt_aufk, if there are multiple entries in coep with the same material number i.e multiple line items for same AUFNR and MATNR, then the select query is picking only the first entry for the combination from COEP.
Please help me solve this problem.
Thanks in Advance,
Bhavika
‎2009 Apr 16 9:20 AM
Hi,
For all enteries will remove all the duplicate entries and only give unique entires.
Cheers,
Surinder
‎2009 Apr 16 9:20 AM
Hi,
For all enteries will remove all the duplicate entries and only give unique entires.
Cheers,
Surinder
‎2009 Apr 16 9:28 AM
Hi Surinder,
Please suggest me what to use, if not For All Entries.
Thanks
Bhavika
‎2009 Apr 16 9:34 AM
Hi,
You can use the FOR ALL ENTRIES but you need add one more field from COEP table which is unique and will not repeat.
SELECT KOKRS
BELNR " << Add these fields in your internal and select
BUZEI " << Add these fields in your internal and select
GJAHR
KSTAR
WRTTP
OBJNR
PERIO
WTGBTR
FROM COEP CLIENT SPECIFIED
INTO TABLE WT_COEP
FOR ALL ENTRIES IN WT_AUFK
WHERE MANDT EQ SY-MANDT
AND LEDNR EQ '00'
AND OBJNR EQ WT_AUFK-OBJNR
AND KOKRS EQ 'UB00'
AND KSTAR IN P_KSTAR
AND WRTTP EQ '04'
AND BEKNZ NE 'A'.
‎2009 Apr 16 9:35 AM
Hi Bhavika,
Instead of FOR ALL ENTRIES, you can use the RANGES.
for more information on the RANGES you will get the from the F1 help..
Thanks
‎2009 Apr 16 9:20 AM
Even if there are multiple netries for one OBJNR and its picking only first one, i dont see a problem coz u get the object number once. What other entries do you want to compare?
‎2009 Apr 16 9:22 AM
Hi bhavika kumar,
Make sure that your are selecting data with all key in Table COEP.
Regards,
Suneel G
‎2009 Apr 16 9:35 AM
Hi Bhavika,
You have not used all the key fields in where clause.
Please make use of following fields in the where clause of your select query
BELNR (Document Number)
BUZEI (Posting row)
Hope this will solve your problem.
Best Regards,
Deepa Kulkarni
‎2009 Apr 16 9:36 AM
Hi ,
Use the condition in following way.
SELECT KOKRS GJAHR KSTAR WRTTP OBJNR PERIO WTGBTR
FROM COEP
INTO TABLE WT_COEP
FOR ALL ENTRIES IN WT_AUFK
WHERE OBJNR EQ WT_AUFK-OBJNR
AND LEDNR EQ '00'
AND KOKRS EQ 'UB00'
AND KSTAR IN P_KSTAR
AND WRTTP EQ '04'
AND BEKNZ NE 'A'.
Hope it helps,
RJ
‎2009 Apr 16 9:46 AM
Remove all other conditions in 'Where' clause except for fields 'MANDT' and 'OBJNR'.
Just use below query.
SELECT KOKRS GJAHR KSTAR WRTTP OBJNR PERIO WTGBTR
FROM COEP CLIENT SPECIFIED
INTO TABLE WT_COEP
FOR ALL ENTRIES IN WT_AUFK
WHERE MANDT EQ SY-MANDT
AND OBJNR EQ WT_AUFK-OBJNR.
Thanks.
‎2009 Apr 16 12:10 PM