UFN_BBNC_GETOPENBATCHSPLITFROMTEMPLATE

Returns the ID of the first open batch created from the specified instance ID and owner.

Return

Return Type
uniqueidentifier

Parameters

Parameter Parameter Type Mode Description
@BATCHTEMPLATEID uniqueidentifier IN
@OWNERID uniqueidentifier IN

Definition

Copy


            create function dbo.UFN_BBNC_GETOPENBATCHSPLITFROMTEMPLATE(@BATCHTEMPLATEID uniqueidentifier, @OWNERID uniqueidentifier) 
            returns uniqueidentifier
            as begin
                return
                (
                    select top (1)
                        BATCH.ID
                    from
                        dbo.BATCH
                        inner join dbo.BATCHWORKFLOWSTATE on BATCH.BATCHWORKFLOWSTATEID = BATCHWORKFLOWSTATE.ID
                    where
                        BATCH.BATCHTEMPLATEID = @BATCHTEMPLATEID
                        and BATCH.APPUSERID = @OWNERID
                        and BATCH.STATUSCODE = 0
                        and BATCH.ORIGINATINGBATCHID is null --TMV 02/27/2007 CR266381-020807 Downloaded transactions should not be added to exception batches

                        and BATCHWORKFLOWSTATE.ISINITIALSTATE = 1 --TMV 04/13/2007 CR266386-020807 Only download transactions into the workflow's initial state.

                    order by
                        BATCH.DATEADDED
                )
            end