What the user does: four steps, one report
The whole customization lives on the Kinetic Miscellaneous Shipment Entry form. We added two buttons with Application Studio, Import and Print, and built everything else behind them.
- Create a pack slip and enter the job number.
- Click Import. The import BAQ finds every material issued to that job (from JobMtl and PartTran) that has not yet shipped, and loads those parts onto the pack slip.
- Save. The pack slip is written to MscShpHd and MscShpDt like any other miscellaneous shipment.
- Click Print. The SSRS Miscellaneous Pack Slip report renders, combining pack slip, job material and inventory transaction data in one document.
One click gives the shipping team and the customer what used to take several screens: for each part, the required and issued quantities and material sequence from JobMtl; the issue dates, transaction types, quantities and lot numbers from PartTran; and the pack slip number and ship date from the miscellaneous shipment.
Why the standard pack slip falls short
A miscellaneous pack slip should answer three questions on one page: what is leaving today, what already left, and what is still owed. The standard output answers only the first, and a naive custom BAQ often answers all three wrongly.
The trouble starts when one job ships on several pack slips. Material is issued to the job in many inventory transactions, shipped in many miscellaneous shipments, and sometimes reversed. Join those tables carelessly and the report multiplies rows, puts quantities on the wrong pack slip, or hides material that was issued but never shipped.
The rest of this article covers how we designed the data model, the allocation logic, the three-section SSRS layout, and every production error we hit on the way, with its fix.
Step 1: Separate “issued” from “shipped”
The most important rule: a PartTran STK-MTL row proves material was issued from stock to a job. It does not prove anything was shipped. Only MscShpHd and MscShpDt prove a shipment.
| Table | What it proves | Key columns used |
|---|---|---|
| JobHead | The job exists; header details | Company, JobNum, PartNum, ProjectID |
| JobMtl | What the job requires and what has been issued | MtlSeq, AssemblySeq, RequiredQty, IssuedQty, IUM |
| PartTran (STK-MTL) | Each issue (+) and reversal (−) to the job, with date and lot | JobSeq, AssemblySeq, TranDate, TranNum, TranType, LotNum, TranQty |
| MscShpHd | A pack slip exists for the job | PackNum, ShipDate, JobNum |
| MscShpDt | What each pack slip line shipped | PackLine, PartNum, MtlSeq, AssemblySeq, Quantity, LotNum |
| SNTran | Serial numbers tied to the material | MtlSeq, AssemblySeq, LotNum, SerialNumber |
The key that ties these together is Company + JobNum + PartNum + MtlSeq (JobSeq in PartTran) + AssemblySeq. Matching on PartNum and PackNum alone causes most wrong reports, because the same part can appear under several material sequences and assemblies on one job.
Which table should drive the report?
| Design | Driving table | Jobs with no shipment | Verdict |
|---|---|---|---|
| Shipment-driven | MscShpHd / MscShpDt | Print nothing | Clean, but hides what is still owed |
| Job-material-driven | JobMtl (IssuedQty > 0) | Print issued lines with a blank pack slip | Shows everything, but mixes shipped and unshipped |
| Hybrid | JobMtl, labelled by shipment status | Print issued lines in a clearly marked Pending section | Chosen |
The hybrid wins because the document often doubles as a Certificate of Conformance for a customer who needs both answers: what is in this box, and what is still coming. One rule keeps it honest: never invent a PackNum, ShipDate or shipped quantity from PartTran alone.
Step 2: Replace independent joins with quantity-range allocation
The first version joined shipment rows and transaction rows to JobMtl independently. With two shipments and two transactions for one material that produces four rows where two are correct. It also used ROW_NUMBER() to keep only the latest shipment, which pushed every transaction onto the newest pack slip.
The fix is to treat both sides as stacks of quantity and match them by position on a number line. Each shipment line occupies a half-open interval [ShipStart, ShipEnd); each surviving transaction occupies [TranStart, TranEnd). A shipment and a transaction belong together only where their intervals overlap, and the overlap length is the allocated quantity.
Worked example
One material with four issues (7, 9, 1 and 33 EA) and three pack slips (7, 10 and 33 EA), both stacked newest first:
The CTE chain
- ShipmentRanked / ShipmentCTE: running sum of MscShpDt.Quantity per material key, newest pack slip first, giving ShipEnd and ShipStart.
- PartTranPositive / PartTranNegative: positive STK-MTL rows with running totals; negatives summed per material and lot.
- PartTranReportCTE: applies reversals to the positives (step 3).
- PartTranCTE: groups surviving quantity by date, lot and unit of measure.
- PartTranRanked / PartTranRange: running sum newest date first, giving TranEnd and TranStart.
- ShipmentPartTran: the overlap join below.
-- ShipmentPartTran: allocate only where the two ranges overlap
FROM ShipmentCTE s
INNER JOIN PartTranRange t
ON s.Company = t.Company
AND s.JobNum = t.JobNum
AND s.PartNum = t.PartNum
AND s.MtlSeq = t.JobSeq
AND s.AssemblySeq = t.AssemblySeq
AND s.ShipStart < t.TranEnd
AND s.ShipEnd > t.TranStart
-- AllocatedQty = MIN(ShipEnd, TranEnd) - MAX(ShipStart, TranStart)
Both running sums must be ordered the same way (newest first) or the stacks drift apart. Add TranNum to the window ORDER BY so two transactions on the same date always sort the same way on every run.
Step 3: Handle reversals and same-day issues
Negative STK-MTL rows are returns or corrections. Allocate gross positives and the report shows material that went back to stock. Net them off first, against the oldest positives, so the most recent valid issue survives with its real date and lot.
-- PartTranReportCTE: surviving quantity per positive transaction
CASE
WHEN RunningPositive <= ISNULL(TotalNegative, 0) THEN 0
WHEN ISNULL(PreviousPositive, 0) < ISNULL(TotalNegative, 0)
THEN RunningPositive - ISNULL(TotalNegative, 0)
ELSE TranQty
END
RunningPositive and PreviousPositive are window sums ordered by TranDate and TranNum, partitioned by the full material key plus LotNum. That lets a large reversal carry across several earlier positives instead of stopping at one.
| Case | Transactions | Surviving |
|---|---|---|
| Full reversal | +15 (Sep 14), +15 (Oct 20), −15 | 15 on Oct 20 |
| Partial reversal | +525, −13 | 512 |
| Reversal larger than one issue | +2, +5, −1, then +2, +1 | 1 + 5, then 2 + 1 (newer issues untouched) |
| Two identical issues, same day | +1, +1 | One row of 2 |
The last row is deliberate. PartTranCTE groups by date, lot, unit of measure and the material key, but not by TranNum. Two issues of the same lot on the same day print as one line; different lots or dates stay separate. Adding TranNum to that GROUP BY is a common “fix” that doubles the line count on the pack slip.
Step 4: Split the SSRS report into Current, Previous and Pending
Every row gets a section number, and the RDL groups and colours by it:
| Section | Rule | Pack Slip column | Issued / Ship | Fulfilled | B/O |
|---|---|---|---|---|---|
| 1, Current | PackNum is the job’s highest PackNum | PackNum | Allocated qty | As calculated | As calculated |
| 2, Previous | Any other PackNum | PackNum | Allocated qty | As calculated | As calculated |
| 3, Pending: awaiting pack slip | No PackNum and IssuedQty > 0 | “Awaiting pack slip” | IssuedQty | 0 | IssuedQty |
| 3, Pending: not issued | RequiredQty > IssuedQty | “Not issued” | 0 | 0 | Required − Issued |
| Hidden | No PackNum, IssuedQty = 0, nothing required | — | — | — | — |
Why the highest PackNum and not the latest ShipDate? The import always creates the newest pack slip with the next number, while ship dates are typed and can be back-dated. On our data the two disagreed for dozens of jobs. Pick one rule, document it, and use it everywhere.
Option A: calculate the section in the SSRS dataset
If the BAQ cannot change quickly, derive the section in the report’s own dataset query, so the logic lives in one place. A simplified version:
SELECT r.*,
CASE WHEN r.MscShpHd_PackNum IS NULL THEN 3
WHEN r.MscShpHd_PackNum = (SELECT MAX(x.MscShpHd_PackNum)
FROM BAQReportResult_<guid> x
WHERE x.JobHead_JobNum = r.JobHead_JobNum) THEN 1
ELSE 2 END AS Calculated_Section,
CASE WHEN r.MscShpHd_PackNum IS NULL THEN r.JobMtl_IssuedQty ELSE 0 END
AS Calculated_PendingQty,
CASE WHEN r.MscShpHd_PackNum IS NULL THEN 'ISSUED-NOT-SHIPPED' ELSE 'SHIPPED' END
AS Calculated_RowStatus
FROM BAQReportResult_<guid> r
WHERE NOT (r.MscShpHd_PackNum IS NULL AND COALESCE(r.JobMtl_IssuedQty, 0) = 0)
UNION ALL
SELECT /* one row per material with a shortfall */ ...,
3, r.JobMtl_RequiredQty - r.JobMtl_IssuedQty, 'NOT-ISSUED'
FROM BAQReportResult_<guid> r
WHERE r.JobMtl_RequiredQty > r.JobMtl_IssuedQty
GROUP BY ...
In the RDL the table name is built from the TableGuid parameter, FROM dbo.[BAQReportResult_" + Parameters!TableGuid.Value + "]. Write the final expression on a single line; the troubleshooting table explains why.
Option B: calculate the section in the BAQ
The cleaner long-term design. Add a LatestPack CTE (MAX(PackNum) per job), left-join it in the top-level query and in every UNION ALL branch, and add Section, PendingQty and RowStatus as calculated fields in the same position in each branch. A third branch over JobMtl with RequiredQty > IssuedQty lists materials that were never issued, including those with IssuedQty = 0 that Option A cannot see.
The RDL changes
- Add the three calculated fields to the BAQReportResult dataset’s field list.
- Wrap the detail group in a parent group on
=Fields!Calculated_Section.Value, sorted ascending. - Add a header row per section with
=Switch(...)text such as “CURRENT PACK SLIP: 26275”, “PREVIOUS PACK SLIPS” and “PENDING: NOT ISSUED OR NOT YET ON A PACK SLIP”, each with its own background colour. - Sort details by PackNum descending, then PartNum, then TranDate descending.
- Show the page-header pack slip as
=Max(Fields!MscShpHd_PackNum.Value, "BAQReportResult"), notFirst(...), which depends on row order.
Troubleshooting: the errors we actually hit
Each of these stopped a real deployment. Most come from the three layers (BAQ, BAQ Report, RDL) getting out of step.
| Error (abridged) | Root cause | Fix |
|---|---|---|
| Incorrect syntax near ‘,’ | Two commas in the RDL dataset column list | Remove the stray comma; check every edit of the ="SELECT ..." expression |
| The Group expression for ‘grpSection’ refers to the field ‘Calculated_Section’ (on upload) | The field was dropped from the RDL dataset, usually by Refresh Fields against a BAQ that does not output it yet | Re-add the field to the dataset; do not refresh fields until the BAQ is updated |
| Invalid column name ‘Calculated_Section’ (at run time) | The RDL expects a column the BAQ does not output, or the BAQ Report points at an unchanged copy of the BAQ | Add the field as a display column in every UNION ALL branch and re-save the BAQ Report, or use Option A |
| Incorrect syntax near ‘ALLSELECT’ | Epicor strips line breaks from the dataset expression on upload, fusing UNION ALL and SELECT | Put the whole query on one line, with a space between every keyword |
| Quantities print as 28.000000000 | A computed IIf() expression loses the textbox’s number format | Set the textbox Format to #,0;(#,0) |
| Unissued materials show “Awaiting pack slip” | Rows with no PackNum and IssuedQty = 0 were treated as shipped-pending | Exclude them from the first branch; they appear once as “Not issued” if anything is still required |
| Pending rows show a Fulfilled quantity | The BAQ falls back to IssuedQty when nothing has shipped | Return 0 when PackNum is null, in the dataset or with =IIf(IsNothing(Fields!MscShpHd_PackNum.Value), 0, ...) |
Validation checklist
Do not judge the new report by row count: fewer printed rows often means the old report was duplicating. Validate against source data, using the full material key.
- For every material, the sum of allocated quantity is no more than the surviving PartTran quantity.
- For every pack slip line, the sum of allocated quantity is no more than the shipped quantity, and any remainder is explained.
- No allocation crosses MtlSeq or AssemblySeq.
- Reversals reduce the oldest issues; newer issues keep their date and lot.
- Same-day, same-lot issues print as one line; different lots stay separate.
- A job with no pack slips prints only Pending rows, with no invented PackNum or ShipDate.
- Materials with Required greater than Issued appear once as “Not issued”.
- The page-header pack slip equals the Current section’s PackNum.
- Running the report twice gives identical output.
What the rebuild achieved on a 630-line test job
| Check | Old report | New report |
|---|---|---|
| Transactions on the correct pack slip | All quantity on the newest slip for multi-shipment materials | Split across slips by quantity range |
| Cross-product duplicates | Present | None |
| Reversed material | Could reappear | Netted off before allocation |
| Layout | One flat list | Current (7 lines), Previous (622), Pending (2) |
| Unshipped and unissued material | Mixed into shipped lines, or missing | Labelled “Awaiting pack slip” or “Not issued” with the B/O quantity |
A job with no miscellaneous shipments at all is the acid test. The old report printed 106 lines of inventory history as if it were shipment detail. The new report prints the issued materials under Pending, and nothing that claims a shipment happened.
Frequently asked questions
Does a PartTran STK-MTL transaction mean the material was shipped?
No. STK-MTL records an issue from stock to a job. Only MscShpHd and MscShpDt records prove a miscellaneous shipment. Use PartTran to explain which lot and date a shipped quantity came from, never to create a shipment.
How do I show multiple pack slips for one job in an Epicor SSRS report?
Give each row a section number (highest PackNum is Current, other PackNums are Previous, no PackNum is Pending), then add a parent row group on that field in the RDL with a header row per section.
Why does my BAQ report return more rows than expected?
Usually because shipment rows and transaction rows are both joined to JobMtl independently, which multiplies them. Allocate by overlapping cumulative quantity ranges instead.
Why do I get "Invalid column name" after changing my SSRS report?
The RDL asks for a column the BAQ Report's runtime table does not have. Add the column to the BAQ, re-save the BAQ Report, then upload the RDL, or calculate the column inside the SSRS dataset query.
Why does Epicor say "Incorrect syntax near 'ALLSELECT'"?
Line breaks in the dataset expression are removed on upload, joining UNION ALL and SELECT. Keep the dataset query on one line with a space between every keyword.
Should the current pack slip be the highest PackNum or the latest ShipDate?
The highest PackNum is the safer default when pack slips are created by an import, because numbering always increases while ship dates can be back-dated. Whichever you choose, use the same rule in the BAQ, the RDL and the page header.
The takeaway
A trustworthy pack slip report in Epicor Kinetic comes down to three decisions: keep “issued” and “shipped” separate, allocate by quantity range instead of joining, and show the customer clearly what is in this shipment, what came before and what is still owed. Get those right and the SSRS work is mostly layout. Put the import and print behind two buttons on the form, and the shipping team gets all of it in one click.
Related: provisioning Epicor users across companies with ASP.NET Core.