Skip to Content
0
Former Member
May 09, 2013 at 09:30 AM

Production order control

26 Views

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