Purging Records from UDT used as Lookup Table on Sales Order Entry

SOLVED

I have developed a UDT and using as a lookup table for UDF in Sales Order Entry.  Prior to updating the table with new look up values my script is:

Do until oUDT.Eof = 1
     retVal = oUDT.GetValue("UDF_SHIP_VIA$",Via)
     if Via <> "" then
          Counter = Counter +1
          ocsVal = oScript.DebugPrint("UDT Delete Count: " & Counter)
          retVal = oUDT.Delete()
     end if
     retVal = oUDT.MoveNext()
Loop

The End of File value is 1 and no records are deleted.  

I have tied the purge script to:  PostLoad and OnExit of forms, a link button, table prewrite and table load.  Nothing is working.  

Parents
  • 0

    Yes I am have "retVal = oUDT.MoveFirst() " in script.  I failed to include in paste to post.

  • 0 in reply to SilverFox

    How are you opening the UDT?

  • 0 in reply to Kevin M

    Full Script:

    retVal = 0 : ocsVal = "" : Counter = 0 : oUDT = 0 : Via = ""

    if oSession.Updating = 0 and oSession.StartProgram = "SO_SALESORDER_UI" then
    oUDT = oSession.GetObject("CM_UDTMaint_bus", "SO_UDT_SHIP_ACTIVE")
    SET oUDT = oSession.AsObject(oUDT)

    ocsVal = oScript.DebugPrint("Purging Lookup Records using purge script")

    ' Reinitialize UDT first
    retVal = oUDT.MoveFirst()
    ocsVal = oScript.DebugPrint("retVal on MoveFirst: " & retVal & "/" & oUDT.LastErrorMsg)
    ocsVal = oScript.DebugPrint("oUDT.Eof: " & oUDT.Eof)
    retVal = oUDT.GetValue("UDF_SHIP_VIA$",Via)
    ocsVal = oScript.DebugPrint("Via: " & Via)

    Do until oUDT.Eof = 1
    if Via <> "" then
    Counter = Counter +1
    ocsVal = oScript.DebugPrint("UDT Delete Count: " & Counter)
    ocsVal = oScript.DebugPrint("Via: " & Via)
    retVal = oUDT.Delete()
    end if
    retVal = oUDT.MoveNext()
    Loop
    end if

  • 0 in reply to SilverFox

    It could be permissions.  I always check for access when creating new objects in a script.  Example:

    oSequenceTable = oSession.GetObject("CM_UDTMaint_bus", "SO_UDT_SEQUENCE")
    if oSequenceTable <> 0 then
    	Set oSequenceTable = oSession.AsObject(oSequenceTable)
    else	
    	retVal = oSession.AsObject(oSession.UI).MessageBox("", "Access to SO_UDT_SEQUENCE is required for the ??? script to work.")
    	exit sub
    end if

  • 0 in reply to Kevin M

    No change.  3 records exist in the table but the trace is:

    SCRIPT/CallScript - RefCount:01 Class:SO_SalesOrder_UI Proc:PostloadPADDRESS **
    Purging Lookup Records using purge script
    retVal on MoveFirst: 0/The file is empty or does not match filter.
    oUDT.Eof: 1
    Via:

Reply Children