As an EDI Gateway Service,
I want to orchestrate and execute all GCX112 EDI data mapping and validation logic,
So that I can ensure strict compliance with US Customs (P140) automated payload constraints in a single consolidated service.
I want to orchestrate and execute all GCX112 EDI data mapping and validation logic,
So that I can ensure strict compliance with US Customs (P140) automated payload constraints in a single consolidated service.
Prerequisites & Setup
- [Initialize EDI Segments M10, P4, M15]
The train processing routine begins → The system initializes M10, P4, M15, and M7A segments with their respective identifiers - [Initialize Notification Message]
The system needs to create a notification message → The GCX105 input message structure must be initialized and the security byte set to high values - [Initialize Email Message Structure]
The email configuration retrieval process starts → The system initializes email message structure, sets function code to 'GU', clears all table key values and flags, and sets EOF flag to FALSE - [Initialize Email Message Structure]
The system begins email setup → The email message structure and return status flag are initialized to empty values - [Initialize Text Message Lines]
The email message content area is being prepared → Text message lines are initialized to spaces - [Initialize Email Message Structure]
The email message structure is being prepared → All message fields are cleared, copy user codes are set to spaces, keywords are cleared, and item width is set to 132 characters - [Initialize Email Message Structure]
The email configuration process starts → The email message structure is initialized and the email found flag is reset - [Initialize EDI Segments M10, P4, M15]
The system begins train data mapping → M10 segment is initialized with identifier 'M10', P4 segment is initialized with identifier 'P4', and M15 segment is initialized with identifier 'M15' - [Initialize M10, P4, M15 Segments]
The system begins mapping cargo data to EDI format → M10, P4, and M15 segments are initialized with their respective identifiers - [Initialize Message Security]
The system sets security parameters for the transmission → The security byte should be set to HIGH-VALUES to authorize the transmission - [Initialize Transmission Segment]
The transmission creation process begins → The transmission segment is initialized with empty values
Core Acceptance Criteria
- [Handle Train Arrival Action]
The train is not configured to send EDI or deletion is not required → The system creates arrival transaction, calls arrival routine, sets arrived flag to 'A', and updates train record - [Handle Train Delete Action]
The train is not configured to send EDI and deletion is required → The system creates deletion transaction, sets deleted flag to true, sets deleted-confirm flag to true, and clears secondary index - [Map Train Data to EDI]
Train data is mapped to M10, P4, and M15 segments → The system applies country code logic (US for export trains ending in 'T' with valid ports, MX for station '2304', CA as default), sets application type '28' for US export trains, and populates vessel name, dates, and location information - [Map Cargo Data to EDI]
Cargo data is mapped to M10, P4, and M15 segments → The system applies notification qualifier logic based on action codes (arrival, export, transfer, etc.), determines bond vs equipment processing, handles car ID formatting, and populates reference numbers and location data - [Create EDI Transmission Records]
Transmission records are created → The system creates transmission root with unique number and '353' transaction set, then creates dependent segments for M10, P4, and M15 data with sequence numbers - [Update US Train Data]
Train record update is performed → The system updates the train record with new status flags, arrival indicators, enroute status, or deletion markers based on the action processed - [Update US Cargo Data]
Cargo record update is performed → The system updates the cargo record with new arrival flags, export indicators, transfer status, or cargo processing status based on the action processed - [Create Log Entries]
Log entry creation is performed → The system creates GCX105 transaction log with action details, user ID, date, time, and descriptive messages for audit trail purposes - [Finalize EDI Transmission]
Transmission finalization is performed → The system spawns GCX109 transaction with transmission number to trigger EDI processing workflow - [Retrieve User Security Table Segment]
The system calls table segment retrieval process → User security table segment is retrieved and return status is captured - [Load Security Settings]
The return flag indicates successful retrieval → The retrieved table segment is moved to user security segment storage - [Set Default Security Settings]
The return flag indicates unsuccessful retrieval → User security segment is initialized to default values - [Set Transmission Prefix to 112]
Transmission prefix is being set → Transmission prefix is set to value 112 - [Set Transmission Number from Machine Time]
Transmission number is being generated → Current machine time is used as the transmission number - [Call READQ to Read Message Queue]
The system calls READQ to retrieve the message → The message is successfully read from the queue using CCCOM communication area and input message length - [Move Message Content to GCX112-INPUT]
The system processes the message content → The message content is moved from AREA-CSI-INPUT to GCX112-INPUT structure for further processing - [Record Type = US Train?]
If the record type and finds it matches the US Train indicator (GCX112-US-TRAIN condition is true) → The system routes the processing to the US Train routine (B200-US-TRAIN-ROUTINE) to handle train-specific business logic - [Record Type = US Cargo?]
If the record type and finds it matches the US Cargo indicator (GCX112-US-CARGO condition is true) → The system routes the processing to the US Cargo routine (B300-US-CARGO-ROUTINE) to handle cargo-specific business logic - [Route to US Train Processing Routine]
The system needs to process the train transaction → The system performs the B200-US-TRAIN-ROUTINE to execute train-specific processing logic including validation, data movement, and transmission creation - [Route to US Cargo Processing Routine]
The system needs to process the cargo transaction → The system performs the B300-US-CARGO-ROUTINE to execute cargo-specific processing logic including validation, status updates, and transmission creation - [Retrieve US Train Data from Database]
The system needs to process the train record → The system retrieves the complete train record from the database using the train identifier - [Check if EDI Send Required]
The system checks the EDI send configuration → If the train is configured to send EDI, processing continues; otherwise, specific action code validations are performed - [Action Code = TD and Delete Required?]
EDI send is not required → The system continues with delete processing - [Action Code = TAR?]
The system processes the action code → The system initiates train arrival processing workflow - [Action Code = TD?]
The system processes the action code → The system initiates train deletion processing workflow - [Action Code = TUA?]
The system processes the action code → The system initiates train un-arrival processing workflow - [Set Train Arrived Flag]
The system processes the train arrival → The system creates a GCX105 message, calls the arrival routine, and exits processing - [Set Train Delete Flags]
The system processes the train deletion → The system creates a GCX105 message, sets deleted and deleted-confirm flags, clears secondary index, and exits processing - [Clear Train Arrived Flag]
The system processes the train un-arrival → The system clears the arrived flag, creates a GCX105 message, and exits processing - [Check Security Settings]
The system checks the UTF change security setting → If UTF change is not 'S', the system performs additional action code validations - [Map Train Data to EDI Segments]
The system prepares EDI transmission → The system maps train data fields to M10, P4, and M15 EDI segments according to business rules - [Create EDI Transmission Record]
The system creates the transmission → The system creates a transmission record with unique number and transaction set '353' - [Create M10 EDI Segment]
The system creates EDI dependent segments → The system creates M10 segment with sequence number '00001' - [Create P4 EDI Segment]
The system creates EDI dependent segments → The system creates P4 segment with sequence number '00002' - [Create M15 EDI Segment]
The system creates EDI dependent segments → The system creates M15 segment with sequence number '00003' - [Update Train Record in Database]
The system updates the train record → The system sets do-not-send-EDI flag and replaces the train record - [Finalize EDI Transmission]
The system finalizes the transmission → The system spawns GCT1091E transaction with transmission number - [Is GCUTR-DO-SEND-EDI Flag Set?]
The system checks the GCUTR-DO-SEND-EDI flag → If flag is set to send EDI, continue with EDI processing, otherwise evaluate alternative processing conditions - [Action Code = 'TD' AND Delete Required?]
The action code is 'TD' and the train record has delete required flag set → Continue with EDI processing for the deletion - [Security Setting: UTF-CHANGE = 'S'?]
The GCSTBRT-US-UTF-CHANGE field equals 'S' → Continue with security override and proceed to EDI data mapping - [Check Train Action Code]
If the action code → The system should route to TAR processing if action code is 'TAR', TD processing if action code is 'TD', TUA processing if action code is 'TUA', or continue to EDI processing for other codes - [Perform SE Table Lookup]
Station code validation is performed → Move the station code to lookup key, set table ID to SE, set function code to GU, and call table segment lookup - [Perform SE Table Lookup]
Location ID validation is performed → Move the location ID to lookup key, set table ID to SE, set function code to GU, and call table segment lookup - [Generate Arrival Log Entry]
EDI transmission segments have been created → The system initializes and populates a GCX105 audit message with train arrival details including train number, action code, user ID, date and time - [Delete Required Flag Set?]
The system processes the TD action code → The system continues with EDI processing without performing delete operations - [Set Train/CCN Information]
The system populates train identification information → The system moves the train or US CCN from input message to the log entry - [Set Record Type Code]
The system populates record type information → The system moves the record type code from input message to the log entry - [Set TD Action Code]
The system populates action code information → The system moves the TD action code from input message to the log entry - [Set Train Control Number]
The train control number needs to be recorded → The train or US CCN from the input message must be copied to the notification message train control number field - [Set Record Type Code]
The record type needs to be specified → The record type code from the input message must be copied to the notification message record type field - [Set Action Code as TUA]
The action code needs to be specified → The action code from the input message must be copied to the notification message action code field - [Set Transaction ID as GCT1121E]
The sending transaction needs to be identified → The sending transaction field must be set to 'GCT1121E' - [Set User ID and Timestamp]
User identification and timing information needs to be recorded → The ACF2 user ID, current date, and current time must be set in the notification message - [Create Log Entry]
The log entry needs to be created → The GCT1051E spawn process must be performed to create the log entry - [Set Cancel Conveyance Arrival Qualifier]
The EDI transmission qualifier needs to be set → The M15 notify entity qualifier must be set to CANCEL-CONVEYANCE-ARRIVAL - [Set EDI Notification Type to Conveyance Enroute]
The train enroute flag is set → The system sets the EDI notification entity qualifier to conveyance enroute - [Action Code IAR or CIR?]
The action code is 'IAR':- 'CIR'
- [Map Cargo Data to EDI Segments]
The cargo data mapping process is initiated → Populate M10 manifest segment with SCAC, transport type, country, vessel details AND populate P4 port segment with location and timing information AND populate M15 notification segment with reference numbers and qualifiers based on action code - [Action Code CAB?]
The in-bond type code is NOT 'TR' AND NOT 'MT' → Create an additional M15 segment with export-by-equipment or export-by-bond qualifier based on CCN status - [Action Code AIA?]
The AIA processing is initiated → Create an additional M15 segment with export-by-equipment or export-by-bond qualifier AND set the yes-no condition flag to 'Y' - [Set Transfer Flag and SCAC Code]
The transfer processing is executed → Set the transfer flag to 'Y' AND update the transfer SCAC code with the carrier SCAC from the input message - [Skip Processing - Exit to B300-END]
The train ID is blank or equals 'TRAIN' → The system should immediately exit the cargo processing routine without further processing - [Update Transfer SCAC Code]
The transfer SCAC update is executed → The RT16 transfer SCAC code field is updated with the carrier SCAC from the input message - [Create TIE Log Entry]
The TIE log entry creation is executed → A GCX105 message with action code 'TIE' is created and spawned for audit trail - [Continue with Normal Processing]
The cargo record either has a SCAC code that is not CPRS:- has CPRS SCAC code with a valid train ID that is not blank and not equal to 'TRAIN'
- [Continue with Export Processing]
The system checks the cargo export indicator field and finds it is not set to 'Y' (meaning cargo has not been exported yet) → The system continues with normal export processing including setting export flags and creating transmission records - [Set Transfer SCAC Code from Input Message]
The transfer SCAC code assignment is executed → The carrier SCAC code from the input message is assigned to the transfer SCAC field - [Store Transfer SCAC Code]
The system updates the cargo record for transfer → The carrier SCAC code from the input message (GCX112-CARRIER-SCAC) is stored in the cargo record field GCUSRT-RT16-TRANSFER-SCAC-CDE - [Map Transfer Notification Data]
The system creates the M15 notification segment → Transfer notification qualifier is set to TRANSFER-BY-EQUIPMENT, car ID is set as reference number, event date and time are populated, location code is set, tax number is used as reference, carrier SCAC and city information are included - [Generate Transfer Message]
The system generates the GCX105 transfer notification message → A TFT action code message is created containing the carrier SCAC code, 'AT' indicator, and city name for the transfer location - [Build Email Address List]
The system checks if BK table use-internet flag equals 'Y' → The system formats the internet address with 'INTERNET:' prefix and adds it to the email message list - [Send Email via EMCSEND3]
The system calls the email service with report details → The system sends the email report and validates successful transmission - [Purge Message Queue]
The system completes the email transmission process → The system purges the message queue to clean up resources - [Read BK Table Segment]
The system performs BK table lookup → The system calls table segment retrieval function to get email configuration data - [BK Table Record Found?]
The BK table record is not found (return flag not equal to '0') → The system initializes empty BK segment and sets EOF flag to TRUE to terminate the email retrieval loop - [Move Table Data to BK Segment]
The BK table record is found (return flag equals '0') → The system moves the retrieved table segment data to BK segment structure for further processing - [Read B1 Table Segment for Internet Address]
The system needs to get internet address details → The system performs B1 table lookup to retrieve internet address configuration data - [B1 Table Record Found?]
The B1 table record is not found (return flag not equal to '0') → The system initializes empty B1 segment and sets EOF flag to TRUE to terminate the email retrieval process - [Move Table Data to B1 Segment]
The B1 table record is found (return flag equals '0') → The system moves the retrieved table segment data to B1 segment structure for email address processing - [Build Internet Email Address 'INTERNET: ' + Address]
The system needs to format the email address for notification → The system concatenates 'INTERNET: ' prefix with the internet address from B1 segment to create formatted email address - [Store Email Address in Message Line]
The system needs to store the email address for notification → The system stores the formatted email address in the message line corresponding to the current counter position - [Set Email Found Flag to TRUE]
The email address is stored in the message structure → The system sets the email found flag to TRUE to indicate successful email configuration - [Read BK Table for Email Config]
The system performs BK table lookup → The email configuration segment is retrieved from the BK table using the configuration key - [Read B1 Table for Internet Address]
The system performs B1 table lookup → The internet address segment is retrieved from B1 table - [Use Internet Email?]
If the use internet flag → If BK use internet flag equals 'Y', internet email processing is enabled, otherwise sequence counter is incremented - [Build Internet Email Address]
The system builds the email address string → The email message line is populated with 'INTERNET: ' concatenated with the B1 internet address - [TER Email Configuration Found?]
TER email configuration has been found during email lookup process → The report recipient should be set to external email system - [Set Merlin System as Recipient]
No TER email configuration has been found during email lookup process → The report recipient should be set to the Merlin customs application identifier - [Send Report to Merlin System]
The report transmission is initiated → The report should be sent through the EMCSEND3 service to the configured recipient - [Configure Email Parameters]
The system configures email parameters → Clear copy user codes and keywords, set report subject, clear item sequence numbers, and set message width to 132 characters - [Add Report Line 1 to Email Message]
The email message content is being assembled → Report line 1 is added to the email text message lines and the line counter is incremented - [Add Blank Line to Email Message]
The email message formatting requires section separation → A blank line is added to the email text message lines and the line counter is incremented - [Add Report Line 2 to Email Message]
The email message content is being assembled → Report line 2 is added to the email text message lines and the line counter is incremented - [Add Report Line 3 to Email Message]
The email message content is being finalized → Report line 3 is added to the email text message lines - [Send Email Report via EMCSEND3]
The report needs to be transmitted to recipients → The system calls the EMCSEND3 service with sender, recipient, subject, and message content - [Purge Message Queue]
Post-transmission cleanup is required → The system purges the message queue using the CIMS service with PURG function - [Handle Email Send Failure]
The email service indicates unsuccessful transmission → The system logs 'SEND TO FILE OF OM01247 FAILED' error message and calls error handling routine - [Read BK Table Segment]
Accessing the BK table for email configuration → The table segment is read using the configuration key and return status is captured - [Move Table Data to BK Segment]
The table read operation was successful → The table segment data is moved to the BK segment structure for further processing - [Read B1 Table Segment]
Accessing the B1 table for internet addresses → The table segment is read and return status is captured - [Move Table Data to B1 Segment]
The table read operation was successful → The table segment data is moved to the B1 segment structure for email processing - [Store Email Address in Message Line]
Storing the email address for notification use → The email address string is stored in the email message line at the current TER index position - [Set Train ID as Key Value]
The system prepares to retrieve train data from the database → The train identifier should be set as the key value for the database query - [Train Data Retrieved Successfully]
The train record is found and successfully retrieved → The train data should be available in the train root segment for further processing - [Extract CCN Key from Input Message]
The system processes the message for cargo data retrieval → The US cargo control number (CCN) is extracted and assigned as the database search key - [Call Database to Get US Cargo Segment]
The system executes the database retrieval operation → The database is accessed to retrieve the US cargo segment data - [US Cargo Data Retrieved Successfully]
The cargo data is successfully loaded into memory → The US cargo segment data is available for further business processing - [Call Database Replace Function]
The database replace function is called with the train segment data → The US train segment is replaced in the database with the updated information - [Update Transfer SCAC Code]
The action code is 'CTR' (Cargo Transfer) or 'MTR' (Manual Transfer) → The transfer SCAC code is updated with the carrier SCAC from the input message - [Replace US Cargo Segment in Database]
All cargo field updates are ready to be persisted → The cargo segment is replaced in the database using the REPL function to save all changes - [Set Standard SCAC Code to CPRS]
The M10 segment SCAC field needs to be populated → The SCAC code is set to 'CPRS' - [Set Transport Type to Rail]
The transportation type code needs to be assigned → The transport type code is set to 'R' indicating rail transportation - [Map Train ID to Vessel Name]
EDI M10 segment vessel name field needs to be populated → The train key (GCUTR-KEY) is mapped to the M10 vessel name field (M10-05-VESSEL-NAME) - [Handle Country Code Mapping - Set Country to US for Export, Set Country to CA for Import, Set Country to MX for Mexico Station]
The system needs to determine the country code for EDI transmission → If vessel name position 23 is 'T' and port is valid, country code is set to 'US' for export trains; if station code is '2304', country code is set to 'MX' for Mexico; otherwise country code is set to 'CA' for Canada - [Set Export Application Type - Set Type 28 for Export Trains]
The train is being processed as an export shipment → The application type is set to '28' in the M10 segment - [Handle Date Format Conversion - Convert EDA Date Format]
The EDA date needs to be formatted for EDI transmission → If EDA date is spaces or zeroes, century is set to 0; if year is less than 70, century is set to 20; otherwise century is set to 19, and the formatted date is mapped to P4 ETA date field - [Set Manifest Type to Header, Set Conditional Response Code to Yes, Set Record Type to TRAIN]
Standard manifest fields need to be populated → Manifest type code is set to 'H' for header, conditional response code is set to 'Y' for yes, record type is set to 'TRAIN', and quantity is set to '1' - [Map Train ID to Record Number, Map Station Code to Location ID, Map Firms Code to ID Code, Map ETA Time]
EDI segments need to be populated with train details → Train key is mapped to M10 record number and M15 reference number, station code is mapped to P4 location ID and M15 location qualifier, firms code is mapped to P4 ID code, and ETA time is mapped to P4 time field - [Set Current Date, Set Current Time]
Date and time fields need to be populated → Current system date is set in M15 date field and current system time is set in M15 time field - [Clear Optional Fields - Seal, SCAC, City, State, Set Condition Flag to No]
Optional fields need to be initialized → Seal number, SCAC, reference number, city name, and state/province code fields are set to spaces, and yes/no condition flag is set to 'N' - [Set SCAC Code from Cargo Data]
Mapping cargo data to M10 segment → SCAC code from cargo record is assigned to M10-01-SCAC field - [Set Transport Type Code]
Mapping cargo data to M10 segment → Transport type code from cargo record is assigned to M10-02-TRANSP-TYP-CDE field - [Set Country Code]
Mapping cargo data to M10 segment → Country code from cargo record is assigned to M10-03-COUNTRY-CDE field - [Set Vessel Name]
Mapping cargo data to M10 segment → Vessel name from cargo record is assigned to M10-05-VESSEL-NAME field - [Set Flight/Voyage Number]
Mapping cargo data to M10 segment → Flight/voyage number from cargo record is assigned to M10-06-FLIGHT-VOYAGE-NUM field - [Set Reference Numbers and Quantities]
Mapping cargo data to M10 segment → Reference number is assigned to M10-07-REF-NUM and quantity is assigned to M10-08-QUANTITY - [Set Manifest Type to 'H']
Setting manifest type information → Manifest type code 'H' is assigned to M10-09-MANIFEST-TYP-CDE field - [Set Record Type to 'CARGO']
Setting record type information → Record type 'CARGO' is assigned to M10-12-RCD-TYPE field - [Set Record Number to CCN Key]
Setting record identification in M10 segment → US CCN key is assigned to M10-12-RCD-NUM field - [Map Location and Date Information]
Mapping cargo data to P4 segment → Location ID is assigned to P4-01-LOCATION-ID and ETA date is assigned to P4-02-ETA-DATE - [Map Arrival Notification Data]
Mapping notification data to M15 segment → Arrival notification qualifier is set based on bond vs equipment type, reference number is set from entry number or car ID, and condition flag is set appropriately - [Map Export Notification Data]
Mapping notification data to M15 segment → Export notification qualifier is set based on bond vs equipment type, reference number is set from entry number or car ID - [Map Transfer Notification Data]
Mapping notification data to M15 segment → Transfer notification qualifier is set, car ID is used as reference, tax number and carrier SCAC are mapped to reference and SCAC fields, city name and state are mapped accordingly - [Map Cancel Notification Data]
Mapping notification data to M15 segment → Cancel notification qualifier is set based on arrival vs export and bond vs equipment type, reference number is set from entry number or car ID - [Map Diversion Notification Data]
Mapping notification data to M15 segment → Inbond diversion qualifier is set, entry number is used as reference, and diversion reference number is mapped - [Set Reference Number Qualifier]
Setting reference number qualifier in M15 segment → If entry number exists, use 'IB' qualifier with entry number; otherwise if in-bond control number exists, use 'IB' qualifier with control number - [Set Location Qualifier and Time]
Setting location and time information in M15 segment → Current date is assigned to M15-03-DATE, location code is assigned to M15-04-LOCATION-QUALIFIER, and current time is assigned to M15-06-TIME - [Set Location Code from Port]
The system processes cargo data validation → The port code is assigned to the working storage location code field - [Map Basic Cargo Data to EDI Segments]
The system processes cargo data for EDI transmission → The cargo data is mapped to M10 segment fields (SCAC, transport type, country, vessel code, vessel name, flight/voyage number, reference number, quantity, manifest type, vessel code qualifier, condition response code, record type, record number) and P4 segment fields (location ID, ETA date, quantity, ID code, time) - [Map CAB Action - Arrival/Export by Bond or Equipment]
The CCN type is unknown (bond processing) and in-bond type code is 'TR' or 'MT' → The system sets notification entity qualifier to EXPORT-BY-BOND and uses entry number as reference, otherwise sets ARRIVAL-BY-BOND for unknown CCN type, or EXPORT-BY-EQUIPMENT/ARRIVAL-BY-EQUIPMENT for known CCN type based on in-bond type code - [Map CAA/MAA Actions - Arrival Notifications]
The system processes arrival notifications → The system sets notification entity qualifier to ARRIVAL-BY-BOND and uses entry number as reference for unknown CCN type, or ARRIVAL-BY-EQUIPMENT and uses car ID as reference for known CCN type - [Map AIA/MIA Actions - Arrival with Special Conditions]
The system processes in-transit arrival notifications → The system sets notification entity qualifier to ARRIVAL-BY-BOND and uses entry number as reference for unknown CCN type, or ARRIVAL-BY-EQUIPMENT and uses car ID as reference for known CCN type, and sets the yes/no condition flag to 'Y' - [Map MUA Action - Cancel Arrival Notifications]
The system processes arrival cancellation → The system sets notification entity qualifier to CANCEL-BOND-ARRIVAL and uses entry number as reference for unknown CCN type, or CANCEL-EQUIPMENT-ARRIVAL and uses car ID as reference for known CCN type - [Map MUE Action - Cancel Export Notifications]
The system processes export cancellation → The system sets notification entity qualifier to CANCEL-BOND-EXPORT and uses entry number as reference for unknown CCN type, or CANCEL-EQUIPMENT-EXPORT and uses car ID as reference for known CCN type - [Map MEX/CEX/IEX Actions - Export Notifications]
The system processes export notifications → The system sets notification entity qualifier to EXPORT-BY-BOND and uses entry number as reference for unknown CCN type, or EXPORT-BY-EQUIPMENT and uses car ID as reference for known CCN type - [Map CTA/MTA Actions - Transfer Notifications]
The system processes transfer notifications → The system sets notification entity qualifier to TRANSFER-BY-EQUIPMENT, uses car ID as reference number, maps tax number to reference number field, carrier SCAC to SCAC field, city name to city field, and city state to state/province field - [Map DIV Action - Inbound Diversion Notifications]
The system processes diversion notifications → The system sets notification entity qualifier to INBOND-DIVERSION, uses entry number as reference number, and maps the cargo reference number to the secondary reference number field - [Set Application Type = '28']
The system assigns application type for the transmission → The application type is set to '28' to indicate US export manifest processing - [Mark as Export Train]
The train qualifies as an export train based on vessel name and valid station code → The export train status flag is set to true for subsequent processing - [Set Reference Numbers and Qualifiers]
System processes location identification → System sets FIRMS code as location ID in notification and for TE in-bond type sets FIRMS code in port segment - [Use Entry Number as Reference]
The system needs to assign a reference number for the notification → The system uses the entry number (GCUSRT-M1202-ENTRY-NUM) as the reference number in the M15 segment - [Use Car ID as Reference]
The system needs to assign a reference number for the notification → The system uses the car ID (WS-CAR-ID) as the reference number in the M15 segment - [Set Location Code from Port Code]
The system needs to populate notification reference data → The location code should be set to the port code from the input message - [Set Current Date and Time]
Reference data is being populated → The notification date should be set to current system date and time should be set to current system time - [Set Carrier SCAC Code]
Carrier information needs to be populated → Set the secondary SCAC code to the carrier SCAC from input, set tax reference number, city name, and state information from input message - [Set Firms Code for Location ID]
The in-bond type code is TE → Set the P4 segment ID code to the firms code from the cargo record - [Set Equipment Reference in M15 Segment]
The routing logic has determined whether to use bond or equipment reference → Set the M15-02-REFERENCE-NUMBER field with either the entry number for bond routing or the formatted car ID for equipment routing - [Use Entry Number as Reference]
The notification segment is being populated → Set the reference number to the cargo's entry number from M1202 field - [Use Car ID as Reference]
The notification segment is being populated → Set the reference number to the processed car ID - [Set Location and Time Data]
The M15 segment is being populated → Set date to current date, location qualifier to port code, time to current time, and initialize SCAC, seal number, city name, and state fields to spaces - [Set Firms Code for Location ID]
The M15 segment is being finalized → Set the location ID field (M15-17-LOC-ID) to the cargo's firms code - [Set Yes Condition Flag]
The M15 notification segment is being created → Set the yes-no condition field to 'Y' - [Set No Condition Flag]
The M15 notification segment is being created for arrival processing → Set the yes-no condition field to 'N' - [Set Entry Number as Reference]
The CCN classification indicates bond processing → The system sets the entry number as the reference number in the M15 segment - [Set Car ID as Reference]
The CCN classification indicates equipment processing → The system sets the car ID as the reference number in the M15 segment - [Set Current Date and Time]
The notification data is being populated → The system sets the current working date and time in the M15 segment - [Clear Additional Fields]
The M15 segment is being populated → The system sets SCAC, seal number, reference number, city name, and state province code fields to spaces - [Set Condition Flag to N]
The M15 segment condition flag needs to be set → The system sets the yes/no condition flag to 'N' - [Update Transfer SCAC Code]
Transfer processing is not skipped due to existing transfer status → The system updates the RT16 transfer SCAC code field with the carrier SCAC from the input message - [Create Transfer Log Entry with TFT Action]
The transfer status has been updated in the cargo record → The system creates a GCX105 message with action code TFT, includes carrier SCAC code, city name with 'AT' prefix, and schedules it for processing with incremented time - [Map Equipment ID to Reference Number]
Creating the M15 notification segment → The system maps the processed car ID to the M15 reference number field - [Set Transfer Notification Type]
Creating the M15 notification segment → The system sets the notify entity qualifier to TRANSFER-BY-EQUIPMENT - [Set Transfer Location Code, Set Transfer Date and Time]
Creating the M15 notification segment → The system sets the location qualifier to the port code from input, sets date to current working date, and sets time to current working time - [Map Transfer Carrier SCAC Code, Map Transfer City Name, Map Transfer State/Province]
Creating the M15 notification segment → The system maps the tax number to reference number field, maps carrier SCAC to SCAC field, maps city name to city field, and maps city state to state/province field - [Set Notification Date and Time]
The notification segment is populated → The system sets the current working date to M15-03-DATE, current working time to M15-06-TIME, and the location code to M15-04-LOCATION-QUALIFIER with YES-NO condition set to 'N' - [Receive DIV Action Code for US Cargo]
The system processes the diversion action code → The system should set the notification entity qualifier to inbound diversion and proceed with diversion processing - [Set Notification Type to Inbound Diversion]
The system maps the diversion data to the M15 EDI segment → The M15-01-NOTIFY-ENTITY-QUALIFIER should be set to INBOND-DIVERSION - [Set Current Date and Time]
Setting up the M15 segment data → The current working storage date should be moved to M15-03-DATE and current time to M15-06-TIME - [Set Location Code from Port]
Processing a diversion notification → The port code should be moved to M15-04-LOCATION-QUALIFIER via working storage location code - [Set Condition Flag to No]
Setting up the M15 segment condition flags → The M15-12-YES-NO-COND field should be set to 'N' - [Create Descriptive Log Message]
Creating the log message for GCX105 → The message should be formatted as 'CARGO DIVERSION REQUEST FROM [original] TO [destination] SENT' - [Format Diversion Message with From/To Locations]
Preparing to send the log entry → The GCX105-ACTION-CODE should be set to 'ZZZ' - [Set CAA Message: 'CARGO ARRIVAL AUTOMATICALLY AT' + Location]
The system processes the CAA action code for log entry creation → The system sets the message to 'CARGO ARRIVAL AUTOMATICALLY AT ' concatenated with the location code and changes the action code to 'ZZZ' - [Set MAA Message: 'CARGO ARRIVAL MANUALLY AT' + Location]
The system processes the MAA action code for log entry creation → The system sets the message to 'CARGO ARRIVAL MANUALLY AT' concatenated with the location code and changes the action code to 'ZZZ' - [Set MUA Message: 'CARGO ARRIVAL CANCELED AT' + Location]
The system processes the MUA action code for log entry creation → The system sets the message to 'CARGO ARRIVAL CANCELED AT' concatenated with the location code and changes the action code to 'ZZZ' - [Set MUE Message: 'CARGO EXPORT CANCELED AT' + Location]
The system processes the MUE action code for log entry creation → The system sets the message to 'CARGO EXPORT CANCELED AT' concatenated with the location code and changes the action code to 'ZZZ' - [Set CAB Message: 'CARGO AUTO ARRIVED BORDER AT' + Location]
The system processes the CAB action code for log entry creation → The system sets the message to 'CARGO AUTO ARRIVED BORDER AT' concatenated with the location code and changes the action code to 'ZZZ' - [Set MAB Message: 'CARGO MAN ARRIVED BORDER AT' + Location]
The system processes the MAB action code for log entry creation → The system sets the message to 'CARGO MAN ARRIVED BORDER AT' concatenated with the location code and changes the action code to 'ZZZ' - [Set CEX Message: 'CARGO EXPORTED AUTOMATICALLY AT' + Location]
The system processes the CEX action code for log entry creation → The system sets the message to 'CARGO EXPORTED AUTOMATICALLY AT' concatenated with the location code and changes the action code to 'ZZZ' - [Set MEX Message: 'CARGO EXPORTED MANUALLY AT' + Location]
The system processes the MEX action code for log entry creation → The system sets the message to 'CARGO EXPORTED MANUALLY AT' concatenated with the location code and changes the action code to 'ZZZ' - [Set DIV Message: 'CARGO DIVERSION REQUEST FROM' + Origin + 'TO' + Destination + 'SENT']
The system processes the DIV action code for log entry creation → The system constructs a message with 'CARGO DIVERSION REQUEST FROM ' concatenated with the origin location, ' TO ' concatenated with the destination location, and ' SENT', then changes the action code to 'ZZZ' - [Prepare GCT1051E Message Structure]
The system needs to prepare the message for transmission → The system moves the formatted message input to the GCT1051E message structure - [Write Message to Log]
The system needs to write the message to the log → The system calls the message logging service to write the message with the specified message code, content, length, and module name - [Generate CAA Message 'CARGO ARRIVAL AUTOMATICALLY AT']
The system processes the automatic arrival action → A log message 'CARGO ARRIVAL AUTOMATICALLY AT [LOCATION]' is generated with the specific location code and the action code is changed to 'ZZZ' for further processing - [Generate MAA Message 'CARGO ARRIVAL MANUALLY AT']
The system processes the manual arrival action → A log message 'CARGO ARRIVAL MANUALLY AT [LOCATION]' is generated with the specific location code and the action code is changed to 'ZZZ' for further processing - [Generate MUA Message 'CARGO ARRIVAL CANCELED AT']
The system processes the arrival cancellation action → A log message 'CARGO ARRIVAL CANCELED AT [LOCATION]' is generated with the specific location code and the action code is changed to 'ZZZ' for further processing - [Generate MUE Message 'CARGO EXPORT CANCELED AT']
The system processes the export cancellation action → A log message 'CARGO EXPORT CANCELED AT [LOCATION]' is generated with the specific location code and the action code is changed to 'ZZZ' for further processing - [Generate CAB Message 'CARGO AUTO ARRIVED BORDER AT']
The system processes the automatic border arrival action → A log message 'CARGO AUTO ARRIVED BORDER AT [LOCATION]' is generated with the specific location code and the action code is changed to 'ZZZ' for further processing - [Generate MAB Message 'CARGO MAN ARRIVED BORDER AT']
The system processes the manual border arrival action → A log message 'CARGO MAN ARRIVED BORDER AT [LOCATION]' is generated with the specific location code and the action code is changed to 'ZZZ' for further processing - [Generate CEX Message 'CARGO EXPORTED AUTOMATICALLY AT']
The system processes the automatic export action → A log message 'CARGO EXPORTED AUTOMATICALLY AT [LOCATION]' is generated with the specific location code and the action code is changed to 'ZZZ' for further processing - [Generate MEX Message 'CARGO EXPORTED MANUALLY AT']
The system processes the manual export action → A log message 'CARGO EXPORTED MANUALLY AT [LOCATION]' is generated with the specific location code and the action code is changed to 'ZZZ' for further processing - [Generate DIV Message 'CARGO DIVERSION REQUEST FROM']
The system processes the diversion request action → A log message 'CARGO DIVERSION REQUEST FROM [ORIGIN] TO [DESTINATION] SENT' is generated with the origin location from cargo data and destination location from current processing location, and the action code is changed to 'ZZZ' for further processing - [Create GCT1051E Transaction]
The system needs to record the transaction in the audit trail → A GCT1051E transaction is created with the generated message content and transaction details - [Prepare GCT1091E Message Input]
The system initializes the GCX109 input message structure → The message input structure should be cleared and ready for data population - [Set Transmission Number from Processing]
The system prepares the EDI transmission message → The transmission number should be assigned to the GCX109 transmission number field - [Call Message Writer for GCT1091E]
The system needs to create the EDI transmission record → The X200-SPAWN-GCT1091E procedure should be executed to process the transmission - [Prepare GCT1091E Message]
The system processes the EDI transmission finalization → The GCX109 input data is moved to the GCT1091E message structure - [Set Transmission Number]
The system sets up the EDI transmission → The transmission number is assigned to the GCX109 transmission number field - [Change to Alternative PCB]
The system needs to process the EDI message through the queue → The system changes to the alternative PCB and clears the accept status - [Write Message to Queue]
The system processes the message transmission → The system writes the message using WRITMSGL with the message code, content, length and module name - [Purge Alternative PCB]
The system finalizes the EDI transmission process → The system purges the alternative PCB to complete the transmission - [Set Flight/Voyage Number to Julian Date]
The system assigns the flight voyage number → The Julian date in YYDDD format should be moved to the M10 segment flight voyage number field - [Create Diversion Log Message]
A log message needs to be created → The system should format a message containing 'CARGO DIVERSION REQUEST FROM', the original location, 'TO', the destination location, and 'SENT' - [Set Export by Bond Notification]
The system processes the CAB action code → An additional M15 EDI segment is created with Export by Bond notification qualifier and the entry number as reference - [Set Export by Equipment Notification]
The system processes the CAB action code → An additional M15 EDI segment is created with Export by Equipment notification qualifier and the car ID as reference - [Set Export by Bond Notification]
The system processes the AIA action code → An M15 EDI segment is created with Export by Bond notification qualifier, entry number as reference, and special condition flag set to Y - [Set Export by Equipment Notification]
The system processes the AIA action code → An M15 EDI segment is created with Export by Equipment notification qualifier, car ID as reference, and special condition flag set to Y - [Add to Transmission Queue]
The segment needs to be transmitted → The M15 segment is added to the transmission queue with sequence number 00004 - [Set Firms Code to Location ID Field]
The notification entity qualifier is ARRIVAL-BY-BOND or ARRIVAL-BY-BILL or ARRIVAL-BY-EQUIPMENT → The system sets the firms code from cargo record to the M15 location ID field (M15-17-LOC-ID) - [Set Firms Code to P4 ID Code Field]
The in-bond type code is 'TE' (Temporary Export) → The system sets the firms code from cargo record to the P4 segment ID code field (P4-04-ID-CODE) - [Set Reference Number Qualifier to 'IB']
The reference number is being assigned to the transmission segment → The reference number qualifier should be set to 'IB' to indicate in-bond processing - [TER - Set Export Enroute Message]
The cargo meets export conditions and action is TER → The system should set the notification entity qualifier to EXP-ENROUTE-MESSAGE - [Action Code Check]
The action code is TER, TAR, or CAB → The system routes to the corresponding action-specific processing logic - [Export Type Classification]
The cargo is classified as export cargo, US-Canada-US transit, multi-transit, or other types → The system applies the corresponding message processing rules for each cargo type - [Set Export Enroute Message Type]
The action code is TER (Train Enroute) → The system sets the notify entity qualifier to EXP-ENROUTE-MESSAGE - [Set Arrival by Equipment Message]
The cargo requires message processing → The system sets the notify entity qualifier to ARRIVAL-BY-EQUIPMENT - [Configure Message Parameters]
Message parameters need to be set → The system sets car ID as reference number, current date and time, location code, and export condition flag to Yes - [Action Code for Export]
The action code is TER (Train Enroute) → The system sets Export Enroute Message notification type - [Configure M15 Segment Data]
The system configures the M15 segment → The car ID is set as reference number, current date and time are recorded, location code is set as qualifier, and condition flag is set to 'Y' for export processing - [Set Transaction Set to 353]
The transaction set type needs to be specified → The transaction set is set to '353' for customs manifest data - [Generate Transmission Number]
A unique transmission identifier is required → The transmission number is generated using prefix 112 concatenated with current machine time - [Set Initial Status to II]
The initial processing status needs to be set → The status is set to 'II' to indicate insertion in progress - [Create M10 Segment]
The manifest header segment needs to be added → The M10 segment is created as a dependent segment with sequence number '00001' - [Create P4 Segment]
Port information needs to be added to the transmission → The P4 segment is created as a dependent segment with sequence number '00002' - [Create M15 Segment]
Notification information needs to be added to the transmission → The M15 segment is created as a dependent segment with sequence number '00003' - [Additional M15 Segments Required?]
The in-bond type code is not 'TR' and not 'MT' → An additional M15 segment is created with sequence number '00004' for export notification - [Additional M15 Segments Required?]
An arrival in advance notification is required → An additional M15 segment is created with sequence number '00004' and yes-no condition set to 'Y' - [Create 'CARGO ARRIVAL AUTOMATICALLY' Message]
The system processes the cargo arrival automatic action → A log message 'CARGO ARRIVAL AUTOMATICALLY AT [location]' is created and the action code is changed to 'ZZZ' - [Create 'CARGO ARRIVAL MANUALLY' Message]
The system processes the cargo arrival manual action → A log message 'CARGO ARRIVAL MANUALLY AT [location]' is created and the action code is changed to 'ZZZ' - [Create 'CARGO ARRIVAL CANCELED' Message]
The system processes the cargo arrival cancellation action → A log message 'CARGO ARRIVAL CANCELED AT [location]' is created and the action code is changed to 'ZZZ' - [Create 'CARGO EXPORT CANCELED' Message]
The system processes the cargo export cancellation action → A log message 'CARGO EXPORT CANCELED AT [location]' is created and the action code is changed to 'ZZZ' - [Create 'CARGO AUTO ARRIVED BORDER' Message]
The system processes the cargo automatic border arrival action → A log message 'CARGO AUTO ARRIVED BORDER AT [location]' is created and the action code is changed to 'ZZZ' - [Create 'CARGO MAN ARRIVED BORDER' Message]
The system processes the cargo manual border arrival action → A log message 'CARGO MAN ARRIVED BORDER AT [location]' is created and the action code is changed to 'ZZZ' - [Create 'CARGO EXPORTED AUTOMATICALLY' Message]
The system processes the cargo automatic export action → A log message 'CARGO EXPORTED AUTOMATICALLY AT [location]' is created and the action code is changed to 'ZZZ' - [Create 'CARGO EXPORTED MANUALLY' Message]
The system processes the cargo manual export action → A log message 'CARGO EXPORTED MANUALLY AT [location]' is created and the action code is changed to 'ZZZ' - [Create 'CARGO DIVERSION REQUEST' Message]
The system processes the cargo diversion request action → A log message 'CARGO DIVERSION REQUEST FROM [origin] TO [destination] SENT' is created and the action code is changed to 'ZZZ'
Structural Validations
- [Generate Invalid Record Type Error]
The record type is neither US Train nor US Cargo (both GCX112-US-TRAIN and GCX112-US-CARGO conditions are false) → The system sets an error message 'INVALID INPUT CODE SHOWN IN CC-PROG', moves the record type code to CC-PROG, and calls the error handling routine - [Get Train From Station Code]
The train from-station code is retrieved → If the from-station code is blank, display a blank station code message, otherwise proceed with validation - [Get Cargo Location ID]
The cargo location ID is retrieved → If the location ID is blank, display a blank location ID message, otherwise proceed with validation - [Is SCAC Code = CPRS?]
The cargo record has SCAC code equal to CPRS AND the train ID is either blank spaces or contains the literal value 'TRAIN' → The system should skip all further processing for this cargo record and exit the routine immediately - [Send Email via EMCSEND3]
The system checks the email service return status → The system continues processing if successful, otherwise sets error message and abends - [Internet Usage Flag = 'Y'?]
The system checks the internet usage flag in BK segment → The system proceeds with email address processing only if the internet usage flag equals 'Y' - [Email Configuration Found?]
The system checks the return status → If return flag is not '0', the BK segment is initialized and EOF flag is set to true, otherwise processing continues - [Internet Address Available?]
The system checks the return status → If return flag is not '0', the B1 segment is initialized and EOF flag is set to true, otherwise processing continues - [Report Send Successful?]
The transmission response is received → If the return status indicates failure, an error should be handled and the program should terminate abnormally - [Email Send Successful?]
The email service returns a status indicator → The system checks if the return status indicates successful transmission - [Log Blank Station Code Warning]
The US from station code field is blank or contains only spaces → The system displays a warning message indicating that the US from station code is blank - [Log Blank Station Code Warning]
The location ID field is blank or contains only spaces → The system displays a warning message indicating that the location ID is blank - [Are Event Date and Time Numeric?]
The system checks if both GCX112-EVENT-TIME and GCX112-EVENT-DATE contain numeric values → The system proceeds with date conversion if both fields are numeric, otherwise skips date conversion processing - [Root Creation Successful?]
The transmission number already exists in the system → The transmission number is incremented by 1 and creation is retried until successful