- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Writing to IM_ItemCos t
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-02-2011 02:02 PM
I have a client having some difficulties with quantities committed to work orders. This is not the committed numbers you see when you go to inventory maintenance but and underlying field in IM_ItemCost that appears to be populated when you enter transactions in work order and should be cleared when the transactions are posted.
Unfortunately they appear to have 100's of these items throughout the inventory which keeps them from using cost layers. It's possible to clear them with DFDM, but it's going to take hours and hours to do it, so I'm trying to find a better way to fix it.
Rebuild sort files on inventory maintenance with a clear committed does not affect it.
Visiual integrator does not allow access to these fields.
So now I'm at the point where I'm trying to write a button script that can run through IM_ItemCost, identify the the bad layers and simply zero out the values in this field. Sounds simple, except that I can't seem to write back to the file. Is it possible that setvalue on these fields is somehow disabled in the IM_ItemCost_bus?
'declare variables
xdebug = 1
tmpStr = ""
tmpNum = 0
rec = ""
oCostLayers = oSession.GetObject("IM_ItemCost_bus")
if oCostLayers <> 0 then
Set oCostLayers = oSession.AsObject(oCostLayers)
else
retval = oSession.AsObject(oSession.UI).Messagebox( "","oCostLayers failed")
' needs to exit here
end if
retval = oCostLayers.MoveFirst() 'go to first record
do until cBool(oCostLayers.Eof) 'loop through the file
retval = oCostLayers.GetRecord(rec, tmpStr)
retval = oCostLayers.GetValue("CostCalcQtyCommitted",ccqc)
retval = oCostLayers.GetValue("CostCalcCostCommitted",cccc)
if ccqc <> 0 or cccc <> 0 then
subDisplayDialog(rec) ' display the record found - code ommitted
msgbox "edit state " & oCostLayers.EditState 'this returns a 1 suggesting that the record is found
'following section was just added to try and go directly to a known bad record and write - not in my original code
retval = oCostLayers.SetKeyValue("ItemCode","BOARD-004320-3
retval = OcostLayers.SetKeyValue("WarehouseCode","000" )
retval = oCostLayers.SetKeyValue("TierType","4")
retval = oCostLayers.SetKeyValue("GroupSort","1000302")
retval = oCostLayers.SetKey()
retval = oCostLayers.SetValue("CostCalcQtyCommitted",0) 'zero out the values
msgbox retval & oBusObj.LastErrorMsg ' LastErrorMsg returns "The is invalid"
retval = oCostLayers.SetValue("CostCalcCostCommitted",0) ' retval is 0 suggesting an error
msgbox retval & oBusObj.LastErrorMsg ' LastErrorMsg returns "The is invalid"
retval = oCostLayers.Write()
if retVal <> 1 then msgbox("Write Failed") end if 'this does not fail
end if
retval = oCostLayers.MoveNext()
loop
retval = Osession.DropObject("IM_ItemCost_bus")
Target System Technology, Inc. - Spokane, WA -
The best solution often comes not from answering the question asked, but understanding WHY the question was asked.
Re: Writing to IM_ItemCos t
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-02-2011 03:10 PM
Tom,
Need $ in "ItemCode$", "WarehouseCode$", "TierType$", and "GroupSort$."
Sr. Software Engineer
Sage 100 ERP
Re: Writing to IM_ItemCos t
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-02-2011 04:26 PM
Thanks Natasha
You are correct on the $.
However it still flakes out when you get to the Setvalues. The return value is a 0 indicating the setvalue is failing.
Seems to suggest that the exposed interface does allow changing the values for costcalcQtyCommitted and costcalcCostCommitted.
Also noted that my test record was for a serialized item and changed it to be a FIFO type item. That did not help either.
Really hope I can figure out a way to do this. This is probably a 6 to 10 hour correction if we have to do it by DFDM.
Target System Technology, Inc. - Spokane, WA -
The best solution often comes not from answering the question asked, but understanding WHY the question was asked.
Re: Writing to IM_ItemCos t
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-02-2011 06:14 PM
Tom,
All numeric fields in IM_ItemCost are set to Read Only in the dictionary. That's why you can't import them or change them in your script. I guess we must not want people messing with them.
Sr. Software Engineer
Sage 100 ERP
Re: Writing to IM_ItemCos t
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-03-2011 08:14 AM
Was afraid of that. Makes sense to do that as someone mucking around in there can cause a lot of problems if they aren't careful.
I've registered a case with Tech Support to see if they can come up with a solution.
One way or another, we need to figure out why this is happening in the first place and keep it from recurring.
Target System Technology, Inc. - Spokane, WA -
The best solution often comes not from answering the question asked, but understanding WHY the question was asked.
Re: Writing to IM_ItemCos t
[ Edited ]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-13-2012 01:47 AM - last edited on 01-13-2012 02:13 AM
I am seeing that writes to a UDF string field does not work for this table either. I get a return code of 1, but nothing changes. Can you confirm this Natasha or Tom?
Set oItemCost = oSession.AsObject(oSession.GetObject("IM_ItemCost_ bus"))
retVal1 = oItemCost.SetKeyValue("ItemCode$", sItemCode)
retVal2 = oItemCost.SetKeyValue("WarehouseCode$", WAREHOUSE)
retVal3 = oItemCost.SetKeyValue("TierType$", "3")
retVal4 = oItemCost.SetKeyValue("GroupSort$", sLotSerialNumber)
retVal = oItemCost.SetKey()
retVal = oItemCost.GetValue("UDF_LOCATION", sLocation) ' retVal = 1 and Works!
retVal = oItemCost.SetValue("UDF_LOCATION", sLotSerialNumber) ' retVal = 1 but doesn't work
Dan
Re: Writing to IM_ItemCos t
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-13-2012 07:33 AM
Hi Dan,
In your example is the "UDF_Location" a string or a numeric? You are trying to return the numeric variable UDF_Location, and store a string variable into it.
retVal = oItemCost.SetValue("UDF_Location$", sLotSerialNumber)
Give that a try.
Elliott
Re: Writing to IM_ItemCos t
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-13-2012 09:01 AM
Elliott,
Thanks for the reply, but there is acually a $ in the code it was a typo in this post. I had used a constant in the actual code:
Const LOCATION = "UDF_LOCATION$"
...
retVal = oItemCost.SetValue(LOCATION, sLotSerialNumber)
I was just trying to abbreviate and take out all of the debugging code. The UDF is definitely a string. I can set it in DFD&M and retrieve it with a GetValue.
Re: Writing to IM_ItemCos t
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-13-2012 09:13 AM
I'm sure you have verified this, but:
Did you declare sLotSerialNumber as a string? Does it have a value? Strange, after you do the Write() it's not in the file?
Can you try a hard-coded string, and then retrieve it right after?
retVal = oItemCost.SetValue("UDF_Location$", "ABC")
tmpVar = ""
retVal = oItemCost.GetValue("UDF_Location$", tmpVar)
I'll set something up here and see if I can reproduce this.
Elliott
Re: Writing to IM_ItemCos t
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-13-2012 09:50 AM
Yes, I have my string variables initialized to an empty string and I have also set a value into UDF_Location via DFD&M which is not changing.
WOW though! I tried as you suggested and did a
tmpVar = ""
retVal = oItemCost.SetValue("UDF_Location$", "ABC")
retVal = oItemCost.GetValue("UDF_Location$", tmpVar)
AND THE tmpVar is set to "ABC", but the field in the table is NOT altered. Weird. Someone must be able to explain this.


