CREATE PROCEDURE [dbo].[spBATGenerateSecondRevGLNumber_Legacy]
@ICPriKey int,
@BranchPriKey int,
@DivisionPriKey int,
@OrdPriKey int,
@BATProcessPriKey int,
@Source varchar(50),
@SourcePriKey int
as
set nocount on
declare @glNumber varchar(50)
declare @glcPriKey int
declare @countGLCSegmets int
declare @glcSourceName varchar(10)
declare @glsCounter int
declare @padLength int
declare @glAccount varchar(100)
declare @secondGLNumber varchar(66)
declare @batErrorCode int
declare @glaPriKey int
declare @shPriKey int
declare @ERROR_GLCPRIKEY_IS_INVALID_FOR_BRANCH int
set @ERROR_GLCPRIKEY_IS_INVALID_FOR_BRANCH = 122
declare @ERROR_GL_ACCOUNT_IS_NULL int
set @ERROR_GL_ACCOUNT_IS_NULL = 123
declare @ERROR_GL_ACCOUNT_TOO_LONG int
set @ERROR_GL_ACCOUNT_TOO_LONG = 124
declare @ERROR_GL_SUBACCOUNT_IS_NULL int
set @ERROR_GL_SUBACCOUNT_IS_NULL = 125
declare @ERROR_SUBACCOUNT_TOO_LONG int
set @ERROR_SUBACCOUNT_TOO_LONG = 126
declare @ERROR_COMPANY_GLCODE_IS_NULL int
set @ERROR_COMPANY_GLCODE_IS_NULL = 127
declare @ERROR_COMPANY_GLCODE_IS_TOO_LONG int
set @ERROR_COMPANY_GLCODE_IS_TOO_LONG = 128
declare @ERROR_GLCODE_IN_BRANCH_IS_NULL int
set @ERROR_GLCODE_IN_BRANCH_IS_NULL = 129
declare @ERROR_GLCODE_IN_BRANCH_IS_TOO_LONG int
set @ERROR_GLCODE_IN_BRANCH_IS_TOO_LONG = 130
declare @ERROR_GLCODE_IN_DIVISION_IS_NULL int
set @ERROR_GLCODE_IN_DIVISION_IS_NULL = 131
declare @ERROR_GLCODE_IN_DIVISION_IS_TOO_LONG int
set @ERROR_GLCODE_IN_DIVISION_IS_TOO_LONG = 132
declare @ERROR_GLSOURCE_IS_INVALID int
set @ERROR_GLSOURCE_IS_INVALID = 133
declare @ERROR_DIVISION_IS_INVALID int
set @ERROR_DIVISION_IS_INVALID = 233
declare @ERROR_GLCPRIKEY_IS_INVALID_FOR_BRANCH_FOR_STMTS int
set @ERROR_GLCPRIKEY_IS_INVALID_FOR_BRANCH_FOR_STMTS = 349
declare @ERROR_GL_ACCOUNT_IS_NULL_FOR_STMTS int
set @ERROR_GL_ACCOUNT_IS_NULL_FOR_STMTS = 350
declare @ERROR_GL_ACCOUNT_TOO_LONG_FOR_STMTS int
set @ERROR_GL_ACCOUNT_TOO_LONG_FOR_STMTS = 351
declare @ERROR_GL_SUBACCOUNT_IS_NULL_FOR_STMTS int
set @ERROR_GL_SUBACCOUNT_IS_NULL_FOR_STMTS = 352
declare @ERROR_SUBACCOUNT_TOO_LONG_FOR_STMTS int
set @ERROR_SUBACCOUNT_TOO_LONG_FOR_STMTS = 353
declare @ERROR_COMPANY_GLCODE_IS_NULL_FOR_STMTS int
set @ERROR_COMPANY_GLCODE_IS_NULL_FOR_STMTS = 354
declare @ERROR_COMPANY_GLCODE_IS_TOO_LONG_FOR_STMTS int
set @ERROR_COMPANY_GLCODE_IS_TOO_LONG_FOR_STMTS = 355
declare @ERROR_GLCODE_IN_BRANCH_IS_NULL_FOR_STMTS int
set @ERROR_GLCODE_IN_BRANCH_IS_NULL_FOR_STMTS = 356
declare @ERROR_GLCODE_IN_BRANCH_IS_TOO_LONG_FOR_STMTS int
set @ERROR_GLCODE_IN_BRANCH_IS_TOO_LONG_FOR_STMTS = 357
declare @ERROR_DIVISION_IS_INVALID_FOR_STMTS int
set @ERROR_DIVISION_IS_INVALID_FOR_STMTS = 358
declare @ERROR_GLCODE_IN_DIVISION_IS_NULL_FOR_STMTS int
set @ERROR_GLCODE_IN_DIVISION_IS_NULL_FOR_STMTS = 359
declare @ERROR_GLCODE_IN_DIVISION_IS_TOO_LONG_FOR_STMTS int
set @ERROR_GLCODE_IN_DIVISION_IS_TOO_LONG_FOR_STMTS = 360
declare @ERROR_GLSOURCE_IS_INVALID_FOR_STMTS int
set @ERROR_GLSOURCE_IS_INVALID_FOR_STMTS = 361
declare @ERROR_MORE_THAN_ONE_RECORD_FOR_NATURAL int
set @ERROR_MORE_THAN_ONE_RECORD_FOR_NATURAL = 707
declare @ERROR_MORE_THAN_ONE_RECORD_FOR_SUB int
set @ERROR_MORE_THAN_ONE_RECORD_FOR_SUB = 708
declare @ERROR_MORE_THAN_ONE_RECORD_FOR_COMPANY int
set @ERROR_MORE_THAN_ONE_RECORD_FOR_COMPANY = 709
declare @ERROR_MORE_THAN_ONE_RECORD_FOR_BRANCH int
set @ERROR_MORE_THAN_ONE_RECORD_FOR_BRANCH = 710
declare @ERROR_MORE_THAN_ONE_RECORD_FOR_DIVISION int
set @ERROR_MORE_THAN_ONE_RECORD_FOR_DIVISION = 711
declare @ERROR_INVALID_BRANCH_PRIKEY int
set @ERROR_INVALID_BRANCH_PRIKEY = 712
declare @ERROR_MANUAL_GL_AND_OVERRIDE_NOT_ALLOWED int
set @ERROR_MANUAL_GL_AND_OVERRIDE_NOT_ALLOWED = 713
declare @ERROR_SECOND_GL_NOT_IN_GREAT_PLAINS int
set @ERROR_SECOND_GL_NOT_IN_GREAT_PLAINS = 742
set @batErrorCode = 0
set @glsCounter = 1
set @secondGLNumber = ' '
declare @theBlankSessionID varchar( 50 )
set @theBlankSessionID = ''
declare @theSourceIsStatements bit
declare @theErrorObjectTable varchar(20)
declare @theErrorObjectID int
declare @theErrorCodeID int
if( @Source in ('StatementDetail', 'StatementDetailDist', 'StatementPayable') )
begin
set @shPriKey = case @Source
when 'StatementDetail' then ( select SHPriKey from StatementDetail where SDPriKey = @SourcePriKey )
when 'StatementDetailDist' then
(
select StatementDetail.SHPriKey
from StatementDetail
inner join StatementDetailDist on ( StatementDetailDist.SDPriKey = StatementDetail.SDPriKey )
where StatementDetailDist.SDDPriKey = @SourcePriKey
)
when 'StatementPayable' then
(
select StatementDetail.SHPriKey
from StatementDetail
join StatementPayable on StatementPayable.StatementDetailFID = StatementDetail.SDPriKey
where StatementPayable.StatementPayableID = @SourcePriKey
)
end
set @theSourceIsStatements = 1
set @theErrorObjectTable = 'StatementHeader'
set @theErrorObjectID = @shPriKey
end
else
begin
set @theSourceIsStatements = 0
set @theErrorObjectTable = 'Order'
set @theErrorObjectID = @OrdPriKey
end
if not exists ( select 1 from Branch where BranchPriKey = @BranchPriKey )
begin
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@ERROR_INVALID_BRANCH_PRIKEY,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else
begin
set @glcPriKey = ( select GLCPriKey from Branch where BranchPriKey = @BranchPriKey )
set @countGLCSegmets = ( select count(*) from GLDetail where GLCPriKey = @glcPriKey )
end
if ( select count(*) from GLSource where SourceName = 'Natural' ) > 1
begin
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@ERROR_MORE_THAN_ONE_RECORD_FOR_NATURAL,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
if (select count(*) from GLSource where SourceName = 'Sub') > 1
begin
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@ERROR_MORE_THAN_ONE_RECORD_FOR_SUB,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
if (select count(*) from GLSource where SourceName = 'Company') > 1
begin
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@ERROR_MORE_THAN_ONE_RECORD_FOR_COMPANY,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
if (select count(*) from GLSource where SourceName = 'Branch') > 1
begin
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@ERROR_MORE_THAN_ONE_RECORD_FOR_BRANCH,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
if (select count(*) from GLSource where SourceName = 'Division') > 1
begin
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@ERROR_MORE_THAN_ONE_RECORD_FOR_DIVISION,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
if( @glcPriKey is null )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_GLCPRIKEY_IS_INVALID_FOR_BRANCH_FOR_STMTS
else @ERROR_GLCPRIKEY_IS_INVALID_FOR_BRANCH
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else
begin
if( 1 = @theSourceIsStatements )
begin
if( @Source = 'StatementDetail' )
begin
if exists
(
select 1
from StatementDetail
inner join BATProcess on ( BATProcess.SourceRecord = StatementDetail.SDPriKey )
where BATProcess.BATProcessPriKey = @BATProcessPriKey and
BATProcess.TransactionAmount = abs( StatementDetail.UnappliedAmount ) and
StatementDetail.UnappliedCash = 1
)
begin
exec @glaPriKey = spBATGetUnappliedCashGLARAP
@glcPriKey,
@OrdPriKey,
@Source,
@SourcePriKey,
@shPriKey
end
else if exists ( select 1 from BATProcess where BATProcessPriKey = @BATProcessPriKey and TransactionType like '%A/R%' )
begin
exec @glaPriKey = spBATSelectionProcess
@ICPriKey,
@glcPriKey,
@OrdPriKey,
'GLARAP',
@Source,
@SourcePriKey,
'AR'
end
else
begin
exec @glaPriKey = spBATSelectionProcess
@ICPriKey,
@glcPriKey,
@OrdPriKey,
'GLARAP',
@Source,
@SourcePriKey,
'AP'
end
end
else if( @Source = 'StatementDetailDist' )
begin
if exists
(
select 1
from StatementDetailDist
inner join BATProcess on ( BATProcess.SourceRecord = StatementDetailDist.SDDPriKey )
where BATProcess.BATProcessPriKey = @BATProcessPriKey and
BATProcess.TransactionAmount = abs( StatementDetailDist.UnappliedAmount ) and
StatementDetailDist.UnappliedCash = 1
)
begin
exec @glaPriKey = spBATSelectionProcess
@ICPriKey,
@glcPriKey,
@OrdPriKey,
'GLARAP',
@Source,
@SourcePriKey,
'AR'
end
else if exists
(
select 1
from StatementDetailDist
inner join BATProcess on BATProcess.SourceRecord = StatementDetailDist.SDDPriKey
left outer join StatementPayable on StatementPayable.StatementDetailDistFID = StatementDetailDist.SDDPriKey
where BATProcess.BATProcessPriKey = @BATProcessPriKey and
BATProcess.TransactionType like '%A/R%' and
StatementDetailDist.Amount > 0 and
StatementPayable.StatementPayableID is null
)
begin
exec @glaPriKey = spBATSelectionProcess
@ICPriKey,
@glcPriKey,
@OrdPriKey,
'GLARAP',
@Source,
@SourcePriKey,
'AR'
end
else
begin
exec @glaPriKey = spBATSelectionProcess
@ICPriKey,
@glcPriKey,
@OrdPriKey,
'GLARAP',
@Source,
@SourcePriKey,
'AP'
end
end
else
begin
exec @glaPriKey = spBATSelectionProcess
@ICPriKey,
@glcPriKey,
@OrdPriKey,
'GLARAP',
@Source,
@SourcePriKey,
'AP'
end
end
else
begin
exec @glaPriKey = spBATSelectionProcess
@ICPriKey,
@glcPriKey,
@OrdPriKey,
'GLARAP',
@Source,
@SourcePriKey,
'AR'
end
end
if exists ( select 1 from GLARAP where GLAPriKey = @glaPriKey and GLCPriKey = @glcPriKey and ManualGL = 1 )
begin
set @secondGLNumber = ( select OverrideGLNumber from GLARAP where GLAPriKey = @glaPriKey and ManualGL = 1 )
if( @secondGLNumber is null )
begin
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@ERROR_MANUAL_GL_AND_OVERRIDE_NOT_ALLOWED,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
end
else if exists ( select 1 from GLARAP where GLAPriKey = @glaPriKey and GLCPriKey = @glcPriKey )
begin
while( @glsCounter <= @countGLCSegmets )
begin
set @padLength = ( select SegmentLength from GLDetail where SegmentNumber = @glsCounter and GLCPriKey = @glcPriKey )
set @glcSourceName =
(
select GLSource.SourceName
from GLSource
inner join GLDetail on ( GLDetail.GLSPriKey = GLSource.GLSPriKey )
where GLDetail.GLCPriKey = @glcPriKey and
GLDetail.SegmentNumber = @glsCounter
)
if( @glcSourceName = 'Natural' )
begin
set @glNumber = ( select ltrim( rtrim( GLAccount ) ) from GLARAP where GLCPriKey = @glcPriKey and GLAPriKey = @glaPriKey )
if( @glNumber is null )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_GL_ACCOUNT_IS_NULL_FOR_STMTS
else @ERROR_GL_ACCOUNT_IS_NULL
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else if( len( rtrim( @glNumber ) ) > @padLength )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_GL_ACCOUNT_TOO_LONG_FOR_STMTS
else @ERROR_GL_ACCOUNT_TOO_LONG
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else
begin
exec @glAccount = udfLeftPadding @padLength, @glNumber
if( @glsCounter > 1 and @secondGLNumber <> ' ' )
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + '-' + ltrim( rtrim( @glAccount ) )
end
else
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + ltrim( rtrim( @glAccount ) )
end
end
end
else if( @glcSourceName = 'Sub' )
begin
set @glNumber = ( select ltrim( rtrim( GLSubAccount ) ) from GLARAP where GLCPriKey = @glcPriKey and GLAPriKey = @glaPriKey )
if( @glNumber is null )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_GL_SUBACCOUNT_IS_NULL_FOR_STMTS
else @ERROR_GL_SUBACCOUNT_IS_NULL
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else if( len( rtrim( @glNumber ) ) > @padLength )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_SUBACCOUNT_TOO_LONG_FOR_STMTS
else @ERROR_SUBACCOUNT_TOO_LONG
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else
begin
exec @glAccount = udfLeftPadding @padLength, @glNumber
if( @glsCounter > 1 and @secondGLNumber <> ' ' )
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + '-' + ltrim( rtrim( @glAccount ) )
end
else
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + ltrim( rtrim( @glAccount ) )
end
end
end
else if( @glcSourceName = 'Company' )
begin
set @glNumber = ( select ltrim( rtrim( CompanyGLCode ) ) from Branch where BranchPriKey = @BranchPriKey )
if( @glNumber is null )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_COMPANY_GLCODE_IS_NULL_FOR_STMTS
else @ERROR_COMPANY_GLCODE_IS_NULL
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else if( len( rtrim( @glNumber ) ) > @padLength )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_COMPANY_GLCODE_IS_TOO_LONG_FOR_STMTS
else @ERROR_COMPANY_GLCODE_IS_TOO_LONG
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else
begin
exec @glAccount = udfLeftPadding @padLength, @glNumber
if( @glsCounter > 1 and @secondGLNumber <> ' ' )
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + '-' + ltrim( rtrim( @glAccount ) )
end
else
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + ltrim( rtrim( @glAccount ) )
end
end
end
else if( @glcSourceName = 'Branch' )
begin
set @glNumber = ( select ltrim( rtrim( GLCode ) ) from Branch where BranchPriKey = @BranchPriKey )
if( @glNumber is null )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_GLCODE_IN_BRANCH_IS_NULL_FOR_STMTS
else @ERROR_GLCODE_IN_BRANCH_IS_NULL
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else if( len( rtrim( @glNumber ) ) > @padLength )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_GLCODE_IN_BRANCH_IS_TOO_LONG_FOR_STMTS
else @ERROR_GLCODE_IN_BRANCH_IS_TOO_LONG
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else
begin
exec @glAccount = udfLeftPadding @padLength, @glNumber
if( @glsCounter > 1 and @secondGLNumber <> ' ' )
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + '-' + ltrim( rtrim( @glAccount ) )
end
else
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + ltrim( rtrim( @glAccount ) )
end
end
end
else if( @glcSourceName = 'Division' )
begin
if not exists ( select 1 from Division where DivisionID = @DivisionPriKey )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_DIVISION_IS_INVALID_FOR_STMTS
else @ERROR_DIVISION_IS_INVALID
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
set @glNumber = ( select ltrim( rtrim( GLCode ) ) from Division where DivisionID = @DivisionPriKey )
if( @glNumber is null )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_GLCODE_IN_DIVISION_IS_NULL_FOR_STMTS
else @ERROR_GLCODE_IN_DIVISION_IS_NULL
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else if( len( rtrim( @glNumber ) ) > @padLength )
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_GLCODE_IN_DIVISION_IS_TOO_LONG_FOR_STMTS
else @ERROR_GLCODE_IN_DIVISION_IS_TOO_LONG
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @secondGLNumber = null
end
else
begin
exec @glAccount = udfLeftPadding @padLength, @glNumber
if( @glsCounter > 1 and @secondGLNumber <> ' ' )
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + '-' + ltrim( rtrim( @glAccount ) )
end
else
begin
set @secondGLNumber = ltrim( rtrim( @secondGLNumber ) ) + ltrim( rtrim( @glAccount ) )
end
end
end
else
begin
set @theErrorCodeID = case @theSourceIsStatements
when 1 then @ERROR_GLSOURCE_IS_INVALID_FOR_STMTS
else @ERROR_GLSOURCE_IS_INVALID
end
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@theErrorCodeID,
@theErrorObjectTable,
@theErrorObjectID
set @glsCounter = @countGLCSegmets + 1
set @secondGLNumber = null
end
set @glsCounter = @glsCounter + 1
end
end
else
begin
set @secondGLNumber = null
end
if( @secondGLNumber is not null )
begin
exec @batErrorCode = spBATCheckGLNumber
@theBlankSessionID,
@secondGLNumber,
@branchPriKey,
@Source,
@SourcePriKey,
@theErrorObjectTable,
@theErrorObjectID
if( @batErrorCode = 0 )
begin
update BATProcess set
OpposingGLNumber = @secondGLNumber
where BATProcessPriKey = @BATProcessPriKey
end
else
begin
exec @batErrorCode = spBATRecordError
@theBlankSessionID,
@Source,
@SourcePriKey,
@ERROR_SECOND_GL_NOT_IN_GREAT_PLAINS,
@theErrorObjectTable,
@theErrorObjectID
end
end
GO
GRANT EXECUTE ON [dbo].[spBATGenerateSecondRevGLNumber_Legacy] TO [MssExec]
GO