Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0
Accepted Solution

In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

Hi Forum,

 

I need to create a Script to verify that the Vendor entered in PO Entry is the Primary Vendor in Inventory Master.

What Objects should i be using to get this done?

Any help/advise will greatly appreciated.

 

Regards,

Manuel Roman

Providex Developer
Sage Employee
jepritch
Posts: 233
Registered: 08-25-2009
0

Re: In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

Hi Manuel,

 

I would probably put a Pre-Validate script on the item code table, using the childhandle to the existing CI_Item_svc object.  Retrieving the PrimaryAPDivisionNo & PrimaryVendorNo from the CI_Item table for the current Item.  You'll also, want to retrieve the current APDivisionNo and VendorNo from the Purchase order header.

 

Keep in mind some potential conflicts:

 

1) What do you want to do if the Div + Vendor combo does not exist in Item Maintenance?

2) You may want to make this Script conditional to only be done from the data entry program itself.  Use oSession.Updating<>0 condition, so that potential updates to the PO lines does not inadvertently run this script.

 

Hope this helps

Elliott

unidentified user
chief_chef
Posts: 8
Registered: 09-07-2011
0

Re: In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

[ Edited ]

Manuel ,

 

Elliots replay sounds a little confusing to me so I may just be re-wording it...

 

I would put a Pre-Validate script on the ItemCode$ column in PO_PurchaseOrderDetail.  I would check oBusObj.EditState.  If it is equal to 2, a new record, then I'd get a handle to the existing child collection for CI_ItemCode_svc and pull the Primary Division and Vendor.  I always do a find on those child objects because I want to make sure they are pointed to the correct record.  Compare the values from CI_Item to those on the PO Header and either display a message or just fail it.  You wouldn't want to display a message in certain cases, V/I in particular.

 

Hope this helps,

Jonathan

Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

Hi Elliott,

 

Thanks, i'll give  it try and let you know the outcome.

 

Regards,

Manuel Roman

Providex Developer
Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

Thanks Jonathan...

 

is it CI_Item_SVC or CI_ItemCode_SVC ?

 

Regards,

Manuel Roman

Providex Developer
Sage Employee
jepritch
Posts: 233
Registered: 08-25-2009
0

Re: In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

Jonathan is correct it's CI_ItemCode_svc, sorry about that.

Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

Hi Elliott,

 

Jonathan had the same CI_Item_SVC as you....

Not a problem, it's just that CI_Item_SVC didn't sound familiar (not that i am familiarwith all Objects)...

 

Regards,

Manuel Roman

Providex Developer
unidentified user
chief_chef
Posts: 8
Registered: 09-07-2011
0

Re: In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

I corrected my post.  Hopefully you can figure it out....

 

Thanks,

Jonathan

Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

Hi,

 

I am trying to test the script with no luck.

Is there a way that i can troublshoot?...

Well, first here the script so you can take alook at it end tell me what i am doing worng?

 

ItemCode = ""

itemtype = ""

LineKey=""

oCIItem = 0

CIVendorNo = ""

POVendorNo = ""

retVal = 0

 

if oBusObj.EditState=2 then

 

if Not(IsObject(oItemSvc)) then

 oItemSvc = oBusObj.GetChildHandle("ItemCode")

 if oItemSvc <> 0 then

  Set oItemSvc = oBusObj.AsObject(oItemSvc)

 msgbox "Yes"

 end if

end If

 

retval = oItemSvc.GetValue("LineKey$", LineKey)

retVal = oItemSvc.GetValue("ItemType$", itemtype)

retVal = oItemSvc.GetValue("ItemCode$", ItemCode)

 

 

 if itemtype = "1" and LineKey <> "" then

 

  oCIItem = oSession.GetObject("CI_ItemCode_svc")

 

  if oCIItem then

  Set oCIItem = oScript.AsObject(oCIItem)

  retVal = oBusObj.GetValue("VendorNo$", POVendorNo)

  retVal = oCIItem.SetKeyValue("ItemCode", ItemCode)

  retVal = oCIItem.Find()

 

if retVal then

    

retVal = CIItem.GetValue("PrimaryVendorNo$", CIVendorNo)

 

if  CIVendorNo<>POVendorNo then

 

msgbox "P/O vendor not the Primary Vendor Code"

 

end if

   end if

  end if

 end if

 

Any suggestions?

 

Regards,

Manuel Roman

Providex Developer
Regular Contributor
Gator
Posts: 269
Registered: 12-05-2008
0

Re: In PO entry need to verify that Vendor is the Primary vendor in Inventory Master

ItemCode = ""
itemtype = ""
LineKey=""
oCIItem = 0
CIVendorNo = ""
POVendorNo = ""
retVal = 0

if oBusObj.EditState=2 then
	retval = oBusObj.GetValue("LineKey$", LineKey)
	retVal = oBusObj.GetValue("ItemType$", itemtype)
	retVal = oBusObj.GetValue("ItemCode$", ItemCode)

	if itemtype = "1" and LineKey <> "" then
		oCIItem = oSession.GetObject("CI_ItemCode_svc")
		if oCIItem then
			Set oCIItem = oScript.AsObject(oCIItem)
			retVal = oHeaderObj.GetValue("VendorNo$", POVendorNo)
			retVal = oCIItem.SetKeyValue("ItemCode", ItemCode)
			retVal = oCIItem.Find()

			if retVal then
				retVal = oCIItem.GetValue("PrimaryVendorNo$", CIVendorNo)

				if  CIVendorNo<>POVendorNo then
					msgbox "P/O vendor not the Primary Vendor Code"
				end if
			end if
		end if
	end if
end if