Wednesday, March 12, 2014

Dynamics GP - SeeHITB - sp to view the Historical Inventory Trial Balance

Use this script to generate the HITB
----------------------------------------------------------------------------
exec seeHITB @I_nSortBy=2,@I_nReceiptOptions=2,@I_sStartItemNumber=N'',@I_sEndItemNumber=N'þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ',@I_sStartAccountNumber=N'   -    -  ',@I_sEndAccountNumber=N'ÿÿÿ-ÿÿÿÿ-ÿÿ',@I_sStartLocationCode=N'',@I_sEndLocationCode=N'þþþþþþþþþþþ',@I_nStartQTYType=1,@I_nEndQTYType=5,@I_dtStart='1900-01-01 00:00:00',@I_dtEnd='2014-03-12 00:00:00',@sStartClass=N'',@sEndClass=N'þþþþþþþþþþþ',@sStartGenericDesc=N'',@sEndGenericDesc=N'þþþþþþþþþþþ',@I_fUseGLPostDate=0,@I_fIncludeZeroQtyItems=1,@O_SQL_Error_State=NULL
-----------------------------------------------------------------------

To build the output table schema from the stored procedure, use
------------------------------------------------------------------------
sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO


SELECT * INTO BI_Temp FROM OPENROWSET('SQLNCLI', 'Server=sql\gp;Database=TWO;Uid=sa;Pwd=mypassword','SET FMTONLY OFF;SET NOCOUNT ON;EXEC seeHITB')
--------------------------------------------------------------------------

To update the tabl ewith values from the stored procedure, use
------------------------------------------------------------------------
insert into BI_Temp
exec seeHITB


The output includes all transactions up to the "to" date.
You have to use the sum of all the transactions before the "from" date to get an opening stock balance

No comments:

Post a Comment