Over the years we have accumulated General Alias item numbers in our inventory that we would like to purge without having to do so one-by-one. Can it be done through VI?
That's exactly what I would do, and have done for the Price Code file.
I don't know about VI, but here is a script that I wrote to delete aliases that are the same as the Item Code. You should be able to easily modify it to do what you need. It is not very beautiful, but…
A script would be best as VI is not designed to delete records, just add or edit.
I don't know about VI, but here is a script that I wrote to delete aliases that are the same as the Item Code. You should be able to easily modify it to do what you need. It is not very beautiful, but I only needed to run it once.
And the usual disclamer... WARNING - BACKUP BEFORE YOU RUN THIS!
' Deletes all Aliases where ItemCode = AliasItemNo
Set oScript = CreateObject("ProvideX.Script")
oScript.Init("M:\M90V440\MAS90\HOME")
Set oSession = oScript.NewObject("SY_Session")
password = Trim(InputBox("Passowrd"))
' TODO - better password entry form
If Not CBool(oSession.nSetUser("DSL", password)) Then
MsgBox oSession.sLastErrorMsg
oSession.nCleanup
oSession.DropObject
Set oSession = Nothing
Set oScript = Nothing
WScript.Quit
End If
retVal = oSession.nSetCompany("TEC")
If retVal = 0 Then
MsgBox oSession.sLastErrorMsg
oSession.nCleanup
oSession.DropObject
Set oSession = Nothing
Set oScript = Nothing
WScript.Quit
End If
retVal = oSession.nSetModule("I/M")
If retVal = 0 Then
MsgBox oSession.sLastErrorMsg
oSession.nCleanup
oSession.DropObject
Set oSession = Nothing
Set oScript = Nothing
WScript.Quit
End If
retVal = oSession.nSetDate("I/M", oSession.sSystemDate)
If retVal = 0 Then
MsgBox oSession.sLastErrorMsg
oSession.nCleanup
oSession.DropObject
Set oSession = Nothing
Set oScript = Nothing
WScript.Quit
End If
task = oSession.nLookupTask("IM_Item_ui")
If task = 0 Then
MsgBox "task not found"
oSession.nCleanup
oSession.DropObject
Set oSession = Nothing
Set oScript = Nothing
WScript.Quit
End If
retVal = oSession.nSetProgram(task)
If retVal = 0 Then
MsgBox oSession.sLastErrorMsg
oSession.nCleanup
oSession.DropObject
Set oSession = Nothing
Set oScript = Nothing
WScript.Quit
End If
Set oAlias = oScript.NewObject("IM_AliasItem_bus", oSession)
retVal = oAlias.nMoveFirst
Do
ItemCode = ""
retVal = oAlias.nGetValue("ItemCode$", ItemCode)
AliasItemNo = ""
retVal = oAlias.nGetValue("AliasItemNo$", AliasItemNo)
If ItemCode = AliasItemNo Then
retVal = oAlias.nDelete
If retVal = 0 Then
MsgBox oAlias.sLastErrorMsg
oAlias.DropObject
Set oAlias = Nothing
oSession.nCleanup
oSession.DropObject
Set oSession = Nothing
Set oScript = Nothing
WScript.Quit
End If
End If
oAlias.nMoveNext
Loop Until oAlias.nEOF
oAlias.DropObject
Set oAlias = Nothing
oSession.nCleanup
oSession.DropObject
Set oSession = Nothing
Set oScript = Nothing
MsgBox "Done"
Hey BigLouie, resurrecting this old thread as I have a very similar question and would like your (and possibly even dlech's) opinion on this. I have a client who has hundreds of Item Codes with both V and G Alias Item Numbers. They have a long list of Alias Item Numbers that need to be changed, but my testing has shown that instead of updating the existing numbers it just creates new ones, which is not what they want.
That's exactly what I would do, and have done for the Price Code file.
What Beth said.
Try it in a test company first (to verify your import works), and be careful with the reinit... there is no undo.
*Community Hub is the new name for Sage City