
[dbo].[VerifyDateInOpenAccountingPostingPeriodForAllBranches]
CREATE PROCEDURE [dbo].[VerifyDateInOpenAccountingPostingPeriodForAllBranches]
@inDate datetime,
@inSeries int,
@outStatusCode int output
as
set nocount on
declare @theGPDBName sysname
declare @theGPNameId int
declare @theGPNameCount int
declare @theGPDBNames table
(
GPNameId int identity( 1, 1 ) not null,
GPDBName sysname
)
declare @theStatusCode int
set @theStatusCode = 0
set @outStatusCode = 0
declare @theAccountingSystem varchar(2) = dbo.GetAccountingSystemType()
if( @theAccountingSystem = 'XL' )
begin
exec dbo.VerifyDateInOpenAccountingPostingPeriod
@inDate = @inDate,
@outStatusCode = @theStatusCode output,
@inAccountingSystem = @theAccountingSystem
if( @theStatusCode != 0 )
begin
set @outStatusCode = 1
end
end
else if( @theAccountingSystem = 'GP' )
begin
insert into @theGPDBNames ( GPDBName)
select distinct GLControl.ADataBase
from Branch
inner join GLControl on GLControl.GLCPriKey = Branch.GLCPriKey
set @theGPNameCount = @@rowcount
set @theGPNameId = 1
while ( @theGPNameId <= @theGPNameCount )
begin
set @theGPDBName = ( select GPDBName from @theGPDBNames where GPNameId = @theGPNameId )
exec dbo.VerifyDateInOpenAccountingPostingPeriod
@inDate = @inDate,
@inGPDBName = @theGPDBName,
@inSeries = @inSeries,
@outStatusCode = @theStatusCode output,
@inAccountingSystem = @theAccountingSystem
if( 0 <> isnull( @theStatusCode, 1 ) )
begin
set @outStatusCode = 1
set @theGPNameId = @theGPNameCount
end
set @theGPNameId = @theGPNameId + 1
end
end
GO
GRANT EXECUTE ON [dbo].[VerifyDateInOpenAccountingPostingPeriodForAllBranches] TO [MssExec]
GO