Site Search:
Sign in | Join | Help
4Penny.net

Dynamics GP

Notes, Tips and Tricks on Developing in Dynamics GP

July 2007 - Posts

  • Sample code for using RetrieveGlobals9 in Dynamics

    Here is a short piece of code that demonstrates how to code for RetrieveGlobals9.dll in Dynamics GP

     Private Sub NextCust_Changed()

        If Me.CustomerID.Value > "" Then
            MsgBox "The Customer Number Field must be empty"
            Exit Sub
        End If
       
        Dim cmd
        Dim rst
        Set userinfo = CreateObject("RetrieveGlobals9.retrieveuserinfo")
        Set conn = userinfo.Connection
       
        'Create an ADO command object.
        Set cmd = CreateObject("ADODB.Command")
       
        'set the database to the currently logged in db.
        conn.DefaultDatabase = userinfo.intercompany_id()

        cmd.ActiveConnection = conn
        cmd.CommandType = 4 'adCmdStoredProc
       
        'Get the next cust number
        cmd.CommandText = "_4P_SOPgetNextCustomerNumber"
        Set rst = cmd.Execute
        If Not rst.EOF Then
            Me.CustomerID.Value = rst("vchrCustomerNumber")
        End If
       
        'Close the connection.
        If conn.State = 1 Then
           conn.Close
        End If
       
        'Cleanup.
        Set cmd = Nothing
        Set cn = Nothing

    End Sub

  • Joining the IV00101 and IV00102

    From a recent email: 
    • IV00101 is the Item Master table and Item Classes are kept here (ITMCLSCD = field name)
    • IV00102 is the quantities table where our on hand, allocated, etc. figures are kept; Item Classes are not in here but they share ITEMNMBR as a key field

    I want to find all of the inventory items in IV00102 with quantities on hand > 0 that belong to our Item Class ID 'NEW PARTS'...I probably need to join the tables in SQL somehow on ITEMNMBR so as to query only the ones I'm looking for. 

    ======================

    select i.itemnmbr, rcrdtype,iq.locncode, qtyonhnd
    from
    iv00101 i
    join iv00102 iq on i.itemnmbr = iq.
    itemnmbr
    --where iq.rcrdtype = 1
    order by i.itemnmbr, iq.rcrdtype, iq.locncode

    The IV00102 has a record type field, the '1' type is a summary of all locations, the '2' type is for the individual locations. You'll need to uncomment the 'where' clause, and make it say either 1 or 2, based on your needs

     

  • Limiting Comments to 40 Characters

    From a recent email: 

    Have you ever written anything to control the format that the Line Item Comment (from SOP)? Example, Customer wants to force a return after 40 characters of typing

     ===================

    I’m doubtful this is possible, because of the way that Dynamics handles comments internally.  Key in a long comment, and then look at the SOP10106 table. There are 5 fields – comment_1 through 4 and cmmttext. Cmmttext holds the full, unaltered comment, the other comment fields hold parsed versions of this, 5 characters each. If you key a 250 character comment, the last 50 chars (at least) will not display in some situations.  Some forms display the entire CMMTTEXT field (like the SOP Transaction Entry form), some display the parsed comment_1 (etc) fields (like the Invoice report).  We could try to set a trigger on the SOP10106 that ‘reparsed’ the other fields on every update… but convey to the customer the risk. I’ve never tried it and I’m unsure of the results. I would grab the CMMTTEXT field, count 40 characters, then walk backward and look for the last ‘word end’ character (usually a space). I’d repeat that 4 times. I’d have to do some research into whether the CMMTTEXT field stores non-visible line feed characters (caused by someone intentionally hitting ‘enter’ in a comment field), and handle that if it did.

     

More Posts Next page »