As an EDI Gateway Service,
I want to orchestrate and execute all GCCS358C 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 A9RT Transmission Segment]
Creating a root transmission segment → The A9RT transmission segment should be initialized to clear any previous data - [Initialize ST Segment Structure]
The ST segment initialization process begins → The ST segment definition structure is initialized and the ST identifier is set to 'ST' - [Initialize M10 Segment Structure]
The system starts building the M10 segment → The M10 segment is initialized and the identifier is set to 'M10' - [Initialize P4 Segment Structure]
The system begins building the P4 segment → The P4 segment structure is initialized and the identifier is set to 'P4' - [Initialize Flat Car Processing Variables]
The flat car and container combination is identified → Initialize FLATCAR-VID-SEGMENT, IM-UNIT-VID-SEGMENT, and IM-UNIT-VID12-ELEMENT variables and store the current VID segment as flat car data - [Initialize VID Segment Structure]
The VID segment initialization is performed → The VID segment structure is initialized and the identifier is set to 'VID' - [Initialize MBL Segment Structure]
The system begins dummy MBL segment creation → The MBL segment structure is initialized to clear any previous data - [Initialize MBL Segment Structure]
The dummy MBL processing begins → The MBL segment structure is initialized to clear any previous data - [Initialize M13 Segment Structure]
The M13 segment initialization is triggered → The M13 segment structure is cleared and ready for data population - [Initialize VID Segment]
A new VID segment needs to be created → The system initializes the VID segment and sets the identifier to 'VID' - [Initialize Flat Car VID Segment]
The flat car and container pairing is identified → Initialize flat car VID segment, container VID segment, and container location element to prepare for data storage - [Initialize Container VID Segment]
Container VID segment needs to be paired with flat car → Initialize container VID segment, store container location ID, and prepare for flat car data transfer - [Initialize VID Segment Structure]
VID segment initialization is required → VID segment structure is cleared and ready for data population - [Initialize N9 Segment Structure]
The N9 segment creation process begins → The N9 segment structure is initialized to clear any previous data - [Initialize MBL Segment Structure]
The system needs to create a dummy MBL segment → The MBL segment structure should be initialized to empty values
Core Acceptance Criteria
- [Build ST Header Segment]
If the post-emanifest flag in the train list → If post-emanifest is true, set destination to 'CACUSTOMS2-ST-O', otherwise set destination to 'CACUSTOMS-ST-O' - [Determine EDI Version Processing]
If the post-emanifest flag → If post-emanifest is true, use 5040 version processing (B231-LOAD-VID-MBL-5040), otherwise use 4040RAIL version processing (B230-LOAD-VID-MBL) - [Handle Special SCAC Assignment]
If the CCN key prefix → If CCN key starts with '2156', set SCAC to 'CFFO', otherwise set SCAC to 'CPRS' - [Handle Revenue Transit Status]
The system processes the Master Bill of Lading segment → Set BOL/Waybill to 'NA', set response code to 'N', and if post-emanifest, set exception code to '08' - [Process Haulage Rights]
The system processes the Master Bill of Lading segment → Set SCAC to the haulage rights SCAC code and set response code to 'N' - [Build Dummy MBL Segment]
No cargo key exists for the equipment but amendment processing is required → Create a dummy MBL segment with SCAC 'CPRS', BOL/Waybill 'NA', and exception code '06' - [Build M13 Amendment Segment]
The system needs to document the amendment → Create M13 segment with SCAC 'CPRS', location ID from station code, BOL/WB number from train key, and amendment code '60' - [Build N9 Reference Segment]
The system creates reference information → Create N9 segment with reference qualifier '76', reference number 'EDT', date from EDA with machine century, time from ETA with '00' seconds, and time code 'ES' - [Generate Transmission Number]
If the processing mode → If foreground mode, use prefix 147. If foreground-02 mode, use prefix 2. If background mode, use prefix 146. Append machine time to create unique transmission number - [Save Current Program Name]
The system begins processing the transaction → The current program name from the control block is saved to a temporary variable - [Set Module Name in Control Block]
The EDI 358 processing begins → The module name is assigned to the program field in the control block - [Continue to Main Processing]
A valid processing mode is confirmed → The AA200-358-PROCESS routine is executed to handle the EDI transaction processing - [Restore Program Name]
The system is preparing to return control to the caller → The saved program name is restored to the control block program field - [Set Prefix to 147 Foreground Mode]
The processing mode is set to foreground (GCWS358C-FOREGROUND is true) → The transmission prefix should be set to 147 - [Set Prefix to 2 Foreground-02 Mode]
The processing mode is set to foreground-02 (GCWS358C-FOREGROUND-02 is true) and not foreground mode → The transmission prefix should be set to 2 - [Set Prefix to 146 Background Mode]
The processing mode is neither foreground nor foreground-02 (default to background) → The transmission prefix should be set to 146 - [Get Current Machine Time]
The system needs to create a unique transmission number → The current machine time should be retrieved and combined with the prefix to form the transmission number - [Set Prefix 147 for Foreground]
The processing mode is foreground → The transmission prefix should be set to 147 - [Set Prefix 2 for Foreground-02]
The processing mode is foreground-02 → The transmission prefix should be set to 2 - [Set Prefix 146 for Background]
The processing mode is background → The transmission prefix should be set to 146 - [Use Machine Time as Counter]
A transmission number needs to be generated → The machine time should be used as the transmission number base - [Set Transaction Set to 358]
Setting up the transmission for customs manifest data → The transaction set should be set to '358' - [Insert Root Segment to Database]
The segment is ready for database storage → The root segment should be inserted into the GCA9RT transmission database - [Set Transaction Code to '358']
The transaction code needs to be assigned → The transaction code is set to '358' to identify this as a customs manifest transaction - [Check Post-Emanifest Flag]
The post-emanifest flag is evaluated → If post-emanifest is true, the destination is set to 'CACUSTOMS2-ST-O', otherwise the destination is set to 'CACUSTOMS-ST-O' - [Prepare Segment for Transmission]
The segment needs to be prepared for database insertion → The ST segment data is moved to the transmission data structure and the dependent segment is initialized - [Insert ST Segment into Database]
The database insertion process is invoked → The ST segment is inserted into the GCA9DP transmission database with proper sequencing - [Set SCAC Code to 'CPRS', Assign Standard CPRS SCAC Code]
The SCAC code needs to be assigned → The SCAC code is set to 'CPRS' - [Set Transport Type Code to 'R']
The transport type code needs to be assigned → The transport type code is set to 'R' for rail - [Set Country Code to 'US']
The country code needs to be assigned → The country code is set to 'US' - [Set Vessel Name from Train Key]
The vessel name needs to be assigned → The vessel name is set to the value from the train key - [Convert Current Date to Julian Format]
The flight/voyage number needs to be calculated → The system converts the current date from Gregorian to Julian format using date conversion service - [Set Manifest Type Code to 'S']
The manifest type code needs to be assigned → The manifest type code is set to 'S' for ship manifest - [Set Reference Number to 'TRAIN']
The reference number needs to be assigned → The reference number is set to 'TRAIN' - [Set Purpose Code to '00' - Add]
The transaction purpose code needs to be determined → The purpose code is set to '00' - [Set Purpose Code to '04' - Change]
The transaction purpose code needs to be determined → The purpose code is set to '04' and amendment flag is set to false - [Set Purpose Code to 'CO' - Amendment]
The transaction purpose code needs to be determined → The purpose code is set to 'CO' and amendment flag is set to true - [Set Purpose Code to '03' - Delete]
The transaction purpose code needs to be determined → The purpose code is set to '03' - [Set Application Type to '27']
The application type needs to be assigned → The application type is set to '27' - [Insert M10 Segment into Transmission]
The segment needs to be added to the transmission → The M10 segment is inserted into the transmission data queue - [Retrieve Canadian Station Information]
The system needs to build the P4 location segment → The system retrieves station information using the train's departure station code - [Set Canadian Station Code as Location ID]
The P4 location segment is being populated → The Canadian station code is assigned as the location identifier - [Set Estimated Departure Year, Set Estimated Departure Month, Set Estimated Departure Day]
The P4 location segment date fields need to be populated → The estimated departure year, month, and day are set from the train list data - [Copy Location ID to ID Code Field, Set Time Field to Spaces]
The remaining P4 segment fields need to be set → The location identifier is copied to the ID code field and the time field is set to spaces - [Insert P4 Segment into Transmission]
The segment needs to be added to the transmission data → The P4 segment is inserted into the transmission data structure - [Extract Equipment Type, Initial, Number]
Equipment data needs to be extracted for VID segment creation → Equipment type, initial, and number are extracted from GCWB4TL fields at SUB-TL position - [Handle Flat Car Logic for Container Cars]
Current equipment is a flat car type (BG, CA, ET, GS, ID, LO, RR, SK, TN) and next equipment is a container type (CC, CH, CM, CN, CX, CZ, LS, OT, PL, PT, RL, RT, TL) → Store flat car information and process both flat car and container as a combined unit with special VID segment handling - [Create VID Segment]
VID segment needs to be created for the equipment → VID segment is initialized and populated with equipment identifier 'VID', equipment description code, equipment initial, equipment number, and load/empty status code - [Create N9 Reference Segment for First Equipment]
Processing the first equipment in the list → Create N9 segment with identifier 'N9', reference number qualifier '76', reference number 'EDT', estimated departure date, estimated time of arrival, and time code 'ES' - [Process Bill of Lading if Loaded]
Equipment processing requires bill of lading information → Process MBL segment with cargo details, SCAC code, bill of lading number, and response codes - [Process Bill of Lading or Dummy MBL]
Equipment has cargo key → Process regular MBL segment, otherwise if this is the first equipment and an amendment, create dummy MBL with exception code '06' and M13 amendment segment - [Extract Equipment Type from GCWB4TL-VID01-EQUIPMENT-TYPE]
Processing equipment data for VID segment creation → The equipment type code should be extracted from the train list and stored in the VID equipment description code field - [Extract Equipment Initial from GCWB4TL-VID02-EQUIPMENT-INIT]
Processing equipment data for VID segment creation → The equipment initial should be extracted from the train list and stored in the VID equipment initial field - [Extract Equipment Number from GCWB4TL-VID03-EQUIPMENT-NUM]
Processing equipment data for VID segment creation → The equipment number should be extracted from the train list and stored in the VID equipment number field - [Does Flat Car Data Exist?]
The current equipment is a container type and FLATCAR-VID-SEGMENT is populated → Store current VID segment as container unit, preserve location ID, process flat car segment first, then process container unit segment, and generate MBL segment if equipment is loaded with cargo - [Process Equipment Normally]
The equipment is not part of a flat car-container sequence or is processed individually → Generate VID segment using standard processing and create MBL segment if equipment is loaded with cargo - [Current Equipment is Container Type? AND Flat Car Segment Exists?]
The current equipment type is CC, CH, CM, CN, CX, CZ, LS, OT, PL, PT, RL, RT, or TL AND a flat car segment has been previously stored → Store current VID as container unit segment, copy container location ID to flat car, and process both flat car and container unit VID segments - [Process Equipment Normally]
The equipment is not part of a flat car-container combination:- is the last equipment in the list
→ Process the equipment using standard VID segment processing and load MBL segment if equipment is loaded with cargo - [Set Equipment Description Code from Train List]
Equipment description code needs to be set → The equipment description code from the train list is assigned to VID-01-EQUIP-DESC-CDE - [Set Equipment Initial from Train List]
Equipment initial needs to be set → The equipment initial from the train list is assigned to VID-02-EQUIP-INIT - [Set Equipment Number from Train List]
Equipment number needs to be set → The equipment number from the train list is assigned to VID-03-EQUIP-NUM - [Equipment Marked as Loaded?]
Equipment is marked as loaded AND cargo key is present → Load status is set to 'L' (Loaded) - [Set Load Status to 'E']
Equipment is not marked as loaded: → Load status is set to 'E' (Empty) - [Insert VID Segment to Database]
VID segment is ready for transmission → VID segment is inserted into the transmission database for EDI processing - [CCN Key = '6105I'?]
The cargo CCN key starts with '6105I' → The system skips all MBL segment processing and proceeds to the next step - [CCN starts with '2156'?]
The CCN key starts with '2156' → The system sets the SCAC code to 'CFFO', otherwise sets it to 'CPRS' - [Set CCN as Bill of Lading Number]
The equipment has a valid CCN key → The system assigns the CCN key as the Bill of Lading/Waybill number - [Set Condition Response Code]
The equipment record contains a condition response code → The system copies the condition response code to the MBL segment - [Response Code Empty?]
The Bill of Lading number is not empty → The system sets the response code to 'Y', otherwise sets it to 'N' - [First Equipment and Amendment?]
This is the first equipment item being processed → The system creates an M13 amendment segment with amendment code '60' - [No CCN and Amendment?]
The equipment has no CCN key and this is the first equipment → The system creates a dummy MBL segment with Bill of Lading 'NA', exception code '06', and follows with M13 amendment segment - [CCN Key Starts with '2156'?]
The system processes the MBL segment for SCAC code assignment → If the CCN key starts with '2156', assign SCAC code 'CFFO', otherwise assign SCAC code 'CPRS' - [Check if Amendment Processing Required]
The system checks if this is the first equipment item (SUB-TL = 1) and the amendment flag is set to true → Amendment processing should be initiated for MBL segment creation - [Process Regular MBL Segment]
The system processes the MBL segment for this equipment → The regular MBL processing function (B240-LOAD-MBL-SEG) should be invoked - [Create Dummy MBL Segment]
The system determines that a dummy MBL is needed for amendment purposes → The dummy MBL creation process (B250-LOAD-DUMMY-MBL-SEG) should be initiated - [Set MBL Identifier to 'MBL']
The system initializes the MBL segment structure → The MBL identifier field should be set to 'MBL' - [Set SCAC Code to 'CPRS']
The system sets the SCAC (Standard Carrier Alpha Code) → The SCAC code should be set to 'CPRS' for Canadian Pacific Railway - [Set Bill of Lading to 'NA']
The system sets the bill of lading/waybill number → The bill of lading field should be set to 'NA' indicating not applicable - [Set Exception Code to '06']
The system sets the exception code for the MBL → The exception code should be set to '06' to indicate this is a dummy MBL for amendment processing - [Insert Dummy MBL into Transmission]
The system processes the MBL for transmission → The dummy MBL segment should be inserted into the transmission data structure (A9DP-TRANSMISSION-DATA) - [Create M13 Amendment Segment]
The system creates amendment documentation → An M13 amendment segment should be created and initialized - [Set M13 Identifier to 'M13']
The system initializes the M13 segment structure → The M13 identifier field should be set to 'M13' - [Set SCAC Code to 'CPRS']
The system sets the SCAC (Standard Carrier Alpha Code) for the amendment → The SCAC code should be set to 'CPRS' for Canadian Pacific Railway - [Set Location ID from Station Code]
The system sets the location identifier for the amendment → The location ID should be set to the Canadian station code (GCSTBRT-SC-CDN-STAT-CODE-X) - [Set Bill/Waybill Number from Train Key]
The system sets the bill/waybill number for the amendment → The bill/waybill number should be set to the train key (GCWB4TL-KEY) - [Set Amendment Code to '60']
The system sets the amendment code → The amendment code should be set to '60' to indicate the specific type of manifest amendment - [Insert M13 Amendment into Transmission]
The system processes the M13 for transmission → The M13 amendment segment should be inserted into the transmission data structure (A9DP-TRANSMISSION-DATA) - [Amendment MBL Processing Complete]
The system completes the amendment processing workflow → The amendment MBL processing should be marked as complete and control should return to the main processing flow - [Set MBL Identifier to 'MBL']
The segment identifier needs to be set → The MBL identifier is set to 'MBL' - [Set Bill of Lading to 'NA']
The bill of lading waybill number needs to be set → The bill of lading waybill is set to 'NA' - [Clear Load Found Flag]
The load found flag needs to be reset → The load found flag is cleared to spaces - [Set Exception Code to '06']
The exception code needs to be assigned → The exception code is set to '06' - [Insert MBL Segment into Transmission]
The segment needs to be added to the transmission → The MBL segment is inserted into the transmission data structure - [Build M13 Amendment Segment]
Amendment processing continues → The M13 amendment segment is built and processed - [Set Bill of Lading to 'NA']
The bill of lading waybill field needs to be populated → The bill of lading waybill is set to 'NA' - [Clear Load Found Flag]
The load found flag needs to be reset → The load found flag is set to spaces - [Configure Exception Code '06']
The exception code needs to be configured → The exception code is set to '06' - [Insert MBL Segment into Transmission]
The segment needs to be added to the transmission → The MBL segment is moved to transmission data and inserted into the data stream - [Trigger M13 Amendment Segment Creation]
Amendment processing is required → The M13 amendment segment creation process is triggered - [Set M13 Identifier]
The segment identifier needs to be set → The M13 identifier is set to 'M13' - [Set SCAC Code to CPRS]
The SCAC code field needs to be set → The SCAC code is set to 'CPRS' - [Set Location ID from Station Code]
The location ID field needs to be populated → The location ID is set to the Canadian station code from GCSTBRT station table - [Set Bill of Lading/Waybill Number from Train Key]
The bill of lading/waybill number field needs to be populated → The bill of lading/waybill number is set to the train key from GCWB4TL - [Set Amendment Code to 60]
The amendment code field needs to be set → The amendment code is set to '60' - [Insert M13 Segment into Transmission]
The segment needs to be added to the transmission → The M13 segment is inserted into the A9DP transmission data structure - [Check Post-Emanifest Flag]
The system checks the post-emanifest flag (GCWB4TL-POST-EMANIFEST) → The system evaluates the flag to determine routing to appropriate EDI version processing - [Route to 5040 Version Processing]
The post-emanifest flag (GCWB4TL-POST-EMANIFEST) is set to true → The system routes processing to B231-LOAD-VID-MBL-5040 for enhanced equipment processing with 5040 version capabilities - [Route to 4040RAIL Version Processing]
The post-emanifest flag (GCWB4TL-POST-EMANIFEST) is not set or is false → The system routes processing to B230-LOAD-VID-MBL for standard equipment processing with 4040RAIL version capabilities - [Process All Equipment in Train List]
The system begins equipment processing → The system iterates through all equipment entries (SUB-TL) in the train list until an empty equipment ID is encountered, processing each equipment entry using the selected processing method - [Get Cargo Information for Equipment]
The system processes the equipment for manifest creation → The system retrieves the corresponding cargo information using the CCN key and sets cargo found flag to true, or initializes empty cargo segment if no cargo exists - [Set Equipment Type from Train List]
Equipment type information is available in the train list → The system copies the equipment type code from the train list to the VID equipment description code field - [Set Equipment Initial from Train List]
Equipment initial information is available in the train list → The system copies the equipment initial from the train list to the VID equipment initial field - [Set Equipment Number from Train List]
Equipment number information is available in the train list → The system copies the equipment number from the train list to the VID equipment number field - [Store Flat Car VID Data]
The flat car VID segment is created → The system stores the flat car VID segment data and initializes container VID structures for subsequent processing - [Create Flat Car VID with Container Location]
Container VID segment is being created → The system creates a flat car VID segment with container location information, then creates the container VID segment, and processes MBL segment if equipment is loaded with cargo - [Create Standard VID Segment]
VID segment processing is performed → The system creates a standard VID segment and processes MBL segment if equipment is loaded with cargo - [Equipment Has CCN and is Loaded?]
If MBL processing requirements → The system creates an MBL segment if the equipment is loaded and has an associated CCN key (cargo control number) - [Store Flat Car Information]
The flat car and container car pairing is identified → The flat car VID segment is stored for later processing with the container car's location information - [Create VID Segment for Flat Car]
The container car is processed and has location information → Two VID segments are created - one for the flat car using the container's location ID and one for the container car - [Process as Regular Equipment]
The equipment is processed individually → A single VID segment is created for the equipment and MBL segment is created if the equipment is loaded with cargo - [Create MBL Segment if Loaded]
The equipment VID segments are created for the pairing → An MBL segment is created for the loaded equipment with cargo details - [Store Flat Car Information in FLATCAR-VID-SEGMENT]
Flat car-container pairing condition is met → Current VID segment information is stored in FLATCAR-VID-SEGMENT for later retrieval and container information storage areas are initialized - [Process Flat Car with Container Location]
Container location information is captured and flat car data is retrieved from storage → Flat car VID segment is processed with container location ID and both segments are transmitted as a paired unit - [Generate MBL Segment for Pair]
Container is loaded and has valid cargo key (CDA-CCN-KEY not is empty) → MBL segment is generated for the paired equipment unit - [Process as Regular Equipment]
Equipment is not a flat car followed by container, or is not a container with stored flat car, or is at end of equipment list → Equipment VID segment is transmitted as individual unit and MBL is generated if equipment has loaded cargo - [Store Current VID as Flat Car]
The current equipment is a flat car type → Copy the current VID segment data to the flat car VID segment storage - [Does Flat Car VID Exist?]
The flat car VID segment is not empty → Process the container as part of a flat car-container pair - [Copy Flat Car VID to Current VID]
Processing flat car-container pair → Copy flat car VID segment data to current VID segment - [Apply Container Location ID to Flat Car]
Processing flat car-container pair → Move the stored container location ID to the VID location field - [Insert Flat Car VID Segment]
Flat car-container pair processing is complete → Insert the flat car VID segment into the transmission data - [Reset VID to Container Data]
Processing the container portion of flat car-container pair → Initialize current VID segment and copy container VID segment data to current VID segment - [Insert Container VID Segment]
Container portion of flat car-container pair is ready → Insert the container VID segment into the transmission data - [Equipment Has CCN and is Loaded?]
The equipment is loaded and has a cargo control number (CCN) that is not spaces → Process the MBL segment for the container - [Process MBL Segment for Container]
MBL processing is required for the container → Execute MBL segment loading procedure for the container - [Insert Single VID Segment]
VID segment is populated and not empty → Insert the VID segment into the transmission data - [Equipment Has CCN and is Loaded?]
The equipment is loaded and has a cargo control number (CCN) that is not spaces → Process the MBL segment for the equipment - [Process MBL Segment]
MBL processing is required for the equipment → Execute MBL segment loading procedure for the equipment - [CCN Key = '6105I'?]
The CCN key starts with '6105I' → Skip MBL segment generation and check if first equipment requires amendment processing - [CCN starts with '2156'?]
The CCN starts with '2156' → Set SCAC code to 'CFFO', otherwise set SCAC code to 'CPRS' - [Set CCN as Bill of Lading Number]
The equipment has a valid CCN key → Set the CCN key as the bill of lading waybill number in the MBL segment - [Set Condition Response Code]
The equipment record contains a condition response code → Set the MBL condition response code to the equipment's condition response code value - [Response Code Empty?]
The bill of lading waybill number is not empty → Set response code to 'Y', otherwise set response code to 'N' - [Cargo Status = 'R' 'Revenue'?]
The cargo in-transit status is 'R' (Revenue) → Set bill of lading to 'NA', set response code to 'N', and if post-emanifest then set exception code to '08' - [Haulage Rights Exist?]
The cargo has haulage rights defined → Set SCAC code to the haulage rights SCAC and set response code to 'N' - [First Equipment & Amendment?]
This is the first equipment (SUB-TL = 1) and the transaction is an amendment → Generate an M13 amendment segment with amendment code '60' - [Check CCN Key Prefix]
If the CCN key prefix during MBL segment creation → CFFO SCAC code is assigned if CCN starts with '2156', otherwise CPRS SCAC code is assigned - [Haulage Rights Exist?]
The cargo has haulage rights defined with a specific SCAC code → The haulage rights SCAC code overrides the standard CCN-based SCAC assignment and response code is set to 'N' - [Set Exception Code '08']
The system processes the MBL segment for this revenue transit cargo → The exception code should be set to '08' to indicate post-emanifest revenue transit processing - [Override Bill of Lading to 'NA']
The system processes the MBL segment → The bill of lading waybill field should be set to 'NA' regardless of the original cargo CCN key - [Set Response Code to 'N']
The system processes the MBL segment → The yes/no response code should be set to 'N' to indicate negative response - [Set Equipment Identifier to 'VID']
Equipment identifier needs to be set → VID identifier is set to 'VID' - [Copy Equipment Type from Train List]
VID segment requires equipment type → Equipment type is copied from train list VID01 field to VID equipment description code - [Copy Equipment Initial from Train List]
VID segment requires equipment initial → Equipment initial is copied from train list VID02 field to VID equipment initial - [Copy Equipment Number from Train List]
VID segment requires equipment number → Equipment number is copied from train list VID03 field to VID equipment number - [Insert VID Segment to Database]
VID segment insertion is performed → VID segment is stored in transmission database with proper sequence number - [Process N9 and MBL Segments]
Associated segment processing is required → N9 reference segments and MBL bill of lading segments are processed based on equipment and cargo conditions - [Equipment Marked as Loaded?]
The equipment load indicator shows loaded status → Check for cargo documentation to confirm load status - [Set Status to 'E' - Empty]
Equipment load indicator shows empty status → Set equipment status to 'E' for empty - [Set Reference Qualifier to '76']
The reference qualifier needs to be assigned → The reference qualifier is set to '76' - [Set Reference Number to 'EDT']
The reference number field needs to be assigned → The reference number is set to 'EDT' - [Extract Departure Date from Train Data]
The N9 segment date field needs to be populated → The departure date from train data is extracted and assigned to the N9 date field positions 3-8 - [Format Date with Century Prefix]
The date is being formatted for the N9 segment → The machine century is added to positions 1-2 of the N9 date field - [Extract Departure Time from Train Data]
The N9 segment time field needs to be populated → The departure time from train data is extracted and assigned to positions 1-4 of the N9 time field - [Set Time Code to 'ES' - Eastern Standard]
The time code field is being assigned → The time code is set to 'ES' for Eastern Standard time - [Insert N9 Segment into Transmission]
The segment needs to be added to the transmission → The N9 segment is inserted into the transmission data structure and the dependent segment insertion process is performed - [CCN Key starts with '6105I'?]
The cargo control number (CCN) key starts with '6105I' → The system skips MBL segment creation and proceeds to check for amendment processing requirements - [CCN starts with '2156'?]
The cargo control number starts with '2156' → The system sets the SCAC code to 'CFFO', otherwise it sets the SCAC code to 'CPRS' - [Set CCN as Bill of Lading Number]
The equipment has an associated cargo control number → The system sets the CCN as the bill of lading waybill number - [Set Condition Response Code from Equipment]
Equipment data contains a condition response code → The system transfers the equipment condition response code to the MBL segment - [Response Code Empty?]
The bill of lading waybill number is present → The system sets the response code to 'Y', otherwise it sets the response code to 'N' - [Haulage Rights Exist?]
The cargo has haulage rights with a haulage rights SCAC code → The system overrides the SCAC code with the haulage rights SCAC and sets the response code to 'N' - [First Equipment and Amendment?]
This is the first equipment item being processed and the transaction is an amendment → The system creates an M13 amendment segment with amendment code '60' - [Set Exception Code '08']
The MBL segment is being created for the cargo → The system sets exception code '08' in the MBL segment - [Continue MBL Processing]
The MBL segment is being processed → The system sets the BOL waybill field to 'NA' - [Continue MBL Processing]
The MBL segment response code is being determined → The system sets the yes/no response code to 'N' - [Handle Special SCAC Assignment - Assign CFFO SCAC for CCN starting with 2156, otherwise use CPRS]
If the CCN prefix to determine the appropriate SCAC code → If the CCN starts with '2156', assign CFFO SCAC code, otherwise assign CPRS SCAC code to the MBL segment - [Set MBL Identifier to 'MBL']
The segment identifier needs to be set → The MBL identifier should be set to 'MBL' - [Set SCAC Code to 'CPRS']
The SCAC code needs to be assigned → The SCAC code should be set to 'CPRS' - [Set Bill of Lading to 'NA']
The bill of lading number needs to be set → The bill of lading should be set to 'NA' to indicate not applicable - [Set Exception Code to '06']
The exception code needs to be assigned → The exception code should be set to '06' - [Insert MBL Segment into Transmission Data]
The segment needs to be added to the transmission → The MBL segment should be inserted into the transmission data structure - [Build M13 Amendment Segment]
Amendment processing continues → An M13 amendment segment should be created - [Set M13 Identifier]
The segment identifier needs to be set → The M13 identifier field is populated with 'M13' - [Set SCAC Code to CPRS]
The SCAC code needs to be assigned → The SCAC code field is populated with 'CPRS' - [Set Location ID from Canadian Station Code]
The location identifier needs to be populated → The location ID field is populated with the Canadian station code from the station reference table - [Set Bill of Lading/Waybill Number from Train Key]
The bill of lading/waybill number needs to be assigned → The bill of lading/waybill number field is populated with the train key identifier - [Set Amendment Code to 60]
The amendment code needs to be assigned → The amendment code field is populated with '60' to indicate train amendment - [Insert M13 Segment into Transmission]
The M13 segment needs to be added to the transmission → The M13 segment is inserted into the transmission data structure for EDI processing - [Store Canadian Station Code]
The station lookup operation completes successfully → The table segment containing the Canadian station code is stored for subsequent processing - [Set EDI Send Function Name]
The EDI send function is being prepared → The system sets the EDI send function name flag to true to identify the correct function type - [Set Security Parameters]
Security parameters need to be configured → The system sets the security byte to high-values to establish maximum security level - [Set Transmission Number]
The EDI transmission structure is being populated → The system assigns the workspace transmission number to the EDI transmission number field - [Prepare Message Output]
The message needs to be formatted for output transmission → The system moves the GCX121 input data to the message output text field - [Set Function Length]
Function length parameters need to be configured → The system sets the EDI send function length flag to true - [Insert Purge Message]
The message needs to be queued for transmission → The system calls the purge message insertion process to queue the message - [Set Security Parameters]
Security parameters need to be established → The security byte should be set to high-values for maximum security - [Prepare Log Entry for Transmission]
The log entry needs to be prepared for transmission → The complete log input structure should be moved to the message output text field - [Send Log Entry to System]
The message length needs to be specified → The log update function length flag should be set to true to indicate proper message sizing - [Send Log Entry to System]
The log entry needs to be transmitted → The system should Execute the insert purge message operation to send the log entry to the logging system - [Database Insert Failed?]
The database insert fails with a non-space status code → Increment the transmission number by 1 and retry the insert operation until successful - [Message Write Failed?]
The message write operation fails with a non-zero return code → Build message write error and terminate processing with error handler
Structural Validations
- [Valid Processing Mode?]
The system checks the processing mode flags → If none of the valid processing modes (foreground, background, or foreground-02) are set, the system sets wrong FB indicator and exits processing - [Retrieve Station Information]
The system looks up the station code in the station table → If station code is not found or returns '0000', generate error message indicating station not found. Otherwise, use the retrieved station information - [Retrieve Cargo Information]
The system attempts to retrieve cargo information → If cargo root is not found, generate error message indicating cargo not found for CCN. Otherwise, set cargo flag to true and use retrieved cargo information - [Check Processing Mode]
The system checks the processing mode configuration → The transaction must be set for foreground, background, or foreground-02 mode, otherwise processing is terminated with an error indicator - [Increment Transmission Number]
The transmission number already exists in the database → The transmission number should be incremented by 1 and insertion should be retried - [Current Equipment is Flat Car Type? AND Next Equipment is Container Type?]
The current equipment type is BG, CA, ET, GS, ID, LO, RR, SK, or TN AND the next equipment type is CC, CH, CM, CN, CX, CZ, LS, OT, PL, PT, RL, RT, or TL → Initialize flat car processing variables and store current VID as flat car segment for paired processing - [Equipment has CCN?]
The system checks the CDA-CCN-KEY field for the equipment → If the CCN key is not spaces, the equipment has cargo data, otherwise it has no cargo data - [Is Stored Flat Car Available?]
FLATCAR-VID-SEGMENT contains previously stored flat car information (not is empty) → Stored flat car is available for pairing and container pairing process is initiated - [Generate Error Message]
The system cannot access the Canadian cargo database or encounters retrieval failures → The system generates an error message indicating cargo retrieval failure and terminates processing - [Generate Station Not Found Error]
The system processes the lookup failure → An error message is generated containing 'SC TABLE ENTRY FOR [station] NOT FOUND RC=' with the station identifier and return code - [Clear Message Field]
The message field needs to be initialized → The message field should be set to spaces to ensure clean data - [Station Table Entry Found?]
The station table entry is not found:- the Canadian station code is '0000'
→ Build error message with station identifier and terminate processing with error handler - [Cargo Record Found?]
The cargo record is not found in the database → Build error message with the cargo control number and terminate processing with error handler - [Call Error Handler CERR]
Error message has been built for the specific error condition → Call the CERR error handling program to terminate processing