tags:

views:

29

answers:

1

I have a need to return the contents of the Payables Distribution Zoom window to another application I'm writing. I have successfully used eConnect to pull back the Payables Transaction entries but cannot find where to get the line item detail. Can someone point me in the right direction? I've never worked with Dynamics. I'm not against going directly to the database, but (so far) haven't found very good references for the DB design.

Any help is much appreciated.

A: 

I'm going to post my current solution, which met my needs, but if anyone sees a better way to accomplish this please let me know!

The SQL:

SELECT 
        P1.VENDORID
        ,LTRIM(RTRIM(GL1.ACTNUMBR_1)) + '-' + LTRIM(RTRIM(GL1.ACTNUMBR_2)) AS 'ACCOUNT' 
        ,P2.DISTTYPE
        ,P2.DEBITAMT
        ,P2.CRDTAMNT
        ,V.[Vendor Name] 
        ,P1.VCHRNMBR    
        ,P1.DOCNUMBR
        ,P1.DOCDATE 
        ,P1.BACHNUMB
        ,P1.TRXDSCRN
        ,P2.DOCTYPE
        ,C.ACTINDX 
        ,P3.DOCNUMBR
    FROM 
        PM30200 P1  WITH(NOLOCK) 
    INNER JOIN 
        PM30600 P2 ON P1.VCHRNMBR = P2.VCHRNMBR
    INNER JOIN
        GL00100 GL1 ON GL1.ACTINDX = P2.DSTINDX
    INNER JOIN
        Vendors V ON V.[Vendor ID] = P1.VENDORID
    LEFT OUTER JOIN
        PM00400 P3 ON P3.TRXSORCE = P1.TRXSORCE AND P3.CNTRLTYP = 1 AND P3.DOCTYPE = 6 AND P3.VENDORID = P1.VENDORID
    LEFT OUTER JOIN
        CM00100 C ON C.CHEKBKID = P3.CHEKBKID

I also created two enums to map some of the data:

public enum DISTTYPE
        {
            Cash = 1,
            Pay = 2,
            Avail = 3,
            Taken = 4,
            Fnchg = 5,
            Purch = 6,
            Trade = 7,
            Misc = 8,
            Freight = 9,
            Taxes = 10,
            Write = 11,
            Other = 12,
            Gst = 13,
            Wh = 14,
            Unit = 15,
            Round = 16
        }

        public enum DOCTYPE
        {
            Invoice = 1,
            [Description("Finance Charge")]
            FinanceCharge = 2,
            [Description("Miscellaneaous Charge")]
            MiscellaneaousCharge = 3,
            Return = 4,
            [Description("Credit Memo")]
            CreditMemo = 5,
            [Description("Manual Checks")]
            ManualChecks = 6
        }
Chuck