Thursday, September 18, 2014

Dynamics GP - SQL View - Connect GL to Inventory Notes

/****** Object:  View [dbo].[BI_GL_INV_Notes]    Script Date: 09/22/2014 13:04:18 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BI_GL_INV_Notes]'))
DROP VIEW [dbo].[BI_GL_INV_Notes]
GO

/****** Object:  View [dbo].[BI_GL_INV_Notes]    Script Date: 09/22/2014 13:04:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[BI_GL_INV_Notes]
AS
SELECT     GL.JRNENTRY, dbo.SY03900.NOTEINDX AS InvNoteIndx, dbo.SY03900.TXTFIELD AS InvNote, IV.TRXSORCE, IV.IVDOCTYP, IV.DOCNUMBR, IV.DOCDATE,
                      IV.BCHSOURC, IV.BACHNUMB, IV.NOTEINDX, IV.GLPOSTDT, IV.SRCRFRNCNMBR, IV.SOURCEINDICATOR, IV.DEX_ROW_TS, IV.DEX_ROW_ID
FROM         (SELECT     TRXSORCE, IVDOCTYP, DOCNUMBR, DOCDATE, BCHSOURC, BACHNUMB, NOTEINDX, GLPOSTDT, SRCRFRNCNMBR, SOURCEINDICATOR,
                                              DEX_ROW_TS, DEX_ROW_ID
                       FROM          dbo.IV30200) AS IV INNER JOIN
                          (SELECT     JRNENTRY, NOTEINDX, ORCTRNUM
                            FROM          dbo.GL20000
                            UNION
                            SELECT     JRNENTRY, NOTEINDX, ORCTRNUM
                            FROM         dbo.GL30000) AS GL ON IV.DOCNUMBR = GL.ORCTRNUM LEFT OUTER JOIN
                      dbo.SY03900 ON IV.NOTEINDX = dbo.SY03900.NOTEINDX

GO


No comments:

Post a Comment