Exceptions with Empty Messages

SUGGESTED

Note the is a .NET application written in C#.

I have an application that imports orders, purchase orders and inventory items into Sage. The customer supplies a file that contains all of the purchase orders w/items. The file is parsed into purchase orders and inventory items. The customer does not keep an actual inventory so each item is added to the inventory with associated vendor/pricing information. The purchase orders are then created. The order is then created from the list of items on the purchase orders. The order is then "finalized" by adding some miscellaneous charges and setting the tax group to use Avalera. This all works perfectly.

At this point they can process a file that contains updates. This file just contain a diff of the "new" and "old" order. The file is parsed much like the original file except that there are "actions" associated with things. The actions include add items, modify items, delete items, add purchase orders and delete purchase orders. If follows similar logic as the original processing.

The problem.

Everything is appears to be processed correctly except there are exceptions thrown when when some items are deleted. The exception that is caught has the typical "Error HRESULT E_FAIL has been returned from a call to a COM component." message. At this point the session errors are examined. There are no entries that have a priority of Error. There sometimes are Warnings about "Information needed to set up the unit price does not exist for price list B, item MBRMET605380XSSP63877. The price list record may not exist, or details have not been entered to price multiple units of measure.". With regard to the warnings, non of them reference the item that is being deleted. The items mentioned are not adjacent to the item being deleted. At this point the processing continues and the updated order posts without errors. The result is not a correct order but there are no errors when the Update method is called.

I am at a loss as to how to attack this. If the item being deleted was referenced in the session errors list I would have something to work off of, but that is not the case.

Deleting the item in question in the UI works fine.

Any ideas?

  • 0

    Make sure all items have price list entries.

  • 0

    I fixed the pricelist warnings but still have the exception with 0 errors in Session.Errors

  • I'd create a public variable and update it with the current item being used in any operation.  Add the variable to all error traps' output so you have your item reference.

  • I already log just about everything that I can. The  price list warnings were a red herring and have been dealt with. Obviously there is something wrong with deleting this and 2 other items because Sage is through an exception. I can't think of why it would do that and then not have anything in the Errors collection. A lot of items are being added and deleted in the process for this single order. These "bad" deletions also do not happen together.

    The basic flow is:

    1. Setup the Views
    2. Do an Init on the Orders view
    3. Set the ORDNUMBER
    4. Set the key to 1
    5. Do a Read
    6. Process the Detail Items

    Add Detail Item Processing:

    1. If the item goes at the end of the list:
      1. Browse with a filter of LINETYPE = "1"
      2. Go to Bottom
    2. If the items goes between to existing items:
      1. Browse with a filter of ITEM = "<ITEMNUMBER>"
      2. Fetch
      3. Read
    3. Record Create
    4. Set fields
    5. Insert into the Details View

    Delete Detail Item Processing:

    1. Go to Top
    2. Browse with a filter of ITEM = "<ITEMNUMBER>"
    3. Read
    4. Delete

    After all of the Detail Items are processed, I do an Update on the Orders View.

    This works for all of the orders that have been processed and it works for the majority of the items in this particular order

  • 0 in reply to Rob Trainer

    If you have shipped a single item, you cannot delete lines.

  • 0 in reply to Rob Trainer

    In addition to Jay's response I'll add: ALWAYS set your keys back to 0 before inserting/updating. Otherwise, you can get updates that 'kind of work' and misleading errors.  If you want to find a record based on the order number, set to key to 1, do the read and then set the key to 0. It won't change the record that you're looking at.

  • 0 in reply to Django

    I will give it a try.

    Just highly annoyed that there is no error in the session. Makes impossible to know what is going on especially when other inserts/delete work find

  • 0 in reply to Rob Trainer

    No change.

    Question: I do an Init, set ORDNUMBER, set Order and then do a read. for the detail I do a GoTop, browse, then a Read and then the Delete. Do I need to do a Fetch in there somewhere?

  • 0 in reply to Rob Trainer
    SUGGESTED

    I have an object that wraps around the order views so I use the following to navigate to an order.

    public function ReadOrderNumber(aOrderNumber as string) as Boolean
        OEOrderHeader.Cancel
        OEOrderHeader.Order = 1
        OEOrderHeader.Fields("ORDNUMBER").PutWithoutVerification aOrderNumber
        ReadOrderNumber = OEOrderHeader.Read
        OEOrderHeader.Order = 0

    end function

    For the detail lines, I have a few functions. This one will use the key field and because I'm filling all of the keys of the index I can use .Read.

    Public Function FindDetail_LineNo(aOrderLineNo As Long) As Boolean

        FindDetail_LineNo = False
        With OEOrderDetail
            .Order = 0
            .Fields("LINENUM").PutWithoutVerification (aOrderLineNo)

            If .Read Then
                FindDetail_LineNo = True
                LastOELineNumber = .Fields("LINENUM").value
            End If

        End With

    End Function

    And this version will search using the DETAILNUM field.  I could be more efficient and change the order to a better key but I didn't.  So this version uses browse/fetch.

    Public Function FindDetail_DetailNum(aOrderLineDetailNum As Long) As Boolean

        FindDetail_DetailNum = False
        With OEOrderDetail
            .Fields("LINENUM").PutWithoutVerification -32000

            .Browse "DETAILNUM=" & aOrderLineDetailNum, True

            If .Fetch Then
                FindDetail_DetailNum = True
                LastOELineNumber = .Fields("LINENUM").value
            End If

        End With

    End Function