Script to recalculate Total Price for all customer orders
Solution ID = KB-235
Goal : Script to recalculate Total Price for all customer orders
Version = All Version
Module : SLCOPO
Symptom 1 : Total Price is wrong on customer order
Symptom 2 : Estimate price is wrong on customer order
Database : Progress, SQL
Cause
If you discover that the Total Price field on a customer order you can have Syteline recalculate the field by making a change to one of the order's amount fields. For example, change the Freight or Miscellaneous Charges, Save the update, and then change the field back to its original value. The Total price will be recalculated.If you know or suspect that a large number of orders have an incorrect Total Price, you can use the below scripts to recalculate that field for all customer orders in the database.
Fix
For Progress
versions (SL6 and
lower):
FOR EACH symix.co WHERE co.co-num <> "" AND co.TYPE <>
"E":
RUN co/sum-co.p (co.co-num).
END.
MESSAGE "Procedure complete".
For SQL
versions (SL7 and
higher):
set
nocount on
DECLARE
@SavedState LongListType
declare
@CoNum CoNumType
,
@Severity int
,
@Infobar InfobarType
EXEC
dbo.SetTriggerStateSp 1, 1, 1, @SavedState OUTPUT, @Infobar OUTPUT
set
@Severity = 0
declare
coCrs cursor local static for
select
co_num
from
co
where
type in ('R', 'B')
--
and stat in ('P', 'O', 'C', 'S')
open
coCrs
while
@Severity = 0
begin
fetch coCrs into @CoNum
if @@fetch_status != 0
break
exec @Severity = dbo.SumCoSp
@PCoNum
= @CoNum
, @Infobar = @Infobar OUTPUT
end
close
coCrs
deallocate
coCrs
EXEC
dbo.RestoreTriggerStateSp 1, @SavedState, @Infobar OUTPUT