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

Change Unit Cost in PO ROG

hi Forum,

 

I need to write a script to change the unit cost (raplace it with STD Cost) in PO ROG data entry....

I am not familiar with the PO Receipts objects.

Any help will be appreciated...

 

Regards,

Manuel Roman

Providex Developer
Moderator
Natasha
Posts: 180
Registered: 07-15-2009
0

Re: Change Unit Cost in PO ROG

This will refresh the unit cost when a inventory item from a PO is added to a receipt entry.   You can start with this and adjust for your need.

 

It first checks if the line is new.  Then it checks if it comes from PO and if it is an inventory item.  Then it gets the item's standard cost and sets unit cost on the line.

 

itemcode = ""

itemtype = ""

orderLineKey=""

oCIItem = 0

stdcost=0

retVal = 0

 

if oBusObj.EditState=2 then

 

      retVal = oBusObj.GetValue("OrderLineKey$", orderLineKey)

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

 

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

 

          oCIItem = oSession.GetObject("CI_ItemCode_svc")

          if oCIItem then

             Set oCIItem = oScript.AsObject(oCIItem)

             retVal = oBusObj.GetValue("ItemCode$", itemcode)

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

             retVal = oCIItem.Find()

             if retVal then

                 retVal = oCIItem.GetValue("StandardUnitCost", stdcost)

                 retVal = oBusObj.SetValue("UnitCost",stdcost)

             end if

          end if

 

     end if

end if

 

Natasha Chang
Sr. Software Engineer
Sage 100 ERP
Moderator
Natasha
Posts: 180
Registered: 07-15-2009
0

Re: Change Unit Cost in PO ROG

Just to simply it a little, you can pass the itemcode into the Find() method.  No need to do SetKeyValue().

 

retVal = oCIItem.Find(itemcode)

 

 

Natasha Chang
Sr. Software Engineer
Sage 100 ERP
Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: Change Unit Cost in PO ROG

Natasha,

 

Thaks, i'll give it a try ...

What event should i use for te script?

PO_Receipt Detail; Column pre_validate???

 

Regards,

Manuel Roman

Providex Developer
Moderator
Natasha
Posts: 180
Registered: 07-15-2009
0

Re: Change Unit Cost in PO ROG

PO_ReceiptDetail; Pre Write

Natasha Chang
Sr. Software Engineer
Sage 100 ERP
Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: Change Unit Cost in PO ROG

Natasha,

 

You are the best... works perfect.

I'll play around with it but i can see that is working...

Thanks so much

 

Regards,

Manuel

 

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

Re: Change Unit Cost in PO ROG

Ye , it is working fine

 

thanks,

Providex Developer