3. Shipment to Receipt¶
Inter-company Processing: SAMINC O/E Shipment to SAMLTD P/O Receipt (SAMACCINTCOIMP)¶
The second of the two intercompany integrations makes the return journey. It reads shipments out of SAMINC, creates the matching P/O Receipt in SAMLTD, and then flags the shipment so it is not exported again.
It is the same seven-step shape as step 2, with the two companies the other way round: SAMINC is now the source and SAMLTD the target.
Both companies must exist in Sage 300 first
Set up both companies in Sage 300 before you run this integration. See Company setup if you have not done so.
This integration has:
- Read
- Hierarchy
- Map
- Connector
- Filter
- Second Map
- Database Write
Raise the shipment in SAMINC¶
Before running it, create a shipment in SAMINC against the intercompany order that step 2 created.
Ship less than was ordered on at least one line. The receipt takes its quantities from the shipment, not the purchase order. If you ship everything, the receipt looks the same either way and you cannot see the difference.
Read¶
A SQL query reads the shipments straight from the SAMINC database.
The SQL statement¶
select H.SHIUNIQ, H.ORDNUMBER, H.SHINUMBER, H.PONUMBER, D.ITEM, D.QTYSHIPPED, OD.VALUE as 'POLINENUM'
from OESHIH H inner join OESHID D on H.SHIUNIQ = D.SHIUNIQ
inner join OESHIHO OH on H.SHIUNIQ = OH.SHIUNIQ and OH.OPTFIELD = 'EXPORTED'
inner join OESHIDO OD on D.SHIUNIQ = OD.SHIUNIQ and D.LINENUM = OD.LINENUM and OD.OPTFIELD = 'POLINE'
where LTRIM(OH.VALUE) = '0' and CUSTOMER = 'SAMINT'
It mirrors step 2's query, and selects an outstanding intercompany shipment the same way:
CUSTOMER = 'SAMINT'— intercompany sales are raised against a particular customer, which distinguishes them from ordinary ones.LTRIM(OH.VALUE) = '0'— the EXPORTED optional field on the shipment is still No. The join ontoOESHIHObrings that optional field into the query.
This query has a second optional-field join, which step 2's query does not.
It joins OESHIDO per line, on OPTFIELD = 'POLINE', to put the purchase
order line sequence back on each row:
SHIUNIQ |
shipment sequence number — the key the flag is written back against |
ORDNUMBER |
the SAMINC order number |
SHINUMBER |
the SAMINC shipment number |
PONUMBER |
the SAMLTD purchase order number — how the receipt finds its order |
ITEM |
item number |
QTYSHIPPED |
the quantity actually shipped |
POLINENUM |
the POLINE optional field, written onto the order line by step 2 |
Press Refresh to run the query. One shipment of two lines, shipped short on both, returns this:
| SHIUNIQ | ORDNUMBER | SHINUMBER | PONUMBER | ITEM | QTYSHIPPED | POLINENUM |
|---|---|---|---|---|---|---|
| 3073 | ORD000000000086 | SH00000000000000000077 | PO000000242 | A1-103/0 | 8.0000 | 37536 |
| 3073 | ORD000000000086 | SH00000000000000000077 | PO000000242 | A1-401/0 | 5.0000 | 37664 |
POLINENUM is the value step 2 wrote onto the O/E Order line. It has travelled
order → shipment → here, and it lets the receipt put the right quantity
on the right line.
Hierarchy¶
The query returns one row per shipment line. The Hierarchy transform turns those flat rows into the header-and-lines shape the P/O Receipt import expects.
SHIUNIQ is Key 1, so the transform builds one Shipments record per shipment.
The four header fields are ticked for import. The three line-level fields are
unticked and stay on the ShipLines child.
Map¶
The Map transform adds a single empty field.
RECEIPTNBR is added empty. It gives the connector a field to write back the
receipt number Sage 300 generates. The filter below tests it, and after a run it
tells you which receipt each shipment produced. ORDNUMBER plays the same role
in step 2.
Sage 300 connector¶
The connector defines how the dataset maps to the SAMLTD P/O Receipt.
The connector named here is the SAMLTD System Connector. Everything before it read from SAMINC, and the database writer at the end goes back to SAMINC.
Field Mapping¶
Transaction Level Mapping pairs the two transactions the hierarchy built
with the two Sage 300 views the import type expects, PO0700 for the receipt
header and PO0710 for the lines.
PONUMBER identifies the purchase order to receipt against. It is mapped to the receipt's Purchase Order Number field, the same field you fill in when you enter a receipt by hand in Sage 300.
ORDNUMBER and SHINUMBER are mapped to Description and Reference, so
the receipt in SAMLTD records which SAMINC order and shipment produced it.
SHIUNIQ is (not mapped), because SAMLTD does not need SAMINC's internal
sequence number. The database writer at the end of the integration does need it,
and only mapped fields flow through a connector. Its Log Key of 20
carries it through. A non-zero Log Key makes an unmapped field available to
downstream transforms, and a non-sequential one keeps it out of the audit
report's Source column. See
Making unmapped fields flow.
On the ShipLines transaction:
Two mappings matter here:
- POLINENUM → Purchase Order Line Sequence (PORLSEQ). This mapping matches each shipment line to the right line of the purchase order.
- QTYSHIPPED → Quantity Received (RQRECEIVED). The receipt takes the quantity that was shipped, not the quantity that was ordered.
ITEM is (not mapped) too, for a different reason. The purchase order line
sequence already identifies the line, so the item number would be redundant on
the receipt. ITEM carries Log Key 2 and PONUMBER carries 1. Because the
pair is sequential, the two name the failing line in the audit report's Source
column if the import fails.
Running it¶
Refresh does not simulate the import. It runs it. When it
finishes, RCPNUMBER holds the receipt number Sage 300 generated:
The receipt is in SAMLTD. Description and Reference hold the O/E Order and O/E Shipment numbers from SAMINC, and each line is receipted for the quantity shipped, not the quantity ordered:
Filter, Second Map and Database Write¶
The last three steps flag the SAMINC shipment as exported so it is not receipted twice. They are the same three steps as in step 2, pointed at the other company. This page shows only what differs.
The Filter keeps only the shipments that produced a receipt:
The second Map adds VALUE, set to 1, the Yes of a Sage 300 Yes/No
optional field:
The transactions are now called PO0700 and PO0710. The connector renamed
them to the Sage 300 views it mapped them to, and every transform downstream of
a connector uses the new names.
The database writer runs the update. Its connection is back to SAMINC, because this is the return leg. The operation is Update, because the EXPORTED optional field already exists on the shipment and the writer changes its value from No to Yes.
- Map To Table —
OESHIHO, the O/E shipment header optional fields table. - Where Clause —
SHIUNIQ = %SHIUNIQ and OPTFIELD = 'EXPORTED'. Together those two columns are the primary key ofOESHIHO, so the writer updates exactly one row.%SHIUNIQis a merge field that takes its value from the record being written. The connector carriedSHIUNIQalong unmapped for this reason. - Column — only
VALUEis given one, soVALUEis the only column the update sets.
The advisory under the Where Clause, and why the update still runs
Version 6.1 shows an advisory beneath the Where Clause. It says that
%SHIUNIQ is an unqualified field reference and that merge fields are written
%[Record.Field]. The clause still resolves and the update still runs. Use
the qualified form in anything you write now.
After the update, the EXPORTED optional field on the shipment reads Yes, and the next run of the integration will not pick it up. The round trip, from purchase order to sales order and from shipment to receipt, is complete.













