0

How can I trace the error I get when running a VB.Net program against Sage 300 ERP 2018? I get System.Runtime.InteropServices.COMException error in the oeDetail.Update() command below. I have a session and composed the views. I copied the code from a VBA macro (where it works)

    oeHeader.Fields.FieldByName("DRIVENBYUI").SetValue("0", False)    ' Driven by UI

    ' Search OE
    oeHeader.Init()
    oeHeader.Fields.FieldByName("ORDUNIQ").SetValue("1985", False)     ' Order Number
    oeHeader.Order = 1
    Dim res = oeHeader.Read(False)

    ' Update Detail
    oeDetail.Fields.FieldByName("LINENUM").SetValue("32", False)
    oeDetail.Read(False)
    ' Quantity Ordered
    oeDetail.Fields.FieldByName("QTYORDERED").SetValue("5.0000", False)    ' Quantity Ordered
    oeDetail.Update()

    oeHeader.Fields.FieldByName("OECOMMAND").SetValue("4", False)
    oeHeader.Process()
    oeHeader.Update()

Thanks

Samuel Lelièvre
  • 3,212
  • 1
  • 14
  • 27
aym
  • 233
  • 1
  • 4
  • 17

1 Answers1

0

Stick the whole thing in a try/catch block. Then in the catch block do something like this:

                        try
                        {
                            oESHIH.Fields.FieldByName("INVNUMBER").SetValue(sInvoiceNumber, true);
                        }
                        catch(Exception ex)
                        {
                            WriteLogFile.WriteLog("Error inserting invoice number: " + sInvoiceNumber + " for customer: " + sCustomerID);

                            for (int i = 0; i < accpacSession.Errors.Count; i++)
                            {
                                WriteLogFile.WriteLog("Sage error message: " + accpacSession.Errors[i].Message);
                            }
                        }

The line "accpacSession.Errors[i].Message" is where it picks the internal Sage message up.

snert
  • 15
  • 6