Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quantity checking inquotes

Status
Not open for further replies.

johnny9864

Programmer
Sep 27, 2013
35
CA
I have a problem with a system creating Quotes/Orders programmatically.
For Orders there is no problems when an item will fall under 0 quantity I have a COM exception and I show the ACCPAC error to the user (we are setup not to allow negative quantities).

For Quotes I get the same error but I am not sure what to do with it. If I record a macro in ACCPAC and change quantities I don't see anything different from an Order and all goes well. If I do in my application the same I get the error for the negative quantity.

If I just ignore the error it seems like the Quote will not get updated. Does the ACCPAC UI change something I am not seeing in the macro that will prevent the negative quantity error?
 
From code that I wrote a long time ago. It might help. The NEGINVENT field in the detail line can prevent the negative inventory warning from appearing.

Code:
Private Sub dsOrderDetails_OnRecordChanged(ByVal eReason As AccpacCOMAPI.tagEventReason, ByVal pField As AccpacDataSrc.IAccpacDSField, ByVal pMultipleFields As AccpacDataSrc.IAccpacDSFields) 
    If eReason = RSN_REFRESH Then 
        If dsOrderDetails.fields("NEGINVENT").Value Then 
            dsOrderDetails.fields("NEGINVENT").Value = False 
        End If 
    End If 
End Sub
 
No it didn't work DjangMan and the funny thing is after I reread the detail line the "NEGINVENT" field is false but still, the error comes up when processing the quote.
 
I'm surprised that a quote is impacting available quantity. A quote is just a quote and not a commitment. You're certain that your TYPE field is set to Quote?
 
Surprising indeed and type is 4, I verified. And if I open the document in the ACCPAC UI I have no problems.

Its getting very annoying !
 
I did a very simple test in C# to see if maybe my code was interfering but I get the same problem. As soon as I hit the line "OEORD1detail1.Update();" I get the COM error and if I verify the content of the ACCPACError[0] value it is a warning for negative Quantity and the line doesn't update.

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ACCPAC_OE_Screen
{
    public partial class TestForm : Form
    {
        private ACCPAC.Advantage.Session accpacSession;
        private ACCPAC.Advantage.DBLink mDBLinkPHARW;
        private ACCPAC.Advantage.View OEORD1header;
        private ACCPAC.Advantage.ViewFields OEORD1headerFields;
        private ACCPAC.Advantage.View OEORD1detail1;
        private ACCPAC.Advantage.ViewFields OEORD1detail1Fields;
        private ACCPAC.Advantage.View OEORD1detail2;
        private ACCPAC.Advantage.ViewFields OEORD1detail2Fields;
        private ACCPAC.Advantage.View OEORD1detail3;
        private ACCPAC.Advantage.ViewFields OEORD1detail3Fields;
        private ACCPAC.Advantage.View OEORD1detail4;
        private ACCPAC.Advantage.ViewFields OEORD1detail4Fields;
        private ACCPAC.Advantage.View OEORD1detail5;
        private ACCPAC.Advantage.ViewFields OEORD1detail5Fields;
        private ACCPAC.Advantage.View OEORD1detail6;
        private ACCPAC.Advantage.ViewFields OEORD1detail6Fields;
        private ACCPAC.Advantage.View OEORD1detail7;
        private ACCPAC.Advantage.ViewFields OEORD1detail7Fields;
        private ACCPAC.Advantage.View OEORD1detail8;
        private ACCPAC.Advantage.ViewFields OEORD1detail8Fields;
        private ACCPAC.Advantage.View OEORD1detail9;
        private ACCPAC.Advantage.ViewFields OEORD1detail9Fields;
        private ACCPAC.Advantage.View OEORD1detail11;
        private ACCPAC.Advantage.ViewFields OEORD1detail11Fields;
        private ACCPAC.Advantage.View OEORD1detail10;
        private ACCPAC.Advantage.ViewFields OEORD1detail10Fields;
        private ACCPAC.Advantage.View OEORD1detail12;
        private ACCPAC.Advantage.ViewFields OEORD1detail12Fields;
        private ACCPAC.Advantage.Errors errors;
        private Int16 editingLine = 32;  // LIne number to be edited

        public TestForm()
        {
            InitializeComponent();

            try
            {
                accpacSession = new ACCPAC.Advantage.Session();
                accpacSession.Init("", "XX", "XX1000", "56A");
                accpacSession.Open("ADMIN", "", "IBXPHA", DateTime.Now, 0);
                mDBLinkPHARW = accpacSession.OpenDBLink(ACCPAC.Advantage.DBLinkType.Company, ACCPAC.Advantage.DBLinkFlags.ReadWrite);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.InnerException.Message, "ACCPAC connection error", MessageBoxButtons.OK);
            }

            OEORD1header = mDBLinkPHARW.OpenView("OE0520");
            OEORD1detail1 = mDBLinkPHARW.OpenView("OE0500");
            OEORD1detail2 = mDBLinkPHARW.OpenView("OE0740");
            OEORD1detail3 = mDBLinkPHARW.OpenView("OE0180");
            OEORD1detail4 = mDBLinkPHARW.OpenView("OE0526");
            OEORD1detail5 = mDBLinkPHARW.OpenView("OE0522");
            OEORD1detail6 = mDBLinkPHARW.OpenView("OE0508");
            OEORD1detail7 = mDBLinkPHARW.OpenView("OE0507");
            OEORD1detail8 = mDBLinkPHARW.OpenView("OE0501");
            OEORD1detail9 = mDBLinkPHARW.OpenView("OE0502");
            OEORD1detail10 = mDBLinkPHARW.OpenView("OE0504");
            OEORD1detail11 = mDBLinkPHARW.OpenView("OE0506");
            OEORD1detail12 = mDBLinkPHARW.OpenView("OE0503");

            OEORD1header.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1, null, OEORD1detail3, OEORD1detail2, OEORD1detail4, OEORD1detail5 });
            OEORD1headerFields = OEORD1header.Fields;
            OEORD1detail1.Compose(new ACCPAC.Advantage.View[] { OEORD1header, OEORD1detail8, OEORD1detail12, OEORD1detail9, OEORD1detail6, OEORD1detail7 });
            OEORD1detail1Fields = OEORD1detail1.Fields;
            OEORD1detail2.Compose(new ACCPAC.Advantage.View[] { OEORD1header });
            OEORD1detail2Fields = OEORD1detail2.Fields;
            OEORD1detail3.Compose(new ACCPAC.Advantage.View[] { OEORD1header, OEORD1detail1 });
            OEORD1detail3Fields = OEORD1detail3.Fields;
            OEORD1detail4.Compose(new ACCPAC.Advantage.View[] { OEORD1header });
            OEORD1detail4Fields = OEORD1detail4.Fields;
            OEORD1detail5.Compose(new ACCPAC.Advantage.View[] { OEORD1header });
            OEORD1detail5Fields = OEORD1detail5.Fields;
            OEORD1detail6.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1 });
            OEORD1detail6Fields = OEORD1detail6.Fields;
            OEORD1detail7.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1 });
            OEORD1detail7Fields = OEORD1detail7.Fields;
            OEORD1detail8.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1 });
            OEORD1detail8Fields = OEORD1detail8.Fields;
            OEORD1detail9.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1, OEORD1detail10, OEORD1detail11 });
            OEORD1detail9Fields = OEORD1detail9.Fields;
            OEORD1detail10.Compose(new ACCPAC.Advantage.View[] { OEORD1detail9 });
            OEORD1detail10Fields = OEORD1detail10.Fields;
            OEORD1detail11.Compose(new ACCPAC.Advantage.View[] { OEORD1detail9 });
            OEORD1detail11Fields = OEORD1detail11.Fields;
            OEORD1detail12.Compose(new ACCPAC.Advantage.View[] { OEORD1detail1 });
            OEORD1detail12Fields = OEORD1detail12.Fields;

            OEORD1headerFields.FieldByName("DRIVENBYUI").SetValue("0", false);


            OEORD1header.Cancel();
            OEORD1header.Init();
            OEORD1detail2.Browse("", true);

            OEORD1headerFields.FieldByName("ORDNUMBER").SetValue("QT000507", false);

            OEORD1header.Order = 1;
            OEORD1header.Read(false);
            OEORD1header.Order = 0;

            OEORD1detail1.RecordClear();
            while (Convert.ToInt32(OEORD1detail1Fields.FieldByName("LINENUM").Value) != editingLine)
            {
                OEORD1detail1.GoNext();
            }

            OEORD1detail1.Fields.FieldByName("QTYORDERED").SetValue(10, true);  //Change Quantity

            bool nothing = OEORD1header.Exists;
            OEORD1detail1.Update();
            OEORD1detail1Fields.FieldByName("LINENUM").SetValue(editingLine, false);
            OEORD1detail1.Read(false);
            OEORD1headerFields.FieldByName("OECOMMAND").SetValue(4, true);
            OEORD1header.Process();
            OEORD1header.Update();
            OEORD1header.Read(false);
            OEORD1detail1.RecordClear();
            while (Convert.ToInt32(OEORD1detail1Fields.FieldByName("LINENUM").Value) != editingLine)
            {
                OEORD1detail1.GoNext();
            }

        }
    }
}
 
Try setting DRIVENBYUI to 1. It does change how some of the logic works.

Also - I don't see where you're setting the order to a quote.
 
No Djangman, I tried changing the value for "DRIVENBYUI" and no difference.

I am simply opening here an existing in-completed quote and modify the quantity for an existing line. I verified the status of the OEORD1Header to make sure I have the right header and the "TYPE" is really set as 4 just before updating the detail line.
 
I'm not able to reproduce. I recorded a macro and stripped it down to do more or less what you're doing. I'm using sample data and turned off allowing negative inventory.

Code:
OEORD1header.Cancel
OEORD1header.Init
OEORD1headerFields("ORDNUMBER").PutWithoutVerification "QT0000000000001"              ' Order Number
OEORD1header.Order = 1
OEORD1header.Read
OEORD1header.Order = 0

OEORD1detail1.RecordClear
OEORD1detail1.GoNext

OEORD1detail1Fields("QTYORDERED").Value = "1350.0000"                  ' I have 137 available at this location.

OEORD1detail1.Update
OEORD1detail1.Read

OEORD1headerFields("OECOMMAND").Value = "4"                           ' Process O/E Command
OEORD1header.Process
OEORD1header.Update
OEORD1header.Read

Try recording a macro while you edit the same quote and then try to get the macro to fail like your .net code is failing. If the macro works then we can point to your .net code or .net interface somewhere. If the macro fails then my testing didn't catch the issue.

This might not be of consequence but your editingline variable is defined as Int16 instead of Int32. We're down to the "that shouldn't matter" stage so I figured it might be worth a try.

Also, try running rvSpy to confirm that Accpac is looking at the right inventory item.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top