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.

  1. Create a pack slip and enter the job number.
  2. 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.
  3. Save. The pack slip is written to MscShpHd and MscShpDt like any other miscellaneous shipment.
  4. 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.

Miscellaneous pack slip workflow in Epicor KineticIn Miscellaneous Shipment Entry the user enters a job number, clicks Import, which runs the import BAQ to calculate issued minus shipped, saves the new pack slip to MscShpHd and MscShpDt, and clicks Print. Print runs the report BAQ with allocation CTEs for the job, the BAQ Report publishes a runtime result table, the SSRS dataset assigns each row a section, and the RDL layout prints Current, Previous and Pending sections.In Miscellaneous Shipment Entry (Kinetic, Application Studio buttons)Behind the Print button1. Enter job numberOn a new pack slip2. ImportImport BAQ: issued minus shipped3. SaveMscShpHd and MscShpDt rows4. PrintRuns the BAQ Report for the jobReport BAQAllocation CTEs for @JobNumBAQ ReportRuntime result tableSSRS datasetAssigns section 1, 2 or 3RDL layoutCurrent, Previous, Pending
Only Import writes data. Everything behind Print reads and labels, so the report can be rerun at any time without changing anything.

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.

Job, pack slip and part numbers in this article are illustrative. The logic, error messages and fixes are from the production build.

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.

TableWhat it provesKey columns used
JobHeadThe job exists; header detailsCompany, JobNum, PartNum, ProjectID
JobMtlWhat the job requires and what has been issuedMtlSeq, AssemblySeq, RequiredQty, IssuedQty, IUM
PartTran (STK-MTL)Each issue (+) and reversal (−) to the job, with date and lotJobSeq, AssemblySeq, TranDate, TranNum, TranType, LotNum, TranQty
MscShpHdA pack slip exists for the jobPackNum, ShipDate, JobNum
MscShpDtWhat each pack slip line shippedPackLine, PartNum, MtlSeq, AssemblySeq, Quantity, LotNum
SNTranSerial numbers tied to the materialMtlSeq, 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?

DesignDriving tableJobs with no shipmentVerdict
Shipment-drivenMscShpHd / MscShpDtPrint nothingClean, but hides what is still owed
Job-material-drivenJobMtl (IssuedQty > 0)Print issued lines with a blank pack slipShows everything, but mixes shipped and unshipped
HybridJobMtl, labelled by shipment statusPrint issued lines in a clearly marked Pending sectionChosen

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:

Quantity-range allocation of four issues to three pack slips Surviving issues, newest first: October 12, 7 EA; March 31 lot B, 9 EA; March 31 lot A, 1 EA; March 28, 33 EA. Pack slips, newest first: 26275 with 7 EA, 22096 with 10 EA, 22021 with 33 EA. Range overlap sends 7 from October 12 to 26275, 9 and 1 from March 31 to 22096, and 33 from March 28 to 22021: four allocation rows, 50 EA in total. Surviving issues, newest firstPack slips, newest first Oct 127 EAMar 31, lot B9 EAMar 31, lot A1 EAMar 2833 EAPack slip 262757 EAPack slip 2209610 EAPack slip 2202133 EA79133
Four allocation rows, 50 EA in total, no duplicates. The old query put all 50 EA on pack slip 26275.

The CTE chain

  1. ShipmentRanked / ShipmentCTE: running sum of MscShpDt.Quantity per material key, newest pack slip first, giving ShipEnd and ShipStart.
  2. PartTranPositive / PartTranNegative: positive STK-MTL rows with running totals; negatives summed per material and lot.
  3. PartTranReportCTE: applies reversals to the positives (step 3).
  4. PartTranCTE: groups surviving quantity by date, lot and unit of measure.
  5. PartTranRanked / PartTranRange: running sum newest date first, giving TranEnd and TranStart.
  6. 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.

CaseTransactionsSurviving
Full reversal+15 (Sep 14), +15 (Oct 20), −1515 on Oct 20
Partial reversal+525, −13512
Reversal larger than one issue+2, +5, −1, then +2, +11 + 5, then 2 + 1 (newer issues untouched)
Two identical issues, same day+1, +1One 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.

Import BAQ caution: a join that treats MtlSeq = 0 or AssemblySeq = 0 as “match anything” counts an assembly-0 shipment against materials in every assembly. Assembly 0 is a real assembly. Join AssemblySeq exactly, or the next import can under-ship.

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:

SectionRulePack Slip columnIssued / ShipFulfilledB/O
1, CurrentPackNum is the job’s highest PackNumPackNumAllocated qtyAs calculatedAs calculated
2, PreviousAny other PackNumPackNumAllocated qtyAs calculatedAs calculated
3, Pending: awaiting pack slipNo PackNum and IssuedQty > 0“Awaiting pack slip”IssuedQty0IssuedQty
3, Pending: not issuedRequiredQty > IssuedQty“Not issued”00Required − Issued
HiddenNo 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"), not First(...), 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 causeFix
Incorrect syntax near ‘,’Two commas in the RDL dataset column listRemove 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 yetRe-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 BAQAdd 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 SELECTPut the whole query on one line, with a space between every keyword
Quantities print as 28.000000000A computed IIf() expression loses the textbox’s number formatSet the textbox Format to #,0;(#,0)
Unissued materials show “Awaiting pack slip”Rows with no PackNum and IssuedQty = 0 were treated as shipped-pendingExclude them from the first branch; they appear once as “Not issued” if anything is still required
Pending rows show a Fulfilled quantityThe BAQ falls back to IssuedQty when nothing has shippedReturn 0 when PackNum is null, in the dataset or with =IIf(IsNothing(Fields!MscShpHd_PackNum.Value), 0, ...)
Deployment order that avoids most of these: change and test the BAQ in BAQ Designer (Analyze, then Get List), open and save the BAQ Report so the new columns reach the runtime table, then upload the RDL. Never in the reverse order.

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

CheckOld reportNew report
Transactions on the correct pack slipAll quantity on the newest slip for multi-shipment materialsSplit across slips by quantity range
Cross-product duplicatesPresentNone
Reversed materialCould reappearNetted off before allocation
LayoutOne flat listCurrent (7 lines), Previous (622), Pending (2)
Unshipped and unissued materialMixed into shipped lines, or missingLabelled “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.