Sage 100

 View Only
  • 1.  Script not populating into UDF Fields in Invoice Data Entry Lines

    Posted 01-18-2021 15:29
    I need a little assistance as to why this script does not populate all the fields within the  Invoice Data Entry Lines.  Only the two main fields are populating the the individual UDFs are not. But I see all the fields populating in the debug trace window but not within the actual field in Sage.  
    'Created by VGriffin @RKL eSolutions 1/10/21
    'Purpose of script is to review the order's line brand and copy the sales to field

    'Set on Pre-Totals

    'Int Var
    sBrand=""
    sWTClass = ""
    nQty = 0
    nCost = 0
    nROTSales = 0
    nROTCOGS = 0
    nRUKSales = 0
    nRUKCOGS = 0
    nSEVSales =0
    nSEVCOGS = 0
    nExtendedSales = 0
    nExtendedCost = 0
    nBrandSales = 0
    sScriptName =""


    sScriptName = "UpdateLinesBrandSales"
    r=oScript.DebugPrint("Made it to " & sScriptName)

    'Get Sales Order Sales and Cost per Brand

    RV = oBusObj.GetValue("JT158_WTCLASS$",sWTClass):r= oScript.DebugPrint("Got Value sWTClass = " & sWTClass)


    Set oLines=oBusObj.AsObject(oBusObj.Lines)
    retval= oLines.MoveFirst()
    Do While CBool(oLines.EOF) = False


    retVal = oLines.GetValue("UDF_BRAND$",sBrand):r= oScript.DebugPrint("Got Value from sBrand =" & sBrand)
    retVal = oLines.GetValue("ExtensionAmt",nExtendedSales): r=oScript.DebugPrint("Got Value from nExtendedSales = " & nExtendedSales)
    retVal = oLines.GetValue("UDF_Brand_Sales",nBrandSales): r=oScript.DebugPrint("Got Value from nBrandSales = " & nBrandSales)
    retVal = oLines.GetValue("UDF_ROT_SALES",nROTSales): r=oScript.DebugPrint("Got Value from nROTSales = " & nROTSales)
    retVal = oLines.GetValue("UDF_RUK_SALES",nRUKSales): r=oScript.DebugPrint("Got Value from nRUKSales = " & nRUKSales)
    retVal = oLines.GetValue("UDF_SEV_SALES",nSEVSales): r=oScript.DebugPrint("Got Value from nSEVSales = " & nSEVSales)

    'Determine which brand sales and cost
    nBrandSales = nExtendedSales
    rv = oLines.SetValue ("UDF_Brand_Sales",nBrandSales):r = oScript.DebugPrint("Current Brand Sales nBrandSales =" & nBrandSales)
    rWrite = oLines.Write ()

    if sBrand = "ROT" then nROTSales = nBrandSales
    rv = oLines.SetValue("UDF_ROT_SALES",nROTSales):r= oScript.DebugPrint("Current ROT Sales nROTSales = " & nROTSales)
    rw = oLines.Write ()
    if sBrand = "RUK" then nRUKSales = nBrandSales
    rv = oLines.SetValue("UDF_RUK_SALES",nRUKSales):r= oScript.DebugPrint("Current RUK SALES nRUKSales = " & nRUKSales)
    rw = oLines.Write()
    if sBrand = "SEV" then nSEVSales = nBrandSales
    rv = oLines.SetValue("UDF_SEV_SALES",nSEVSales):r= oScript.DebugPrint("Current SEV SALES nSEVSales = " & nSEVSales)
    rw = oLines.Write ()


    'rw = oLines.Write
    retVal = oLines.MoveNext()
    Loop
    _____________________________________________________________________________________________________________________________________________
    'Created by VGriffin @RKL eSolutions 1/10/21
    'Purpose of script is to review the order's line brand and copy the sales to field

    'Set on Pre-Totals

    'Int Var
    sBrand=""
    sWTClass = ""
    nQty = 0
    nCost = 0
    nROTCOGS = 0
    nRUKCOGS = 0
    nSEVCOGS = 0
    nBrandCOGS = 0
    sScriptName =""


    sScriptName = "UpdateLinesBrandSales_COGS"
    r=oScript.DebugPrint("Made it to " & sScriptName)

    'Get Sales Order Sales and Cost per Brand

    RV = oBusObj.GetValue("JT158_WTCLASS$",sWTClass):r= oScript.DebugPrint("Got Value sWTClass = " & sWTClass)


    Set oLines=oBusObj.AsObject(oBusObj.Lines)
    retval= oLines.MoveFirst()
    Do While CBool(oLines.EOF) = False

    retVal = oLines.GetValue("UDF_BRAND$",sBrand):r=oScript.DebugPrint("Got Value from sBrand = " & sBrand)
    retVal = oLines.GetValue("UnitCost",nCost):r=oScript.DebugPrint("Got Value from nCost = " & nCost)
    retVal = oLines.GetValue("QuantityShipped",nQty):r=oScript.DebugPrint("Got Value from nQty = " &nQty)
    retVal = oLines.GetValue("UDF_BRAND_COGS",nBrandCOGS):r= oScript.DebugPrint("Got Value from nBrandCOGS =" & nBrandCOGS)
    retVal = oLines.GetValue("UDF_ROT_COGS", nROTCOGS): r=oScript.DebugPrint("Got Value from nROTCOGS = " & nROTCOGS)
    retVal = oLines.GetValue("UDF_RUK_COGS",nRUKCOGS): r=oScript.DebugPrint("Got Value from nRUKCOGS = " & nRUKCOGS)
    retVal = oLines.GetValue("UDF_SEV_COGS",nSEVCOGS): r=oScript.DebugPrint("Got Value from nSEVCOGS = " & nSEVCOGS)


    'Determine which brand sales and cost
    nBrandCOGS = nQty*nCost
    rv = oLines.SetValue ("UDF_BRAND_COGS",nBrandCOGS):r = oScript.DebugPrint("Current Brand COGS nBrandCOGS =" & nBrandCOGS)
    rWrite = oLines.Write

    if sBrand = "ROT" then nROTCOGS = nBrandCOGS
    rv = oLines.SetValue("UDF_ROT_COGS",nROTCOGS):r= oScript.DebugPrint("Current ROT COGS nROTCOGS = " & nROTCOGS)
    rw = oLines.Write
    if sBrand = "RUK" then nRUKCOGS = nBrandCOGS
    rv = oLines.SetValue("UDF_RUK_COGS",nRUKCOGS):r= oScript.DebugPrint("Current RUK COGS nRUKCOGS = " & nRUKCOGS)
    rw = oLines.Write
    if sBrand = "SEV" then nSEVCOGS = nBrandCOGS
    rv = oLines.SetValue("UDF_SEV_COGS",nSEVCOGS):r= oScript.DebugPrint("Current SEV COGS nSEVCOGS = " & nSEVCOGS)
    rw = oLines.Write


    'rw = oLines.Write
    retVal = oLines.MoveNext()
    Loop



    'Refresh grid
    oScript.LinesAdded = 1
    oScript.LoadGrid("GD_Lines")


    ------------------------------
    Venessa Griffin
    RKL eSolutions, LLC
    ------------------------------


  • 2.  RE: Script not populating into UDF Fields in Invoice Data Entry Lines

    Posted 01-19-2021 04:08
    I always include the return value from the prior command in the DebugPrint, so i can see where something goes awry.
    r= oScript.DebugPrint("Got Value from sBrand =" & sBrand & "; retVal=" & retVal)​

    It appears the abundance of oLines.Write statements were an abundance of force. Don't forget to remove those in favor of uncommenting the one that you probably started with before the oLines.MoveNext().

    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------