I'm trying to find the last unit cost for a warehouse in Sales Order entry. Sage defaults to the last unit cost for all warehouses. I'm getting a not found from this code. I don't know the GROUPSORT.
If oSession.CompanyCode = "TST" Then
retval = oSession.AsObject(oSession.UI).Messagebox( "","Pre Write SO_Last_Warehouse_Cost Script")
'************* ITEM COST & COST**************
ItemCode = ""
StdCost = 0
ItemType = ""
Cost_Type =""
Warehouse = ""
retval = oHeaderObj.GetValue("OrderType$",OrderType)
retval = oBusObj.GetValue("ItemCode$",ItemCode)
retval = oBusObj.GetValue("WarehouseCode$",Warehouse)
retval = oBusObj.GetValue("UnitCost",StdCost)
retval = oSession.AsObject(oSession.UI).Messagebox( "","Key=" & itemcode & warehouse)
'*** ITEM WAREHOUSE COST ***
oItemCode = oSession.GetObject("IM_ItemCost_bus")
if oItemCode <> 0 then
Set oItemCode = oSession.AsObject(oItemCode)
else
retval = oSession.AsObject(oSession.UI).Messagebox( "","oItemCode failed")
return
end if
retval = oItemCode.SetKeyValue("ItemCode$",ItemCode)
retval = oItemCode.SetKeyValue("WarehouseCode$",Warehouse)
retval = oItemCode.SetKeyValue("TierType$","1")
retVal = oItemCode.SetKey()
'if 1 then Item was found
if retVal = 1 then
retval = oSession.AsObject(oSession.UI).Messagebox( "","Warehouse Item Cost Found")
else
retval = oSession.AsObject(oSession.UI).Messagebox( "","Warehouse Item Cost Not Found")
end if
retval = oSession.DropObject("IM_ItemCost_bus")
end if