09 August 2010

Weekly Dynamic: SQL to Balance AP to GL

An important part of maintaining Dynamics GP is balancing the AP subledger to the General Leger. GP has a utility to help you do this if they are out of balance. Additionally, The Close can go beyond the capabilities in Dynamics GP to provide even better balancing options. But what if you are regularly in balance and you want to make sure that you stay that way without having to run the big AR Trial Balance report every day? Well, here is a little bit of SQL that can I’ve used before that can do just that. This compares the AP subledger to the selected AP GL account and shows the difference. It’s a quick way to see if AP balance.

SELECT     'AP' as SubType, (SUM(currblnc))*-1 AS SUBBAL, 0 AS GLBAL
into #SubtoGLCompare
FROM         PM00201

/*Get the GL total for this Account. Change the account below or optionally add additional
actnumbr parameters to tighten or broaden the account*/
INSERT #SubtoGLCompare (SubType,SubBal,GLBAL)
SELECT     'AP' as Subtype, 0 AS Subbal, SUM(Perdblnc) AS GLBal
FROM         GL11110
WHERE     actnumbr_2 = '2100' -- Change this

Select SubType, sum(Subbal) as SubBal, Sum(GLBal) as GLBAL, sum(SubBal)-Sum(GLBAL) as Difference,
'Difference is Subledger minus GL.' as Instructions
from #SubtoGLCompare
Group by SubType

Drop Table  #SubtoGLCompare