Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Contributor
alanrich
Posts: 30
Registered: 01-02-2009
0

Item Inquiry Scripting troubles

I am working with MAS 90 4.40.04

 

I have a UDF in the PO_VendorPriceLevel file to hold the Effective Date of a Vendor's price. In Item Inquiry, I want a button to pop-up a messagbox that displays all Vendor's of the item, along with the Vendor's Price and my UDF Effective Date.

 

 

 

The following script works fine when called from Item MAINTENANCE but not from Item INQUIRY. I'm testing with an Admin account that has all rights enabled. The behavior suggests that a "write" permission is failing due to the "Read-Only" state of an Inquiry, but for the life of me, I can't figure out where it's occuring. Anyone out there care to peruse my script and offer any clues?

 

' IM-ListAllVendorCosts.vbs - 01/13/2011 - AER
'
' Purpose: Show a list of vendor's for an item with the vendor's price & effctive dates.

 

strMsg = ""
TheItemCode = ""


retVal = oBusObj.GetValue("ItemCode", TheItemCode)

'Get a handle to the PO_VendorPriceLevel table
oPOVenPriceLvl = 0
oPOVenPriceLvl = oSession.GetObject("PO_VendorPriceLevel_svc")
if oPOVenPriceLvl <> 0 then
    'Assign PO_VendorPriceLevel Table as an object
    SET oPOVenPriceLvl = oScript.AsObject(oPOVenPriceLvl)

    'Get a handle to the IM_ItemVendor table
    oIMItemVendor = 0
    oIMItemVendor = oSession.GetObject("IM_ITEMVENDOR_SVC")

    'retVal = oScript.DebugPrint("oIMItemVendor: " & CStr(oIMItemVendor))
    if oIMItemVendor <> 0 then
        'Assign oIM_ItemVendor Table as an object
        SET oIMItemVendor = oScript.AsObject(oIMItemVendor)

        'Restrict IM_ItemVendor records to this item
        retVal = oIMItemVendor.SetBrowseFilter(TheItemCode)

        'Loop through IM_ItemVendor records and look up each vendors PO_VendorPriceLevel record
        oIMItemVendor.MoveFirst
        do until cbool(oIMItemVendor.Eof)
            'Get the Vendor fields from the IM_ItemVendor record
            tmpItemCode = ""
            retVal = oIMItemVendor.GetValue("ItemCode", tmpItemcode)
            if tmpItemCode = TheItemCode then

                TheDivision = ""
                TheVendorNumber = ""
                retVal = oIMItemVendor.GetValue("APDivisionNo", TheDivision)
                retVal = oIMItemVendor.GetValue("VendorNo", TheVendorNumber)

                'Lookup the Vendor's Price record
             retVal = oPOVenPriceLvl.SetKeyValue("APDivisionNo$", TheDivision)
             retVal = oPOVenPriceLvl.SetKeyValue("VendorNo$", TheVendorNumber)
             retVal = oPOVenPriceLvl.SetKeyValue("PricingType$", "I")
             retVal = oPOVenPriceLvl.SetKeyValue("ProductLine$", "")
             retVal = oPOVenPriceLvl.SetKeyValue("ItemCode$", TheItemCode)
             retVal = oPOVenPriceLvl.Find()
                TheVendorItemPrice = 0
                TheVendorItemPriceEff = ""
                if retVal = 1 then
                    retVal = oPOVenPriceLvl.GetValue("DiscountMarkup1", TheVendorItemPrice)
                    retVal = oPOVenPriceLvl.GetValue("UDF_VPRICE_EFFDATE", TheVendorItemPriceEff)
                    strMsg = strMsg & TheDivision & "-" & TheVendorNumber & "   " & FormatNumber(CStr(TheVendorItemPrice), 4, -1) & "   "
                    strMsg = strMsg & Mid(TheVendorItemPriceEff, 5, 2)& "/" & Mid(TheVendorItemPriceEff, 7, 2) & "/" & Mid(TheVendorItemPriceEff, 1, 4) & vbCRLF
                end if
            end if
            oIMItemVendor.MoveNext
        loop
    else
        'Could not get handle to oIM_ItemVendor
        retVal = oScript.DebugPrint("Failed to get handle to oIMItemVendor Last Err: " & oBusObj.LastErrorMsg)
    end if
else
    'Could not get handle to oPOVenPriceLvl
        retVal = oScript.DebugPrint("Failed to get handle to oPOVenPriceLvl")
end if

 

intButton = 64 'set icon to information
'display message box
retVal = MsgBox (strMsg, intButton, "Lookup Results")