I am giving my best attempt at scripting a calculation of what we have on hand compared to the original ordered quantity and populating a UDF. I know I have some holes as to the logic of the process and my end goal but I think I can figure those out if I can get this script to populate the UDF. I piggy backed off of this script, using-im_itemwarehouse_bus-or-_svc, because it is almost the same of what I am trying to do except different table. My knowledge of "looping" is limited and I receive an error stating below to start off. Any help in direction?
'on pretotals of the SO_HEADER table 'calculates the quantity on hand - quantity on sales order to populate qty pulled rVal = 0 sItem = "" sItemType = "" oItem = 0 QOH = 0 'QTY ON HAND QOS = 0 'QTY ON SALES ORDER QORD = 0 'QTY ORDERED QAVAIL = 0 QPULLED = 0 sWHS = "" Set oSOLines = oBusObj.AsObject(oBusObj.Lines) lineupdated = 0 oSOLines.MoveFirst do until (oSOLines.Eof and lineupdated = 1) rVal = oSOLines.GetValue("ItemType$", sItemType) set oItemWhse = oSession.As.Object(oSession.GetObject("IM_ItemWarehouse_svc")) if trim(sItemType) = "1" then 'START- only run for inventory items rVal = oSOLines.GetValue("ItemCode$", sItem) rVal = oSOLines.GetValue("WareouseCode$", sWHS) rVal = oSOLines.GetValue("QuantityOrdered$", QORD) 'rVal = oItemWhse.SetKeyValue("ItemCode$", sItem) 'rVal = oItemWhse.SetKeyValue("WarehouseCode$", sWHS) rVal = oItemWhse.Find() if rVal = 1 then QOH = 0 QOS = 0 rVal = oItemWhse.GetValue("QuantityOnHand", QOH) rVal = oItemWhse.GetValue("QuantityOnSalesOrder", QOS) end if QAVAIL = QOH - QOS if QORD > QAVAIL then QPULLED = QAVAIL rVal = oSOLines.SetValue("UDF_QTY_PULLED", QPULLED) rVal =oSOLines.Write() lineUpated = 1 if QORD <= QAVAIL then QPULLED = QORD rVal = oSOLines.SetValue("UDF_QTY_PULLED", QPULLED) rVal =oSOLines.Write() lineUpated = 1 end if end if end if rVal = oSOLines.MoveNext() loop