InventoryQtyAdjAdapter

Is the InventoryQtyAdjAdapter designed to plunge you into madness?

Or a more helpful question - has anyone successfully used this adapter?

I am boinking my way thru and it’s a damn mess. If I explicitly create a row in InventoryQtyAdjData - ala adj.InventoryQtyAdjData.InventoryQtyAdj.AddInventoryQtyAdjRow() then I get the error:
Cannot insert duplicate key row in object ‘Erp.PartFIFOCost’ with unique index ‘IX_PartFIFOCost’. The duplicate key value is (CP, X002, , 1, 2017-09-08, 1, 0).
The statement has been terminated.

Hmmm, I wasn’t aware I was inserting that row…

Otherwise creating my own copies of the datasets I get this error:
ttInventoryQtyAdj record not found.

Both datasets seem the same so I am puzzled.

You have to create a new ttInventoryQtyAdj, if I remember. I have some sample code somewhere. I think its in the office but if you can, create that tt and add it, then you should be ok. i think it changed at a certain patch, maybe 10.1.400.7.

1 Like

I am on V10.1.500.19. If you have some sample code I’d much appreciate it. I wouldn’t even know where\how to add a new ttInventoryQtyAdj record.

Sure – will do. It’s a bpm basically. You can type it as a var which is kinda’ lazy, or define your ttDataSet.DataTable.Row type which can be put in a try catch and initialised to null.

1 Like

I got it working using the created DS. After comparing the 2 ds’s, I guess I forgot to modify the actual data and set to modified lol

Here is some basic working code. Note that I have lot’s of info hardcoded for my use and little to no error checking (yet) - buyer beware.:

public static void Adjust(string PartNum, string BinNum, decimal AdjustQty)
        {
            string WH = "CPMAIN";
            string primaryBin;

            InventoryQtyAdjAdapter adj = new InventoryQtyAdjAdapter(oTrans);
            adj.BOConnect();
       
            string Company = ((Session)epiSession).CompanyID;
            const string ReasonCode = "PHY";//S
            string LotNum = ""; //??
            const string Reference = "PhysInvCC";
            DateTime TransDate = DateTime.Now;

            //Get from part eventually...
            string UnitOfMeasure = "EA";
            string StkUOMCode = UnitOfMeasure;
            string OnHandUOM = UnitOfMeasure;
            string PCID = "";
            Guid SysRowID = Guid.Empty;
           
            string PartIUM = UnitOfMeasure;
            string PartSalesUM = UnitOfMeasure;
            string ptran;

            bool multipleMatches = false;
            string question, serialWarning;
            string negact, pcmsg;
            bool reqUserInput = false;
            bool snRequired = false;

            adj.GetPartXRefInfo(ref PartNum, null, null, ref UnitOfMeasure, out serialWarning, out question, out multipleMatches); //get any xrefs
  
            InventoryQtyAdjDataSet iqadj = adj.GetInventoryQtyAdj(PartNum,""); //??ea?
            InventoryQtyAdjBrwDataSet ibrw = adj.GetInventoryQtyAdjBrw(PartNum, WH, out primaryBin); //used to get mainly bin info?
            adj.NegativeInventoryTest(PartNum, WH, BinNum, LotNum, "", UnitOfMeasure, 1, AdjustQty, out negact, out pcmsg);
            
            bool preSetOK = adj.PreSetInventoryQtyAdj(out reqUserInput);

            
            adj.CheckSN(PartNum, WH, out snRequired);
                iqadj.Tables[0].Rows[0]["RowMod"] = "M";
                iqadj.Tables[0].Rows[0]["ReasonCode"] = ReasonCode;
                iqadj.Tables[0].Rows[0]["BinNum"] = BinNum;
                iqadj.Tables[0].Rows[0]["AdjustQuantity"] = AdjustQty;
                iqadj.Tables[0].Rows[0]["Reference"] = Reference;

                adj.SetInventoryQtyAdj(iqadj, out ptran);
         

            adj.Update();
            adj.Dispose();
        }

@Chris Found it! I was trying to read the bpm file by unzipping it! I would be lost without my years of gathering sample code…. I have recently been thinking about releasing an api of helpers for standard customisation tasks module by module…anyway as attached. Hope it helps.

InventoryQtyAdjTableset JobAsmblDS = new InventoryQtyAdjTableset ();

var tt = new SelectedJobAsmblRow();

if(tt == null)

throw new Ice.BLException("Error: Record Not Found; InventoryQtyAdjTableset ");

tt.Company = Session.CompanyID;

tt.RowMod = “A”;

(ttInventoryQtyAdjDS.RequiredTT).Create();

(ttInventoryQtyAdjDS. RequiredTT).Add(tt);

export.bpm (269 KB)

I too had considered creating a friendly API. Maybe someday. Thanks for your help.

No worries. As I said it was problematic even in bl tester due to the failure to create that record but the good thing about the framework nowadays is you can do a lot of reflection.

1 Like

I put your code into my customization with custom assemblies:
Erp.Adapters.InventoryQtyAdj
Erp.Contracts.BO.InventoryQtyAdj
and I get the errors below.
I know it is something simple, but please help!
Thanks,
Richard

430 InventoryQtyAdjDataSet iqadj = adj.GetInventoryQtyAdj(PartNum,""); //??ea?
431 InventoryQtyAdjBrwDataSet ibrw = adj.GetInventoryQtyAdjBrw(PartNum, WH, out primaryBin); //used to get mainly bin info?
Compiling Custom Code …

----------errors and warnings------------

Error: CS0246 - line 430 (938) - The type or namespace name ‘InventoryQtyAdjDataSet’ could not be found (are you missing a using directive or an assembly reference?)
Error: CS0246 - line 431 (939) - The type or namespace name ‘InventoryQtyAdjBrwDataSet’ could not be found (are you missing a using directive or an assembly reference?)

** Compile Failed. **

Most likely using statements missing.

Try using Erp.Tablesets;