How to use RoundUp in UDF Scripts for Sage 100

SOLVED

Hi Everyone,

I created the following Script and there are no errors. I am trying to figure out how many packages are needed by dividing the Quantity Shipped / Pack Qty. The issue is I do not know how to ROUNDUP in the Sage 100 Scripts.

Example #1: 99 / 3 = 33 packages, which is good

Example #2 100/3 = 33.33 packages. I want it to be 34 packages, not round down to 33 packages.

---

numQuantityShipped = 0
numPackQty = 0
numPackageCount1 = 0
numPackageCount = 0

retVal = oBusObj.GetValue("QuantityShipped", numQuantityShipped)
retVal = oBusObj.GetValue("UDF_PACK_QTY", numPackQty)

if numPackQty = 0 then
numPackageCount = numQuantityShipped
retVal = oBusObj.SetValue("UDF_Package_Count", numPackageCount)
end if

if numPackQty <> 0 then
numPackageCount1 = numQuantityShipped / numPackQty
numPackageCount = round(numPackageCount1,0)
retVal = oBusObj.SetValue("UDF_Package_Count", numPackageCount)
end if

---

ISSUE ARISES WHEN I Change:

numPackageCount = round(numPackageCount1,0) 

to 

numPackageCount = roundup(numPackageCount1,0)

I get an ERROR 88 by using ROUNDUP.

 

Is there a way to Round Up in the Sage 100 Scripts?

Any help would be appreciated...

Parents
  • 0
    verified answer

    The workaround that I've been advised to use in the past is to add .4 to the original value, then round.  If the original value is 1.2, it will become 1.7 and round to 2.  If the original value is 2, it will become 2.4 and round to 2.  

    Change this: numPackageCount1 = numQuantityShipped / numPackQty

    to this:  numPackageCount1 = (numQuantityShipped / numPackQty) + .4

Reply
  • 0
    verified answer

    The workaround that I've been advised to use in the past is to add .4 to the original value, then round.  If the original value is 1.2, it will become 1.7 and round to 2.  If the original value is 2, it will become 2.4 and round to 2.  

    Change this: numPackageCount1 = numQuantityShipped / numPackQty

    to this:  numPackageCount1 = (numQuantityShipped / numPackQty) + .4

Children