RE: Gaps in PSTGNMBR in GL20000
There might be un-posted journal entries in [ GL10000 ] Transaction Work, therefore, you need to check the serial in both tables [ GL20000 ] and [ GL10000 ].
In case you still have variances, you might need to check whether the "Next Journal Entry" number has been changed from ( Tools > Setup > Financial > General Ledger ), which might obviously cause gaps if used every now and then
Please consider the script below as it might help you find out your Journal Entry Gaps precisely;
Tables:
- GL10000 | Transaction Work
- GL20000 | Year to Date Transaction Open
- GL30000 | Account Transaction History
SELECT Row_ID, JE_Status, JRNENTRY,JRNENTRY+JE_Gap AS Next_Journal_Entry, JE_Gap FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY JRNENTRY ASC) AS Row_ID,
JE_Status,
JRNENTRY,
COALESCE(
(
SELECT TOP 1 JRNENTRY
FROM
(
SELECT DISTINCT X.JRNENTRY FROM
(
SELECT JRNENTRY FROM GL10000
UNION ALL
SELECT JRNENTRY FROM GL20000
UNION ALL
SELECT JRNENTRY FROM GL30000
) AS X
) AS Y
WHERE Y.JRNENTRY > B.JRNENTRY
ORDER BY
JRNENTRY ASC
), 0) - B.JRNENTRY AS JE_Gap
FROM
(
SELECT DISTINCT A.JE_Status,
A.JRNENTRY
FROM
(
SELECT 'Work' as JE_Status, JRNENTRY FROM GL10000
UNION ALL
SELECT 'Open' as JE_Status, JRNENTRY FROM GL20000
UNION ALL
SELECT 'History' as JE_Status, JRNENTRY FROM GL30000
) AS A
) AS B
) AS F
WHERE F.JE_Gap <> 1