Adding Shipments to MasterPack in Function

Hi,
I am making progress with one of my customizations with the help of others here. Some background - we sometimes ship many single cartons for a single order line/product via UPS. My understanding from multiple Epicor sources is that in order to create the required EDI ASN document that includes individual tracking numbers will require creating Customer Shipments for each carton (one carton per shipment entry) and then a Master Pack to aggregate the individual packs. Even Quickship would require this if we decided to use that for UPS. I already have an external app that creates the UPS shipment and returns the labels and tracking numbers in our existing system and generate a CSV file from there. With my prior postings here and the responses, I so far have functions I can call via Rest to create the individual shipments and create a Master Pack header. I am unable to add the Shipments to the Master pack using a widget based approach or a code based approach, even though both seem to follow the trace file I collected. I have worst case approaches- one being generate a DMT file and use the DMT command line (works but difficult to handle errors) or use my functions up until the Master Pack detail step and use a generated Excel file to have the user Paste Insert in the Master Pack screen (works but an extra step for users). Here is my current code- any help is appreciated if someone has tried this successfully.

        this.CallService<Erp.Contracts.MasterPackSvcContract>(csc => {
            Erp.Tablesets.MasterPackTableset tsMasterPack = new Erp.Tablesets.MasterPackTableset();
             try
            {
                string ostr = "";
                tsMasterPack = csc.GetByID(inMPack);

                tsMasterPack.MasterPack[0].RowMod = "U";
                var tsPack = tsMasterPack.MasterPack[0].PackNum.ToString();
                csc.GetNewMasterPackDtl(ref tsMasterPack, inPack);

                var ret = csc.CartonExists(inPack, "SALES");

                ostr = csc.CheckShipStatus(inPack, "SALES");
                // Added Carton Detail as it does not seem to exist otherwise at this point even though no BO call in trace for this
                var carton = new Erp.Tablesets.CartonDetailRow();
                carton.PackNum = inMPack;
                carton.DtlPackNum = inPack;
                carton.OrderLine = 1;
                carton.OrderNum = 1197;
                carton.PartNumber = "XXX";
                carton.RowMod = "A";
                carton.PackQty = 1.00M;
                carton.Company = "XXXX";
                carton.PackLine = 1;
                tsMasterPack.CartonDetail.Add(carton);

                //Trace calls these twice sometimes?
                ostr = csc.CheckShipStatus(inPack, "SALES");//
                var exists = csc.CartonExists(inPack, "SALES");

                //Exception "Invalid Carton" calling the following
                csc.GetShipDetails(ref tsMasterPack, inMPack, inPack, "SALES");

                tsMasterPack.MasterPack[0].RowMod = "U";
                csc.Update(ref tsMasterPack);
            }
            catch (Exception ex)
            {
                throw new Ice.BLException("Exception with: Master Pack " + inMPack.ToString() + "/" + inPack.ToString() + "]" + ex.Message + "     " + ex.StackTrace);
            }

        });

Hi Carl, I think I encounter a similar issue when creating a PackDtl, which I manage to solve. My code for creating a PackDtl looks like this.

masterPackSvc.GetNewMasterPackDtl(ref mpTs, masterPack.PackNum);
var exists = masterPackSvc.CartonExists(singlePack.PackNum, "Sales");
var checkShipStatus = masterPackSvc.CheckShipStatus(singlePack.PackNum, "Sales");

//set the Row Mod of the MasterPackHeader to "U"
masterPack.RowMod = IceRow.ROWSTATE_UPDATED;
masterPackSvc.GetShipDetails(ref mpTs, masterPack.PackNum, singlePack.PackNum, "Sales");


// I get the last MasterPackDtl Record (which is the one I created), I set the RowMod to "A" and I set the PackNum
var masterPackDtl = mpTs.MasterPackDtl.LastOrDefault();
masterPackDtl.RowMod = "A";
masterPackDtl.DtlPackNum = singlePack.PackNum;
// Finally I setthe MasterPackHeader RowMod to U and I update
masterPack.RowMod = IceRow.ROWSTATE_UPDATED;
masterPackSvc.Update(ref mpTs);

I hope this helps.

Hi,
Thank you so much!!! That works!!!

Carl

1 Like

Nice Carl!