👨💻 Technical ACs (Gherkin)
Context: A CCN key is provided for processing
GIVEN
A CCN key is provided for processing
Applied to: 2:Get First Follower Manifest
WHEN
The system initializes follower manifest processing
THEN
The first follower manifest record matching the CCN key is retrieved and processing status is set based on record availability
Context: The system is processing follower manifest records
GIVEN
The system is processing follower manifest records
Applied to: More Follower Manifests?
WHEN
A database operation is performed to retrieve records
THEN
Processing continues if status code is spaces, otherwise processing stops
Context: A follower manifest record is retrieved
GIVEN
A follower manifest record is retrieved
Applied to: 4:Validate Manifest for Processing
WHEN
The system compares the manifest CCN key with the input CCN key
THEN
The manifest is processed only if the CCN keys are different, otherwise it is skipped
Context: A manifest is being processed for cancel release
GIVEN
A manifest is being processed for cancel release
Applied to: 6:Set Manifest Status Based on CSA Indicator
WHEN
The system checks the CSA indicator status
THEN
If CSA indicator is ON, status is set to CSA-DLV, otherwise status is set to MANUAL
Applied to: 11:Set Manual Change Flag
WHEN
The system updates manifest data
THEN
The 309 manual change flag is set to true
Context: A manifest is being cancelled
GIVEN
A manifest is being cancelled
Applied to: 7:Update Release Information
WHEN
The system updates release information
THEN
Current machine date is recorded as unrelease date, current user ID is recorded, original release date is preserved, release information is cleared, and unrelease reason is set
Context: A manifest has a destination station name
GIVEN
A manifest has a destination station name
Applied to: 8:Lookup Station Information
WHEN
The system performs station lookup using table ID 'MC'
THEN
If lookup is successful (return flag = '0'), station number from lookup is used, otherwise existing destination station number is retained
Context: A manifest has an in-transit status
GIVEN
A manifest has an in-transit status
Applied to: 9:Update In-Transit Status
WHEN
The in-transit status is 'Z' or 'E'
THEN
The in-transit status is changed to 'L'
Applied to: 10:Handle Special Transit Cases
WHEN
The in-transit status is 'R' or 'T'
THEN
The destination station number for index is cleared to spaces
Applied to: 9:M10 Segment Processing
WHEN
The in-transit status is 'T'
THEN
The system should set application type to '29', otherwise set to '27'
Context: A manifest is being processed
GIVEN
A manifest is being processed
Applied to: 12:Clear Delete Status
WHEN
The current status is not equal to 'DELETED'
THEN
The delete status field is cleared to spaces
Applied to: 1:Manifest from 66MASTER station?
WHEN
The manifest from station equals '66MASTER'
THEN
The system should exit processing immediately without performing any manifest operations
Applied to: 32:Post-Emanifest Amendment Flag?
WHEN
The post-emanifest amendment flag is set to true
THEN
The system should process the M13 amendment segment
Context: A manifest cancel release has been processed
GIVEN
A manifest cancel release has been processed
Applied to: 13:Log Cancel Release Activity
WHEN
The system logs the activity
THEN
An audit record is created with CCN key, user ID, current date and time, and cargo release removed action code
Context: Current follower manifest processing is complete
GIVEN
Current follower manifest processing is complete
Applied to: 15:Get Next Follower Manifest
WHEN
The system retrieves the next follower manifest
THEN
If status code is spaces and CCN key matches the master manifest CCN, processing continues, otherwise processing stops
Context: The cargo report program is starting
GIVEN
The cargo report program is starting
Applied to: 1:Initialize Program
WHEN
Program initialization begins
THEN
Description arrays are cleared to spaces, index counters are set to 1, and cargo control number array is initialized to spaces
Context: A valid shipment root key exists
GIVEN
A valid shipment root key exists
Applied to: 2:Get Shipment Root Data
WHEN
The system needs to access shipment root data
THEN
The SHIPROOT segment is retrieved using the root key with 'GU' function code
Context: Shipment mine data has been retrieved
GIVEN
Shipment mine data has been retrieved
Applied to: 4:Extract EDI BOL Key
WHEN
The system needs to identify the EDI BOL key
THEN
If shipment mine data is found, the first data line becomes the EDI BOL key, otherwise the key is set to spaces
Context: The system needs to identify the customs broker
GIVEN
The system needs to identify the customs broker
Applied to: 5:Build Broker Information
WHEN
Building broker information
THEN
First attempt to get broker from EDI BOL data, if not found then search Fastway system data, if still not found then set broker name to 'UNKNOWN'
Context: Multiple broker records exist in EDI BOL data
GIVEN
Multiple broker records exist in EDI BOL data
Applied to: 5:Build Broker Information
WHEN
Processing broker information from EDI BOL
THEN
If organization ID is 'XQ', use that broker name and stop searching; if organization ID is 'CB' and no XQ found yet and custom ID is not 'XR' or 'XU', store as temporary broker
Context: Broker name needs to be extracted from special handling instructions
GIVEN
Broker name needs to be extracted from special handling instructions
Applied to: 5:Build Broker Information
WHEN
Processing Fastway data for broker information
THEN
Remove standard prefixes ('CUSTOMS BROKER ', 'CUSTOMS BROKER: ', 'BROKER ', 'BROKER: ', 'CB ', 'XQ ', 'CB: ', 'XQ: ') from the instruction text to get the actual broker name
Context: A broker long name has been determined
GIVEN
A broker long name has been determined
Applied to: 5:Build Broker Information
WHEN
Finalizing broker information
THEN
Look up the broker in GCST2RT table and if found use the short name, otherwise use the long name
Context: EDI BOL data is available and reference number processing is needed
GIVEN
EDI BOL data is available and reference number processing is needed
Applied to: 10:Build N9 Reference Numbers
WHEN
Building N9 reference numbers from BOL data
THEN
Search for 'BM' and 'SI' qualified reference numbers, set empty references to 'N/A', and add them to the reference array up to maximum of 10 entries
Context: Shipment data contains a non-empty shipment ID number
GIVEN
Shipment data contains a non-empty shipment ID number
Applied to: 10:Build N9 Reference Numbers
WHEN
Processing reference numbers from BOL data
THEN
Add the shipment ID as a 'CN' (Container Number) qualified reference to the reference array
Context: BM or SI reference numbers are missing from EDI BOL and space is available in reference array
GIVEN
BM or SI reference numbers are missing from EDI BOL and space is available in reference array
Applied to: 10:Build N9 Reference Numbers
WHEN
Building reference numbers
THEN
Use shipper bill number as 'BM' reference and search special handling codes for 'SI' type references
Context: Reference numbers may contain leading spaces
GIVEN
Reference numbers may contain leading spaces
Applied to: 15:Compress Reference Numbers
WHEN
Compressing reference number data
THEN
For each reference number that starts with spaces, shift all non-space characters to the left to remove leading spaces
Context: Equipment seal records exist with 'SN' type
GIVEN
Equipment seal records exist with 'SN' type
Applied to: 16:Build Seal Numbers
WHEN
Building seal number information
THEN
Extract up to 4 seal numbers from each record, excluding spaces and low-values, up to a maximum of 20 total seal numbers
Context: Shipment processing is in progress
GIVEN
Shipment processing is in progress
Applied to: Multi-Bill Shipment?
WHEN
Determining processing path
THEN
If GCCC-MULTI-BILL-TO-BE-CREATED flag is true, proceed with multi-bill CCN processing
Context: Multi-bill processing is required and EDI BOL data exists
GIVEN
Multi-bill processing is required and EDI BOL data exists
Applied to: 17:Find Multi-Bill CCNs
WHEN
Finding related cargo control numbers
THEN
Search 'RF' type records for 'XC' qualified cargo control numbers and add them to the CCN array, excluding the current cargo control number
Context: Shipment processing requires manifest checking
GIVEN
Shipment processing requires manifest checking
Applied to: Multi-Manifest Indicator = Y?
WHEN
Evaluating manifest requirements
THEN
If MULTI-MANIFEST-IND equals 'Y', set multi-bill shipment flag and process N10 data, otherwise set not-multi-bill shipment flag
Context: Multi-manifest shipment with matching cargo control number found
GIVEN
Multi-manifest shipment with matching cargo control number found
Applied to: 18:Process Multi-Bill N10 Data
WHEN
Processing N10 lading data
THEN
Extract numeric quantity from right to left, pad with leading zeros, set lading quantity and origin country, and collect description lines
Context: Lading description processing is required
GIVEN
Lading description processing is required
Applied to: 19:Process Lading Descriptions
WHEN
Building cargo descriptions
THEN
Collect primary descriptions from L5 segments, additional descriptions from related records, special instructions with codes 'VA', 'VS', or 'EV', and vehicle identification numbers
Context: Description data has been collected and is not empty
GIVEN
Description data has been collected and is not empty
Applied to: 19:Process Lading Descriptions
WHEN
Finalizing description processing
THEN
Call GCCCOMP to compress descriptions, move compressed result to lading description field, and if extra descriptions exist, call GCCDESC to store them separately
Context: Shipment processing is complete
GIVEN
Shipment processing is complete
Applied to: 27:Process CSA Data
WHEN
Checking for CSA requirements
THEN
If destination road number is 105 (Canada) and haulage right carrier is empty, proceed with CSA data processing
Context: CSA processing is required and EDI BOL importer segment is found
GIVEN
CSA processing is required and EDI BOL importer segment is found
Applied to: 27:Process CSA Data
WHEN
Validating importer information
THEN
If entity ID is 'IM' with non-empty name and ID code qualifier is 'M5' with non-empty ID code, set CSA indicator ON and copy importer data; if qualifier is 'BN' or 'AI', only copy importer data without setting CSA indicator
Context: CSA processing is required but EDI BOL importer segment is not found
GIVEN
CSA processing is required but EDI BOL importer segment is not found
Applied to: 27:Process CSA Data
WHEN
Searching Fastway data for CSA information
THEN
Search for 'N1-01 IM' segments followed by 'N1-02' importer name, 'N1-03' qualifier ('M5', 'BN', or 'AI'), and 'N1-04' business number; set CSA indicator ON only for 'M5' qualifier
Context: A waybill key is provided for cargo manifest processing
GIVEN
A waybill key is provided for cargo manifest processing
Applied to: Waybill Key Valid?
WHEN
The system validates the waybill key format and retrieves shipment data
THEN
If the waybill key is blank or non-numeric, set return status to invalid waybill key. If the waybill key is valid but no shipment is found, set return status to waybill not found. If the waybill key is valid and shipment exists, set return status to OK
Context: Importer name, business number, and business number qualifier are all provided
GIVEN
Importer name, business number, and business number qualifier are all provided
Applied to: Importer Data Backup
WHEN
The system searches through customs records sequence 3 to 24 for existing importer data
THEN
For each sequence, retrieve customs record type 55. If entity ID equals 'IM', extract all importer details including name, address, contact information, and CSA indicator. Set importer found flag and clear importer fields from input
Context: A waybill date is available from the shipment root
GIVEN
A waybill date is available from the shipment root
Applied to: Border Arrival Date Calculation
WHEN
The system calculates the border arrival ETA using the date calculation service
THEN
Add the configured number of days to the waybill date to determine border arrival ETA. If the date calculation fails, add an error message for invalid waybill date
Context: Origin and destination station information from shipment data
GIVEN
Origin and destination station information from shipment data
Applied to: Station Information Retrieval
WHEN
The system validates station names and state codes
THEN
If origin station name is blank, add error message for invalid origin station name. If origin station state code is blank, add error message for invalid origin province/state code, otherwise determine origin country from state code lookup. If destination station name is blank, add error message for invalid destination station name
Context: An action code and multi-manifest indicator from the request
GIVEN
An action code and multi-manifest indicator from the request
Applied to: Manifest Port Determination
WHEN
The system determines manifest port requirements
THEN
If action is IIS-A6 or multi-manifest indicator equals 'Y' and manifest from port is blank, set manifest from port to 'IIS-A6'. If action is IIS-A6 or multi-manifest indicator equals 'Y' and manifest to port is blank, set manifest to port to 'IIS-A6'
Context: A CCN with type '9' and manifest port information
GIVEN
A CCN with type '9' and manifest port information
Applied to: Special Port Code Processing
WHEN
The system evaluates special port processing conditions
THEN
If CCN type equals '9' and US exit code is not '00000' or manifest from station is not 'IIS-A6' or manifest to station is not 'IIS-A6' or manifest stations are different, force both manifest from and to stations to 'IIS-A6'
Context: Manifest from and to port names requiring customs code validation
GIVEN
Manifest from and to port names requiring customs code validation
Applied to: Customs Code Validation
WHEN
The system looks up ports in the MC table and validates customs codes
THEN
For manifest from port: if lookup successful but Canadian customs code equals '00000', add error for invalid Canadian customs code. If lookup fails, add error for invalid manifest port. For manifest to port: if blank, set error flag 1. If lookup successful but Canadian customs code equals '00000', set error flag 2. If lookup fails, set error flag 3
Context: Manifest to station name and destination country information
GIVEN
Manifest to station name and destination country information
Applied to: Sub-location Code Determination
WHEN
The system determines sub-location code requirements
THEN
If manifest to station equals 'IIS-A6' and destination is not US, lookup destination station in CM table to get port manifest information and set sub-location code from lookup results
Context: Consignee chop code and destination station number
GIVEN
Consignee chop code and destination station number
Applied to: Bonded Siding Location Check
WHEN
The system looks up the consignee in the RF bonded siding table
THEN
If consignee is found in RF table, set customer bonded status to TRUE and get sub-location code from RF record. If consignee is not found in RF table, set customer bonded status to FALSE
Context: Sub-location code, CSA indicator, manifest station information, destination country, and arrival indicator
GIVEN
Sub-location code, CSA indicator, manifest station information, destination country, and arrival indicator
Applied to: Sub-location Requirement Validation
WHEN
The system evaluates sub-location code requirements
THEN
If sub-location code is present OR (sub-location code is blank AND (CSA indicator is on OR manifest stations are the same but not 'IIS-A6' OR destination is US OR arrival indicator is 'Y')), continue processing. Otherwise, set sub-location error flag
Context: Conveying car initial and number from shipment data, and TOFC/COFC indicator
GIVEN
Conveying car initial and number from shipment data, and TOFC/COFC indicator
Applied to: Conveying Car Processing
WHEN
The system processes conveying car information
THEN
If conveying car initial is present, use conveying car data from shipment. If conveying car initial is blank and TOFC/COFC indicator equals 'T' or 'C', set default conveying car to 'UNKN' and '00000001'. If conveying car initial is blank and not TOFC/COFC, clear conveying car fields
Context: A conveying car initial that is not blank
GIVEN
A conveying car initial that is not blank
Applied to: Equipment Validation
WHEN
The system validates the car ID using the GCCCARID service
THEN
Call GCCCARID service to validate the conveying car. If validation returns all asterisks, add error message for invalid conveying car. If validation succeeds, update conveying car with validated value
Context: Previous carrier number and previous cargo control number from shipment data
GIVEN
Previous carrier number and previous cargo control number from shipment data
Applied to: Previous Carrier Control Processing
WHEN
The system processes previous carrier control information
THEN
If previous carrier number is not '0000' and not blank, combine previous carrier number (positions 1-4) with previous cargo control number (positions 5-21) to form complete previous CCN
Context: EDI BOL commodity data or FastWay shipment commodity data
GIVEN
EDI BOL commodity data or FastWay shipment commodity data
Applied to: Weight and Quantity Roll-up
WHEN
The system rolls up weight and quantity information
THEN
For each commodity sequence 1-98, retrieve EDI commodity data and add lading quantity to total units. For first sequence, get weight data and set weight unit based on metric indicator. If no EDI data found, retrieve FastWay commodity data using GU then GN functions, adding units and weight from each commodity record
Context: Equipment load/empty status and current quantity qualifier
GIVEN
Equipment load/empty status and current quantity qualifier
Applied to: Quantity Qualifier Setting
WHEN
The system determines the appropriate quantity qualifier
THEN
If equipment status is 'E' (empty), set quantity qualifier to 'UNT'. If equipment is loaded and quantity qualifier indicates carload ('C/L', 'CLD', 'CL ', ' CL'), set quantity qualifier to 'PCS'. If quantity qualifier is blank, default to 'PCS'
Context: EDI BOL special handling data
GIVEN
EDI BOL special handling data
Applied to: Consolidated Load Indicator Retrieval
WHEN
The system checks for consolidated load indicators
THEN
For each special handling sequence 1-98, retrieve EDI special handling data. If special handling code equals 'CNS', set consolidated indicator to 'Y'. If no CNS code found, set consolidated indicator to blank
Context: Shipper information from shipment root data
GIVEN
Shipper information from shipment root data
Applied to: Shipper Data Extraction
WHEN
The system extracts and validates shipper data
THEN
Extract shipper chop, name, and address from shipment data. If shipper name is blank, add error message for invalid shipper name. If shipper address line 1 is blank, set to 'NA'. Process address line 2 with special formatting rules and set default country to 'US' if address is incomplete
Context: Consignee information from shipment root data
GIVEN
Consignee information from shipment root data
Applied to: Consignee Data Extraction
WHEN
The system extracts and validates consignee data
THEN
Extract consignee name, chop, and address from shipment data. If consignee name is blank, add error message for invalid consignee name. If consignee address line 1 is blank, set to 'NA'. Process address line 2 with special formatting rules and set default country to 'CA' if address is incomplete
Context: State/province codes for shipper and consignee addresses
GIVEN
State/province codes for shipper and consignee addresses
Applied to: Address Validation
WHEN
The system validates address information
THEN
For each address with state/province code, search state-country table to find matching entry and set corresponding country code. If state/province code is not found in table, add error message for invalid state/province code and leave country code blank
Context: Address fields that may be blank or incomplete
GIVEN
Address fields that may be blank or incomplete
Applied to: Default Address Setting
WHEN
The system processes address information
THEN
If address line 1 is blank, set to 'NA'. If address line 2 is blank or has only first character with remaining 18 characters blank, set first 18 characters to 'NA' and set appropriate default country code
Context: Commodity descriptions from shipment commodity data, shipment root free-form descriptions, and special handling instructions
GIVEN
Commodity descriptions from shipment commodity data, shipment root free-form descriptions, and special handling instructions
Applied to: Commodity Description Building
WHEN
The system builds the complete commodity description
THEN
Extract descriptions from 10 commodity description fields and 2 free-form description fields. For special handling codes 'VA', 'EV', or 'VS', combine handling code with handling instruction and add to description in available special handling description slots (up to 3 slots)
Context: Complete description data assembled from various sources
GIVEN
Complete description data assembled from various sources
Applied to: Description Data Compression
WHEN
The system compresses the description data
THEN
Call GCCCOMP service with 45000 byte source description and 22500 byte target description lengths. Move compressed description to cargo record lading description field. Distribute compressed description data across 46 cargo data segments in customs record 53
Context: Potential hazardous material data from EDI BOL, FastWay shipment, or commodity master
GIVEN
Potential hazardous material data from EDI BOL, FastWay shipment, or commodity master
Applied to: Hazardous Material Processing
WHEN
The system processes hazardous material information
THEN
First check EDI hazmat data for UN numbers and proper shipping names. If not found in EDI, check FastWay emergency response data for UN codes. If still not found, lookup commodity master for hazmat classification and UN numbers. Extract UN number and commodity description for dangerous goods
Context: Bill of lading data and potential multiple CCN requirements
GIVEN
Bill of lading data and potential multiple CCN requirements
Applied to: Bill of Lading Processing
WHEN
The system processes bill of lading information using GCCCBOL service
THEN
Call GCCCBOL service with cargo record, customs records, and shipment data. If multiple CCN array is returned with data, process each CCN in the array (up to 99) and spawn GCT0111E process for each additional manifest with waybill key, waybill date, CCN, and action code 'AM'
Context: CSA indicator status, AU table data availability, and existing importer information
GIVEN
CSA indicator status, AU table data availability, and existing importer information
Applied to: Importer Data Processing
WHEN
The system determines importer data source and processing
THEN
If CSA indicator is on or AU table is blank or existing importer data is present, continue with current importer data. Otherwise, if AU table contains importer and business number, use AU importer data, set business number qualifier to 'M5', and turn on CSA indicator
Context: In-transit status (transit or return) and CSA indicator status
GIVEN
In-transit status (transit or return) and CSA indicator status
Applied to: CSA Indicator Management
WHEN
The system processes CSA indicator for transit shipments
THEN
If in-transit status is transit or return and CSA indicator is on, turn off CSA indicator, set AU importer not found flag, and clear importer name, business number qualifier, and business number fields
Context: Action code of 'US' or 'RT' and a description source CCN provided
GIVEN
Action code of 'US' or 'RT' and a description source CCN provided
Applied to: Description Capture from Related CCN
WHEN
The system captures description from the related CCN
THEN
Retrieve description data from specified CCN using GCCCCIO2 service. If successful, extract lading description and cargo data. For 'US' action, prepend CCN and ' MOVING IN TRANSIT THROUGH CANADA ' to description. For 'RT' action, prepend CCN and ' MOVING IN TRANSIT THROUGH US ' to description. Compress modified description and update cargo records
Context: Origin and destination station state codes
GIVEN
Origin and destination station state codes
Applied to: Country Code Determination
WHEN
The system determines country codes
THEN
For origin station state code, search state-country table to find matching entry and set origin country. For destination station state code, search state-country table to find matching entry and set destination country. If no match found, leave country code blank
Context: Notify party name and consignee country code
GIVEN
Notify party name and consignee country code
Applied to: Notify Party Country Setting
WHEN
The system processes notify party information
THEN
If notify party name is not blank, copy consignee country code to notify party country code field
Context: Origin country and destination country codes
GIVEN
Origin country and destination country codes
Applied to: Application Type Determination
WHEN
The system determines application type
THEN
Search application type table using origin-destination country combination. If match found, set application type code and in-transit status from table entry. If CCN key starts with '6105E' and in-transit status is ocean, set broker name to 'NOT-REQ'
Context: Action code not 'RT' or 'US' and CCN key starting with '6105E' or '6105P'
GIVEN
Action code not 'RT' or 'US' and CCN key starting with '6105E' or '6105P'
Applied to: Broker Information Retrieval
WHEN
The system retrieves broker information
THEN
Call GCCCROS2 service with shipper chop, consignee chop, origin station, destination station, origin SPLC wildcard, destination road number, and commodity code. If no data found, retry with shipper chop and origin station wildcards. If still no data found, retry with commodity code wildcard
Context: Broker data from crossing table lookup and existing broker information
GIVEN
Broker data from crossing table lookup and existing broker information
Applied to: Broker Data Validation
WHEN
The system validates and applies broker data
THEN
If crossing table data found and override flag equals 'Y', apply broker data. If crossing table data found and override flag not 'Y', apply broker data only if current broker name is blank, 'UNKNOWN', or 'NOT-REQ'. If broker specifies Canadian manifest to station, update manifest to station information and validate customs codes
Context: Action code of 'RT' (return) or 'US' (transit)
GIVEN
Action code of 'RT' (return) or 'US' (transit)
Applied to: Customs 2000 Detour Processing
WHEN
The system processes transit/return actions
THEN
Set broker name to 'NOT-REQ' and clear broker name 2. For 'RT' action: set in-transit status to RETURN, application type to '33', clear destination station information, and update origin station from port lookup. For 'US' action: set in-transit status to TRANSIT and application type to '33'
Context: In-transit status determination and CCN key information
GIVEN
In-transit status determination and CCN key information
Applied to: In-Transit Status Setting
WHEN
The system sets in-transit status and manages indexes
THEN
If in-transit status is RETURN, clear destination station index, destination station index station, and error/release status index. If CCN key does not start with '6105E', set in-transit status to LOCAL and clear destination station and error/release status indexes
Context: EDI BOL shipper data or FastWay shipment shipper data
GIVEN
EDI BOL shipper data or FastWay shipment shipper data
Applied to: Shipper Record Building
WHEN
The system builds the shipper customs record
THEN
Set entity ID to 'SH', sequence to '0001'. If EDI shipper data found, use consignor name and shipper chop from EDI, get address from EDI address segments, get contact information from EDI contact segments. If EDI data not found, use shipper data from FastWay shipment root. Validate all segments and insert customs record
Context: EDI BOL consignee data or FastWay shipment consignee data
GIVEN
EDI BOL consignee data or FastWay shipment consignee data
Applied to: Consignee Record Building
WHEN
The system builds the consignee customs record
THEN
Set entity ID to 'CN', sequence to '0002'. If EDI consignee data found, use shipper name and consignee chop from EDI, get address from EDI address segments, get contact information from EDI contact segments. If EDI data not found, use consignee data from FastWay shipment root. Validate all segments and insert customs record
Context: EDI transportation data or FastWay shipment data for various entity types
GIVEN
EDI transportation data or FastWay shipment data for various entity types
Applied to: N1 Entity Segment Building
WHEN
The system builds N1 entity segments
THEN
For each entity type (SF, UC, BN, C1, N1, PF, SS, 11, MC, OO, FW, NN), search EDI transportation data for matching organization ID. If found, extract entity information, address data, and contact information. Build complete N1 segment with entity ID, name, address, and contact details. Validate segment data and insert customs record with appropriate sequence number
Context: Contact information from EDI or FastWay data sources
GIVEN
Contact information from EDI or FastWay data sources
Applied to: Contact Information Processing
WHEN
The system processes contact information for entity records
THEN
Extract contact function code, contact name, communication number qualifier, and communication number. Validate communication qualifier is blank, 'FX', or 'TE'. If contact information is incomplete, generate appropriate error messages for missing required fields
Context: Completed customs record 55 data with CCN key, record type, and sequence number
GIVEN
Completed customs record 55 data with CCN key, record type, and sequence number
Applied to: Customs Record 55 Insertion
WHEN
The system inserts customs record 55
THEN
If sequence index is within maximum sequence limit, set CCN key, record type to '55', and sequence number. Move complete record to customs record array and increment sequence index. Validate all required fields before insertion
Context: EDI importer data, AU table importer data, or backed up importer information
GIVEN
EDI importer data, AU table importer data, or backed up importer information
Applied to: Importer Segment Building
WHEN
The system builds the importer segment
THEN
If EDI importer data found, create importer record with EDI details and manage CSA indicator based on business number qualifier. If EDI data not found but backed up importer data exists, use backed up data. If AU table data found and no other importer data, create importer record from AU table with business number qualifier 'M5' and turn on CSA indicator
Context: A cargo processing request is received with an action type
GIVEN
A cargo processing request is received with an action type
Applied to: Action Type?
WHEN
The system evaluates the action type
THEN
The system routes to release processing if action is RELEASE, routes to cancel release processing if action is CANCEL-RELEASE, or continues without action for any other action type
Context: A Container Control Number key is provided for cargo processing
GIVEN
A Container Control Number key is provided for cargo processing
Applied to: Manifest Data Retrieval
WHEN
The system attempts to retrieve the corresponding manifest data
THEN
The system loads the manifest record if found, or displays error message 'CAN NOT LOCATE MANIFEST FOR RELEASE/CANCEL RELEASE' if the manifest cannot be located
Context: A cargo release request is initiated
GIVEN
A cargo release request is initiated
Applied to: Manifest Release Processing
WHEN
The system processes the manual release
THEN
The system sets message ID to GCW123, sets manual release flag to true, copies the CCN key, clears the release quantity field, and moves the release reason to comments
Context: A cancel release operation is being processed
GIVEN
A cancel release operation is being processed
Applied to: CSA Cargo Status Management
WHEN
The CSA indicator is ON
THEN
The system sets the cargo status to CSA-DLV (CSA Delivery)
Applied to: Release Audit Trail Creation
WHEN
The system creates audit trail data
THEN
The system records current machine date as unreleased date, captures ACF2 user ID as the user who performed cancel, saves original release date, clears release information, and sets the unrelease reason
Applied to: Master Manifest Processing
WHEN
The manifest is identified as a master manifest
THEN
The system calls GCCCANRL program with CCCOM and CCN key parameters for additional cancel release processing
Context: A cancel release operation is being processed and CSA indicator is OFF
GIVEN
A cancel release operation is being processed and CSA indicator is OFF
Applied to: Manifest Status Determination
WHEN
The system evaluates the original CCN and manifest type
THEN
The system sets status to MANUAL if original CCN is blank OR it's a follower manifest, otherwise sets status to SENT
Context: A cancel release operation requires station information
GIVEN
A cancel release operation requires station information
Applied to: Station Information Lookup
WHEN
The system performs station lookup using manifest destination station name
THEN
The system uses station number from lookup table if successful (return flag = '0'), otherwise uses existing destination station number and initializes station data
Context: A cancel release operation is processing cargo with in-transit status
GIVEN
A cancel release operation is processing cargo with in-transit status
Applied to: In-Transit Status Management
WHEN
The in-transit status is 'Z' OR 'E'
THEN
The system changes the in-transit status to LOCAL
Context: A cancel release operation has been processed
GIVEN
A cancel release operation has been processed
Applied to: Cargo Release Logging
WHEN
The system creates audit log entry
THEN
The system initializes logging input, sets action code to LOG-CARGO-RELEASE-REMOVED, and spawns GCT1051E message with security information, CCN key, cargo type CA-CARGO, transaction details, user ID and timestamp
Context: A cargo release has been processed
GIVEN
A cargo release has been processed
Applied to: Release Notification Generation
WHEN
The operation is NOT an export operation
THEN
The system generates and sends GCT1231E notification message with release details
Context: Cargo processing operations have been completed
GIVEN
Cargo processing operations have been completed
Applied to: Manifest Data Update
WHEN
The system finalizes the transaction
THEN
The system updates the manifest record with all changes made during processing using REPL function
Context: A CCN key is provided for manifest processing
GIVEN
A CCN key is provided for manifest processing
Applied to: 2:Initialize manifest data retrieval
WHEN
The system initializes manifest data retrieval
THEN
The system should fetch all manifest segments and set up data structures for processing
Context: An action code is provided in the input parameters
GIVEN
An action code is provided in the input parameters
Applied to: 3:Action Code Processing
WHEN
The system processes the action code
THEN
The system should store the action code for use in subsequent manifest processing steps
Context: A manifest has commodity and origin country information
GIVEN
A manifest has commodity and origin country information
Applied to: 4:Automotive Release Check
WHEN
The origin country is US, CA, or blank OR the origin country is MX with automotive type code 'C' in position 2, AND the CSA indicator is off
THEN
The system should set the automotive flag to true
Context: A manifest is being processed with broker notification enabled
GIVEN
A manifest is being processed with broker notification enabled
Applied to: 33:Broker Notification Processing
WHEN
The notify broker flag is set to true
THEN
The system should prepare broker message with action code 'ZZZ' and spawn GCT1051E transaction
Context: A transaction type is specified for processing
GIVEN
A transaction type is specified for processing
Applied to: 5:Transmission Number Generation
WHEN
The transaction type is 'GCT036', 'GCT0021E', 'GCT1251E', 'GCT0111E', or other
THEN
The system should assign transmission prefix 036, 002, 125, 011, or 901 respectively
Context: A manifest requires customs notification
GIVEN
A manifest requires customs notification
Applied to: 6:Destination Address Setup
WHEN
The notify customs flag is true AND the manifest is not a pre-emanifest
THEN
The system should set destination to 309-DESTINATION-5040, otherwise set to 309-DESTINATION
Context: A transmission number is generated
GIVEN
A transmission number is generated
Applied to: 7:Root Transaction Creation
WHEN
The system creates the root transaction
THEN
The system should create transaction root with transmission number, transaction set '309', and handle duplicate transmission numbers by incrementing
Context: A transaction is being processed
GIVEN
A transaction is being processed
Applied to: 8:ST Segment Processing
WHEN
The ST segment is created
THEN
The system should create ST segment with identifier 'ST', destination address, and transaction code '309'
Context: A manifest is being processed with arrival and program information
GIVEN
A manifest is being processed with arrival and program information
Applied to: 9:M10 Segment Processing
WHEN
The arrival indicator is 'Y' OR program name is 'GCX148'
THEN
The system should set manifest type code to 'A' for arrival, otherwise evaluate Canadian customs train ID and program name to set 'C' for customs or 'P' for pre-manifest, with special case of spaces for 5040 destination
Context: A manifest has an action code and border arrival information
GIVEN
A manifest has an action code and border arrival information
Applied to: 9:M10 Segment Processing
WHEN
The action code is '04', '05', or '06' AND border arrival date is not blank AND manifest is not pre-emanifest
THEN
The system should set transaction purpose code to 'CO' and set post-emanifest amendment flag to true, otherwise use the action code as transaction purpose code
Context: A manifest requires ETA date processing
GIVEN
A manifest requires ETA date processing
Applied to: 10:P4 Segment Processing
WHEN
The destination is 309-DESTINATION
THEN
The system should use current machine date, otherwise use border arrival ETA or calculate from waybill date plus configured days if ETA is blank
Context: A transaction requires line number identification
GIVEN
A transaction requires line number identification
Applied to: 11:LX Segment Processing
WHEN
The LX segment is processed
THEN
The system should create LX segment with identifier 'LX' and assigned number '000001'
Context: A post-emanifest amendment is required
GIVEN
A post-emanifest amendment is required
Applied to: 12:M13 Segment Processing
WHEN
The M13 segment is processed
THEN
The system should create M13 segment with SCAC 'CPRS', manifest from station name, CCN key, and amendment code '60' if blank or use existing amendment code
Context: A manifest has consolidated shipment information
GIVEN
A manifest has consolidated shipment information
Applied to: 13:M11 Segment Processing
WHEN
The consolidated indicator is 'Y'
THEN
The system should set bill of lading type code to 'Y', otherwise set to spaces
Context: A manifest has weight unit qualifier information
GIVEN
A manifest has weight unit qualifier information
Applied to: 13:M11 Segment Processing
WHEN
The weight unit qualifier is 'KG ' or ' KG'
THEN
The system should set weight unit code to 'K', otherwise set to 'L'
Context: A manifest has CSA indicator information
GIVEN
A manifest has CSA indicator information
Applied to: 14:N9 Reference Processing
WHEN
The CSA indicator is on
THEN
The system should set reference number to '01', otherwise set to '00'
Context: A manifest has in-transit status and origin country information
GIVEN
A manifest has in-transit status and origin country information
Applied to: 14:N9 Reference Processing
WHEN
The in-transit status is 'T' OR (status is 'L' AND origin country is not 'CA' AND table lookup is successful) OR (status is 'E' AND origin country is not 'CA')
THEN
The system should create N9 segment with qualifier 'KD' and reference number 'IN-TRANSIT'
Context: Entity information is being processed for a specific destination type
GIVEN
Entity information is being processed for a specific destination type
Applied to: 15:N1-N3-N4 Entity Processing
WHEN
The destination is 309-DESTINATION
THEN
The system should validate N1 codes against 4040 table, otherwise validate against 5040 table and require city name, country code, and postal/state codes for US/CA addresses
Context: A manifest requires in-bond processing
GIVEN
A manifest requires in-bond processing
Applied to: 18:M12 Segment Processing
WHEN
The M12 segment is created
THEN
The system should set in-bond type code to '61'
Context: Port information is being processed for different locations
GIVEN
Port information is being processed for different locations
Applied to: 19:R4 Port Processing
WHEN
Multiple R4 segments are created for origin, border crossing, and destination
THEN
The system should assign function codes 'O'/'J' for origin (based on destination type), '3' for border crossing, '4' for destination border, and 'E'/'R' for final destination (based on destination type)
Context: Equipment information is being processed
GIVEN
Equipment information is being processed
Applied to: 20:VID Equipment Processing
WHEN
The conveying car field is blank
THEN
The system should set equipment description code to 'RR' for railroad, otherwise set to 'CN' for container
Context: A manifest is being processed with a specific destination type
GIVEN
A manifest is being processed with a specific destination type
Applied to: Destination Type?
WHEN
The destination type is 5040
THEN
The system should skip M7 seal processing and proceed to N10 description processing, otherwise process M7 seals first
Context: A manifest has seal number information
GIVEN
A manifest has seal number information
Applied to: 21:M7 Seal Processing
WHEN
Seal numbers are available in the manifest data
THEN
The system should create M7 segments with up to 4 seal numbers per segment, processing up to 20 total seal numbers
Context: A manifest is being processed with equipment information
GIVEN
A manifest is being processed with equipment information
Applied to: 22:N10 Description Processing
WHEN
An idler car is found in the shipment
THEN
The system should set quantity to zero for the N10 segment, otherwise use the lading quantity from the manifest
Context: A manifest has commodity information
GIVEN
A manifest has commodity information
Applied to: Hazardous Material?
WHEN
The UN number is blank OR starts with 'NA' OR commodity description danger field is blank
THEN
The system should skip hazardous material processing, otherwise process H1-H2 segments
Context: Hazardous material information is being processed
GIVEN
Hazardous material information is being processed
Applied to: 24:H1-H2 Hazardous Material Processing
WHEN
The destination is 309-DESTINATION
THEN
The system should use the full UN number, otherwise use positions 3-4 of the UN number
Context: A manifest is classified as an idler shipment
GIVEN
A manifest is classified as an idler shipment
Applied to: Idler Shipment?
WHEN
The manifest is an idler shipment AND customs notification is required
THEN
The system should process additional idler cars in the consist
Context: An idler shipment requires processing of follower cars
GIVEN
An idler shipment requires processing of follower cars
Applied to: 25:Idler Car Processing
WHEN
Additional idler cars are found in the consist
THEN
The system should process VID segments for each idler car and include N10 and H1-H2 segments based on destination type and hazardous material presence
Context: All required segments have been processed
GIVEN
All required segments have been processed
Applied to: 30:Transaction Completion
WHEN
The transaction completion phase is reached
THEN
The system should finalize the EDI transaction structure
Context: A transaction has been completed
GIVEN
A transaction has been completed
Applied to: 34:Transaction Completion Notification
WHEN
The transaction completion notification is triggered
THEN
The system should spawn GCT1211E transaction with the transmission number
Context: The program is executing and the first-time processing flag is set
GIVEN
The program is executing and the first-time processing flag is set
Applied to: 2:Process Merlin Configuration
WHEN
The system checks if this is the first OTI processing
THEN
The system processes Merlin configuration, validates Merlin IDs, and initializes reference data, then sets the flag to indicate subsequent processing
Context: Four Merlin user IDs are retrieved from the admin table (DC-P-MERLIN-1 through 4)
GIVEN
Four Merlin user IDs are retrieved from the admin table (DC-P-MERLIN-1 through 4)
Applied to: 3:Control Merlin ID Validation
WHEN
Each Merlin ID is validated against the EMTZ segment
THEN
If DC-P-MERLIN-1 is invalid, use default 'OM01247' and set not-found flag; for other invalid IDs (2,3,4), fall back to DC-P-MERLIN-1 value
Context: A reference number and transaction type indicator are provided
GIVEN
A reference number and transaction type indicator are provided
Applied to: 4:Initialize Reference Data
WHEN
The system initializes reference data and processing flags
THEN
Set message label to 'TRAIN REPORT NUMBER :' for train transactions, 'CARGO CONTROL NUMBER :' for cargo transactions, or 'REFERENCE NUMBER :' for other types
Context: An incoming message with a specific type indicator
GIVEN
An incoming message with a specific type indicator
Applied to: Message Type?
WHEN
The system evaluates the message type
THEN
Route to acknowledgment processing for ACK messages, or route to error processing for ERROR and WARNING messages
Context: An acknowledgment message is received
GIVEN
An acknowledgment message is received
Applied to: 5:Process Acknowledgment Messages
WHEN
The system processes the acknowledgment
THEN
Set MST processing flag to false and route to train or cargo acknowledgment processing based on transaction type
Context: A train acknowledgment message with a reference number
GIVEN
A train acknowledgment message with a reference number
Applied to: 6:Process Train Acknowledgment
WHEN
The system looks up the train report
THEN
If train not found, set error flag and add error message; if found, clear security errors for deleted records, set ACK status with timestamp, and send AEI notification if flag is 'Y'
Context: A cargo acknowledgment message with a control number
GIVEN
A cargo acknowledgment message with a control number
Applied to: 7:Process Cargo Acknowledgment
WHEN
The system looks up the cargo control record
THEN
If cargo not found, add error message and set DCP interface error flag; if found, set status to 'ACK' when current status is 'SENT', determine processing terminal, and process arrival if indicator is 'Y'
Context: An error or warning message is received
GIVEN
An error or warning message is received
Applied to: 8:Process Error Messages
WHEN
The system processes the error message
THEN
Check if message is test data first; if not test data, route to train or cargo error processing based on transaction type
Context: A train error message with a reference number
GIVEN
A train error message with a reference number
Applied to: 9:Process Train Errors
WHEN
The system processes the train error
THEN
If train not found, add appropriate error message (V67 warning or general train error); if found, determine processing terminal and handle V67 warnings specially
Context: A cargo error message with a control number
GIVEN
A cargo error message with a control number
Applied to: 10:Process Cargo Errors
WHEN
The system processes the cargo error
THEN
If cargo not found and message is V67, process as train error; if cargo not found and not V67, add cargo error message; if found, save current status and determine processing terminal
Context: An error code from the message
GIVEN
An error code from the message
Applied to: 11:Retrieve Error Message Text
WHEN
The system looks up the error message text in the MS table
THEN
If message found, use English text from table; if not found, use free-form message text and add 'message not found' error
Context: An error message with error type and a found train or cargo record
GIVEN
An error message with error type and a found train or cargo record
Applied to: 12:Update Train/Cargo Status
WHEN
The system updates the record status
THEN
If error type is 'X', set status to 'WARNING' or 'INFO' and exit; for train records not deleted, set error resend flag and status to 'REJECT' for type 'R' or 'ERROR' otherwise; for cargo records, set status to 'REJECT' for type 'R' or 'ERROR' otherwise
Context: A message with a reference number
GIVEN
A message with a reference number
Applied to: Test Message?
WHEN
The system checks if the message is test data
THEN
Identify as train test if reference equals '6105ETESTTRAIN00000000000', or cargo test if reference starts with '6105ECPRSTESTCARGO' or '6105ETESTCARGO'
Context: A message identified as test data
GIVEN
A message identified as test data
Applied to: 13:Handle Test Messages
WHEN
The system processes the test message
THEN
Set appropriate test flags (TEST-TRAIN or TEST-CARGO) and proceed to special check processing, bypassing normal error message handling
Context: A train record with AEI send flag set to 'Y' and a status change
GIVEN
A train record with AEI send flag set to 'Y' and a status change
Applied to: 14:Send AEI Messages
WHEN
The system processes the train acknowledgment or status update
THEN
Look up email addresses for the port code, send notification with train ID and status, and fall back to default recipients if lookup fails
Context: Messages need to be sent to users
GIVEN
Messages need to be sent to users
Applied to: 15:Process Message Routing
WHEN
The system processes message routing
THEN
Get supervisor Merlin ID from terminal table, validate DC-P Merlin IDs, and prepare for sending messages to MST system and Merlin users
Context: A processing terminal identifier
GIVEN
A processing terminal identifier
Applied to: 16:Get Supervisor Merlin ID
WHEN
The system looks up supervisor information in the LT table
THEN
If table entry found, use alternate terminal if specified and retrieve supervisor Merlin ID; if supervisor ID invalid, add error message and clear user Merlin ID
Context: DC-P Merlin ID needs validation for message sending
GIVEN
DC-P Merlin ID needs validation for message sending
Applied to: 17:Validate Merlin User IDs
WHEN
The system validates the Merlin user ID
THEN
If DC-P1 ID not found, add error message indicating invalid DC&P Merlin userid
Context: An error message that needs to be sent to users
GIVEN
An error message that needs to be sent to users
Applied to: Train Error?
WHEN
The system determines the routing destination
THEN
Route to train message sending if train error flag is set, otherwise route to cargo message sending
Context: A cargo-related message and validated user Merlin ID
GIVEN
A cargo-related message and validated user Merlin ID
Applied to: 18:Send Cargo Messages to Merlin
WHEN
The system sends the message to Merlin users
THEN
Send message to user Merlin ID; if sending fails, fall back to sending to default recipient 'OM01247'
Context: A train-related message and validated user Merlin ID
GIVEN
A train-related message and validated user Merlin ID
Applied to: 19:Send Train Messages to Merlin
WHEN
The system sends the message to Merlin users
THEN
Send message to user Merlin ID with fallback to 'OM01247' if failed, and additionally send a copy to 'CAERROR' file with 'OM01247' as recipient
Context: Messages ready for distribution and MST processing flag is enabled
GIVEN
Messages ready for distribution and MST processing flag is enabled
Applied to: 20:Send MST Messages
WHEN
The system sends messages to MST
THEN
Send header message first, then send each message entry using terminal call letters, and finally send wrap-up message
Context: A cargo record with arrival indicator set to 'Y'
GIVEN
A cargo record with arrival indicator set to 'Y'
Applied to: 21:Process Arrival Notifications
WHEN
The system processes the cargo acknowledgment
THEN
Create arrival notification message with cargo control number, set action code to 'CAA', and send to GCT1481E transaction
Context: A cargo record with status change and Iron Highway configuration
GIVEN
A cargo record with status change and Iron Highway configuration
Applied to: 22:Update Iron Highway Records
WHEN
The system updates the cargo record and status differs from saved status
THEN
Look up Iron Highway configuration, populate record with cargo details including status, car ID, waybill, and shipment ID from N9 segments, then call Iron Highway update program
Context: A processed transaction with current status and reference number
GIVEN
A processed transaction with current status and reference number
Applied to: 24:Log Transaction Activities
WHEN
The system logs the transaction activity
THEN
Create log message with current status, include transaction number for ACK status, set appropriate cargo or train indicator, and send to GCT1051E logging transaction
Context: A test message (train or cargo) being processed
GIVEN
A test message (train or cargo) being processed
Applied to: 25:Process Special Checks
WHEN
The system performs special check processing
THEN
Look up T2 table entry, update 358-ACK timestamp for train test messages or 309-ACK timestamp for cargo test messages with current machine date, century, and time