🚀 Synthesized 1 highly-detailed Agile User Stories covering 1 EDI-active COBOL programs in Canada Cargo/Train Manifest response - EDI350.
🔍

Module: GCX126R 1 Consolidated Epic Story

Epic: GCX126R Complete EDI Specification Extracted from Legacy
Contains 504 distinct extracted legacy rules
EDI Epic Specification
As an EDI Gateway Service,
I want to orchestrate and execute all GCX126R 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
  • [1:Initialize Program Configuration]
    Initialization is performed → Set log index to 1, clear remark index, clear log array, clear previous CRN, set all segment flags to not found, set cargo not found flag, initialize line counters, set from usercode to 'OM01247', set accept status to 'GE', initialize all segment structures (M10, P4, V9, K1, X4, N7), retrieve admin table with table ID 'AD' and sequence ID 'ADMINID', if admin segment found then set Merlin recipient to admin DC Merlin 1 value, format machine date and time from system values, initialize date conversion parameters, convert machine date to Julian format, read message queue, connect to MQ manager, and open MQ queue
  • [Initialize Working Storage Fields]
    Working storage initialization is performed → LOG-INDX is set to 1, WS-K1-REMARK-NDX is set to ZEROES, LOG-ARRAY is set to SPACES, WS-PREV-CRN is set to SPACES, WS-MQS-LEN-HEADER is set to LENGTH OF MQS-MESSAGE-HEADER, WS-MQS-LEN-OF-1-ENTRY is set to LENGTH OF MQS-TABLE-ENTRY(1), MRLN-LINE is set to 1, WS-CTR-NEW is set to 1, and MRLN-350-REPORT is set to SPACES
  • [Initialize Segment Flags]
    Segment flags are being initialized → WS-NO-HEADER-FOUND, WS-NO-TRAILER-FOUND, WS-NO-M10-SEG-FOUND, WS-NO-P4-SEG-FOUND, WS-NO-N7-SEG-FOUND, WS-NO-X4-SEG-FOUND, WS-NO-K1-SEG-FOUND, WS-NO-V9-SEG-FOUND, WS-NO-END-FOUND, and WS-CARGO-NOT-FOUND are all set to TRUE
  • [Initialize Working Storage Fields]
    Database access parameters are initialized → CC-ACCEPT-STATUS in CCCOM is set to 'GE', GCCTBIO-FUNC-CODE is set to GU, GCSTBRT-KEY-VALUE is set to SPACES, GCSTBDP-KEY-VALUE is set to SPACES, GCCTBIO-RETURN-FLAG is set to SPACES, GCSTBRT-AD-SEGMENT is set to SPACES, SECOND-PCB-FLAG is set to SPACES, and UNQUAL-SSA-FLAG is set to SPACES
  • [Initialize Working Storage Fields]
    Message segment structures are initialized → M10-SEGMENT, P4-SEGMENT, V9-SEGMENT, K1-SEGMENT, X4-SEGMENT, and N7-SEGMENT are all initialized to their default values
  • [Open MQ Queue for Input]
    W03-COMPCODE != MQCC-OK → W03-REASON is moved to W03-REASON-CODE, OUTPUT-MESSAGE-TEXT is initialized, GCCMQERR is called with W03-REASON-CODE and OUTPUT-MESSAGE-TEXT, W03-REASON-CODE and OUTPUT-MESSAGE-TEXT are concatenated into MQ-ERROR-TEXT, '355' is moved to MQ-TRANS-SET, 'OPEN FAILED' is moved to PGM-ERROR-TEXT, ERROR-MESSAGE2 is moved to CC-ERROR-MESSAGE in CCCOM, and the program aborts by performing Z900-ABEND
  • [Initialize Table Access Fields]
    The initialization process begins → All table access parameters are cleared (GCSTBRT-KEY-VALUE, GCSTBDP-KEY-VALUE, GCCTBIO-RETURN-FLAG, GCSTBRT-AD-SEGMENT) and control flags (SECOND-PCB-FLAG, UNQUAL-SSA-FLAG) are set to spaces
  • [Open MQ Queue for Reading]
    The system attempts to open the queue with input-as-queue-defined option → If open is successful, proceed to retrieve messages; If open fails, generate error message with reason code and abort processing with message 'OPEN FAILED' for transaction set '355'
  • [Initialize M10 Segment Structure]
    Preparing to load M10 segment data → The M10 segment data structure is initialized to spaces/zeros
  • [Initialize P4 Segment Structure]
    The P4 segment processing begins → The system initializes the P4 segment data structure by clearing all fields to spaces or zeros
  • [Initialize V9 Segment]
    The system begins processing the V9 segment → The system initializes the V9 segment data structure to spaces or zeros
  • [Initialize N7 Segment Structure]
    The N7 segment found flag has been set → The system initializes the N7 segment structure to spaces to clear any previous data
  • [Initialize Loop Counter to 1]
    The system begins the equipment logging process → The loop counter (LOG-INDX) is set to 1 to start processing from the first LOG-LINE entry
  • [Call Z200-MOVE-LOG-INFORMATION to Initialize Log Structure]
    The log structure initialization is invoked → The log input area is cleared to spaces AND the security byte is set to high-value AND the sending transaction is set to 'GCT1261E' AND the user ID from the common control area is copied to the log structure
  • [Initialize GCX105 Input Structure]
    The log message preparation process begins → The GCX105 input structure is cleared to spaces to ensure no residual data remains
  • [Initialize Function Code to GU, Clear Key Values and Flags]
    The Merlin contact fetch process is initiated → The function code should be set to 'GU' (Get Unique), all key values (GCSTBRT-KEY-VALUE, GCSTBDP-KEY-VALUE) should be cleared to spaces, the return flag (GCCTBIO-RETURN-FLAG) should be cleared to spaces, the MC segment (GCSTBRT-MC-SEGMENT) should be cleared to spaces, and both SECOND-PCB-FLAG and UNQUAL-SSA-FLAG should be cleared to spaces
  • [Initialize Search with >= Operator, Retrieve First US Cargo Record]
    Initiating the US cargo search using the car-waybill index with greater-than-or-equal-to operator → The system retrieves the first US cargo record from GCSUSRT table matching or exceeding the search criteria
Core Acceptance Criteria
  • [2:Read EDI 350 Message from Queue]
    MQGET operation is performed → Read message into MQS-MESSAGE buffer, calculate maximum MQS entries as (data length minus header length) divided by entry length rounded, if calculated entries exceed maximum constant then set to maximum constant value
  • [3:Determine Message Type]
    Message header is examined → If MQS cross-way header positions 1 through 10 equal '+++3505040' then set conveyance 350 flag to true, else set cargo 350 flag to true
  • [4:Parse EDI Segments and Segment Type?]
    Each message line is processed → If table ID is 'ST' then set header found and first X4 flags, else if table ID is 'M10' then Execute M10 segment processing, else if table ID is 'P4' then Execute P4 segment processing, else if table ID is 'V9' then Execute V9 segment processing, else if table ID is 'VID' then continue, else if table ID is 'K1' then Execute K1 segment processing, else if table ID is 'X4' then initialize K1 comments and Execute X4 segment processing, else if table ID is 'N7' then Execute N7 segment processing, else if table ID is 'SE' then set trailer found and end found flags and Execute rest of message processing
  • [5:Process M10 Notice Segment]
    M10 segment is processed → Set M10 segment found flag to true, initialize M10 segment structure, and move table entry to M10 segment structure
  • [6:Process P4 Port Segment]
    P4 segment is processed → Set P4 segment found flag to true, initialize P4 segment structure, and move table entry to P4 segment structure
  • [7:Process V9 Notice Reason Segment]
    V9 segment is processed → Set V9 segment found flag to true, initialize V9 segment structure, and move table entry to V9 segment structure
  • [8:Process K1 Remarks Segment]
    K1 segment is processed → Set K1 segment found flag to true, initialize K1 segment structure, move table entry to K1 segment structure, add 1 to K1 remark index, if K1 remark index exceeds maximum (50) then set index to maximum value, else move K1 segment to K1 remark array at current index position
  • [9:Process N7 Equipment Segment]
    N7 segment is processed → Set N7 segment found flag to true, initialize N7 segment structure, move table entry to N7 segment structure, if N7 equipment number is not spaces then move equipment number to log data at current log index with type 'EDI 350 EQP#:' and add 1 to log index
  • [10:Process Conveyance 350 Train Arrival and Train Found?]
    X4 segment processing is performed → If X4 release document ID positions 1 through 25 equal previous CRN then continue, else move X4 release document ID positions 1 through 25 to B4 key value and previous CRN, Execute train lookup by CRN, if train not found (status code not spaces) then prepare unknown train error message with CRN, set line count to 4, set message type to unknown, and Execute email send preparation, else if train found then move log information, format date and time from machine values, set action code to 'ZZZ', move CRN to train or US CCN field, set cargo type to CA train, set message to '350 ACK - ARRIVAL ACK AT BORDER', and spawn log entry
  • [11:Update Cargo Border Arrival Status]
    Cargo border update is performed → Execute cargo lookup by CCN, if cargo is found then set message to '350 ACK - ARRIVAL ACK AT BORDER', move cargo CCN key to current CCN key, Execute log cargo info message, set cargo border arrival acknowledgment flag to true, clear status code, set accept status to spaces, and replace cargo record
  • [14:Log K1 Remarks]
    Rest of message processing is performed → Execute varying index from 1 by 1 until index exceeds K1 remark index: if K1 remark for X4 at index is not spaces then initialize K1 segment, move K1 remark for X4 at index to K1 segment, clear info message, concatenate 'EDI 350 K1: ' with K1 free form message 1 into info message, Execute log cargo info message, if K1 free form message 2 is not spaces then clear info message, concatenate 'EDI 350 K1: ' with K1 free form message 2 into info message, and Execute log cargo info message
  • [15:Log N7 Equipment Information]
    Rest of message processing is performed → Execute varying log index from 1 by 1 until log line at index is spaces or log index exceeds 50: clear info message, move log line at index to info message, and Execute log cargo info message
  • [16:Lookup Cargo by CCN]
    Cargo lookup is performed → Move M10 CCN positions 1 through 25 to cargo key value, set accept status to 'GE', call database with get hold unique function for cargo using cargo qualifier, Execute cargo switch setting, if cargo found then set accept status to 'GE' and call database with get hold unique function for cargo secondary using A2 qualifier, if status code is 'GE' then clear cargo secondary segment
  • [17:Handle Unknown Cargo Release]
    Unknown cargo processing is performed → Clear detail line 1, concatenate 'UNKNOWN EDI 350 RELEASE FROM CBSA ' with M10 CCN positions 1 through 25 into detail line 1, move 'THIS CCN WAS NOT FOUND.' to detail line 3, concatenate 'RELEASE NUMBER: ' with X4 CBSA release reference ID positions 1 through 15, ' DONE BY PORT ' with P4 port code positions 1 through 4 into detail line 4, set line count to 5, set message type to unknown, and Execute email send preparation
  • [18:Handle Unknown Cargo Deconsolidation]
    Unknown cargo processing is performed → Clear detail line 1, concatenate 'UNKNOWN EDI 350 DCON NOTICE ' with M10 CCN positions 1 through 25 into detail line 1, move 'THIS CCN WAS NOT FOUND.' to detail line 3, concatenate 'HOUSE BILL CLOSE NUMBER' with X4 CBSA release reference ID positions 1 through 25, ' DONE BY PORT ' with P4 port code positions 1 through 4 into detail line 4, set line count to 5, set message type to unknown, and Execute email send preparation
  • [19:Handle Unknown Cargo Entry]
    Unknown cargo processing is performed → Clear detail line 1, concatenate 'UNKNOWN EDI 350 ENTRY FROM CBSA ' with M10 CCN positions 1 through 25 into detail line 1, move 'THIS CCN WAS NOT FOUND.' to detail line 3, concatenate 'NOTICE DOC TYPE: ' with M10 notice document type code, ' WITH REASON CODE ' with V9 notice reason code positions 1 through 4 into detail line 4, set line count to 5, set message type to unknown, and Execute email send preparation
  • [20:Process Document Not Matched]
    Cargo processing is performed → Clear info message, move 'EDI 350: DOC NOT MATCHED ' to info message, and Execute log cargo info message
  • [21:Process Cargo Complete]
    Cargo processing is performed → Clear info message, move 'EDI 350: CARGO COMPLETE MESSAGE ' to info message, and Execute log cargo info message
  • [22:Process Document Package Complete]
    Cargo processing is performed → If X4 CBSA release reference ID positions 1 through 15 not equal cargo broker entry positions 1 through 15 or X4 CBSA release reference ID positions 1 through 14 not equal cargo customs transaction number positions 1 through 14, and X4 CBSA release reference ID is not spaces, then move X4 CBSA release reference ID positions 1 through 15 to cargo broker entry, move X4 CBSA release reference ID positions 1 through 14 to cargo customs transaction number, move machine date to cargo broker date, move machine time positions 1 through 4 to cargo broker time, clear info message, concatenate 'EDI 350: DOC PKG COMPLETE : ' with X4 CBSA release reference ID positions 1 through 15 into info message, Execute log cargo info message, and Execute cargo replace
  • [23:Process Document Not On File]
    Cargo processing is performed → Clear info message, if X4 release document type code position 1 equals 'R' then concatenate 'EDI 350: DOC NOT ON FILE FOR RELEASE ' with X4 CBSA release reference ID positions 1 through 15 into info message and Execute log cargo info message, else concatenate 'EDI 350:DOC NOT ON FILE H-BILL CLOSE ' with X4 CBSA release reference ID positions 1 through 25 into info message and Execute log cargo info message
  • [24:Process Cargo Reported]
    Cargo processing is performed → Clear info message, concatenate 'EDI 350: CARGO REPORTED ' into info message, and Execute log cargo info message
  • [25:Process Cargo Arrived]
    Cargo processing is performed → Clear info message, concatenate 'EDI 350: CARGO ARRIVED AT PORT ' with P4 port code positions 1 through 4 into info message, and Execute log cargo info message
  • [26:Process Cargo Release]
    Cargo processing is performed → Execute set release information, clear info message, concatenate 'EDI 350: RELEASE : ' with X4 CBSA release reference ID positions 1 through 15, ' AT PORT ' with P4 port code positions 1 through 4 into info message, concatenate X4 CBSA release reference ID positions 1 through 15, '/' with P4 port code positions 1 through 4 into cargo release reason, Execute log cargo info message, Execute process US manifest, move cargo release date to hold date, move cargo release time to hold time, Execute cargo replace, if cargo is master manifest then save cargo segment, move cargo CCN key to B0 CCN key, set follower not end of database flag, Execute process multi follower manifests, restore cargo segment, move cargo waybill key to save waybill index, and move cargo equipment car to current car ID key
  • [27:Process Authorized to Deliver]
    Cargo processing is performed → If cargo CSA indicator is on then move 'EDI 350: ACCEPTED - CSA' to info message, Execute log cargo info message, set cargo status to CSA delivery, set cargo CSA authorization to deliver received flag to true, and Execute cargo replace, else move 'EDI 350: NOT ACCEPTED - NON-CSA' to info message and Execute log cargo info message, then Execute process US manifest
  • [28:Process Cargo Hold]
    Cargo processing is performed → Clear info message, move 'EDI 350: GOODS HELD FOR EXAMINATION' to info message, Execute log cargo info message, set cargo status to hold, Execute cargo replace, if cargo CCN key positions 1 through 4 equal '6105' then Execute Merlin prepare hold notification
  • [29:Process Deconsolidation Release]
    Cargo processing is performed → Execute set release information, clear info message, concatenate 'EDI 350: RELEASE VIA DECON AT PORT ' with P4 port code positions 1 through 4 into info message, concatenate 'DECONSOLIDATION AT ' with P4 port code positions 1 through 4 into cargo release reason, Execute log cargo info message, Execute process US manifest, move cargo release date to hold date, move cargo release time to hold time, Execute cargo replace, if cargo is master manifest then save cargo segment, move cargo CCN key to B0 CCN key, set follower not end of database flag, Execute process multi follower manifests, restore cargo segment, move cargo waybill key to save waybill index, and move cargo equipment car to current car ID key
  • [31:Process Associated US Manifest]
    US manifest processing is performed → Set US manifest not found flag, set not end of file flag, Execute get unique US cargo by car and waybill, Execute get next US cargo by car and waybill until US manifest found or end of file, if end of file then exit, else move log information, concatenate machine century with machine date into log date, move machine time to log time, move log use input message to action code, move US cargo CCN key to train or US CCN field, set cargo type to US cargo, concatenate 'CDN CCN RLSED BY EDI 350: ' with cargo CCN key into message, and Execute spawn log entry
  • [32:Process CSA Authorization]
    CSA authorization processing is performed → If cargo CSA indicator is on then move 'EDI 350: ACCEPTED - CSA' to info message, Execute log cargo info message, set cargo status to CSA delivery, set cargo CSA authorization to deliver received flag to true, and Execute cargo replace, else move 'EDI 350: NOT ACCEPTED - NON-CSA' to info message and Execute log cargo info message
  • [33:Process Follower Manifests]
    Multi follower processing is performed → Set accept status to 'GEGB', clear follower manifest array, set index to 1, Execute until follower end of database or index exceeds 100: call database with get next function for cargo using B0 qualifier, if status code is spaces and saved CCN equals master manifest CCN then if cargo is master manifest then continue else move cargo CCN key to follower manifest array at index and add 1 to index, else set follower end of database flag, subtract 1 from index, if index is less than or equal to zero then exit, else Execute varying index from 1 by 1 until follower manifest at index is spaces or low values or index exceeds limit: move follower manifest CCN to cargo key value, Execute cargo lookup, if cargo found then Execute set release information, clear info message, if V9 released then concatenate 'EDI 350: RELEASE : ' with X4 CBSA release reference ID positions 1 through 15, ' AT PORT ' with P4 port code positions 1 through 4 into info message and concatenate X4 CBSA release reference ID positions 1 through 15, '/' with P4 port code positions 1 through 4 into cargo release reason, else concatenate 'EDI 350: RELEASE VIA DECON AT PORT ' with P4 port code positions 1 through 4 into info message and concatenate 'DECONSOLIDATION AT ' with P4 port code positions 1 through 4 into cargo release reason, move cargo CCN key to current CCN key, Execute log cargo info message, move cargo waybill key to save waybill index, move cargo equipment car to current car ID key, Execute process US manifest, clear status code, set accept status to spaces, and call database with replace function for cargo
  • [34:Prepare Cargo Hold Email]
    Merlin hold preparation is performed → Clear detail line 1, concatenate 'Cargo on HOLD for inspection by CBSA - EDI350' into detail line 1, clear detail line 2, concatenate 'Equipment : ' with cargo equipment ID for index into detail line 3, concatenate 'Waybill : ' with cargo CCN carrier index, cargo origin station number index, cargo waybill number index into detail line 4, concatenate 'CCN : ' with cargo CCN key into detail line 5, concatenate 'DESTINATION : ' with cargo destination station name, ', ' with cargo destination station state code into detail line 6, concatenate 'MANIFEST UPON : ' with cargo manifest to station name into detail line 7, set line count to 7, set message type to hold, and Execute email send preparation
  • [39:Send Email Notification]
    Email send preparation is performed → If message type is error then concatenate 'CUSTOMS RECEIVED ERR MSG ' with cargo CCN key into subject, else if message type is info then concatenate 'BROKER/MANIFEST MISMATCH ' with cargo CCN key into subject, else if message type is hold then concatenate 'CBSA CARGO HOLD - ' with cargo CCN key into subject, else move detail line 1 to subject, save current recipient and filename, clear recipient, if admin segment found then move admin DC Merlin 1 to recipient 1 and admin DC Merlin 5 to recipient 2, else move 'OM01247' to recipient 1 and clear recipient 2, if keywords are spaces or low values then if cargo found and cargo CCN key not spaces then move cargo CCN key to keywords, else move current CCN key to keywords, if message type is unknown then move 'UNKNOWN' to filename, clear recipient, move 'OM01247' to recipient 1, and Execute call email send, else if message type is error then move 'CAERROR' to filename, Execute call email send, move 'IN' to filename, clear recipient, move 'OM01247' to recipient 1, and Execute call email send, else if message type is info then move 'IN' to filename, clear recipient, move 'OM01247' to recipient 1, and Execute call email send, else if message type is unrelease then move 'IN' to filename, Execute call email send, clear recipient, Execute fetch manifest station segment, if manifest station Merlin ID not spaces then move 'IN' to filename, move manifest station Merlin ID to recipient 1, and Execute call email send, else if message type is release then clear recipient, Execute fetch manifest station segment, if manifest station Merlin ID not spaces then move 'IN' to filename, move manifest station Merlin ID to recipient 1, and Execute call email send, else if message type is hold then move 'CAHOLD' to filename, clear recipient, move 'OM01247' to recipient 1, and Execute call email send, then Execute reset report fields
  • [Retrieve Admin Configuration from GCSTBRT Table]
    Admin configuration is retrieved with TABLE-ID 'AD' and SEQID 'ADMINID' → GCCTBIO is called with function GU to retrieve GCSTBRT segment
  • [Extract Merlin User Code from Admin Config]
    GCCTBIO-RETURN-FLAG equals '0' → 88-AD-SEGMENT-FOUND is set to TRUE, WS-TABLE-SEGMENT is moved to GCSTBRT-AD-SEGMENT, and GCSTBRT-AD-DC-P-MERLIN-1 is moved to WS-EMI-TO-USERCODE
  • [Read Initial Message from IMS Queue]
    Initial queue read is performed → WS-IOAREA is set to SPACES, CC-ACCEPT-STATUS in CCCOM is set to 'QCQD', and CIMS is called with CCCOM, GU function, IO-PCB from CCCOM, and WS-IOAREA
  • [Establish MQ Connection to Queue Manager]
    MQ connection is established → MQCONNC is called with W03-MQMANAGER, W03-HCONN, W03-COMPCODE, and W03-REASON
  • [Call GCCTBIO to Read GCSTBRT Table]
    The GCCTBIO program is called with parameters CCCOM, SECOND-PCB-FLAG, UNQUAL-SSA-FLAG, GCCTBIO-FUNC-CODE, GCSTBRT-LIT, GCSTBRT-KEY-VALUE, GCSTBDP-KEY-VALUE, WS-TABLE-SEGMENT, and GCCTBIO-RETURN-FLAG → The admin configuration record is retrieved and stored in WS-TABLE-SEGMENT with operation status returned in GCCTBIO-RETURN-FLAG
  • [Set Admin Segment Found Flag]
    The admin segment status needs to be recorded → The condition 88-AD-SEGMENT-FOUND is set to TRUE
  • [Move Merlin User Code from Admin Config to EMI-TO-USERCODE]
    The Merlin user code needs to be extracted → WS-TABLE-SEGMENT is moved to GCSTBRT-AD-SEGMENT and GCSTBRT-AD-DC-P-MERLIN-1 is moved to WS-EMI-TO-USERCODE
  • [Call GCCTBIO to Read GCSTBRT Table]
    The system calls GCCTBIO to retrieve the administrative configuration with Table ID 'AD-TABLE-ID' and Sequence ID 'ADMINID' → If the configuration record is found (return flag equals '0'), the system extracts the Merlin user code from GCSTBRT-AD-DC-P-MERLIN-1 field and sets the admin segment found indicator to true; otherwise, the system continues without the administrative configuration
  • [Set Function Code to GU - Get Unique]
    The initialization process begins → The system sets the function code to 'GU' (Get Unique), clears all key values (GCSTBRT-KEY-VALUE, GCSTBDP-KEY-VALUE), clears the return flag (GCCTBIO-RETURN-FLAG), clears the segment data (GCSTBRT-AD-SEGMENT), and clears all control flags (SECOND-PCB-FLAG, UNQUAL-SSA-FLAG)
  • [Call GCCTBIO Program]
    The system calls GCCTBIO program with parameters CCCOM, SECOND-PCB-FLAG, UNQUAL-SSA-FLAG, GCCTBIO-FUNC-CODE, GCSTBRT-LIT, GCSTBRT-KEY-VALUE, GCSTBDP-KEY-VALUE, WS-TABLE-SEGMENT, and GCCTBIO-RETURN-FLAG → The GCCTBIO program executes the database operation and returns the result in GCCTBIO-RETURN-FLAG with the retrieved data in WS-TABLE-SEGMENT if successful
  • [Move Table Segment to GCSTBRT-AD-SEGMENT]
    The system processes the retrieved data → The system moves the contents of WS-TABLE-SEGMENT to GCSTBRT-AD-SEGMENT
  • [Extract Merlin User Code from Admin Config]
    The system extracts the Merlin routing information → The system moves the value from GCSTBRT-AD-DC-P-MERLIN-1 to WS-EMI-TO-USERCODE for use in message routing
  • [Set Admin Segment Found Flag]
    The system completes the administrative configuration retrieval process → The system sets the condition name 88-AD-SEGMENT-FOUND to true, indicating that valid administrative configuration is available
  • [Call MQCONNC API with Queue Manager Name]
    The system initiates connection to the MQ Queue Manager → The system calls the MQCONNC API with the Queue Manager name and receives a connection handle and completion status
  • [Connection Established Successfully]
    The completion code returned equals MQCC-OK → The system confirms the connection is established successfully and proceeds with message processing operations
  • [Connect to MQ Queue Manager]
    The system attempts to connect to the MQ Queue Manager → If connection is successful, proceed to open the queue; If connection fails, generate error message with reason code and abort processing with message 'CONN FAILED' for transaction set '355'
  • [Retrieve Message from Queue]
    The system executes MQGET operation with message buffer length set to the size of MQS-MESSAGE → The message is retrieved into MQS-MESSAGE buffer with actual data length returned in W03-DATALEN, and completion code and reason code are set to indicate operation status
  • [MQ Operation Successful?]
    If the completion code → If completion code equals MQCC-OK, proceed to check message status; If completion code equals MQCC-FAILED and reason equals MQRC-NO-MSG-AVAILABLE, set message not available flag; For any other completion code, set end of queue flag and prepare error message
  • [Set Message Not Available Flag]
    The system processes the no message available condition → Set MSG-NOT-AVAILABLE flag to TRUE and exit message retrieval process without error
  • [Set Skip Message Flag]
    The system identifies a previously failed message → Set SKIP-MSG-FOUND flag to TRUE and exit message retrieval process without further processing
  • [Set Good Message Found Flag]
    All message validation checks pass successfully → Set GOOD-MSG-FOUND flag to TRUE and proceed to calculate number of EDI segments
  • [Calculate Number of EDI Segments]
    The system computes WS-MAX-MQS-ENTRIES as ((W03-DATALEN minus WS-MQS-LEN-HEADER) divided by WS-MQS-LEN-OF-1-ENTRY) rounded → If calculated WS-MAX-MQS-ENTRIES exceeds CST-MAX-MQS-ENTRIES, set WS-MAX-MQS-ENTRIES to CST-MAX-MQS-ENTRIES; Otherwise, use calculated value for segment count
  • [Set End of Queue Flag]
    The system encounters an unexpected MQ error condition → Set END-OF-MQUEUE flag to TRUE and proceed to prepare error message with reason code
  • [Abort Processing]
    The system determines processing cannot continue → Call CERR program with CCCOM to abort processing and terminate program execution
  • [Calculate: Segments = Data Length - Header Length / Entry Length]
    ['The system calculates the number of segments'] → ['Subtract the header length from the total message data length to get net data length', 'Divide the net data length by the single entry length', 'Round the result to get the number of complete segments', 'Store the calculated value in WS-MAX-MQS-ENTRIES']
  • [Get Header Length]
    ['The system initializes message processing parameters'] → ['Set WS-MQS-LEN-HEADER to the length of MQS-MESSAGE-HEADER structure', 'This value will be used to subtract header length from total message length']
  • [Get Single Entry Length]
    ['The system initializes message processing parameters'] → ['Set WS-MQS-LEN-OF-1-ENTRY to the length of one MQS-TABLE-ENTRY structure', 'This value will be used as the divisor to calculate segment count']
  • [Get Message Data Length from MQ]
    ['The MQGET call completes successfully'] → ['The actual data length of the retrieved message is returned in W03-DATALEN', 'This length includes both the message header and all segment entries', 'W03-DATALEN will be used to calculate the number of segments in the message']
  • [Calculate: Segments = Data Length - Header Length / Entry Length]
    The system calculates the number of message segments → The number of segments (WS-MAX-MQS-ENTRIES) is calculated as: (Data Length minus Header Length) divided by Entry Length, rounded to the nearest whole number
  • [Get Header Length]
    Initializing message processing parameters → The header length (WS-MQS-LEN-HEADER) is set to the length of the MQS-MESSAGE-HEADER structure
  • [Get Single Entry Length]
    Initializing message processing parameters → The single entry length (WS-MQS-LEN-OF-1-ENTRY) is set to the length of one MQS-TABLE-ENTRY structure
  • [First 10 Characters = '+++3505040'?]
    The first 10 characters of MQS-XWAY-HDR equal '+++3505040' → Set the message type indicator WS-CONV-350 to TRUE to identify this as a Conveyance EDI 350 message
  • [First 10 Characters = '+++3505040'?]
    The first 10 characters of MQS-XWAY-HDR do NOT equal '+++3505040' → Set the message type indicator WS-CARGO-350 to TRUE to identify this as a Cargo EDI 350 message
  • [ST - Transaction Set Header Set Header Found Flag]
    The current segment table ID equals 'ST ' → Set the header found flag to TRUE and set the first X4 segment flag to TRUE to indicate the start of a new transaction set
  • [M10 - Notice/Reference Extract CCN and Notice Info]
    The current segment table ID equals 'M10' → Set the M10 segment found flag to TRUE, initialize the M10 segment structure, and move the entire M10 table entry data into the M10 segment structure for subsequent processing
  • [P4 - Port/Location Extract Port Code and Sub-Location]
    The current segment table ID equals 'P4 ' → Set the P4 segment found flag to TRUE, initialize the P4 segment structure, and move the entire P4 table entry data into the P4 segment structure for subsequent processing
  • [V9 - Notice Reason Extract Notice Reason Code]
    The current segment table ID equals 'V9 ' → Set the V9 segment found flag to TRUE, initialize the V9 segment structure, and move the entire V9 table entry data into the V9 segment structure for subsequent processing
  • [VID - Vehicle ID Skip Processing]
    The current segment table ID equals 'VID' → Continue to the next segment without performing any processing or data extraction
  • [K1 - Remarks Store Free-Form Message Increment Remark Index]
    The current segment table ID equals 'K1 ' and the remark index is less than or equal to the maximum of 50 → Set the K1 segment found flag to TRUE, initialize the K1 segment structure, move the K1 table entry data into the K1 segment structure, increment the remark index by 1, and store the K1 segment in the remark array at the current index position. If the remark index exceeds 50, set it to 50 and overwrite the last remark
  • [X4 - Release/Disposition Extract Release Reference Extract Date and Time]
    The current segment table ID equals 'X4 ' → Initialize the K1 comments structure, initialize the X4 segment structure, move the X4 table entry data into the X4 segment structure, and set the X4 segment found flag to TRUE for subsequent processing
  • [N7 - Equipment Extract Equipment Number Store in Log Array]
    The current segment table ID equals 'N7 ' and the equipment number field is not spaces → Set the N7 segment found flag to TRUE, initialize the N7 segment structure, move the N7 table entry data into the N7 segment structure, move the equipment number to the log data array at the current log index position with log type 'EDI 350 EQP#:', and increment the log index by 1
  • [SE - Transaction Set Trailer Set Trailer Found Flag Set End Found Flag]
    The current segment table ID equals 'SE ' → Set the trailer found flag to TRUE, set the end found flag to TRUE, and Execute the rest of message processing which includes logging all K1 remarks and N7 equipment numbers to the cargo information message log
  • [Trigger 350 Message Processing]
    The X4 segment found flag is TRUE and the V9 segment found flag is TRUE and the first X4 flag is TRUE → Set the first X4 flag to FALSE (not first X4) and Execute the 350 message processing routine which evaluates the V9 notice reason code and updates cargo records based on the customs action type
  • [Trigger 350 Message Processing]
    The V9 segment found flag is TRUE and the first X4 flag is TRUE and the end found flag is TRUE → Set the first X4 flag to FALSE (not first X4) and Execute the 350 message processing routine which evaluates the V9 notice reason code and updates cargo records based on the customs action type
  • [Move to Next Segment]
    The current segment processing is complete → Increment the line counter by 1 and continue the segment processing loop until the line counter exceeds the maximum number of message queue entries or the end found flag is set to TRUE
  • [X4 - Release/Disposition Extract Release Reference Extract Date and Time]
    The related document ID (CRN) in positions 1-25 is different from the previous CRN → Move the related document ID to the train key value and the previous CRN field, Execute train lookup by CRN. If train is not found, prepare an unknown train notification message with the CRN and send it. If train is found, log the arrival acknowledgment at border message, create a log entry with action code 'ZZZ', train CRN, and message '350 ACK - ARRIVAL ACK AT BORDER', and spawn the log entry. Then move the CBSA release reference ID to the cargo key value and Execute cargo border update processing. If the cargo is a master manifest, retrieve all follower manifests (maximum 100) linked to the master and update each follower with border arrival acknowledgment
  • [X4 - Release/Disposition Extract Release Reference Extract Date and Time]
    The entry type code != '992':
    • the message type is not conventional 350
    → Set the segment previous X4 flag to TRUE and set the X4 segment found flag to TRUE
  • [SE - Transaction Set Trailer Set Trailer Found Flag Set End Found Flag]
    The remark index is greater than 0 and there are K1 remarks stored in the remark array → For each remark from index 1 to the remark index, if the remark is not spaces, initialize the K1 segment structure, move the remark to the K1 segment, initialize the information message field, concatenate 'EDI 350 K1: ' with the first free-form message field and move to the information message field, and log the cargo information message. If the second free-form message field is not spaces, initialize the information message field, concatenate 'EDI 350 K1: ' with the second free-form message field and move to the information message field, and log the cargo information message
  • [SE - Transaction Set Trailer Set Trailer Found Flag Set End Found Flag]
    There are log entries in the log array from index 1 to 50 → For each log line from index 1 until the log line is spaces or index exceeds 50, initialize the information message field, move the log line to the information message field, and log the cargo information message
  • [Is Conveyance 350 AND Entry Type = 992?]
    The message type is Conveyance 350 (WS-CONV-350 is true) AND the X4 entry type code (X4-03-ENTRY-TYP-CDE) equals '992' → Process as train arrival acknowledgment at border, otherwise process as cargo release segment and set X4 segment found flag for cargo processing
  • [Extract Train ID from X4-04-REL-DOC-ID]
    The X4-04-REL-DOC-ID (first 25 characters) is different from the previous CRN → Move X4-04-REL-DOC-ID (first 25 characters) to B4-KEY-VALUE for train lookup and to WS-PREV-CRN for duplicate tracking
  • [Verify Train Exists in System]
    The system performs a database lookup using the CRN as the key value in the train root segment (B4RT) → Return the train record if found, otherwise return a not found status code in CC-STATUS-CODE
  • [Log Train Arrival Action Code: ZZZ Message: 350 ACK - ARRIVAL ACK AT BORDER]
    The train record exists (CC-STATUS-CODE equals spaces) → Create a log entry with current machine date in GCX105-DATE, current machine time in GCX105-TIME, action code 'ZZZ' in GCX105-ACTION-CODE, the CRN (first 25 characters of X4-04-REL-DOC-ID) in GCX105-TRAIN-OR-US-CCN, set cargo type to Canadian train (GCX105-CA-TRAIN), message '350 ACK - ARRIVAL ACK AT BORDER' in GCX105-MESSAGE, and spawn the log entry process (Z300-SPAWN-GCT1051E)
  • [Update Cargo Border Arrival Status]
    The cargo is found using X4-01-CBSA-REL-REF-ID (first 25 characters) as the CCN key → Log the message '350 ACK - ARRIVAL ACK AT BORDER' to cargo information, set the cargo border arrival acknowledgment flag (GCCC-BORDER-ARRIVAL-ACK) to true, and replace the cargo record in the database
  • [Is Master Manifest?]
    The cargo master manifest indicator (GCCC-MASTER-MFST) is true → Proceed to retrieve and update all follower manifests, otherwise skip follower processing and continue to next segment
  • [Update Border Arrival for Each Follower]
    Processing each follower CCN from index 1 to the count of followers found → For each follower CCN: retrieve the cargo record using the CCN as key, if cargo is found then log message '350 ACK - ARRIVAL ACK AT BORDER', set the border arrival acknowledgment flag (GCCC-BORDER-ARRIVAL-ACK) to true, and replace the cargo record
  • [Set X4 Segment Found Flag for Cargo Processing]
    The message is not a conveyance 350 (WS-CONV-350 is false):
    • the entry type code is not '992'
    → Set the previous X4 segment indicator (WS-SEGMENT-PREV-X4) to true and set the X4 segment found flag (WS-X4-SEGMENT-FOUND) to true to enable cargo release processing in subsequent steps
  • [Receive Train ID from X4 Segment]
    The system extracts the related document ID from position 1 to 25 of the X4-04-REL-DOC-ID field → The extracted train ID is stored as the search key for train record lookup
  • [Set Train ID as Search Key]
    The system prepares to search for the train record in the database → The train ID is moved to the B4-KEY-VALUE field for database query
  • [Call Database to Retrieve Train Record]
    The system executes the Z5000-GU-B4-TRAIN procedure → A database GET UNIQUE operation is performed on the train root segment using the provided train ID
  • [Set Train Found Status]
    The system processes the found train record → The system logs an arrival acknowledgment message with action code 'ZZZ', the train ID, and the message '350 ACK - ARRIVAL ACK AT BORDER' by spawning the GCT1051E process
  • [Add 'Train Not Found' Message]
    The system adds supplementary error information → The message 'THIS CRN WAS NOT FOUND.' is placed in the third detail line of the Merlin report and the line counter is set to 4
  • [Verify Train Exists in System]
    The related document ID (positions 1-25) matches the previously processed train ID stored in WS-PREV-CRN → The system skips all train verification and processing steps and continues to the next segment
  • [Retrieve Cargo Record by CCN from X4 Segment]
    The system processes the X4 segment for border arrival acknowledgment → The system retrieves the cargo record using the CBSA Release Reference ID as the CCN key
  • [Log Message: '350 ACK - ARRIVAL ACK AT BORDER']
    The system logs the border arrival event → The system creates a log entry with message '350 ACK - ARRIVAL ACK AT BORDER' including the CCN and current date/time
  • [Log Arrival Message for Follower CCN]
    The system logs the border arrival event for the follower → The system creates a log entry with message '350 ACK - ARRIVAL ACK AT BORDER' including the follower CCN and current date/time
  • [Set M10 Segment Found Flag]
    The M10 segment processing begins → The M10 segment found indicator is set to true
  • [Move MQS Table Entry to M10 Segment]
    Loading M10 segment data → The message queue table entry at the current line position is moved to the M10 segment structure
  • [Extract Notice Document Type Code]
    Extracting customs notice information → The notice document type code (M10-05-NOTICE-DOC-TYP-CDE) is available from the M10 segment for business processing
  • [Extract CBSA Reference/CCN]
    Extracting cargo identification information → The CCN reference (M10-07-CCN) containing up to 25 characters is available from the M10 segment for cargo lookup and processing
  • [Set P4 Segment Found Flag to TRUE]
    The P4 segment processing routine is invoked → The system sets the P4 segment found indicator to TRUE to track that port information has been received
  • [Move MQ Table Entry to P4 Segment]
    The system processes the P4 segment entry → The system moves the complete message queue table entry data to the P4 segment structure, making port code (P4-01-PORT-CDE) and sub-location code (P4-02-SUB-LOC-CDE) available for use
  • [P4 Segment Ready for Processing]
    The P4 segment processing completes → The system has the port code (4-character identifier) and sub-location code available in the P4 segment structure for use in cargo processing, release operations, and notification messages
  • [MATCHED - Document Matched]
    The V9 notice reason code indicates MATCHED status (V9-02-MATCHED is true) → The system continues processing without updating cargo status or logging additional messages
  • [NOT-MATCHED - Document Not Matched]
    The V9 notice reason code indicates NOT-MATCHED status (V9-02-NOT-MATCHED is true) → The system logs the message 'EDI 350: DOC NOT MATCHED' to the cargo information log
  • [CARGO-COMPLETE - Cargo Complete]
    The V9 notice reason code indicates CARGO-COMPLETE status (V9-02-CARGO-COMPLETE is true) → The system logs the message 'EDI 350: CARGO COMPLETE MESSAGE' to the cargo information log
  • [DOC-PKG-COMPLETE - Document Package Complete]
    The V9 notice reason code indicates DOC-PKG-COMPLETE status (V9-02-DOC-PKG-COMPLETE is true) and either the first 15 characters of X4 CBSA release reference ID do not match the broker entry:
    • the first 14 characters do not match the customs transaction number AND the X4 CBSA release reference ID is not spaces
    → The system updates the cargo broker entry with the first 15 characters of X4 CBSA release reference ID, updates the customs transaction number with the first 14 characters, sets the broker date to current machine date, sets the broker time to current machine time (first 4 digits), logs the message 'EDI 350: DOC PKG COMPLETE : ' concatenated with the first 15 characters of X4 CBSA release reference ID, and replaces the cargo record in the database
  • [DOC-NOT-ON-FILE - Document Not On File]
    The V9 notice reason code indicates DOC-NOT-ON-FILE status (V9-02-DOC-NOT-ON-FILE is true) and the first character of X4 release document type code equals 'R' → The system logs the message 'EDI 350: DOC NOT ON FILE FOR RELEASE ' concatenated with the first 15 characters of X4 CBSA release reference ID to the cargo information log
  • [DOC-NOT-ON-FILE - Document Not On File]
    The V9 notice reason code indicates DOC-NOT-ON-FILE status (V9-02-DOC-NOT-ON-FILE is true) and the first character of X4 release document type code does not equal 'R' → The system logs the message 'EDI 350:DOC NOT ON FILE H-BILL CLOSE ' concatenated with the first 25 characters of X4 CBSA release reference ID to the cargo information log
  • [REPORTED - Cargo Reported]
    The V9 notice reason code indicates REPORTED status (V9-02-REPORTED is true) → The system logs the message 'EDI 350: CARGO REPORTED' to the cargo information log
  • [ARRIVED - Cargo Arrived at Port]
    The V9 notice reason code indicates ARRIVED status (V9-02-ARRIVED is true) → The system logs the message 'EDI 350: CARGO ARRIVED AT PORT ' concatenated with the first 4 characters of P4 port code to the cargo information log
  • [RELEASED - Cargo Released]
    The V9 notice reason code indicates RELEASED status (V9-02-RELEASED is true) → The system clears destination station numbers, sets release date to current machine date, sets release time to current machine time, sets release by to current user ID, sets current status to 'RELEASED', sets release status to 'R', sets release type to 'A', clears error or release status index, clears error status, sets release reason to X4 CBSA release reference ID (first 15 characters) concatenated with '/' and P4 port code (first 4 characters), logs the message 'EDI 350: RELEASE : ' concatenated with X4 CBSA release reference ID (first 15 characters) and ' AT PORT ' and P4 port code (first 4 characters), processes associated US manifest records, replaces the cargo record in the database, and if the cargo is a master manifest then processes all follower manifests (up to 100) with the same release information
  • [AUTH-TO-DELIVER - Authorized to Deliver]
    The V9 notice reason code indicates AUTH-TO-DELIVER status (V9-02-AUTH-TO-DELIVER is true) → The system logs the message 'EDI 350: ACCEPTED - CSA', sets cargo status to CSA delivery, sets CSA authorization to deliver received flag to true, replaces the cargo record in the database, and processes associated US manifest records
  • [AUTH-TO-DELIVER - Authorized to Deliver]
    The V9 notice reason code indicates AUTH-TO-DELIVER status (V9-02-AUTH-TO-DELIVER is true) → The system logs the message 'EDI 350: NOT ACCEPTED - NON-CSA' and processes associated US manifest records without updating the cargo record
  • [HELD - Goods Held for Examination]
    The V9 notice reason code indicates HELD status (V9-02-HELD is true) → The system logs the message 'EDI 350: GOODS HELD FOR EXAMINATION', sets cargo status to HOLD, replaces the cargo record in the database, and if the first 4 characters of the cargo CCN equal '6105' then prepares a Merlin hold notification containing equipment ID, waybill number, CCN, destination station name and state, and manifest upon station name, and sends the notification to the Merlin system
  • [DECON - Deconsolidation Release]
    The V9 notice reason code indicates DECON status (V9-02-DECON is true) → The system clears destination station numbers, sets release date to current machine date, sets release time to current machine time, sets release by to current user ID, sets current status to 'RELEASED', sets release status to 'R', sets release type to 'A', clears error or release status index, clears error status, sets release reason to 'DECONSOLIDATION AT ' concatenated with P4 port code (first 4 characters), logs the message 'EDI 350: RELEASE VIA DECON AT PORT ' concatenated with P4 port code (first 4 characters), processes associated US manifest records, replaces the cargo record in the database, and if the cargo is a master manifest then processes all follower manifests (up to 100) with the same release information
  • [Move MQS Table Entry to V9 Segment]
    The system processes the V9 segment table entry → The system moves the message queue table entry at the current line position to the V9 segment data structure
  • [Set V9 Segment Found Flag]
    The V9 segment extraction is complete → The system sets the V9 segment found flag to true
  • [Process K1 Remarks Segment - Store up to 9 free-form message segments in array for later logging]
    The K1 segment is identified and needs to be stored for later logging → The system sets the K1 segment found indicator to true, initializes the K1 segment structure, copies the message queue table entry to the K1 segment structure, increments the K1 remark index counter by 1, and stores the K1 segment in the remark array at the current index position
  • [Store K1 Segment in Remark Array at Current Index]
    The K1 segment needs to be stored in the remark array → The system stores the complete K1 segment structure in the remark array at the position indicated by the current K1 remark index counter value
  • [Set K1 Segment Found Flag]
    K1 segment processing begins → The system sets the K1 segment found indicator flag to true to track that at least one K1 remark segment has been processed in the current transaction
  • [Set N7 Segment Found Flag]
    The N7 segment processing begins → The system sets the N7 segment found indicator to TRUE to track that equipment information is present in this transaction
  • [Move MQ Table Entry to N7 Segment]
    The current line in the message queue table contains an N7 segment → The system moves the message queue table entry data to the N7 segment structure for further processing
  • [Store Equipment Number in Log Array]
    The equipment number validation passes → The system stores the equipment number value from the N7 segment into the log data array at the current log index position
  • [Set Log Type as 'EDI 350 EQP#:']
    The log entry is being prepared → The system sets the log type field to 'EDI 350 EQP#:' to identify this entry as equipment information from an EDI 350 message
  • [Skip Logging]
    The equipment number validation determines the field is blank → The system skips all equipment logging steps and proceeds to end the N7 segment processing
  • [Is X4 Segment Entry Type = '992' AND Conveyance 350?]
    The X4-03-ENTRY-TYP-CDE equals '992' AND the message type indicator WS-CONV-350 is true → Proceed with train arrival processing for conveyance 350
  • [Extract Train ID from X4-04-REL-DOC-ID First 25 Characters]
    The first 25 characters of X4-04-REL-DOC-ID are extracted → Store the extracted train ID in B4-KEY-VALUE for database lookup AND store in WS-PREV-CRN for duplicate checking
  • [Log Arrival Acknowledgment: Date: Current Machine Date, Time: Current Machine Time, Action Code: 'ZZZ', Train ID: From X4 Segment, Message: '350 ACK - ARRIVAL ACK AT BORDER']
    The arrival acknowledgment needs to be logged → Move log information to GCX105 structure AND set GCX105-DATE to current machine century and date (CC-MACHINE-CENTURY concatenated with CC-MACHINE-DATE-X) AND set GCX105-TIME to current machine time (CC-MACHINE-TIME-X) AND set GCX105-ACTION-CODE to 'ZZZ' AND set GCX105-TRAIN-OR-US-CCN to the train ID from X4-04-REL-DOC-ID (first 25 characters) AND set GCX105-CA-TRAIN indicator to true AND set GCX105-MESSAGE to '350 ACK - ARRIVAL ACK AT BORDER'
  • [Is Master Manifest?]
    The system checks the manifest type → If GCCC-MASTER-MFST indicator is true, proceed to update follower manifests, otherwise continue to next segment
  • [Log Border Arrival Message: '350 ACK - ARRIVAL ACK AT BORDER']
    The system prepares to update the border arrival status → An information message '350 ACK - ARRIVAL ACK AT BORDER' is logged to the cargo history with the current follower CCN as the reference
  • [Set Border Arrival Acknowledgment Flag]
    The system updates the cargo record status → The border arrival acknowledgment flag in the cargo record is set to true to indicate customs has acknowledged the cargo's arrival at the border
  • [Set Accept Status to 'GEGB']
    The system prepares to execute a Get Next operation → The system sets Accept Status to 'GEGB', Segment Type to GCSUSRT, Function to GN (Get Next), Index Type to CAR-WB (Car ID and Waybill), and Operator to '>' (greater than)
  • [Call GCCUSIO to Get Next Record]
    The system calls GCCUSIO program → The system retrieves the next US cargo record from GCSUSRT table based on Car ID and Waybill index
  • [Retrieve Cargo Record by CCN]
    The system performs a Get Hold Unique operation on the cargo database using the CCN key → The cargo record segment (GCCC-CARGO-REPORT-SEGMENT) is retrieved if it exists, and the cargo status switches are set to indicate whether the cargo was found, deleted, or has other status conditions
  • [Set Border Arrival Acknowledgment Flag]
    The system processes a border arrival acknowledgment from the EDI 350 message → The GCCC-BORDER-ARRIVAL-ACK flag is set to true in the cargo record segment
  • [Log Message: '350 ACK - ARRIVAL ACK AT BORDER']
    The system prepares to log the border arrival event → The message '350 ACK - ARRIVAL ACK AT BORDER' is moved to WS-GCX105-INFO-MSG, the log information is populated with current machine date, time, user ID, and CCN, the action code is set to LOG-USE-INPUT-MESSAGE, the cargo type is set to GCX105-CA-CARGO, and the GCT1051E transaction is spawned to create the log entry
  • [Update Cargo Record in Database]
    The system executes the replace operation → The CIMS program is called with REPL function code, GCCC-PCB, and GCCC-CARGO-REPORT-SEGMENT to update the cargo record in the database, and the accept status is cleared
  • [Is Cargo a Master Manifest?]
    The system checks if the cargo is a master manifest → If cargo is NOT a master manifest, skip follower processing and exit; If cargo IS a master manifest, proceed to initialize follower manifest array and retrieve all associated follower manifests
  • [Get Next Cargo Record from Database]
    The system executes a Get Next database call → Retrieve the next cargo report segment from the database using PCB7 with qualified SSA for B0RT segment
  • [Retrieve Follower Cargo Record]
    The system retrieves the follower cargo record → Execute Get Hold Unique (GHU) call to retrieve the cargo report segment from the database using the follower's CCN key
  • [Set Border Arrival Acknowledgment Flag = TRUE]
    The system updates the border arrival status → Set the border arrival acknowledgment flag (GCCC-BORDER-ARRIVAL-ACK) to true in the cargo report segment
  • [Log Message: '350 ACK - ARRIVAL ACK AT BORDER']
    The system logs the border arrival event → Create a log entry with message '350 ACK - ARRIVAL ACK AT BORDER', current CCN key, current date and time, and action code 'ZZZ' for Canadian cargo type
  • [Update Follower Cargo Record in Database]
    The system saves the changes to the database → Execute Replace (REPL) call to update the cargo report segment in the database, clear status code and set accept status to blank
  • [Log Border Arrival Message: '350 ACK - ARRIVAL ACK AT BORDER']
    The system prepares to update the cargo record with border arrival acknowledgment → The system creates a log entry with the message '350 ACK - ARRIVAL ACK AT BORDER' associated with the follower manifest CCN
  • [Call CIMS with GN Function]
    The CIMS program is called with GN (Get Next) function using PCB7 and qualified SSA for master CCN → The next cargo report segment is retrieved into the cargo report segment area
  • [Train ID Same as Previous CRN?]
    The X4 related document ID (first 25 characters) matches the previously processed train ID stored in memory → The system skips all processing for this train ID and continues to the next segment without performing train lookup, validation, or border arrival acknowledgment
  • [Lookup Train in System Using Train ID]
    The system needs to validate the train entry → The system stores the X4 related document ID (first 25 characters) as the current train ID in memory and performs a database lookup using this train ID as the key value to retrieve the train root segment
  • [Set Message: 'UNKNOWN TRAIN ENTRY IN EDI 350']
    The error report preparation begins → The system clears the first detail line of the report and sets the message to 'UNKNOWN TRAIN ENTRY IN EDI 350 ' concatenated with the train ID (first 25 characters of X4 related document ID)
  • [Add Train ID to Report]
    The train ID needs to be added to the report → The system appends the X4 related document ID (first 25 characters) to the error message 'UNKNOWN TRAIN ENTRY IN EDI 350 ' in the first detail line of the report
  • [Add Message: 'THIS CRN WAS NOT FOUND']
    Additional explanation is needed in the report → The system sets the third detail line of the report to the message 'THIS CRN WAS NOT FOUND.'
  • [Continue Processing]
    Train validation is complete → The system proceeds to log the train arrival information, create a log entry with action code 'ZZZ', message '350 ACK - ARRIVAL ACK AT BORDER', and spawns the logging transaction for the train
  • [Check if K1 Segments Were Found]
    The system begins the K1 remarks logging process → The system initiates the loop to process all stored K1 remarks from index 1 to the maximum K1 remark index
  • [Get K1 Remark from Array, Build Log Message: 'EDI 350 K1:' + First Free-Form Message, Log Cargo Information Message]
    The system retrieves the K1 segment from the remark array → The system initializes the K1 segment structure, moves the remark data to K1 segment, clears the information message work area, concatenates 'EDI 350 K1: ' with the first free-form message field (K1-01-FREE-FORM-MESSAGE), stores the result in the information message work area, and invokes the cargo information message logging process
  • [Check Second Free-Form Message Exists?, Build Log Message: 'EDI 350 K1:' + Second Free-Form Message, Log Cargo Information Message]
    The second free-form message field (K1-02-FREE-FORM-MESSAGE) is populated → The system clears the information message work area, concatenates 'EDI 350 K1: ' with the second free-form message field, stores the result in the information message work area, and invokes the cargo information message logging process
  • [Check if K1 Segments Were Found]
    The K1 segment found indicator is set to false (no K1 segments were found) → The system skips the K1 remarks logging process entirely and proceeds to the next processing step
  • [N7 Segment Found?]
    The N7 segment found indicator is set to false (WS-NO-N7-SEG-FOUND) → The system skips all N7 equipment logging operations and proceeds to the end of the logging process
  • [N7 Segment Found?]
    The N7 segment found indicator is set to true (WS-N7-SEGMENT-FOUND) → The system initiates the loop to process and log all equipment information from the LOG-LINE array starting at index 1
  • [Move LOG-LINE to Message Field]
    The system prepares the equipment information for logging → The LOG-LINE entry content is moved to the WS-GCX105-INFO-MSG field, clearing any previous content in that field
  • [42: Log Cargo Information Message]
    The system invokes the Z150-LOG-CARGO-INFO-MSG procedure → The equipment information is logged to cargo history with current date, time, CCN, cargo type indicator, and action code
  • [Extract CCN from M10 Segment M10-07-CCN]
    The cargo lookup process is initiated → The CCN value from M10-07-CCN field (positions 1-25) is extracted and prepared for database search
  • [Set Search Keys: - CCRT-SSAQ Key = CCN - A2RT-SSAQ Key = CCN]
    Database search keys need to be established → The CCN value is assigned to both CCRT-SSAQ KEY-VALUE and A2RT-SSAQ KEY-VALUE for qualified segment search
  • [Call Database GHU Function to Retrieve Cargo]
    The cargo record retrieval is executed → The system calls CIMS with GHU function code against GCCC-PCB using CCRT-SSAQ qualified search to retrieve GCCC-CARGO-REPORT-SEGMENT
  • [Retrieve Secondary Cargo Segment GCSCCS52]
    Secondary segment retrieval is initiated → The system calls CIMS with GHU function code against GCA2-PCB using A2RT-SSAQ qualified search to retrieve GCSCCS52 segment, and if not found (status = 'GE'), initializes GCSCCS52 to SPACES
  • [Save Cargo Data: - CCN Key - Equipment Car ID - Waybill Index - Release Information]
    Cargo data needs to be preserved for processing → The system saves GCCC-CARGO-REPORT-SEGMENT to WS-SAVE-GCSCCRT, GCCC-CCN-KEY to WS-CURRENT-CCN-KEY and WS-SAVE-CCN, GCCC-EQUIPMENT-CAR to WS-CURRENT-CARID-KEY, GCCC-RELEASE-INFORMATION to WS-SAVE-RELEASE-INFORMATION, and GCCC-WAYBILL-KEY-FOR-INDEX to SAVE-WAYBILL-INDEX
  • [Notice Reason = RELEASED?]
    The V9 segment notice reason code is evaluated → The system checks if the notice reason code equals RELEASED (V9-02-RELEASED)
  • [Set Report Line 1: 'UNKNOWN EDI 350 RELEASE FROM CBSA' + CCN]
    The system constructs the error message → The system sets MRLN-DTL-LINE(01) to 'UNKNOWN EDI 350 RELEASE FROM CBSA ' concatenated with the CCN from M10-07-CCN (first 25 characters)
  • [Set Report Line 3: 'THIS CCN WAS NOT FOUND.']
    The system continues building the error message → The system sets MRLN-DTL-LINE(03) to 'THIS CCN WAS NOT FOUND.'
  • [Set Report Line 4: 'RELEASE NUMBER:' + Release Reference + 'DONE BY PORT' + Port Code]
    The system adds release details to the error message → The system sets MRLN-DTL-LINE(04) by concatenating 'RELEASE NUMBER: ', X4-01-CBSA-REL-REF-ID (first 15 characters), ' DONE BY PORT ', and P4-01-PORT-CDE (first 4 characters)
  • [Set Report Line Count = 5]
    The system finalizes the error report structure → The system sets MRLN-LINE to 5 indicating the total number of report lines
  • [Check Notice Reason is DECON?]
    If the cargo not found condition and the V9-02-DECON notice reason code is true → The system prepares an error report with subject line 'UNKNOWN EDI 350 DCON NOTICE' followed by the CCN from M10-07-CCN field (first 25 characters), sets detail line 3 to 'THIS CCN WAS NOT FOUND.', sets detail line 4 with house bill close number from X4-01-CBSA-REL-REF-ID (first 25 characters) and port code from P4-01-PORT-CDE (first 4 characters) in format 'HOUSE BILL CLOSE NUMBER [value] DONE BY PORT [value]', sets total lines to 5, marks message type as unknown, routes the notification to user OM01247 with filename UNKNOWN, and invokes the email notification process
  • [Add House Bill Close Information: House Bill Close Number, Port Code]
    The system adds detailed information to the error report → The system constructs a string starting with 'HOUSE BILL CLOSE NUMBER' followed by X4-01-CBSA-REL-REF-ID field positions 1 through 25, then ' DONE BY PORT ' followed by P4-01-PORT-CDE field positions 1 through 4, and stores this complete string in MRLN-DTL-LINE array element 4
  • [Set Email Routing: Route to OM01247, Filename UNKNOWN]
    The system determines the routing for the error notification → The system sets EMI-DESTINATION-FILENAME to 'UNKNOWN', clears EMI-TO-USERCODE to spaces, and sets EMI-TO-USERCODES array element 1 to 'OM01247'
  • [Handle Unknown Cargo Entry]
    The V9 notice reason code is NOT 'RELEASED' AND NOT 'DECON' → The system prepares an error email notification with subject 'UNKNOWN EDI 350 ENTRY FROM CBSA' followed by the CCN, message line 1 contains 'UNKNOWN EDI 350 ENTRY FROM CBSA' with the CCN, message line 3 contains 'THIS CCN WAS NOT FOUND.', message line 4 contains 'NOTICE DOC TYPE: ' followed by the notice document type code, ' WITH REASON CODE ' followed by the first 4 characters of the notice reason code, sets the line count to 5, sets the recipient to 'OM01247', sets the email type indicator to 'UNKNOWN', and sends the email notification
  • [Check Notice Reason Code]
    The V9 notice reason code indicates 'RELEASED' → The system skips the unknown entry notification process and exits without sending the generic unknown cargo entry email
  • [Check Notice Reason Code]
    The V9 notice reason code indicates 'DECON' (deconsolidation) → The system skips the unknown entry notification process and exits without sending the generic unknown cargo entry email
  • [Set Subject: 'UNKNOWN EDI 350 ENTRY FROM CBSA']
    The email subject is being prepared → The system sets the email subject to 'UNKNOWN EDI 350 ENTRY FROM CBSA ' concatenated with the 25-character CCN from M10-07-CCN field
  • [Add CCN to Message Line 1]
    The email message body is being constructed → The system sets message detail line 1 to 'UNKNOWN EDI 350 ENTRY FROM CBSA ' concatenated with the first 25 characters of M10-07-CCN field
  • [Add 'THIS CCN WAS NOT FOUND' to Message Line 3]
    The email message body is being constructed → The system sets message detail line 3 to 'THIS CCN WAS NOT FOUND.'
  • [Add Notice Document Type and Reason Code to Line 4]
    The email message body is being constructed → The system sets message detail line 4 to 'NOTICE DOC TYPE: ' concatenated with M10-05-NOTICE-DOC-TYP-CDE, followed by ' WITH REASON CODE ' concatenated with the first 4 characters of V9-02-NOTICE-RSN-CDE field
  • [Add Notice Document Type and Reason Code to Line 4]
    The email is ready to be sent → The system sets the message line count to 5
  • [Send Email Notification]
    The notification is ready to be dispatched → The system performs the email preparation and sending routine (Z110-PREP-EMCSEND)
  • [Process Document Not Matched - Log 'DOC NOT MATCHED' message when V9 notice reason is NOT-MATCHED]
    The V9 segment notice reason code indicates NOT-MATCHED status → The system clears the log information message variable, sets the message text to 'EDI 350: DOC NOT MATCHED', moves the message to the log info variable, and invokes the log cargo information message process to record the message with the current CCN, current machine date, current machine time, current user ID, action code for input message, and cargo type indicator
  • [Process Cargo Complete - Log 'CARGO COMPLETE MESSAGE' when V9 notice reason is CARGO-COMPLETE]
    The system processes the V9 segment with CARGO-COMPLETE notice reason code → The system prepares a log message 'EDI 350: CARGO COMPLETE MESSAGE', sets the log information with current machine date and time, the cargo CCN key, action code for input message, and cargo type as CA-CARGO, and spawns a GCT1051E transaction to record the message in the cargo history log
  • [Update broker entry, customs transaction number, broker date/time, log 'DOC PKG COMPLETE' message, and update cargo record]
    The X4 CBSA Release Reference ID (first 15 characters) is different from the current broker entry:
    • the X4 CBSA Release Reference ID (first 14 characters) is different from the current customs transaction number, AND the X4 CBSA Release Reference ID is not spaces
    → Update the cargo broker entry with X4 Release Reference ID (first 15 characters), update the customs transaction number with X4 Release Reference ID (first 14 characters), update the broker date with current machine date, update the broker time with current machine time (first 4 characters), build and log the message 'EDI 350: DOC PKG COMPLETE : ' concatenated with X4 Release Reference ID (first 15 characters), and replace the cargo record in the database
  • [Skip Update - Values Already Match]
    The X4 CBSA Release Reference ID (first 15 characters) equals the current broker entry AND the X4 CBSA Release Reference ID (first 14 characters) equals the current customs transaction number → Skip all update operations and continue to next processing step without modifying the cargo record
  • [Build Log Message: 'EDI 350: DOC PKG COMPLETE : ' + X4 Release Reference First 15 Characters]
    Preparing to log the document package completion event → Construct a log message by concatenating the literal text 'EDI 350: DOC PKG COMPLETE : ' with the first 15 characters of X4 CBSA Release Reference ID and store in the log message field
  • [Log Cargo Information Message]
    Recording the document package completion event → Invoke the log cargo information message process (Z150-LOG-CARGO-INFO-MSG) to write the message to the cargo audit log with current date, time, user ID, CCN, and the constructed message text
  • [Log Message: 'EDI 350: DOC NOT ON FILE FOR RELEASE' with CBSA Release Reference ID]
    The X4 release document type code (position 1, length 1) starts with 'R' indicating a release type transaction → The system logs an informational message 'EDI 350: DOC NOT ON FILE FOR RELEASE' concatenated with the CBSA release reference ID (first 15 characters) to the cargo information log
  • [Log Message: 'EDI 350: DOC NOT ON FILE H-BILL CLOSE' with CBSA Release Reference ID]
    The X4 release document type code (position 1, length 1) does not start with 'R' indicating a non-release type transaction (house bill close) → The system logs an informational message 'EDI 350:DOC NOT ON FILE H-BILL CLOSE' concatenated with the CBSA release reference ID (full 25 characters) to the cargo information log
  • [Process Document Not On File]
    The V9 segment notice reason code equals 'DOC-NOT-ON-FILE' → The system proceeds to check the release document type to determine the appropriate logging message format
  • [Process Cargo Reported - Log 'CARGO REPORTED' message when V9 notice reason is REPORTED]
    The V9 segment notice reason code indicates REPORTED status → The system clears the message work area (WS-GCX105-INFO-MSG), builds the message string 'EDI 350: CARGO REPORTED', and invokes the log cargo information message process (Z150-LOG-CARGO-INFO-MSG) to record this status change in the cargo history with the current CCN, date, time, and user information
  • [Process Cargo Reported - Log 'CARGO REPORTED' message when V9 notice reason is REPORTED]
    If the V9 notice reason code against the REPORTED condition (V9-02-REPORTED) → If the condition is true, the system proceeds to log the cargo reported message; otherwise, the system continues to evaluate other notice reason code conditions
  • [Process Cargo Reported - Log 'CARGO REPORTED' message when V9 notice reason is REPORTED]
    The system prepares the log message content → The system clears the message work area (WS-GCX105-INFO-MSG) to spaces and builds the message string 'EDI 350: CARGO REPORTED' into the work area
  • [Process Cargo Reported - Log 'CARGO REPORTED' message when V9 notice reason is REPORTED]
    The system invokes the log cargo information message process (Z150-LOG-CARGO-INFO-MSG) → The logging service records the message to cargo history with the current machine date, machine time, user ID (ACF2-USERID), action code (LOG-USE-INPUT-MESSAGE), cargo CCN, cargo type indicator (GCX105-CA-CARGO), and the prepared message text
  • [Process Cargo Arrived - Log 'CARGO ARRIVED AT PORT' message when V9 notice reason is ARRIVED]
    The system processes the cargo arrival status → The system prepares a log message 'EDI 350: CARGO ARRIVED AT PORT' concatenated with the 4-character port code from P4 segment, sets the current machine date and time, sets the CCN key as the cargo identifier, sets the action code to indicate input message usage, marks the log as Canadian cargo type, and writes the log message to the IMS message queue via GCT1051E transaction
  • [Prepare Log Message: 'EDI 350: CARGO ARRIVED AT PORT']
    The system prepares the arrival log message → The system initializes the log message field to spaces, concatenates the text 'EDI 350: CARGO ARRIVED AT PORT ' with the 4-character port code from P4-01-PORT-CDE positions 1 through 4, and stores the result in WS-GCX105-INFO-MSG field
  • [Set Log Information: - Current Date/Time - CCN Key - Action Code]
    The system sets the log information for the arrival event → The system clears the GCX105 input area to spaces, sets the security byte to high-value, sets the sending transaction to 'GCT1261E', sets the ACF2 user ID from the common control area, concatenates the machine century with the machine date to form GCX105-DATE, moves the machine time to GCX105-TIME, moves the current CCN key to GCX105-TRAIN-OR-US-CCN, sets the cargo type indicator to Canadian cargo, sets the action code to LOG-USE-INPUT-MESSAGE, and moves the prepared arrival message from WS-GCX105-INFO-MSG to GCX105-MESSAGE
  • [42: Log Cargo Information Message to IMS Message Queue]
    The system writes the log entry to the message queue → The system replaces all spaces in GCX105-DATE with zeroes, replaces all spaces in GCX105-TIME with '1', moves the GCX105-INPUT to GCT1051E-MSG, sets the accept status to blank, calls CIMS with CHNG function for the alternate PCB and GCT1051E segment, calls WRITMSGL with the alternate PCB, message code, message text, message length and module name, and calls CIMS with PURG function for the alternate PCB to commit the message
  • [Build Log Message: RELEASE: release-ref AT PORT port-code]
    The system builds the release log message → The log message is formatted as 'EDI 350: RELEASE : ' concatenated with the first 15 characters of X4 CBSA release reference ID concatenated with ' AT PORT ' concatenated with the first 4 characters of P4 port code
  • [Build Release Reason: release-ref / port-code, release-ref / port-code]
    The system builds the release reason → The release reason is formatted as the first 15 characters of X4 CBSA release reference ID concatenated with '/' concatenated with the first 4 characters of P4 port code
  • [Log Release Message to Cargo]
    The system logs the release information → A log entry is created with current system date, current system time, cargo CCN as the reference, cargo type indicator set to Canadian cargo, action code set to use input message, and the message set to the constructed release log message
  • [Log to US Cargo: CDN CCN RLSED BY EDI 350: canadian-ccn]
    The system logs the release to US cargo → A log entry is created with current system date, current system time, US CCN as the reference, cargo type indicator set to US cargo, action code set to use input message, and the message formatted as 'CDN CCN RLSED BY EDI 350: ' concatenated with the Canadian cargo CCN
  • [Update Canadian Cargo Record with Release Information]
    The system updates the cargo record → The cargo report segment is replaced in the database with the updated release information
  • [Build Message Based on Type]
    The system builds the log message for the follower → If V9 notice reason code indicates RELEASED, then format message as release type, otherwise if V9 notice reason code indicates DECON, then format message as deconsolidation type
  • [RELEASE: release-ref AT PORT port-code]
    The system builds the release message → The log message is formatted as 'EDI 350: RELEASE : ' concatenated with the first 15 characters of X4 CBSA release reference ID concatenated with ' AT PORT ' concatenated with the first 4 characters of P4 port code
  • [RELEASE VIA DECON AT PORT port-code]
    The system builds the release message → The log message is formatted as 'EDI 350: RELEASE VIA DECON AT PORT ' concatenated with the first 4 characters of P4 port code
  • [Build Reason Based on Type]
    The system builds the release reason for the follower → If V9 notice reason code indicates RELEASED, then format reason as standard release type, otherwise if V9 notice reason code indicates DECON, then format reason as deconsolidation type
  • [DECONSOLIDATION AT port-code]
    The system builds the release reason → The release reason is formatted as 'DECONSOLIDATION AT ' concatenated with the first 4 characters of P4 port code
  • [Log Release Message to Follower Cargo]
    The system logs the release information → A log entry is created with current system date, current system time, follower cargo CCN as the reference, cargo type indicator set to Canadian cargo, action code set to use input message, and the message set to the constructed release log message
  • [Log to US Cargo: CDN CCN RLSED BY EDI 350]
    The system logs the release to US cargo → A log entry is created with current system date, current system time, US CCN as the reference, cargo type indicator set to US cargo, action code set to use input message, and the message formatted as 'CDN CCN RLSED BY EDI 350: ' concatenated with the follower Canadian cargo CCN
  • [Update Follower Cargo Record]
    The system updates the follower cargo record → The follower cargo report segment is replaced in the database with the updated release information
  • [Set Search Criteria: Function: Get Unique GU, Index Type: Car-Waybill, Operator: Greater Than or Equal]
    The system prepares to execute the database search → The search function is set to Get Unique (GU), segment type is set to US cargo record (GCSUSRT), index type is set to Car-Waybill, and operator is set to greater than or equal (>=)
  • [Execute Database Search on US Cargo Table]
    The system executes the database call → The GCCUSIO program is invoked with the search parameters to retrieve US cargo records from GCSUSRT table
  • [Continue to Next Record]
    The system needs to continue searching for valid records → The search function is set to Get Next (GN), segment type remains GCSUSRT, index type remains Car-Waybill, operator is set to greater than (>), and the database call is executed to retrieve the next record in sequence
  • [Call GCCUSIO to Search US Cargo]
    The system executes the database search → The GCCUSIO module is called with the control communication area, search parameters, and US cargo segment structure to retrieve matching records
  • [Set Search Parameters]
    Preparing to search for associated US cargo records → Set search parameters with car ID from current cargo key, waybill index from saved waybill, US CCN key to LOW-VALUES, database accept status to 'GEGB', segment type to GCSUSRT, function to Get Unique (GU), index type to CAR-WB (Car-Waybill), and operator to greater than or equal ('>=')
  • [Set Segment Type to GCSUSRT]
    Specifying which segment type to retrieve → Set GCWUSIO-SEG-GCSUSRT to TRUE to indicate US cargo report segment (GCSUSRT) should be accessed
  • [Call GCCUSIO with Parameters]
    The system executes the database search → The GCCUSIO program is called with the control communication area, search parameters, and US cargo segment structure to retrieve matching records
  • [Save Master Cargo Information]
    The system prepares to process follower manifests → Save the complete master cargo report segment to working storage; Save the master CCN key; Save the master waybill key for index; Save the master equipment car identifier
  • [Get Next Follower Manifest Using Master CCN]
    The system requests the next follower manifest record → Execute database Get Next operation using master CCN key; Set database accept status to 'GEGB'; Use cargo report segment PCB7; Use qualified SSA with master CCN key (CCRT-B0RT-SSAQ)
  • [Retrieve Follower Cargo by CCN]
    The system retrieves the follower cargo record → Move the follower CCN to the cargo report segment key value (CCRT-SSAQ); Move the follower CCN to the alternate segment key value (A2RT-SSAQ); Execute Get Hold Unique database operation (Z3000-GHU-CARGO); Evaluate cargo found status based on database return
  • [Notice Reason Type?]
    The system determines the type of release message to log → If the V9 notice reason code indicates RELEASED, proceed to log release message; If the V9 notice reason code indicates DECONSOLIDATION, proceed to log deconsolidation message
  • [Log Message: 'EDI 350: RELEASE : [Ref] AT PORT [Port]', Set Release Reason: '[Ref]/[Port]']
    The system logs the release information → Clear the information message field to spaces; Build message string: 'EDI 350: RELEASE : ' concatenated with CBSA release reference ID (first 15 characters) concatenated with ' AT PORT ' concatenated with port code (first 4 characters); Move the built message to information message field; Build release reason string: CBSA release reference ID (first 15 characters) concatenated with '/' concatenated with port code (first 4 characters); Move the built reason to cargo release reason field; Set current CCN key to information message CCN key; Execute log cargo information message procedure (Z150-LOG-CARGO-INFO-MSG)
  • [Log Message: 'EDI 350: RELEASE VIA DECON AT PORT [Port]', Set Release Reason: 'DECONSOLIDATION AT [Port]']
    The system logs the deconsolidation information → Clear the information message field to spaces; Build message string: 'EDI 350: RELEASE VIA DECON AT PORT ' concatenated with port code (first 4 characters); Move the built message to information message field; Build release reason string: 'DECONSOLIDATION AT ' concatenated with port code (first 4 characters); Move the built reason to cargo release reason field; Set current CCN key to information message CCN key; Execute log cargo information message procedure (Z150-LOG-CARGO-INFO-MSG)
  • [Process Associated US Manifest: Find US Cargo by Car ID and Waybill, Log Release to US CCN]
    The system processes associated US manifest → Set US manifest not found flag to true; Set not end-of-file flag to true; Move current equipment car ID key to US cargo car ID index; Move saved waybill index to US cargo waybill index; Execute Get Unique US cargo by car and waybill (Z3300-GU-US-CARGO-BY-CARWB); Execute Get Next US cargo by car and waybill repeatedly (Z3350-GN-US-CARGO-BY-CARWB) until US manifest found or end-of-file; If end-of-file reached, exit US manifest processing; If US manifest found: move log information, build date string from machine century and date, move machine time to log time, set action code to use input message, move US CCN key to train or US CCN field, set US cargo indicator to true, build message string 'CDN CCN RLSED BY EDI 350: ' concatenated with Canadian CCN key, execute spawn log entry procedure (Z300-SPAWN-GCT1051E)
  • [Update Follower Cargo Record in Database]
    The system updates the follower cargo record → Move spaces to database status code; Move blank to database accept status; Execute database Replace operation using cargo PCB; Pass cargo report segment for update
  • [Restore Master Cargo Information]
    The system completes follower processing → Move saved master cargo report segment to current cargo report segment; Move saved master waybill key to current waybill index; Move saved master equipment car to current car ID key
  • [Call IMS GN Function Using Master CCN Key]
    The IMS Get Next function is called with PCB7 using the CCRT-B0RT-SSAQ qualified search → The next cargo report segment is retrieved into GCCC-CARGO-REPORT-SEGMENT
  • [End Loop]
    Loop processing ends → The loop counter I is decremented by 1 to reflect the actual count of follower manifests collected AND if the count is zero or negative, processing exits immediately OR if follower manifests were collected, they are available in the WS-FOLLOWER-MANI array for further processing
  • [Set Release Type to 'A']
    The system sets release information → The release type is set to 'A' indicating automatic release
  • [Retrieve US Cargo Record by Car ID and Waybill]
    The system executes the initial US cargo retrieval using GU function with CAR-WB index and >= operator → The system retrieves the first US cargo record matching or exceeding the search criteria
  • [Prepare Log Entry: Current Date/Time, US CCN, Action Code: LOG-USE-INPUT-MESSAGE, Message: CDN CCN RLSED BY EDI 350]
    The system prepares the log entry → The log date is set to current machine century concatenated with current machine date AND the log time is set to current machine time AND the action code is set to LOG-USE-INPUT-MESSAGE AND the US CCN key is set as the train or US CCN identifier AND the cargo type indicator is set to US cargo AND the message is set to 'CDN CCN RLSED BY EDI 350: ' concatenated with the Canadian CCN key
  • [Spawn GCT1051E Transaction to Log Release Message]
    The system invokes the GCT1051E logging process → A log transaction is created recording the Canadian cargo release notification for the associated US cargo
  • [Prepare Log Entry: - Current Date/Time - US CCN - Action Code: LOG-USE-INPUT-MESSAGE - Message: CDN CCN RLSED BY EDI 350]
    ['The system processes the US manifest associated with the released Canadian cargo'] → ['Extract current machine century and date in CCYYMMDD format', 'Extract current machine time in HHMMSS format', 'Set the action code to LOG-USE-INPUT-MESSAGE', 'Set the target identifier to the US cargo control number', 'Set the cargo type indicator to US-CARGO', "Build the log message by concatenating 'CDN CCN RLSED BY EDI 350: ' with the Canadian cargo control number", 'Populate the GCX105 log structure with date, time, action code, US CCN, cargo type, and message', 'Invoke the GCT1051E transaction to create the log entry']
  • [Set Action Code to LOG-USE-INPUT-MESSAGE]
    ['Setting the action code for the log entry'] → ['Set GCX105-ACTION-CODE to LOG-USE-INPUT-MESSAGE']
  • [Build Message Text and Concatenate: 'CDN CCN RLSED BY EDI 350: ' + Canadian CCN]
    ['Building the log message text'] → ["Concatenate the literal text 'CDN CCN RLSED BY EDI 350: ' with GCCC-CCN-KEY", 'Store the concatenated message in GCX105-MESSAGE field']
  • [Call GCT1051E Transaction to Log Entry]
    ['Ready to create the log entry'] → ['Call Z300-SPAWN-GCT1051E procedure to create the log entry']
  • [Move Log Input to GCT1051E Message]
    The log entry preparation is in progress → The system moves the complete GCX105-INPUT structure to the GCT1051E-MSG field
  • [Call CIMS with CHNG Function]
    The system is ready to write the log entry → The system calls CIMS with CHNG function using the alternate PCB and GCT1051E message to change the message destination
  • [Call WRITMSGL to Write Message Log]
    The system is ready to persist the log entry → The system calls WRITMSGL with the alternate PCB, GCT1051E message code, message content, message length, and module name to write the log entry
  • [Call CIMS with PURG Function to Commit]
    The log entry write operation is complete → The system calls CIMS with PURG function using the alternate PCB to commit the transaction and make the log entry permanent
  • [Log Message: 'EDI 350: AUTHORIZED TO PROCEED']
    The authorization to deliver processing begins → The system logs the message 'EDI 350: AUTHORIZED TO PROCEED' to the cargo information log with current date, time, and cargo CCN
  • [Is Cargo CSA Manifest?]
    If the cargo's CSA indicator → If CSA indicator is ON, proceed with CSA authorization processing; If CSA indicator is OFF, log non-CSA rejection message
  • [Process CSA Authorization: - Log 'EDI 350: ACCEPTED - CSA' - Set Status to CSA-DLV - Set CSA Authorization Flag]
    The system processes the CSA authorization → The system logs 'EDI 350: ACCEPTED - CSA' message, sets cargo current status to 'CSA-DLV', sets CSA authorization to deliver received flag to TRUE
  • [Log Message: 'EDI 350: NOT ACCEPTED - NON-CSA']
    If the non-CSA cargo → The system logs 'EDI 350: NOT ACCEPTED - NON-CSA' message to the cargo information log without updating cargo status
  • [Process Associated US Manifest: - Find US Cargo by Car ID and Waybill - Log Release Message to US CCN - Reference Canadian CCN]
    The authorization processing is complete → The system searches for US cargo records matching the car ID and waybill number, and if found and not deleted and no train created, logs a message 'CDN CCN RLSED BY EDI 350' with the Canadian CCN to the US cargo log entry
  • [Log Message: 'EDI 350: GOODS HELD FOR EXAMINATION']
    The cargo hold processing is initiated → The system logs the message 'EDI 350: GOODS HELD FOR EXAMINATION' to the cargo information log
  • [Set Cargo Status to HOLD]
    The hold status processing is executed → The cargo status is set to HOLD in the cargo record
  • [Prepare Hold Email: - Subject: 'CBSA CARGO HOLD' - Equipment ID - Waybill Number - CCN - Destination Station - Manifest Station]
    The hold notification preparation is executed → The system creates an email with subject 'CBSA CARGO HOLD - [CCN]' and body containing: line 1 - 'Cargo on HOLD for inspection by CBSA - EDI350', line 3 - 'Equipment: [Equipment ID]', line 4 - 'Waybill: [Carrier][Origin Station][Waybill Number]', line 5 - 'CCN: [CCN]', line 6 - 'DESTINATION: [Destination Station Name], [State Code]', line 7 - 'MANIFEST UPON: [Manifest Station Name]'
  • [Set Email Route: - Filename: CAHOLD - To: OM01247]
    The email routing is configured → The system sets the destination filename to 'CAHOLD', sets the primary recipient to 'OM01247', and sets the message type indicator to HOLD
  • [V9 Notice Reason = DECON?]
    If the V9 notice reason code field → If V9-02-DECON is true, proceed with deconsolidation release processing; otherwise, skip deconsolidation processing and continue to next evaluation
  • [Log Message: 'RELEASE VIA DECON AT PORT' + Port Code]
    The system logs the deconsolidation release event → Construct message 'EDI 350: RELEASE VIA DECON AT PORT ' concatenated with P4-01-PORT-CDE (first 4 characters), store in WS-GCX105-INFO-MSG, and Execute Z150-LOG-CARGO-INFO-MSG to create audit log entry
  • [Update Release Reason: 'DECONSOLIDATION AT' + Port Code]
    The system updates the release reason for deconsolidation → Construct string 'DECONSOLIDATION AT ' concatenated with P4-01-PORT-CDE (first 4 characters) and store in GCCC-RELEASE-REASON field
  • [31: Process Associated US Manifest - Find US manifest by car ID and waybill - Log release message to US CCN - Reference Canadian CCN]
    The system processes the associated US manifest → Execute Z3300-GU-US-CARGO-BY-CARWB to retrieve US cargo by car ID and waybill, then Execute Z3350-GN-US-CARGO-BY-CARWB until WS-US-MFST-FOUND is true or WS-EOF is true; if US manifest found and not EOF, Execute Z200-MOVE-LOG-INFORMATION, construct GCX105-DATE from CC-MACHINE-CENTURY and CC-MACHINE-DATE-X, set GCX105-TIME to CC-MACHINE-TIME-X, set GCX105-ACTION-CODE to LOG-USE-INPUT-MESSAGE, set GCX105-TRAIN-OR-US-CCN to GCUSRT-US-CCN-KEY, set GCX105-US-CARGO to true, construct GCX105-MESSAGE as 'CDN CCN RLSED BY EDI 350: ' concatenated with GCCC-CCN-KEY, and Execute Z300-SPAWN-GCT1051E
  • [43: Update Cargo Record - Replace cargo record in database]
    The system updates the cargo record → Execute Z3100-REPL-CARGO which clears CC-STATUS-CODE, sets CC-ACCEPT-STATUS to spaces, and calls CIMS with REPL function code, GCCC-PCB, and GCCC-CARGO-REPORT-SEGMENT to replace the cargo record
  • [33: Process Follower Manifests - Retrieve all follower manifests - Set release information for each - Log release message - Update release reason - Process US manifest - Update cargo record]
    The system processes follower manifests → Save GCCC-CARGO-REPORT-SEGMENT to WS-SAVE-GCSCCRT, set CC-ACCEPT-STATUS to 'GEGB', initialize WS-FOLLOWER-MANI-ARRAY to spaces, set WS-FOLLOWER-NOT-END-OF-DB to true, set I to 1; Execute until WS-FOLLOWER-END-OF-DB or I > 100: call CIMS with GN, GCCC-PCB7, GCCC-CARGO-REPORT-SEGMENT, and CCRT-B0RT-SSAQ; if CC-STATUS-CODE is space and GCCC-MASTER-MFST-CCN equals WS-SAVE-CCN: if GCCC-FOLLOWER-MFST is true, move GCCC-CCN-KEY to WS-FOLLOWER-MANI(I) and add 1 to I; else set WS-FOLLOWER-END-OF-DB to true; subtract 1 from I; if I > 0, Execute varying J from 1 by 1 until WS-FOLLOWER-MANI(I) is spaces or low-values or J > I: move WS-FOLLOWER-MANI(J) to KEY-VALUE of CCRT-SSAQ and A2RT-SSAQ, Execute Z3000-GHU-CARGO; if WS-CARGO-FOUND: Execute D110-SET-RELEASE-INFORMATION, construct WS-GCX105-INFO-MSG as 'EDI 350: RELEASE VIA DECON AT PORT ' concatenated with P4-01-PORT-CDE (first 4 characters), construct GCCC-RELEASE-REASON as 'DECONSOLIDATION AT ' concatenated with P4-01-PORT-CDE (first 4 characters), move GCCC-CCN-KEY to WS-CURRENT-CCN-KEY, Execute Z150-LOG-CARGO-INFO-MSG, move GCCC-WAYBILL-KEY-FOR-INDEX to SAVE-WAYBILL-INDEX, move GCCC-EQUIPMENT-CAR to WS-CURRENT-CARID-KEY, Execute D120-PROCESS-US-MFST, clear CC-STATUS-CODE, set CC-ACCEPT-STATUS to spaces, and call CIMS with REPL, GCCC-PCB, and GCCC-CARGO-REPORT-SEGMENT
  • [33: Process Follower Manifests - Retrieve all follower manifests]
    The system retrieves follower manifests → Set CC-ACCEPT-STATUS to 'GEGB', initialize WS-FOLLOWER-MANI-ARRAY to spaces, set I to 1, set WS-FOLLOWER-NOT-END-OF-DB to true; Execute until WS-FOLLOWER-END-OF-DB is true or I > 100: call CIMS with GN function, GCCC-PCB7, GCCC-CARGO-REPORT-SEGMENT, and CCRT-B0RT-SSAQ; if CC-STATUS-CODE is space and GCCC-MASTER-MFST-CCN equals WS-SAVE-CCN: if GCCC-FOLLOWER-MFST is true, move GCCC-CCN-KEY to WS-FOLLOWER-MANI(I) and add 1 to I; else if CC-STATUS-CODE is not space or GCCC-MASTER-MFST-CCN does not equal WS-SAVE-CCN, set WS-FOLLOWER-END-OF-DB to true; subtract 1 from I after loop completes
  • [33: Process Follower Manifests - Log release message]
    The system logs the release message for the follower → Clear WS-GCX105-INFO-MSG to spaces, construct message 'EDI 350: RELEASE VIA DECON AT PORT ' concatenated with P4-01-PORT-CDE (first 4 characters) and store in WS-GCX105-INFO-MSG, move GCCC-CCN-KEY to WS-CURRENT-CCN-KEY, and Execute Z150-LOG-CARGO-INFO-MSG
  • [33: Process Follower Manifests - Update release reason]
    The system updates the release reason for the follower → Construct string 'DECONSOLIDATION AT ' concatenated with P4-01-PORT-CDE (first 4 characters) and store in GCCC-RELEASE-REASON field
  • [33: Process Follower Manifests - Process US manifest]
    The system processes the US manifest for the follower → Move GCCC-WAYBILL-KEY-FOR-INDEX to SAVE-WAYBILL-INDEX, move GCCC-EQUIPMENT-CAR to WS-CURRENT-CARID-KEY, and Execute D120-PROCESS-US-MFST which sets WS-US-MFST-NOT-FOUND to true, sets WS-NOT-EOF to true, performs Z3300-GU-US-CARGO-BY-CARWB, performs Z3350-GN-US-CARGO-BY-CARWB until WS-US-MFST-FOUND or WS-EOF; if not EOF: performs Z200-MOVE-LOG-INFORMATION, constructs GCX105-DATE from CC-MACHINE-CENTURY and CC-MACHINE-DATE-X, sets GCX105-TIME to CC-MACHINE-TIME-X, sets GCX105-ACTION-CODE to LOG-USE-INPUT-MESSAGE, sets GCX105-TRAIN-OR-US-CCN to GCUSRT-US-CCN-KEY, sets GCX105-US-CARGO to true, constructs GCX105-MESSAGE as 'CDN CCN RLSED BY EDI 350: ' concatenated with GCCC-CCN-KEY, and performs Z300-SPAWN-GCT1051E
  • [33: Process Follower Manifests - Update cargo record]
    The system updates the follower cargo record → Clear CC-STATUS-CODE to spaces, set CC-ACCEPT-STATUS to spaces, and call CIMS with REPL function code, GCCC-PCB, and GCCC-CARGO-REPORT-SEGMENT to replace the cargo record
  • [Save Master Cargo Information]
    The system begins processing follower manifests → The master cargo segment, master CCN key, and master waybill index are saved to temporary storage for later restoration
  • [Retrieve Follower Cargo by CCN]
    The system retrieves the cargo record → The follower CCN is used as the key value to retrieve the cargo report segment from the database
  • [Build Release Message]
    The system builds the release message → The message is formatted as 'EDI 350: RELEASE VIA DECON AT PORT' followed by the port code from the P4 segment (first 4 characters)
  • [Set Release Reason with Deconsolidation Port]
    The system sets the release reason → The release reason field is populated with 'DECONSOLIDATION AT' followed by the port code from the P4 segment (first 4 characters)
  • [Log Release Message to Follower CCN]
    The system logs the release message → The current follower CCN key is set as the current CCN key AND the release message is logged to the cargo information message log with current date, time, user ID, and action code
  • [Save Follower Waybill Index]
    The system prepares to process the US manifest → The follower's waybill key for index is saved to the waybill index variable AND the follower's equipment car ID is saved to the current car ID key variable
  • [Process Associated US Manifest for Follower]
    The system processes the US manifest → The system searches for US cargo records matching the equipment car ID and waybill number, and if found (not deleted and no train created), logs a message indicating the Canadian CCN was released by EDI 350 with the US CCN reference
  • [Update Follower Cargo Record]
    The system updates the database → The cargo report segment is replaced in the database with the updated follower cargo information
  • [Restore Master Cargo Information]
    The system completes follower processing → The saved master cargo segment is restored to the cargo report segment, the saved master waybill index is restored to the waybill index variable, and the saved master equipment car ID is restored to the current car ID key variable
  • [Set Release Type to 'A']
    The release information is being set → The cargo release type field is set to the code 'A' indicating automatic release
  • [Prepare Log Message]
    The system prepares to create a log entry → The log input structure is cleared to spaces, the security byte is set to high-value, the sending transaction is set to 'GCT1261E', and the user identifier is set to the current session's user identifier
  • [Build Message: 'CDN CCN RLSED BY EDI 350: ' + Canadian CCN]
    The system builds the log message content → The log message is constructed by concatenating the text 'CDN CCN RLSED BY EDI 350: ' with the Canadian cargo control number key from the current cargo record
  • [Set Log Details: Date/Time from System, Action Code: LOG-USE-INPUT-MESSAGE, US CCN as Reference, Type: US Cargo]
    The system completes the log entry details → The log date is set to the current machine century concatenated with the current machine date, the log time is set to the current machine time, the action code is set to LOG-USE-INPUT-MESSAGE, the train or US cargo control number field is set to the US cargo control number key from the retrieved record, and the cargo type indicator is set to US cargo
  • [Spawn GCT1051E Transaction to Log Message]
    The system executes the log entry creation process → If the log message is not spaces or low-values, the system replaces all spaces in the date with zeroes, replaces all spaces in the time with '1', moves the log input to the GCT1051E message structure, changes the alternate program communication block, calls the write message log function with the message code, message content, message length and module name, and purges the alternate program communication block
  • [Set Security Byte to HIGH-VALUE]
    Security attributes need to be set for the log entry → The security byte in GCX105 structure is set to HIGH-VALUE to indicate system-level security
  • [Set Sending Transaction = 'GCT1261E']
    The sending transaction identifier needs to be recorded → The sending transaction field in GCX105 structure is set to 'GCT1261E'
  • [Format Message for GCT1051E]
    The message needs to be formatted for the GCT1051E transaction → The GCX105 input data is moved to the GCT1051E message structure for subsequent logging operations
  • [Move Log Input to GCT1051E Message]
    The log message is ready to be written to the audit trail → The system moves the entire log input structure to the GCT1051E message format (GCT1051E-MSG)
  • [Call CIMS with CHNG Function]
    The system needs to write the log entry to the audit trail → The system calls CIMS with CHNG function using the alternate PCB (ALT-PCB OF CCCOM) and the GCT1051E message structure to change the message destination
  • [Call WRITMSGL to Write Message]
    The system is ready to persist the log entry → The system calls WRITMSGL utility with parameters: CCCOM control block, alternate PCB, message code (GCT1051E-MSG-CODE), message text (GCT1051E-MESSAGE), message length (GCT1051E-MSG-LGTH), and module name (GCT1051E-MOD-NAME) to write the log entry to the audit trail
  • [Call CIMS with PURG Function]
    The log writing operation is complete → The system calls CIMS with PURG function using the alternate PCB (ALT-PCB OF CCCOM) to purge the message from the queue
  • [Set Release Type to 'A']
    The release information is being set → The cargo release type field is set to the character 'A'
  • [Retrieve First US Cargo Record by Car ID and Waybill]
    The system executes first US cargo retrieval using car-waybill index with '>=' operator → Database returns first US cargo record matching or exceeding the search criteria
  • [Prepare Log Information: - Current Date/Time - US CCN - Action Code: LOG-USE-INPUT-MESSAGE - Message Type: US Cargo]
    The system prepares to log the release message → Log date is set to current machine century and date AND log time is set to current machine time AND log CCN is set to US cargo CCN AND action code is set to LOG-USE-INPUT-MESSAGE AND cargo type indicator is set to US Cargo
  • [Build Release Message: 'CDN CCN RLSED BY EDI 350: ' + Canadian CCN]
    The system builds the release message → Message text is set to 'CDN CCN RLSED BY EDI 350: ' concatenated with Canadian cargo CCN key
  • [Spawn GCT1051E Transaction to Log Message]
    The system invokes GCT1051E logging transaction → Log entry is created with date, time, US CCN, action code, cargo type, and release message
  • [Call Database to Get First US Cargo Record]
    The system calls the database I/O module to retrieve US cargo using the car ID and waybill index → The system executes a GU (Get Unique) function against the US cargo segment with the specified search criteria and returns the first matching or next higher record
  • [Call GCCUSIO to Retrieve US Cargo]
    The system executes the database retrieval operation → The GCCUSIO module is called with the configured parameters to retrieve the US cargo record into the GCSUSRT segment
  • [Set Search Parameters: - Car ID from Current Cargo - Waybill Index from Current Cargo - Operator: Greater Than]
    The system prepares to retrieve the next US cargo record by car and waybill → The search parameters are set with car ID from current cargo's car identification key, waybill index from saved waybill index, function code set to Get Next, segment type set to US cargo, index type set to car-waybill, and operator set to greater than ('>') for sequential retrieval
  • [Call Database to Get Next US Cargo Record by Car/Waybill Index]
    The database retrieval operation is invoked → The system calls the cargo input/output module to retrieve the next US cargo record based on the car-waybill index
  • [Set Accept Status to 'GEGB']
    The system prepares to call the database access routine → The accept status is set to 'GEGB', segment type is set to GCSUSRT, function code is set to Get Next (GN), index type is set to Car/Waybill, and operator is set to '>' for sequential retrieval
  • [Call GCCUSIO to Read Next Record]
    The GCCUSIO routine is called with the parameter block and US cargo segment → The system retrieves the next US cargo record from the GCSUSRT table based on the car/waybill index position
  • [Is Cargo CSA Manifest?]
    The system processes the authorization to deliver message → The system logs the message 'EDI 350: ACCEPTED - CSA' AND sets the cargo current status to CSA-DLV (GCCC-STATUS-CSA-DLV) AND sets the CSA authorization to deliver received flag to TRUE (GCCC-CSA-AUTH-DELIVER-RECD) AND updates the cargo record in the database
  • [Is Cargo CSA Manifest?]
    The system processes the authorization to deliver message → The system logs the message 'EDI 350: NOT ACCEPTED - NON-CSA' AND does not update the cargo record in the database
  • [Log Message: 'EDI 350: ACCEPTED - CSA']
    The system logs the CSA acceptance → The system creates a log message 'EDI 350: ACCEPTED - CSA' AND includes the current machine date in format CCYYMMDD AND includes the current machine time in format HHMMSS AND includes the current CCN key (WS-CURRENT-CCN-KEY) AND sets the cargo type indicator to CA-CARGO AND sets the action code to 'LOG-USE-INPUT-MESSAGE' AND spawns a GCT1051E log entry
  • [Set Cargo Status to CSA-DLV]
    The system updates the cargo status → The system sets the cargo status indicator to GCCC-STATUS-CSA-DLV (CSA delivery authorized status)
  • [Set CSA Authorization Deliver Flag to TRUE]
    The system sets the authorization flag → The system sets the CSA authorization to deliver received flag (GCCC-CSA-AUTH-DELIVER-RECD) to TRUE
  • [Update Cargo Record in Database]
    The system updates the cargo record → The system replaces the cargo record (GCCC-CARGO-REPORT-SEGMENT) in the database using the REPL function through the GCCC-PCB program control block
  • [End Process]
    The system completes the authorization processing → The system performs US manifest processing (D120-PROCESS-US-MFST) to update any associated US cargo records with the Canadian CCN release information
  • [Set Master CCN as Search Key]
    Preparing to search for follower manifests → The master manifest CCN is set as the search key in the database query structure
  • [Notice Reason?]
    Determining the type of release → If the notice reason code indicates 'Released', log a standard release message; if it indicates 'Decon', log a deconsolidation release message
  • [Log Message: 'EDI 350: RELEASE' with Release Ref and Port]
    Logging the release action → A message is logged with the text 'EDI 350: RELEASE : ' concatenated with the release reference ID (first 15 characters) and ' AT PORT ' concatenated with the port code (first 4 characters)
  • [Set Release Reason: Release Ref / Port Code]
    Recording the release reason → The release reason field is set to the release reference ID (first 15 characters) concatenated with '/' and the port code (first 4 characters)
  • [Log Message: 'EDI 350: RELEASE VIA DECON AT PORT' with Port]
    Logging the deconsolidation action → A message is logged with the text 'EDI 350: RELEASE VIA DECON AT PORT ' concatenated with the port code (first 4 characters)
  • [Set Release Reason: 'DECONSOLIDATION AT' Port]
    Recording the deconsolidation reason → The release reason field is set to 'DECONSOLIDATION AT ' concatenated with the port code (first 4 characters)
  • [Get Next Cargo Record Using Master CCN]
    The system needs to find the next cargo record in the hierarchy → A database call is made using function code GN (Get Next) with the cargo report segment and the master CCN qualifier to retrieve the next record
  • [Call IMS Database with GN Function]
    The system executes the database call with GN function for PCB7 and cargo report segment using qualified SSA for B0RT → The next cargo record is retrieved into the cargo report segment and the database status code is updated to reflect the result
  • [Notice Reason Type?]
    The system determines the type of release message to create → If V9-02-RELEASED is true, process as standard release, otherwise if V9-02-DECON is true, process as deconsolidation release
  • [Build Release Message with Release Reference and Port]
    The system builds the release message for logging → The message 'EDI 350: RELEASE : ' is concatenated with X4-01-CBSA-REL-REF-ID (first 15 characters) and ' AT PORT ' and P4-01-PORT-CDE (first 4 characters) into WS-GCX105-INFO-MSG
  • [Build Decon Release Message with Port]
    The system builds the deconsolidation release message for logging → The message 'EDI 350: RELEASE VIA DECON AT PORT ' is concatenated with P4-01-PORT-CDE (first 4 characters) into WS-GCX105-INFO-MSG
  • [Set Release Reason with Release Reference and Port]
    The system updates the cargo release reason field → X4-01-CBSA-REL-REF-ID (first 15 characters) and '/' and P4-01-PORT-CDE (first 4 characters) are concatenated into GCCC-RELEASE-REASON
  • [Set Release Reason with Deconsolidation Port]
    The system updates the cargo release reason field → The text 'DECONSOLIDATION AT ' is concatenated with P4-01-PORT-CDE (first 4 characters) into GCCC-RELEASE-REASON
  • [42: Log Cargo Information Message]
    The system logs the release information → A GCT1051E log entry is created with current machine date in GCX105-DATE, current machine time in GCX105-TIME, follower CCN in GCX105-TRAIN-OR-US-CCN, cargo type set to CA-CARGO, action code set to LOG-USE-INPUT-MESSAGE, and the release message in GCX105-MESSAGE
  • [31: Process Associated US Manifest]
    The system searches for associated US cargo manifest → The system retrieves US cargo from GCSUSRT table using equipment car ID and waybill number AND if a matching US cargo is found that is not deleted and has no train created, a log entry is created with message 'CDN CCN RLSED BY EDI 350: ' concatenated with the Canadian follower CCN
  • [43: Update Cargo Record]
    The system updates the follower cargo record → The cargo record is replaced in GCSCCRT table using REPL operation with the updated cargo segment data
  • [Lookup Cargo by Follower CCN]
    The system attempts to retrieve the cargo record using the follower CCN as the search key → The system retrieves the cargo report segment and secondary segment if the cargo exists, or indicates cargo not found if the CCN does not match any existing cargo record
  • [Call CIMS with GHU Function]
    The system invokes the database access function with GHU operation → The system attempts to retrieve the cargo report segment (GCCC-CARGO-REPORT-SEGMENT) from the cargo database (GCCC-PCB) using the qualified search argument
  • [Read Cargo Secondary Segment]
    The system attempts to read the cargo secondary segment using GHU function → The system retrieves the cargo secondary segment (GCSCCS52) from the secondary cargo database (GCA2-PCB) using the secondary search key
  • [Clear Secondary Segment]
    The system processes the missing secondary segment condition → The secondary segment data structure (GCSCCS52) is cleared to spaces to prevent processing of invalid data
  • [Set Action Code to Input Message]
    The system assigns the action code → The action code is set to the value of LOG-USE-INPUT-MESSAGE constant
  • [Build Message: 'CDN CCN RLSED BY EDI 350' + Canadian CCN]
    The system builds the log message text → The message field is populated by concatenating the literal text 'CDN CCN RLSED BY EDI 350: ' with the Canadian cargo CCN key from the saved cargo report segment
  • [Spawn GCT1051E Transaction to Log Message]
    The system submits the log entry → The GCT1051E transaction is spawned by calling the Z300-SPAWN-GCT1051E routine which validates the message is not blank, replaces spaces with appropriate values in date and time fields, moves the input to the message structure, changes the alternate PCB, calls WRITMSGL to write the message, and purges the alternate PCB
  • [Set Sending Transaction to 'GCT1261E']
    The source transaction identifier needs to be recorded → The system shall set the GCX105-SENDING-TRANSACTION field to 'GCT1261E' to identify this program as the source of the log entry
  • [Move Input to GCT1051E Message]
    The message needs to be written to the IMS message queue → The system moves the input message to the GCT1051E message structure (GCT1051E-MSG)
  • [Set Accept Status to Blank]
    The system prepares to call IMS message services → The system sets the accept status (CC-ACCEPT-STATUS) to blank (two spaces) to enable standard message processing
  • [Call CIMS with CHNG Function]
    The message destination needs to be set in the IMS message queue → The system calls CIMS with CHNG function using the alternate PCB and GCT1051E message structure to establish the message destination
  • [Call WRITMSGL to Write Message Log]
    The message needs to be permanently logged → The system calls WRITMSGL with the alternate PCB, message code (GCT1051E-MSG-CODE), message content (GCT1051E-MESSAGE), message length (GCT1051E-MSG-LGTH), and module name (GCT1051E-MOD-NAME) to write the log entry
  • [Call CIMS with PURG Function]
    The logging transaction needs to be completed → The system calls CIMS with PURG function using the alternate PCB to remove the message from the queue and finalize the transaction
  • [Set Line 1: 'Cargo on HOLD for inspection by CBSA - EDI350']
    The system constructs the notification message → Set the first detail line to 'Cargo on HOLD for inspection by CBSA - EDI350'
  • [Set Line 2: Blank]
    The system formats the notification content → Set the second detail line to blank space
  • [Set Total Lines to 7]
    The system finalizes the notification structure → Set the line counter to 7 to indicate seven detail lines are included in the notification
  • [Set Email Subject, Append CCN to Subject]
    The error email preparation process is initiated → The email subject is set to 'CUSTOMS RECEIVED ERR MSG' concatenated with the cargo CCN key
  • [Admin Config Available?, Set Primary Recipient from Admin Config, Set Secondary Recipient from Admin Config]
    Email recipients need to be configured for error notification → The first email recipient usercode is set to the primary Merlin user ID from admin table field AD-DC-P-MERLIN-1 and the second email recipient usercode is set to the secondary Merlin user ID from admin table field AD-DC-P-MERLIN-5
  • [Admin Config Available?, Set Default Recipient OM01247]
    Email recipients need to be configured for error notification → The first email recipient usercode is set to the default value 'OM01247' and the second email recipient usercode is set to spaces
  • [Set Email Keywords, Keywords Empty?, Cargo Found?, Use Cargo CCN as Keywords]
    Email keywords need to be assigned → The email keywords field is set to the cargo CCN key from the cargo report segment
  • [Call EMCSEND2 to Send Email]
    The system calls the email sending service EMCSEND2 → The email is sent with from-usercode 'OM01247', destination filename 'IN', recipient usercode 'OM01247', the prepared subject line, keywords, and the 350 report message content
  • [Check Notice Reason Code]
    If the V9 segment notice reason code → If notice reason code indicates RELEASED then prepare release error notification OR if notice reason code indicates DECON then prepare deconsolidation error notification OR if notice reason code is any other value then prepare general entry error notification
  • [Set Destination Filename: UNKNOWN]
    The system configures routing parameters → Set the destination filename to 'UNKNOWN' to route the message to the unknown message queue
  • [Call Email Send Process]
    The system invokes the email send process → Call the email notification service with all prepared notification parameters to deliver the message to the recipient
  • [CCN starts with '6105'?]
    The cargo status is set to HELD and the CCN starts with '6105' → The system prepares a hold notification email with subject 'CBSA CARGO HOLD - [CCN]', body containing cargo on hold message, equipment details, waybill information, CCN, destination station, and manifest upon station, and routes it to recipient OM01247 with destination filename CAHOLD
  • [Add Line 1: 'Cargo on HOLD for inspection by CBSA - EDI350']
    The email body content is being constructed → The system adds 'Cargo on HOLD for inspection by CBSA - EDI350' as the first detail line in the email body
  • [Add Line 2: Blank]
    The email body content is being constructed → The system adds a blank line as the second line in the email body
  • [Purge IMS Message Queue]
    The email send operation completes without errors → The system calls CIMS with PURG function to purge the alternate PCB message queue
  • [Resend Failed Email to OM01247]
    The resend operation completes without errors → The system calls CIMS with PURG function to purge the alternate PCB message queue
  • [Email Sent Successfully]
    The EMCSEND2 service returns EMI-NO-ERRORS status indicating successful email delivery → The system purges the IMS alternate PCB message queue and completes the email send process successfully
  • [Call EMCSEND2 to Send Email]
    EMCSEND2 program is called with these parameters → The email is sent through the EMCSEND2 interface and return status flag is populated
  • [Purge IMS Message Queue]
    Email send operation completes successfully → IMS message queue is purged using PURG function against alternate PCB
  • [Resend Successful?]
    Email was successfully rerouted to default recipient → Clear subject, build new subject with bad Merlin ID and message 'INVALID MERLIN TO - REPORT REROUTE', and resend notification
  • [Call EMCSEND2 with Parameters: From User Code, Destination Filename, To User Code, Copy User Code, Subject, Keywords, Report Content, Return Status Flag, Segment Numbers, Item Type]
    The system invokes EMCSEND2 program → The email is sent with all specified parameters and the return status flag is populated with the result
  • [Resend Failed Email to OM01247 with Reroute Notification]
    The email has been rerouted to default user → The system clears EMI-SUBJECT, builds a new subject message containing WS-BAD-MERLIN-ID and text 'INVALID MERLIN TO - REPORT REROUTE', and performs Z116-RESEND-MERLIN again to send the notification
  • [Prepare Reroute Notification Subject]
    The system prepares the reroute notification → The system clears EMI-SUBJECT and creates a message containing the invalid Merlin ID (WS-BAD-MERLIN-ID) with text 'INVALID MERLIN TO - REPORT REROUTE', then calls Z116-RESEND-MERLIN again to send this notification
  • [Resend Failed Email to OM01247]
    The system attempts to resend the notification → The system clears the TO usercode field, sets the TO usercode to 'OM01247', sets the destination filename to 'IN', calls the email sending service (EMCSEND2) with the original subject, keywords, and message content, and increments the machine sequence number by 1
  • [Abend - Invalid FROM Usercode]
    The email send service returns a status indicating the FROM usercode was not found → The system sets the error message to 'EMI - INVALID MERLIN FROM' and terminates processing abnormally
  • [Abend - Invalid TO/COPY Usercode]
    The email send service returns a status indicating the TO or COPY usercode was not found → The system sets the error message to 'EMI - INVALID MERLIN TO OR COPY' and terminates processing abnormally
  • [Increment Machine Sequence Number]
    The resend operation completes → The system adds 1 to the formatted machine sequence number
  • [Purge IMS Message Queue]
    The email send operation completes with EMI-NO-ERRORS status → The system calls CIMS with PURG function to purge the alternate PCB message queue
  • [Call EMCSEND2 with Parameters]
    The system executes the email send operation → The system calls EMCSEND2 with ISCOM, from user code, destination filename, to user code, copy user code, subject, keywords, report content (MRLN-350-REPORT), return status flag, segment numbers, and item type to send the email notification
  • [Purge IMS Message Queue]
    If the email send result → The system calls CIMS with CCCOM, PURG function, and ALT-PCB to purge the message from the IMS queue
  • [Save Bad Merlin ID from TO-USERCODES 02]
    The return status flag indicates EMI-TO-OR-COPY-NOT-FOUND → The system saves the invalid Merlin ID from TO-USERCODES position 02 to WS-BAD-MERLIN-ID for error reporting
  • [Save Bad Merlin ID from TO-USERCODES 01]
    The return status flag indicates EMI-TO-OR-COPY-NOT-FOUND → The system saves the invalid Merlin ID from TO-USERCODES position 01 to WS-BAD-MERLIN-ID for error reporting
  • [Build Reroute Message: Bad Merlin ID + INVALID MERLIN TO - REPORT REROUTE]
    The resend operation completes successfully → The system clears the EMI-SUBJECT, builds a new subject message containing the bad Merlin ID concatenated with ' INVALID MERLIN TO - REPORT REROUTE', and sends this notification via EMCSEND2
  • [Email Send Failed]
    The system detects the recipient not found error → The system saves the invalid recipient ID, clears the TO recipient field, sets the TO recipient to OM01247, sets the destination filename to IN, resends the original email, and if successful, sends a reroute notification with subject containing the invalid Merlin ID and message 'INVALID MERLIN TO - REPORT REROUTE'
  • [Call EMCSEND2 to Resend Email]
    The system calls the Z116-RESEND-MERLIN procedure → The system invokes EMCSEND2 program with all email parameters including FROM usercode, destination filename, TO usercode, COPY usercode, subject, keywords, report content, return status flag, segment numbers, and item type
  • [Send Reroute Notification Email]
    The system calls the Z116-RESEND-MERLIN procedure again → The system invokes EMCSEND2 program with the reroute notification subject and all other email parameters to send the notification to OM01247
  • [Email Successfully Rerouted]
    The system completes the email send operation in Z116-RESEND-MERLIN → Call CIMS program with PURG function code and ALT-PCB to remove the message from the queue
  • [Set Table ID to MC Customs Table]
    Preparing to fetch Merlin contact information → The table identifier (GCSTBRT-KEY-TABLE-ID) should be set to 'MC-TABLE-ID' to identify the Merlin contact segment in the customs table
  • [Call GCCTBIO to Retrieve MC Segment]
    The table I/O service is invoked → The GCCTBIO program should be called with parameters: CCCOM, SECOND-PCB-FLAG, UNQUAL-SSA-FLAG, GCCTBIO-FUNC-CODE, GCSTBRT-LIT, GCSTBRT-KEY-VALUE, GCSTBDP-KEY-VALUE, WS-TABLE-SEGMENT, and GCCTBIO-RETURN-FLAG to retrieve the MC segment
  • [Move Retrieved Segment to MC Segment Structure, Extract Merlin Email ID from MC Segment]
    The return flag (GCCTBIO-RETURN-FLAG) equals '0' indicating successful retrieval → The retrieved segment (WS-TABLE-SEGMENT) should be moved to the MC segment structure (GCSTBRT-MC-SEGMENT), making the Merlin email ID (GCSTBRT-MC-MERLIN-ID) available for use in notification routing
  • [Clear MC Segment Set to Spaces]
    The return flag (GCCTBIO-RETURN-FLAG) does not equal '0' indicating retrieval failure → The MC segment structure (GCSTBRT-MC-SEGMENT) should be cleared to spaces, indicating that no Merlin email ID is available for the manifest-to station
  • [Prepare Log Information Structure]
    The log information structure is being prepared → The log input structure should be cleared to spaces, security byte should be set to HIGH-VALUE, sending transaction should be set to 'GCT1261E', and ACF2 user ID should be populated from the common control area
  • [Set Action Code to LOG-USE-INPUT-MESSAGE]
    The action code is being assigned → The action code should be set to LOG-USE-INPUT-MESSAGE to indicate this is an input message log
  • [Set Message Text]
    The message text is being populated → The information message content should be moved to the log message field
  • [Move Log Input to GCT1051E Message]
    The log data is being transferred to the message structure → The complete log input structure should be moved to the GCT1051E message field
  • [Change Alternate PCB Status]
    The alternate PCB status is being changed → The CIMS program should be called with CHNG function for the alternate PCB using the GCT1051E message
  • [Call WRITMSGL to Write Message]
    The message writing is invoked → The WRITMSGL program should be called with the common control area, alternate PCB, message code, message text, message length, and module name parameters
  • [Purge Alternate PCB]
    The alternate PCB is being purged → The CIMS program should be called with PURG function for the alternate PCB to complete the logging transaction
  • [Update Cargo Record - Replace cargo record in database with updated information]
    The system needs to persist the changes to the cargo database → The system clears the status code, sets the accept status to blank, and replaces the cargo record in the GCSCCRT cargo database using the IMS REPL function
  • [Call IMS REPL Function]
    The system calls the IMS CIMS program with the REPL function → The system passes the common communication area, REPL function code, cargo PCB, and the cargo report segment to update the GCSCCRT cargo database record
  • [Call Get Next US Cargo by Car and Waybill Index]
    The US cargo retrieval function is invoked → The system calls GCCUSIO to retrieve the next US cargo record matching the car and waybill criteria
  • [Set Database Status Code to 'GEGB', Set Segment Type to GCSUSRT, Set Function to Get Next - GN, Set Index Type to Car-Waybill, Set Operator to Greater Than]
    The system prepares the database call parameters → The database status code is set to 'GEGB', the segment type is set to GCSUSRT, the function is set to Get Next (GN), the index type is set to Car-Waybill, and the operator is set to greater than ('>') for sequential retrieval
  • [Call GCCUSIO to Retrieve Next US Cargo Record]
    The GCCUSIO program is called with the configured parameters and US cargo segment → The system retrieves the next US cargo record from the database and returns the database status code
  • [Set Train ID as Search Key]
    The system prepares to query the train database → The system sets the train database search key (B4-KEY-VALUE) to the value from X4 related document ID positions 1-25 AND stores this value as the previous CRN (WS-PREV-CRN) for duplicate checking
  • [Retrieve Train Record from Database]
    The system executes the database retrieval operation → The system performs a GU (Get Unique) function call to retrieve the train root segment (GCB4R-TRAIN-ROOT-SEGMENT) from the train database (GCB4-PCB) using the qualified search key (B4RT-SSAQ) AND the database returns a status code indicating whether the record was found or not found
  • [Train Exists in System]
    The system confirms train existence → The system prepares log information with current machine date (CC-MACHINE-CENTURY and CC-MACHINE-DATE-X concatenated into GCX105-DATE) AND current machine time (CC-MACHINE-TIME-X into GCX105-TIME) AND action code 'ZZZ' (into GCX105-ACTION-CODE) AND the Consist Release Number from X4 positions 1-25 (into GCX105-TRAIN-OR-US-CCN) AND sets the cargo type indicator to Canadian train (GCX105-CA-TRAIN) AND sets the message text to '350 ACK - ARRIVAL ACK AT BORDER' (into GCX105-MESSAGE) AND spawns the GCT1051E log entry process
  • [Train Not Found]
    The system confirms train non-existence → The system clears the first detail line (MRLN-DTL-LINE 01 to spaces) AND constructs an error message by concatenating 'UNKNOWN TRAIN ENTRY IN EDI 350 ' with the Consist Release Number from X4 positions 1-25 into the first detail line AND sets the third detail line to 'THIS CRN WAS NOT FOUND.' AND sets the report line counter (MRLN-LINE) to 4 AND sets the message type indicator to unknown (88-Z110-MRLN-TYPE-IS-UNKNOWN) AND invokes the email send preparation process (Z110-PREP-EMCSEND)
Structural Validations
  • [Message Available? and Message Valid?]
    Message status is evaluated → If completion code is not OK and reason code is 2033 then set message not available flag, else if completion code is OK and backout count is not zero then set skip message flag, else if completion code is OK and maximum MQS entries is less than 1 then abort with error 'USER ABEND 350 MESSAGE TOO SHORT', else if completion code is OK and backout count is zero then set good message found flag, else set end of queue flag
  • [13:Send Train Not Found Error]
    Error notification is prepared → Clear detail line 1, concatenate 'UNKNOWN TRAIN ENTRY IN EDI 350 ' with X4 release document ID positions 1 through 25 into detail line 1, move 'THIS CRN WAS NOT FOUND.' to detail line 3, set line count to 4, set message type to unknown, and Execute email send preparation
  • [Convert Gregorian Date to Julian Date]
    DATCV-PARM-ERROR is TRUE → CC-ERROR-MESSAGE in CCCOM is set to 'MODULE ISCDATCV SAID CCCOM CONTAIN INVALID DATE' and the program aborts by performing Z900-ABEND
  • [Establish MQ Connection to Queue Manager]
    W03-COMPCODE != MQCC-OK → W03-REASON is moved to W03-REASON-CODE, OUTPUT-MESSAGE-TEXT is initialized, GCCMQERR is called with W03-REASON-CODE and OUTPUT-MESSAGE-TEXT, W03-REASON-CODE and OUTPUT-MESSAGE-TEXT are concatenated into MQ-ERROR-TEXT, '355' is moved to MQ-TRANS-SET, 'CONN FAILED' is moved to PGM-ERROR-TEXT, ERROR-MESSAGE2 is moved to CC-ERROR-MESSAGE in CCCOM, and the program aborts by performing Z900-ABEND
  • [Call GCCMQERR to Get Error Message Text]
    The system needs to provide a descriptive error message for the failure → The system calls the GCCMQERR program with the reason code and receives the corresponding error message text
  • [Build Error Message: Reason Code, Error Text, Transaction Set: '355', Error Type: 'CONN FAILED']
    The system prepares to report the connection failure → The system builds an error message containing: the MQ reason code concatenated with the error message text, transaction set value '355', and error type 'CONN FAILED'
  • [Abend Program with Error Message]
    The system cannot proceed without a valid MQ connection → The system abends the program with the error message containing the reason code, error text, transaction set '355', and error type 'CONN FAILED'
  • [Backout Count > 0?]
    The system checks if MQMD-BACKOUTCOUNT != 0 → If backout count is not equal to 0, set SKIP-MSG-FOUND flag to TRUE; If backout count equals 0, proceed to validate message length
  • [Message Length Valid?]
    The system calculates WS-MAX-MQS-ENTRIES by subtracting header length from total data length and dividing by entry length, and checks if result is less than 1 → If WS-MAX-MQS-ENTRIES is less than 1, prepare error message 'USER ABEND 350 MESSAGE TOO SHORT' and abort processing; If WS-MAX-MQS-ENTRIES is 1 or greater, set GOOD-MSG-FOUND flag to TRUE
  • [Prepare Error Message]
    The system needs to report the MQ failure → Move W03-REASON to W03-REASON-CODE, call GCCMQERR to get error description into OUTPUT-MESSAGE-TEXT, move error text to MQ-ERROR-TEXT, set MQ-TRANS-SET to '350' or '355', set PGM-ERROR-TEXT to 'OPEN FAILED', 'CLOSE FAILED', 'DISC FAILED', or 'CONN FAILED' as appropriate, and move complete error message to CC-ERROR-MESSAGE
  • [Calculated Segments > Maximum Allowed?]
    ['The calculated number of segments (WS-MAX-MQS-ENTRIES) exceeds the maximum allowed (CST-MAX-MQS-ENTRIES)'] → ['Set WS-MAX-MQS-ENTRIES to the maximum allowed value CST-MAX-MQS-ENTRIES', 'Discard any segments beyond the maximum limit']
  • [Segments > Maximum Allowed?]
    The calculated number of segments exceeds the maximum allowed segment count → The number of segments to process (WS-MAX-MQS-ENTRIES) is set to the maximum allowed value (CST-MAX-MQS-ENTRIES)
  • [X4 - Release/Disposition Extract Release Reference Extract Date and Time]
    The related document ID (CRN) in positions 1-25 equals the previous CRN → Continue to the next segment without performing any train or cargo processing
  • [Is Train ID Same as Previous?]
    The train release document ID from X4-04-REL-DOC-ID (first 25 characters) equals the previously processed CRN stored in WS-PREV-CRN → Skip processing this X4 segment and continue to next segment, otherwise proceed with train verification
  • [Prepare Error Report: UNKNOWN TRAIN ENTRY IN EDI 350]
    The train is not found (CC-STATUS-CODE is not spaces) → Prepare error message 'UNKNOWN TRAIN ENTRY IN EDI 350' concatenated with the CRN in detail line 1, add message 'THIS CRN WAS NOT FOUND.' in detail line 3, set message line count to 4, and set message type to unknown
  • [Send Error to Merlin]
    The error preparation is complete → Invoke the Merlin email send process (Z110-PREP-EMCSEND) to transmit the error notification to the configured recipients
  • [Prepare Error Report]
    The system begins error notification preparation → The first detail line of the Merlin report is cleared to spaces to prepare for the error message
  • [Add Train ID to Error Message]
    The system constructs the error message → The message 'UNKNOWN TRAIN ENTRY IN EDI 350 ' concatenated with the train ID (positions 1-25 of X4-04-REL-DOC-ID) is placed in the first detail line of the Merlin report
  • [Cargo Found?]
    The system checks the cargo record status → If cargo is found and not deleted, proceed with border arrival update; otherwise, skip the update process
  • [Other - Invalid Notice Reason]
    The V9 notice reason code does not match any of the recognized status codes (MATCHED, NOT-MATCHED, CARGO-COMPLETE, DOC-PKG-COMPLETE, DOC-NOT-ON-FILE, REPORTED, ARRIVED, RELEASED, AUTH-TO-DELIVER, HELD, or DECON) → The system logs the message 'EDI 350: INVALID NOTICE REASON CODE ' concatenated with the first 4 characters of the V9 notice reason code to the cargo information log
  • [Index Exceeds Maximum of 9?]
    The K1 remark index counter exceeds the maximum allowed value of 9 → The system resets the K1 remark index counter to the maximum value of 9, preventing any additional remarks beyond the ninth position from being stored, and the current K1 segment overwrites the remark at position 9
  • [Equipment Number Present?]
    If the equipment number field in the N7 segment → If the equipment number field contains spaces, skip equipment logging; otherwise, proceed to log the equipment number
  • [Is Train ID Same as Previous?]
    The first 25 characters of X4-04-REL-DOC-ID equal the value stored in WS-PREV-CRN → Skip processing and continue to the next segment without any updates
  • [Prepare Error Report: 'UNKNOWN TRAIN ENTRY IN EDI 350' Include Train ID 'THIS CRN WAS NOT FOUND']
    The train verification fails → Prepare error report with message 'UNKNOWN TRAIN ENTRY IN EDI 350' concatenated with the train ID in MRLN-DTL-LINE(01) AND add message 'THIS CRN WAS NOT FOUND.' in MRLN-DTL-LINE(03) AND set MRLN-LINE to 4 AND set message type indicator to unknown (88-Z110-MRLN-TYPE-IS-UNKNOWN)
  • [Send Error Report to Merlin]
    The error notification is ready to be sent → Invoke the Merlin notification preparation process (Z110-PREP-EMCSEND) to send the error report
  • [Train Exists in System?]
    The database operation completes → If the database status code is not blank (spaces), the train does not exist and error processing is triggered; if the database status code is blank (spaces), the train exists and normal processing continues
  • [Send Error Report to Merlin]
    The error report is ready to be sent → The system invokes the Merlin notification preparation process to send the error report to the configured recipients
  • [Check if K1 Segments Were Found, More K1 Remarks to Process?, K1 Remark Empty?]
    The current K1 remark entry in the array equals spaces → The system increments the loop counter and continues to check the next K1 remark without logging
  • [Cargo Found?]
    The system attempts to retrieve the cargo record using the CCN → The system determines if the cargo record exists or not found in the database
  • [Prepare Error Report: Subject, Include CCN, Message]
    The system begins preparing the error notification → The system clears MRLN-DTL-LINE array element 1, constructs a string 'UNKNOWN EDI 350 DCON NOTICE ' concatenated with M10-07-CCN field positions 1 through 25 and stores it in MRLN-DTL-LINE element 1, and sets MRLN-DTL-LINE element 3 to the literal value 'THIS CCN WAS NOT FOUND.'
  • [Prepare Error Report: Subject, Include CCN, Message]
    The system finalizes the error report structure → The system sets MRLN-LINE to value 5 indicating 5 detail lines are present and sets the 88-level condition 88-Z110-MRLN-TYPE-IS-UNKNOWN to true
  • [Send Error Email Notification via EMCSEND2]
    The system is ready to send the notification → The system invokes the Z115-CALL-EMCSEND procedure which calls the EMCSEND2 program passing the from usercode, destination filename, to usercode, copy usercode, subject, keywords, report content, return status flag, segment numbers, and item type parameters
  • [Skip Update - Values Already Match]
    The X4 CBSA Release Reference ID is spaces (blank) → Skip all update operations and continue to next processing step without modifying the cargo record
  • [Set Release Information: Clear destination station, Set release date/time from system, Set release by user ID, Set status to RELEASED, Set release status R, Set release type A, Clear error fields]
    The system processes the release notification → The cargo destination station number index field is set to spaces AND the cargo destination station number for index field is set to spaces
  • [Set Release Information: Clear destination station, Set release date/time from system, Set release by user ID, Set status to RELEASED, Set release status R, Set release type A, Clear error fields]
    The system processes the release notification → The cargo release date is set to current machine date AND the cargo release time is set to current machine time
  • [Set Release Information: Clear destination station, Set release date/time from system, Set release by user ID, Set status to RELEASED, Set release status R, Set release type A, Clear error fields]
    The system processes the release notification → The cargo release by field is set to the current user ID from the system
  • [Set Release Information: Clear destination station, Set release date/time from system, Set release by user ID, Set status to RELEASED, Set release status R, Set release type A, Clear error fields]
    The system processes the release notification → The cargo current status field is set to 'RELEASED'
  • [Set Release Information: Clear destination station, Set release date/time from system, Set release by user ID, Set status to RELEASED, Set release status R, Set release type A, Clear error fields]
    The system processes the release notification → The cargo release status field is set to 'R'
  • [Set Release Information: Clear destination station, Set release date/time from system, Set release by user ID, Set status to RELEASED, Set release status R, Set release type A, Clear error fields]
    The system processes the release notification → The cargo release type field is set to 'A'
  • [Set Release Information: Clear destination station, Set release date/time from system, Set release by user ID, Set status to RELEASED, Set release status R, Set release type A, Clear error fields]
    The system processes the release notification → The cargo release reason field is set to spaces
  • [Set Release Information: Clear destination station, Set release date/time from system, Set release by user ID, Set status to RELEASED, Set release status R, Set release type A, Clear error fields]
    The system processes the release notification → The cargo error or release status index field is set to spaces
  • [Set Release Information: Clear destination station, Set release date/time from system, Set release by user ID, Set status to RELEASED, Set release status R, Set release type A, Clear error fields]
    The system processes the release notification → The cargo error status field is set to spaces
  • [Log Message Empty?]
    The GCX105-MESSAGE field is empty (spaces):
    • contains only low-values
    → The system skips the log entry creation process and exits the Z300-SPAWN-GCT1051E section without writing any log record
  • [Normalize Date - Replace Spaces with Zeros]
    The GCX105-DATE field contains space characters → The system replaces all spaces in GCX105-DATE with zeroes to ensure proper date formatting
  • [Normalize Time - Replace Spaces with '1']
    The GCX105-TIME field contains space characters → The system replaces all spaces in GCX105-TIME with the character '1' to ensure proper time formatting
  • [Format Message for GCT1051E]
    The message content in GCX105-MESSAGE is spaces or low-values → The log message preparation process is terminated without further processing
  • [Log Message Empty?]
    The log message field contains only spaces:
    • low values
    → The system skips all logging operations and exits the Z300-SPAWN-GCT1051E section without writing any log entry
  • [Replace Spaces with Zeroes in Date]
    The date field contains any space characters → The system replaces all spaces in the date field with zeroes to ensure numeric consistency
  • [Replace Spaces with '1' in Time]
    The time field contains any space characters → The system replaces all spaces in the time field with the character '1' to ensure data consistency
  • [Log Message: 'EDI 350: NOT ACCEPTED - NON-CSA']
    The system logs the non-CSA rejection → The system creates a log message 'EDI 350: NOT ACCEPTED - NON-CSA' AND includes the current machine date in format CCYYMMDD AND includes the current machine time in format HHMMSS AND includes the current CCN key (WS-CURRENT-CCN-KEY) AND sets the cargo type indicator to CA-CARGO AND sets the action code to 'LOG-USE-INPUT-MESSAGE' AND spawns a GCT1051E log entry
  • [Secondary Status = GE?]
    If the secondary segment database status code → If the status code equals 'GE' (segment not found), the secondary segment does not exist; otherwise, the secondary segment is available
  • [Message Empty?]
    The message content (GCX105-MESSAGE) is either spaces or low-values → The system skips the logging process and exits without creating any log entry
  • [Replace Spaces with '1' in Time]
    The time field contains any space characters → The system replaces all spaces in the time field with the character '1' to ensure valid time format
  • [Prepare Release Error Email]
    The system attempts to process the release notification → Prepare email notification with subject 'UNKNOWN EDI 350 RELEASE FROM CBSA' AND message line 1 contains 'UNKNOWN EDI 350 RELEASE FROM CBSA' followed by the CCN AND message line 3 contains 'THIS CCN WAS NOT FOUND.' AND message line 4 contains 'RELEASE NUMBER: ' followed by the CBSA release reference ID and ' DONE BY PORT ' followed by the port code AND set message line count to 5 AND set destination filename to 'UNKNOWN' AND set recipient to 'OM01247' AND route the notification
  • [Prepare Deconsolidation Error Email]
    The system attempts to process the deconsolidation notification → Prepare email notification with subject 'UNKNOWN EDI 350 DCON NOTICE' AND message line 1 contains 'UNKNOWN EDI 350 DCON NOTICE' followed by the CCN AND message line 3 contains 'THIS CCN WAS NOT FOUND.' AND message line 4 contains 'HOUSE BILL CLOSE NUMBER' followed by the CBSA release reference ID and ' DONE BY PORT ' followed by the port code AND set message line count to 5 AND set destination filename to 'UNKNOWN' AND set recipient to 'OM01247' AND route the notification
  • [Prepare General Entry Error Email]
    The system attempts to process the notification → Prepare email notification with subject from message line 1 AND message line 1 contains 'UNKNOWN EDI 350 ENTRY FROM CBSA' followed by the CCN AND message line 3 contains 'THIS CCN WAS NOT FOUND.' AND message line 4 contains 'NOTICE DOC TYPE: ' followed by the notice document type code and ' WITH REASON CODE ' followed by the notice reason code AND set message line count to 5 AND set destination filename to 'UNKNOWN' AND set recipient to 'OM01247' AND route the notification
  • [Abort: Invalid FROM User]
    The return status flag indicates FROM user not found → The system sets error message 'EMI - INVALID MERLIN FROM' and calls CERR to abort the program
  • [Abort: Invalid Filename]
    The return status flag indicates filename is invalid → The system sets error message 'EMI - INVALID MERLIN FILENAME' and calls CERR to abort the program
  • [Resend Failed Email to OM01247]
    The resend operation return status flag indicates TO or COPY user not found → The system sets error message 'EMI - INVALID MERLIN TO OR COPY' and calls CERR to abort the program
  • [Resend Failed Email to OM01247]
    The resend operation return status flag indicates FROM user not found → The system sets error message 'EMI - INVALID MERLIN FROM' and calls CERR to abort the program
  • [Resend Failed Email to OM01247]
    The resend operation return status flag indicates filename is invalid → The system sets error message 'EMI - INVALID MERLIN FILENAME' and calls CERR to abort the program
  • [Resend Failed Email to OM01247]
    The system determines which recipient was invalid based on message type → If message type is UNRLSE, store the second TO usercode as the bad Merlin ID, otherwise store the first TO usercode as the bad Merlin ID
  • [FROM User Not Found Error]
    The EMCSEND2 service returns EMI-FROM-NOT-FOUND status indicating the FROM usercode does not exist in the system → The system sets error message 'EMI - INVALID MERLIN FROM' and aborts the program execution
  • [Invalid Filename Error]
    The EMCSEND2 service returns EMI-FILENAME-INVALID status indicating the destination filename is not valid → The system sets error message 'EMI - INVALID MERLIN FILENAME' and aborts the program execution
  • [Resend Email with Reroute Notice]
    The system prepares a new email with subject containing the invalid Merlin ID and message 'INVALID MERLIN TO - REPORT REROUTE' → The system sends the reroute notification email to OM01247 with destination filename 'IN' and purges the IMS message queue upon successful delivery
  • [Abort with Invalid TO/COPY Error]
    The resend attempt returns EMI-TO-OR-COPY-NOT-FOUND status indicating even the default recipient OM01247 is invalid → The system sets error message 'EMI - INVALID MERLIN TO OR COPY' and aborts the program execution
  • [FROM User Not Found Error]
    The resend attempt returns EMI-FROM-NOT-FOUND status indicating the FROM usercode does not exist → The system sets error message 'EMI - INVALID MERLIN FROM' and aborts the program execution
  • [Invalid Filename Error]
    The resend attempt returns EMI-FILENAME-INVALID status indicating the destination filename is not valid → The system sets error message 'EMI - INVALID MERLIN FILENAME' and aborts the program execution
  • [From User Not Found?]
    Email send operation fails due to invalid sender usercode → System abends with error message 'EMI - INVALID MERLIN FROM'
  • [Filename Invalid?]
    Email send operation fails due to invalid destination filename → System abends with error message 'EMI - INVALID MERLIN FILENAME'
  • [No Errors: Purge IMS Message Queue]
    The email sending completes successfully → The system calls CIMS program with PURG function code and ALT-PCB to purge the message from the queue
  • [From User Not Found: Set Error Message 'EMI - INVALID MERLIN FROM']
    The email sending fails due to invalid sender user code → The system sets error message to 'EMI - INVALID MERLIN FROM' in CCCOM error message field and calls CERR program to abort
  • [To/Copy User Not Found: Identify Bad Merlin ID]
    The email sending fails due to invalid recipient → The system moves EMI-TO-USERCODES(02) to WS-BAD-MERLIN-ID, clears EMI-TO-USERCODE, sets EMI-TO-USERCODES(01) to 'OM01247', sets EMI-DESTINATION-FILENAME to 'IN', and performs Z116-RESEND-MERLIN
  • [To/Copy User Not Found: Identify Bad Merlin ID]
    The email sending fails due to invalid recipient → The system moves EMI-TO-USERCODES(01) to WS-BAD-MERLIN-ID, clears EMI-TO-USERCODE, sets EMI-TO-USERCODES(01) to 'OM01247', sets EMI-DESTINATION-FILENAME to 'IN', and performs Z116-RESEND-MERLIN
  • [Filename Invalid: Set Error Message 'EMI - INVALID MERLIN FILENAME']
    The email sending fails due to invalid destination filename → The system sets error message to 'EMI - INVALID MERLIN FILENAME' in CCCOM error message field and calls CERR program to abort
  • [No Errors - Email Sent Successfully]
    The return status indicates no errors (EMI-NO-ERRORS) → The system purges the alternate message queue to complete the email transaction
  • [From User Not Found Error]
    The return status indicates the FROM user was not found (EMI-FROM-NOT-FOUND) → The system sets error message 'EMI - INVALID MERLIN FROM' and aborts the program
  • [Filename Invalid Error]
    The return status indicates the destination filename is invalid (EMI-FILENAME-INVALID) → The system sets error message 'EMI - INVALID MERLIN FILENAME' and aborts the program
  • [Send Successful?]
    The email send service returns a status indicating no errors occurred → The system purges the IMS alternate message queue
  • [Abend - Invalid Filename]
    The email send service returns a status indicating the filename is invalid → The system sets the error message to 'EMI - INVALID MERLIN FILENAME' and terminates processing abnormally
  • [Abend: Invalid FROM Usercode]
    EMCSEND2 returns EMI-FROM-NOT-FOUND status → The system sets error message to 'EMI - INVALID MERLIN FROM' and performs Z900-ABEND to terminate processing
  • [Abend: Invalid TO/COPY Usercode]
    EMCSEND2 returns EMI-TO-OR-COPY-NOT-FOUND status → The system sets error message to 'EMI - INVALID MERLIN TO OR COPY' and performs Z900-ABEND to terminate processing
  • [Abend: Invalid Filename]
    EMCSEND2 returns EMI-FILENAME-INVALID status → The system sets error message to 'EMI - INVALID MERLIN FILENAME' and performs Z900-ABEND to terminate processing
  • [Set Error: Invalid Merlin FROM]
    If the email send result → The system moves 'EMI - INVALID MERLIN FROM' to the error message field in CCCOM and performs the abend routine (Z900-ABEND)
  • [Set Error: Invalid Merlin TO or COPY]
    If the email send result → The system moves 'EMI - INVALID MERLIN TO OR COPY' to the error message field in CCCOM and performs the abend routine (Z900-ABEND)
  • [Set Error: Invalid Merlin Filename]
    If the email send result → The system moves 'EMI - INVALID MERLIN FILENAME' to the error message field in CCCOM and performs the abend routine (Z900-ABEND)
  • [No Errors - Purge Message Queue]
    The return status flag indicates EMI-NO-ERRORS → The system purges the message from the alternate PCB message queue and increments the machine sequence number
  • [Abort with Error Message: EMI - INVALID MERLIN FROM]
    The return status flag indicates EMI-FROM-NOT-FOUND → The system sets the error message to 'EMI - INVALID MERLIN FROM' and aborts processing
  • [Abort with Error Message: EMI - INVALID MERLIN TO OR COPY]
    The resend operation fails with a status other than EMI-NO-ERRORS → The system sets the error message to 'EMI - INVALID MERLIN TO OR COPY' and aborts processing
  • [Abort with Error Message: EMI - INVALID MERLIN FILENAME]
    The return status flag indicates EMI-FILENAME-INVALID → The system sets the error message to 'EMI - INVALID MERLIN FILENAME' and aborts processing
  • [Save Failed Recipient ID]
    The system needs to identify the invalid recipient → If the message type is unrelease (88-Z110-MRLN-TYPE-IS-UNRLSE), save EMI-TO-USERCODES(02) as the bad Merlin ID, otherwise save EMI-TO-USERCODES(01) as the bad Merlin ID
  • [Abend: Invalid FROM User]
    If the return status in Z116-RESEND-MERLIN → Move 'EMI - INVALID MERLIN FROM' to CC-ERROR-MESSAGE and call CERR program to abend the transaction
  • [Abend: Invalid TO/COPY User]
    If the return status in Z116-RESEND-MERLIN → Move 'EMI - INVALID MERLIN TO OR COPY' to CC-ERROR-MESSAGE and call CERR program to abend the transaction
  • [Abend: Invalid Filename]
    If the return status in Z116-RESEND-MERLIN → Move 'EMI - INVALID MERLIN FILENAME' to CC-ERROR-MESSAGE and call CERR program to abend the transaction
  • [Message Text Empty?]
    Message text validation is performed → If the message text is spaces or low-values, exit without creating a log entry; otherwise, proceed with log creation
  • [Replace Spaces with Zeroes in Date, Replace Spaces with '1' in Time]
    Date and time normalization is performed → All spaces in the date field should be replaced with zeroes, and all spaces in the time field should be replaced with '1'
  • [Verify Train Exists - Retrieve Canadian train information from database using train ID to verify train exists in system]
    The system attempts to retrieve the train record from the train database using the CRN as the search key → IF the train record is found in the database (indicated by blank status code) THEN the train is confirmed to exist in the system and processing continues with logging arrival acknowledgment at border ELSE IF the train record is not found in the database (indicated by non-blank status code) THEN the system identifies the train as not existing and generates an unknown train notification message containing the CRN with text 'UNKNOWN TRAIN ENTRY IN EDI 350' and 'THIS CRN WAS NOT FOUND'