USP_SALESORDER_REFRESHITEMEXPIRATION

Executes the "Sales order item expiration refresh." record operation.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the ID of the record being updated.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the update.

Definition

Copy


                    CREATE procedure dbo.USP_SALESORDER_REFRESHITEMEXPIRATION
                    (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier
                    )
                    as begin
                        if @CHANGEAGENTID is null  
                            exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output

                        declare @CURRENTDATE datetime
                        set @CURRENTDATE = getdate()

                        --Does not update items that have already expired

                        update dbo.[SALESORDERRESERVEDITEM] with (rowlock)
                        set 
                            [DATECHANGED] = @CURRENTDATE,
                            [CHANGEDBYID] = @CHANGEAGENTID
                        where 
                            [EXPIRATIONDATE] >= @CURRENTDATE and
                            [SALESORDERID] = @ID
                    end