2. Purchase Order
Inter-company Processing: SAMLTD P/O to SAMINC O/E (SAMACCINTCOEXP)
The first integration required for this process extracts the P/O from SAMLTD to export a corresponding O/E Order in SAMINC, with a final step that flags the exported orders to prevent them from being re-exported.
Some setup is required in order to see this process.
This integration has:
- Read
- Hierarchy
- Map
- Connector
- Filter
- Second Map
- Database Write
Read Transform
This extracts purchase orders from SAMLTD using SQL Query.
The SQL Statement
To denote inter-company orders, a specific vendor is used and must be specified in the query to the database. In these examples, this vendor Id is 'SAMINT'.
The where clause in the query limits the result set to only purchase orders where the EXPORTED optional field is False (i.e. the order has not been exported!).
The SQL query extracts the very basic fields required for the integration:
- Purchase Order Sequence Number
- Purchase Order Number
- Purchase Order Date
- Purchase Order Line Sequence (below)
- Item Number
- Quantity Ordered
When the refresh button is pressed, the records that are imported from SAMLTD will appear in Preview.
The 'Purchase Order Line Sequence' is used to record on which line an item belongs. It will be stored with the line on the O/E Order and will be used in the return transaction to uniquely identify the item to receipt.
Hierarchy Transform
Transforms the flat dataset to a hierarchical dataset consisting of a header and details.
Map Transform
The Map transforms adds two fields to the dataset and modifies the value of another so the order can be imported into SAMINC.
- DATE
- Uses the NumberToDate function to convert the numeric Date value (yyyymmdd format) to a date format which can be imported into Sage300 (dd/mm/yyyy or mm/dd/yyyy depending on your region).
- CUSTOMER
- Set to a static value ‘SAMINT’.
- ORDNUMBER
- An empty field to capture the generated order number used on the audit report.
Sage300 Connector
The Sage300 Connector defines the mapping of the data into the SAMINC O/E Order.
- In the Field Mapping tab, we map each of the fields in our data set.
- The Order Details transaction's PO Line Sequence is mapped to the POLINE optional field.
- As stated previously, this value will be used in the return transaction to identify the record in the receipt.
- The resulting preview will look something like:
- See the result! The O/E Order appears in SAMINC:
- With the POLINE optional field:
Filter Transform
The next three steps flag the SAMLTD Purchase Order to indicate it has been processed and prevent it from being exported again.
This Filter step is optional and would depend on the logic desired, but in this example we want to prevent orders which cannot be imported (for whatever reason) from flagging the EXPORTED. I.e. The order will continue to be exported from SAMLTD until it can be imported into SAMINC or until the EXPORTED optional field on the Purchase Order is manually set to True.
Second Map Transform
In this transform a field (VALUE) is added to the dataset which will enable the EXPORTED optional field to be set to True (1).
Database Writer
This step performs the update to the EXPORTED optional field.
The Options tab specifies the database to update and the type of SQL Operation to perform.
- The Field Mapping tab is where the Update operation is setup:
- Map To Table
- Updating the Purchase Order Header Optional Fields Table.
- Where Clause
- This property specifies the Where clause used in the SQL Update command.
- Here we limit the records being updated to a single record by specifying the OPTFIELD field and then parameterising clause with the Purchase Order Header Sequence field (PORHSEQ), forming the primary key on the POPORHO table.
- Value
- Tells the operation to update the Value field to true (i.e. the item has been exported).
- Map To Table
- After the update is run, the EXPORTED optional field on the Purchase Order should be set to True.