cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP Query to Show Duplicate Bins

RahF
Participant
0 Kudos
535

Hello Experts

We have a UDF called work bins in the production order and I am trying to write a query that will show me production orders with duplicate work bins

But I am getting the below error, can someone please point me in the right direction

SELECT 

T0.[DocNum], 

T0.[DueDate], 

T0.[ItemCode], 

T0.[ProdName], 

T0.[PlannedQty], 

T0.[Status],

T0.[U_WORKBIN] 

FROM OWOR T0 

WHERE T0.[U_WORKBIN] >1 

ORDER BY T0.[U_INE_WORKBIN], T0.[DocNum]<br>

Regards

Rah

Accepted Solutions (1)

Accepted Solutions (1)

Johan_Hakkesteegt
Active Contributor
0 Kudos

Hi Rah,

Apparently T0.[U_WORKBIN] is of type nvarchar, and you have records in the OWOR table where it contains a none-numeric value. When you try to do a calculation type comparison (>1), the sql parser cannot tell if the value WRK00280 is larger than 1.

Regards,

Johan

RahF
Participant
0 Kudos

Hi Johan

Thank you for your reply

What else can I use instead of >1 so I can identify if there are duplicate values

Johan_Hakkesteegt
Active Contributor
0 Kudos

Hi Rah,

Please give this a try:

SELECT
T0.[DocNum], 
T0.[DueDate], 
T0.[ItemCode], 
T0.[ProdName], 
T0.[PlannedQty], 
T0.[Status],
T0.[U_WORKBIN] 
FROM OWOR T0 
WHERE T0.[U_WORKBIN] IN (select x.[U_WORKBIN]
                         from OWOR x
                         group by x.[U_WORKBIN]
			 having COUNT(x.[DocNum]) > 1)
ORDER BY T0.[U_INE_WORKBIN], T0.[DocNum]<br>

Regards,

Johan

Answers (0)