cancel
Showing results for 
Search instead for 
Did you mean: 

Production order control

Former Member
0 Kudos

Dear EXperts

when i am executing below query stored procedure, i am getting control over production order.

if @transaction_type in ('A','U') and @object_type = '202'

BEGIN

If (Select COUNT (*) from OWOR where DocEntry in

(select a.DocNum

from OWOR a

inner join NNM1 b on a.Series = b.Series

inner join ORDR c on c.DocNum = a.OriginNum and c.CardCode = a.CardCode

inner join POR1 d on d.DocEntry = c.DocEntry

where

a.PIndicator = '13-14' and a.OriginNum = '98' and a.ItemCode = 'SE 001800056 00 L1 -'

GROUP BY a.DocNum, a.ItemCode, a.CardCode, a.OriginNum,

a.Series, b.Series, b.SeriesName)) > 12

begin

select @error = 1,@error_message = N'Production Order Control: Multiple Production Order Based on a sale order for an item are not allowed (Contact to Administrator) '

end

end

But when i am executing runtime query, it removed the control over Production order, pleaes help me out..

if @transaction_type in ('A','U') and @object_type = '202'

BEGIN

declare @a varchar(20)

set @a = (Select Distinct q.PIndicator from OWOR p inner join ORDR q on q.DocNum = p.OriginNum Where p.PIndicator = @list_of_cols_val_tab_del)

declare @b varchar(20)

set @b = (Select Distinct q.DocNum from OWOR p inner join ORDR q on q.DocNum = p.OriginNum where p.OriginNum = @list_of_cols_val_tab_del)

declare @c varchar(20)

set @c = (Select Distinct r.ItemCode from OWOR p inner join ORDR q on q.DocNum = p.OriginNum

inner join RDR1 r on r.DocEntry = q.DocEntry where p.ItemCode = @list_of_cols_val_tab_del)

If (Select COUNT (*) from OWOR where DocEntry in

(select a.DocNum

from OWOR a

inner join NNM1 b on a.Series = b.Series

inner join ORDR c on c.DocNum = a.OriginNum and c.CardCode = a.CardCode

inner join POR1 d on d.DocEntry = c.DocEntry

where

a.PIndicator = @a and a.OriginNum = @b and a.ItemCode = @c

GROUP BY a.DocNum, a.ItemCode, a.CardCode, a.OriginNum,

a.Series, b.Series, b.SeriesName)) > 12

begin

select @error = 1,@error_message = N'Production Order Control: Multiple Production Order Based on a sale order for an item are not allowed (Contact to Administrator) '

end

end

How can i get control over production order...

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ,

Try this...

IF

@transaction_type IN (N'A') AND (@Object_type = N'202')


BEGIN

if Exists (select  T2.ItemCode,T0.OriginAbs,COUNT(*) from OWOR T0

INNER JOIN ORDR T1 ON T0.OriginAbs=T1.DocEntry

INNER JOIN RDR1 T2 On T2.DocEntry=T1.DocEntry AND T2.ItemCode=T0.ItemCode

WHERE T0.DocEntry=@list_of_cols_val_tab_del

GROUP BY  T0.OriginAbs,T2.ItemCode

HAVING COUNT(*)=1)

BEGIN

SELECT @Error = 1, @error_message = 'Production Order Already Exist!'

END

END

we discussed in the following thread,

http://scn.sap.com/message/14033662#14033662

Regards,

Shanmugam V.

KennedyT21
Active Contributor
0 Kudos

Can you explain what is the Issue

Former Member
0 Kudos

Thanks for interest..

I want to restrict the production order to be raised twice for the same sale order with same item.

ie. Multiple prod order should not be raised based on single sale order for same item.

Please help me out on this.

Thanks