USP_BBIS_BATCH_PREPAREFORCOMMIT

Executes the "Prepare BBIS Batch For Commit Record Operation" 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_BBIS_BATCH_PREPAREFORCOMMIT
(
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier
)
as begin

  if @CHANGEAGENTID is null
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

    declare @CURRENTDATE datetime
  set @CURRENTDATE = getdate();

  declare @WORKFLOWSTATEID uniqueidentifier
  declare @NAME nvarchar(100)
  select top 1 @WORKFLOWSTATEID = BATCHWORKFLOWSTATE.ID, @NAME = BATCHWORKFLOWSTATE.NAME from dbo.BATCHWORKFLOWSTATE
    inner join dbo.BATCHWORKFLOW on BATCHWORKFLOWSTATE.BATCHWORKFLOWID = BATCHWORKFLOW.ID
    inner join dbo.BATCHTEMPLATE on BATCHWORKFLOW.ID = BATCHTEMPLATE.BATCHWORKFLOWID
    inner join dbo.BATCH on BATCHTEMPLATE.ID = BATCH.BATCHTEMPLATEID
  where BATCH.ID = @ID
    and BATCHWORKFLOWSTATE.ALLOWCOMMIT = 1
  order by BATCHWORKFLOWSTATE.NAME desc

  update dbo.BATCH
  set BATCHWORKFLOWSTATEID = @WORKFLOWSTATEID,
  CHANGEDBYID = @CHANGEAGENTID,
  DATECHANGED = @CURRENTDATE
  where ID = @ID

    return 0;

end