Having a bit of frustration with creating a part lot record from form code. I’m creating Part Lot records on the fly to create user testing data. I’m attempting doing it by following the same methods that fire from a quantity adjustment transaction, but I keep failing at the end when I try to call the SetInventoryQtyAdj method from the Inventory Quantity Adjustment adapter. Here’s what I’ve tried:
string errorLocation = String.Empty;
for(int i = 0; i<recs; i++)
{
try{
//try creating part lots for test parts and give them a qty
//Lot Adapter
LotSelectUpdateAdapter adapterLSA = new LotSelectUpdateAdapter(oTrans);
adapterLSA.BOConnect();
bool result = adapterLSA.GetNewPartLot(partNum);
if(result){
//lotDataSet and part lot row approach. Set plRow to random lot
LotSelectUpdateDataSet lsaData = adapterLSA.LotSelectUpdateData;
LotSelectUpdateDataSet.PartLotRow plRow = (LotSelectUpdateDataSet.PartLotRow)lsaData.PartLot[0];
errorLocation= "245";
//generate random lot number
lotNumRand = RandomString(7);
plRow.LotNum = lotNumRand;
adapterLSA.GetByID(partNum,lotNum);
adapterLSA.Update();
errorLocation = "251";
//MessageBox.Show(adapterLSA.GetByID(partNum,lotNum).ToString());
if(adapterLSA.GetByID(partNum,lotNum)){
//set the inventory quantity
InventoryQtyAdjAdapter adapterQtyAdj = new InventoryQtyAdjAdapter(oTrans);
adapterQtyAdj.BOConnect();
//get by ID?
InventoryQtyAdjDataSet qtyAdjData = adapterQtyAdj.InventoryQtyAdjData;
errorLocation = "259";
//Neg inv test
string pcMessage;
string pcNeqQtyAction;
adapterQtyAdj.NegativeInventoryTest(partNum, "52", "receipt", lotNumRand,"", "EA", 1, -1, out pcNeqQtyAction, out pcMessage);
//Pre Set Inv Qty Adj row and method
//InventoryQtyAdjDataSet.InventoryQtyAdjRow qaRow = (InventoryQtyAdjDataSet.InventoryQtyAdjRow)qtyAdjData.InventoryQtyAdj[0]; //No Row exists, try creating one
InventoryQtyAdjDataSet.InventoryQtyAdjRow qaRow = (InventoryQtyAdjDataSet.InventoryQtyAdjRow)qtyAdjData.InventoryQtyAdj.NewInventoryQtyAdjRow();
errorLocation = "267";
qaRow.BinNum = "receipt";
qaRow.AdjustQuantity = 1;
qaRow.ReasonCode = "DJ002";
qaRow.LotNum = lotNumRand;
qaRow.ReasonCodeDescription = "Accounting Adjust Disposition";
qaRow.WhseBinDescription = "Receipt Denver";
adapterQtyAdj.Update();
errorLocation = "275";
bool requiresUserInput;
adapterQtyAdj.PreSetInventoryQtyAdj(out requiresUserInput);
//Set Inv Qty Adj, no attributes called
string partTranPKs;
qaRow.RowMod = "U";
adapterQtyAdj.SetInventoryQtyAdj(qtyAdjData,out partTranPKs);
//cleanup adapter
adapterQtyAdj.Dispose();
}
Specifically the error I get is at my fancy location marker “275” and the error message is “ttInventoryQtyAdj record not found”, which seems to tell me that I haven’t provided a valid data set for that method to consume.
Probably a long shot, but if anyone has done something similar, I’d appreciate any help. Thanks
If you look at a Trace you are missing the following calls, those get you an inventory InventoryQtyAdjDataSet which you can then update to change the quantity
Thanks Jose,
I was basically following the trace from an inventory qty adjustment transaction, but I did not see those methods until much later in the transaction. I will try calling those methods, thank you for your help!
It does not. Before I call this code block, I am (I think) creating the lot shell.
I intended to create the actual inventory with this quantity adjustment transaction though, just as I would if interacting through the quantity adjustment form.
for(int i = 0; i<recs; i++)
{
try{
//try creating part lots for test parts and give them a qty
//Lot Adapter
LotSelectUpdateAdapter adapterLSA = new LotSelectUpdateAdapter(oTrans);
adapterLSA.BOConnect();
bool result = adapterLSA.GetNewPartLot(partNum);
if(result){
//lotDataSet and part lot row approach. Set plRow to random lot
LotSelectUpdateDataSet lsaData = adapterLSA.LotSelectUpdateData;
LotSelectUpdateDataSet.PartLotRow plRow = (LotSelectUpdateDataSet.PartLotRow)lsaData.PartLot[0];
errorLocation= "245";
//generate random lot number
lotNumRand = RandomString(7);
MessageBox.Show(lotNumRand);
plRow.LotNum = lotNumRand;
adapterLSA.GetByID(partNum,lotNum);
adapterLSA.Update();
errorLocation = "251";
if(adapterLSA.GetByID(partNum,lotNum)){ //this is where the above code then starts.
Edit: Yes there is inventory in the system, but I am attempting to create more from this code. I don’t think I answered your question properly.
This is fantastic, thank you Jose! I am curious as to why this solution works though. From what I can see, in my code, I referenced the row, which apparently doesn’t exist in the way I think it does. In your above code, what index are you going after?
I think the function you were using GetInventoryQtyAdj returns a dataset vs the one I used GetInventoryQtyAdjustmentData merges the dataset into the adapter. That’s likely the issue
Same Exact error in Service Connect. Same exact methods called as Aaron did. Unfortunately, GetInventoryQtyAdjustmentData is not an available method to use in the InventoryQtyAdj adapter.
If you guys have any ideas, i’d greatly appreciate it.
Just an idea, but is there a way for you to hydrate a dataset without calling the GetInventoryQtyAdjusmentData method?
Once that’s filled out, there might be a way to call the code above (or a variation of) to accomplish the task.
Just figured it out. Thanks for the input. A silly mistake by me really. If anyone else runs into this while Building a Service Connect solution, you need to hardcode an A for the RowMod on the conversion going to the InventoryQtyAdj.PreSetInventoryQtyAdj Request.