Innovative Instructions — AS400 Extraction for FreightMath
This guide explains how to use the KSMUploadStandalone extraction utility to pull data from an Innovative system running on IBM i / AS400 and generate FreightMath-ready Order and Segment extract files. It is intended for client IT, DBA, and analytics teams who support the integration.
1. Purpose & High-Level Architecture
KSMUploadStandalone is a Windows console application that:
- Connects to the client’s Innovative system on IBM i / AS400 using ODBC and the IBM iAccess ODBC driver.
- Executes predefined queries against the Innovative database (DB2/400).
- Builds two CSV files:
- Order Extract (Order-level data)
- Segment Extract (Segment/leg-level data)
- Uploads those CSVs to FreightMath via SFTP for ingestion.
The core business logic has been packaged into a standalone project so that IT teams can run extracts on a schedule without needing to embed this logic directly into the TMS.
2. System Requirements
| Component | Requirement | Notes |
|---|---|---|
| Operating System | Windows Server or Windows 10/11 | Used as the extraction host; must be able to reach both AS400 and SFTP. |
| Innovative Access | ODBC access to Innovative DB2/400 schema | Typically via a dedicated service account with read access to required tables. |
| IBM iAccess ODBC Client | IBM iAccess v1r1 Windows Application Package (or approved equivalent) | Installs the iSeries ODBC driver used by the extraction utility. |
| ODBC DSN | System DSN matching the JSON config connection string | Example: dsn=AS400x64 in the connection string. |
| .NET Runtime | .NET runtime compatible with the compiled executable | Confirm with KSMTA which runtime version is required if not bundled. |
| Network Connectivity | Outbound to AS400 (DB2/ODBC) and FreightMath SFTP | Firewall must allow ODBC and SFTP traffic from the extraction host. |
3. Files in the Code Package
When you download the code package (Innovative Code Package (ZIP)), you will see something similar to the following structure:
KSMUploadStandalone/
├─ KSMUploadStandalone.exe
├─ Company - Copy.json
├─ ReportJSON/
│ ├─ OrderExtract.json
│ └─ SegmentExtract.json
├─ ReportModels/
├─ Repositories/
└─ Readme.txt
- KSMUploadStandalone.exe — compiled console app you will run.
- Company - Copy.json — template for per-client company configuration.
- ReportJSON — JSON definitions of the Order and Segment reports (field mappings and query logic for Innovative).
- ReportModels / Repositories — internal C# code (no changes required for normal operation).
- Readme.txt — short summary; this page is the detailed version.
4. Company Configuration JSON
Each Innovative client requires its own company configuration JSON, which tells the extractor how to connect to AS400 and how to label its output.
Example (ClientABC.json):
{
"CompanyName": "Client ABC Trucking",
"CompanyAS400ConnectionString": "dsn=AS400x64;UID=FREIGHTUSR;PWD=SuperSecret123;QueryTimeout=0",
"Library": "IFILE",
"SCAC": "ABCT"
}
4.1 Field Definitions
- CompanyName Friendly name shown in logs, not used in joins or keys.
- CompanyAS400ConnectionString
Full ODBC connection string for the Innovative AS400 instance, typically:
dsn=AS400x64;UID=UserID;PWD=Password;QueryTimeout=0 Thedsn=...part must match a configured System DSN on the extraction host. - Library
The primary DB2/400 library where the Innovative tables live (e.g.,
IFILE). - SCAC The company’s official SCAC code (used to prefix output file names).
CompanyAS400ConnectionString. The client should reinsert it locally.
5. ODBC DSN Setup (Innovative on AS400)
- Open ODBC Data Sources (64-bit) on the extraction machine.
- Go to the System DSN tab and click Add....
- Choose the IBM i Access ODBC Driver and click Finish.
-
Configure the connection:
- System: AS400 hostname or IP
- Description: e.g., Innovative Production
- Default Library: e.g.,
IFILE - User ID / Password: Dedicated service account for reporting
- Name the DSN to match the JSON, e.g. AS400x64.
- Use the Test Connection button to confirm connectivity and credentials.
If the DSN name doesn’t match the config file’s dsn=... value, the extractor will
fail with an ODBC connection error.
6. Running the Extraction Utility
The executable accepts up to three arguments:
KSMUploadStandalone CompanySettings CutOffDate StartDate
- CompanySettings (required)
Path to the company JSON file, e.g.
ClientABC.json. - CutOffDate (optional,
YYYYMMDD) Latest date to include in the extract. - StartDate (optional,
YYYYMMDD) Earliest date to include in the extract.
6.1 Examples
Example 1: Full/default extract (no dates)
KSMUploadStandalone ClientABC.json
Uses internal date defaults defined in the report repository logic. Good for initial tests or small data sets.
Example 2: Extract up to a cutoff date
KSMUploadStandalone ClientABC.json 20251201
Includes records up to December 1, 2025, using internal rules for the start date.
Example 3: Extract a specific date range
KSMUploadStandalone ClientABC.json 20251201 20251101
Includes only records between November 1, 2025 and December 1, 2025 (inclusive, depending on the query filters).
StartDate to the last
successful run date and CutOffDate to today. This keeps extract sizes small and
simplifies debugging if something goes wrong.
7. What the Utility Produces
On a successful run, the utility builds two CSV files in the working directory and then uploads them via SFTP:
- SCAC_KSMTA_ORDER_YYYYMMDD.csv
- SCAC_KSMTA_SEGMENT_YYYYMMDD.csv
Examples for SCAC ABCT on January 7, 2025:
ABCT_KSMTA_ORDER_20250107.csv
ABCT_KSMTA_SEGMENT_20250107.csv
Column names and field definitions correspond to the FreightMath Data Schema.
8. SFTP Upload Behavior
After generating CSV files, the utility:
- Establishes an SFTP connection to the FreightMath inbound server (using credentials baked into the deployment or configuration).
- Uploads the Order and Segment files.
- Logs any connection or file errors to the console.
SFTP host, port, username, and password are managed by KSMTA. Clients are not expected to change these values.
9. Scheduling Recurring Runs
Once a manual test is successful, most clients schedule recurring runs using Windows Task Scheduler on the extraction host.
-
Create or choose a Windows service account with:
- Permissions to run the executable.
- Access to the folder containing the config and outputs.
- Network access to AS400 and SFTP.
-
In Task Scheduler, create a new task to run
KSMUploadStandalone.exewith the appropriate arguments (e.g., daily at 1:00 AM). -
Optionally use a small wrapper script (
.bator.ps1) to compute date arguments dynamically (yesterday, last week, etc.). -
Configure logging by redirecting console output to a file, for example:
KSMUploadStandalone ClientABC.json 20251201 20251101 >> logs\extract_2025-12-01.log 2>&1
10. Common Errors & Troubleshooting
10.1 Syntax / Usage Errors
If you run the executable with no arguments, it will display usage instructions similar to:
Syntax: KSMUploadStandalone CompanySettings CutOffDate StartDate
Fix: Always pass at least the company JSON file name.
10.2 ODBC / Connection Errors
Typical messages include:
ERROR [08001] [IBM] System errorERROR [28000] [IBM] Authentication failed
Possible causes:
- DSN name in JSON doesn’t match an existing System DSN on the host.
- Incorrect AS400 user ID or password.
- Network/firewall blocking access to the AS400.
- Insufficient library/table permissions for the user.
Fix:
- Verify DSN configuration and test via ODBC Data Sources.
- Confirm credentials and user profile authorities on IBM i.
- Work with IT/network team to open required ports.
10.3 JSON Configuration Errors
If the company JSON is malformed or missing fields, you may see JSON deserialization errors.
Fix:
- Validate the JSON file using a JSON validator.
- Ensure all required fields are present:
CompanyName,CompanyAS400ConnectionString,Library,SCAC.
10.4 SFTP Upload Failures
Symptoms include console messages such as:
Upload failed: <error message>
Fix:
- Confirm outbound SFTP connectivity with KSMTA IT.
- Verify that any outbound firewall rules allow the SFTP destination.
- Check credentials or key configuration if managed outside the executable.
11. Related Documentation
- FreightMath Data Schema — full field definitions for Order and Segment extracts.
- Innovative Code Package (ZIP) — executable and source files for the Innovative extraction model (placeholder link; update to actual path when published).