DECLARE @I_sSeries SMALLINT,
@I_cOrigin CHAR(50),
@I_dDate DATETIME,
@I_dUserDate DATETIME,
@O_sPeriodID SMALLINT, -- Period ID
@O_tClosed TINYINT, -- 1 if period is closed
@O_sYear SMALLINT, -- fiscal year
@O_iOUTErr INT, -- 0=no errors; 2=date not in a fiscal year; 3=unknown
@O_iErrorState INT;
-- Financial=2, PM=4, Sales=3, IV=5, PR=6
SET @I_sSeries = 2;
-- SELECT DISTINCT odesctn FROM sy40100 ORDER BY odesctn
SET @I_cOrigin = 'General Entry';
-- date to check if period is closed
SET @I_dDate = '11/1/17';
SET @I_dUserDate = CAST(GETDATE() AS DATE);
EXEC Glcalculateglperiod @I_sSeries, @I_cOrigin, @I_dDate, @I_dUserDate,
@O_sPeriodID OUTPUT, @O_tClosed OUTPUT, @O_sYear OUTPUT, @O_iOUTErr OUTPUT, @O_iErrorState OUTPUT;
SELECT @O_sPeriodID, @O_tClosed, @O_sYear, @O_iOUTErr, @O_iErrorState
PRINT CASE WHEN @O_tClosed = 1
THEN 'Period is Closed'
ELSE 'Period is Open' END;
I'm a former Microsoft Dynamics consultant specializing in SQL Server integrations, reports and customizations.
Tuesday, November 21, 2017
SQL code to check for open GL period in Dynamics GP
In Dynamics GP periods can and should be closed to prevent users from posting data where they should not. To determine if the period is closed use the following code in SQL Server:
No comments:
Post a Comment