Bits In Glass
BIG Pega COE Team

Detailed Acceptance Criteria (ACs)

Category: GCX015R

This report presents the exact business rules dynamically extracted from the legacy system. Rules are formatted in an Agile/BDD Given/When/Then structure, offering a bridge between business requirements and technical implementation constraints. Component rules have been logically grouped into feature sets.

🎯 GCX015R Scope Detected: Extracted 385 rules, Optimally Merged into 42 Feature Scenarios.
R-GCX015-cbl-00001 (+23) File: GCX015.cbl Overview Rules Merged 24 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Overview Rules':
  • Context - the system is starting message processing:
    For 1:Initialize System Configuration:
    When administrative configuration is being initialized, then the system should retrieve admin segment with table id 'ad' and sequence id 'adminid', and if not found, set default merlin id to 'om01247'.
  • Context - the system has initialized configuration:
    For 2:Load Incoming Messages:
    When loading messages from the queue, then the system should connect to mq manager, open the queue, and get messages with conversion options enabled.
  • Context - a message retrieval attempt has been made:
    For Message Available?:
    When the completion code is mqcc-ok and message entries are greater than 1 and backout count equals 0, then the message should be marked as good for processing, otherwise skip or terminate based on specific conditions.
  • Context - a valid message is being processed:
    For 3:Determine Message Type:
    When m10 segment reference number starts with 'train', then the message should be classified as train type, or if m10 reference number starts with 'cargo' then classify as cargo type, or if neither but m11 segment exists then extract cargo information from m11.
  • Context - an m10 segment is being processed:
    For Test Message?:
    When the table reference number equals 'traincprstesttrain0000000000' or 'cargocprs940000000000', then the message should be processed as a special test case with timestamp updates to t1 table segment.
  • Context - a message has been classified as train or cargo:
    For Train or Cargo?:
    When m10 manifest type code is 'p', 'x', 'y', 't', or 's', then the system should set status update flag to true, and if manifest type code is 'h' for trains, set delete status flag to true.
  • Context - a message has been classified as train type:
    For 16:Retrieve Train Records:
    When retrieving train records using the train id from m10 data, then the system should call train i/o module with get function for root record only, and if not found, log error message indicating train id was not found.
  • Context - a message has been classified as cargo type:
    For 15:Retrieve Cargo Records:
    When retrieving cargo records using the cargo control number from m10 data, then the system should call cargo i/o module with get function for cargo segment, and if not found, log error message indicating cargo control number was not found.
  • Context - message segments are available for processing:
    For 6:Process Message Segments:
    When processing segments by type where m10 contains manifest data, p4 contains additional data, n10 contains line release number, k1 contains message text, and k3 contains acceptance data, then the system should process each segment type appropriately and continue until end marker or spaces are encountered.
  • Context - message segments have been processed:
    For 8:Validate Required Segments:
    When checking for required segments, then the system should log error if m10 segment not found, or if p4 segment not found, or if k3 segment not found and create default k3 segment.
  • Context - a k3 segment is being processed:
    For 9:Process Rejection Information:
    When k3 total reject count equals zero and total accept count is greater than zero, then the system should set ack status, but if total reject count is greater than zero, set error status, and if both counts are zero, set ack status with warning message.
  • Context - k3 acceptance data has been processed with zero rejections and positive acceptances:
    For 10:Determine Final Status:
    When train is in pre-arrived status, then the system should set pre-arrival status, or if train review is complete, set review-completed status, otherwise set standard ack status.
  • Context - an error status has been determined:
    For 12:Send Error Messages:
    When error status flag is set, then the system should send error notification message via emcsend to configured merlin recipients.
  • Context - train processing requires status update:
    For 17:Update Train Status:
    When train is deleted and status is ack, or train is delete-pending and status is ack, then the system should set status to 'deleted', or if train is not deleted or delete-pending, update with current status.
  • Context - cargo processing requires status update:
    For 18:Update Cargo Status:
    When status is ack and saved status description is spaces, then the system should set cargo ack flags, or if saved status exists, restore saved status and description, or if status is error, save current status and set error flags.
  • Context - train status has been updated:
    For 19:Check AEI Train Qualification:
    When train has ack status and aei-send flag and enroute-not-reported flag and train id position 23 equals 't', then the system should qualify train for aei processing and prepare customs transaction data.
    For 23:Process Automatic Train Arrival:
    When train has ack status and arrived-pending flag, then the system should trigger automatic train arrival processing with current date and time.
  • Context - train qualifies for aei processing:
    For 20:Load Train Car Information:
    When loading car information where container indicator is not 'c', then the system should load car initials, numbers, and equipment types, and determine loaded/empty status based on next car's container indicator.
  • Context - train has aei-send flag set:
    For 21:Send AEI Status Messages:
    When sending aei status messages, then the system should retrieve aei merlin recipients from database, format train and status information, and send via emcsend3.
  • Context - train status processing is complete:
    For 22:Send Terminal Status Messages:
    When train has ack status and aei-send flag and enroute-reported flag, then the system should send enroute message to aei merlin recipients.
  • Context - message processing activities need to be logged:
    For 13:Log Message Processing:
    When creating log entries, then the system should format different log messages for cargo versus train operations, and use special format when status should not be updated.
  • Context - processing activities require reporting:
    For 26:Send Merlin Reports:
    When sending merlin reports, then the system should send reports to primary recipients and copy to administrative recipients with appropriate error handling.
  • Context - special test message is being processed:
    For 25:Update Administrative Tables:
    When manifest type is 'p', then the system should update t1-309-ack timestamp, or if manifest type is 'h', update t1-353-ack timestamp, or if manifest type is 's', update t1-358-ack timestamp.
  • Context - message processing is complete or terminated:
    For 27:Close MQ Connections:
    When closing mq resources, then the system should close queue handle and disconnect from mq manager with appropriate error handling.
👨‍💻 Technical ACs (Gherkin)
Context: The system is starting message processing
GIVEN
The system is starting message processing
Applied to: 1:Initialize System Configuration
WHEN
Administrative configuration is being initialized
THEN
The system should retrieve admin segment with table ID 'AD' and sequence ID 'ADMINID', and if not found, set default Merlin ID to 'OM01247'
Context: The system has initialized configuration
GIVEN
The system has initialized configuration
Applied to: 2:Load Incoming Messages
WHEN
Loading messages from the queue
THEN
The system should connect to MQ manager, open the queue, and get messages with conversion options enabled
Context: A message retrieval attempt has been made
GIVEN
A message retrieval attempt has been made
Applied to: Message Available?
WHEN
The completion code is MQCC-OK and message entries are greater than 1 and backout count equals 0
THEN
The message should be marked as good for processing, otherwise skip or terminate based on specific conditions
Context: A valid message is being processed
GIVEN
A valid message is being processed
Applied to: 3:Determine Message Type
WHEN
M10 segment reference number starts with 'TRAIN'
THEN
The message should be classified as Train type, or if M10 reference number starts with 'CARGO' then classify as Cargo type, or if neither but M11 segment exists then extract cargo information from M11
Context: An M10 segment is being processed
GIVEN
An M10 segment is being processed
Applied to: Test Message?
WHEN
The table reference number equals 'TRAINCPRSTESTTRAIN0000000000' or 'CARGOCPRS940000000000'
THEN
The message should be processed as a special test case with timestamp updates to T1 table segment
Context: A message has been classified as Train or Cargo
GIVEN
A message has been classified as Train or Cargo
Applied to: Train or Cargo?
WHEN
M10 manifest type code is 'P', 'X', 'Y', 'T', or 'S'
THEN
The system should set status update flag to true, and if manifest type code is 'H' for trains, set delete status flag to true
Context: A message has been classified as Train type
GIVEN
A message has been classified as Train type
Applied to: 16:Retrieve Train Records
WHEN
Retrieving train records using the train ID from M10 data
THEN
The system should call train I/O module with GET function for root record only, and if not found, log error message indicating train ID was not found
Context: A message has been classified as Cargo type
GIVEN
A message has been classified as Cargo type
Applied to: 15:Retrieve Cargo Records
WHEN
Retrieving cargo records using the cargo control number from M10 data
THEN
The system should call cargo I/O module with GET function for cargo segment, and if not found, log error message indicating cargo control number was not found
Context: Message segments are available for processing
GIVEN
Message segments are available for processing
Applied to: 6:Process Message Segments
WHEN
Processing segments by type where M10 contains manifest data, P4 contains additional data, N10 contains line release number, K1 contains message text, and K3 contains acceptance data
THEN
The system should process each segment type appropriately and continue until end marker or spaces are encountered
Context: Message segments have been processed
GIVEN
Message segments have been processed
Applied to: 8:Validate Required Segments
WHEN
Checking for required segments
THEN
The system should log error if M10 segment not found, or if P4 segment not found, or if K3 segment not found and create default K3 segment
Context: A K3 segment is being processed
GIVEN
A K3 segment is being processed
Applied to: 9:Process Rejection Information
WHEN
K3 total reject count equals zero and total accept count is greater than zero
THEN
The system should set ACK status, but if total reject count is greater than zero, set ERROR status, and if both counts are zero, set ACK status with warning message
Context: K3 acceptance data has been processed with zero rejections and positive acceptances
GIVEN
K3 acceptance data has been processed with zero rejections and positive acceptances
Applied to: 10:Determine Final Status
WHEN
Train is in pre-arrived status
THEN
The system should set pre-arrival status, or if train review is complete, set review-completed status, otherwise set standard ACK status
Context: An error status has been determined
GIVEN
An error status has been determined
Applied to: 12:Send Error Messages
WHEN
Error status flag is set
THEN
The system should send error notification message via EMCSEND to configured Merlin recipients
Context: Train processing requires status update
GIVEN
Train processing requires status update
Applied to: 17:Update Train Status
WHEN
Train is deleted and status is ACK, or train is delete-pending and status is ACK
THEN
The system should set status to 'DELETED', or if train is not deleted or delete-pending, update with current status
Context: Cargo processing requires status update
GIVEN
Cargo processing requires status update
Applied to: 18:Update Cargo Status
WHEN
Status is ACK and saved status description is spaces
THEN
The system should set cargo ACK flags, or if saved status exists, restore saved status and description, or if status is error, save current status and set error flags
Context: Train status has been updated
GIVEN
Train status has been updated
Applied to: 19:Check AEI Train Qualification
WHEN
Train has ACK status and AEI-SEND flag and ENROUTE-NOT-REPORTED flag and train ID position 23 equals 'T'
THEN
The system should qualify train for AEI processing and prepare customs transaction data
Applied to: 23:Process Automatic Train Arrival
WHEN
Train has ACK status and ARRIVED-PENDING flag
THEN
The system should trigger automatic train arrival processing with current date and time
Context: Train qualifies for AEI processing
GIVEN
Train qualifies for AEI processing
Applied to: 20:Load Train Car Information
WHEN
Loading car information where container indicator is not 'C'
THEN
The system should load car initials, numbers, and equipment types, and determine loaded/empty status based on next car's container indicator
Context: Train has AEI-SEND flag set
GIVEN
Train has AEI-SEND flag set
Applied to: 21:Send AEI Status Messages
WHEN
Sending AEI status messages
THEN
The system should retrieve AEI Merlin recipients from database, format train and status information, and send via EMCSEND3
Context: Train status processing is complete
GIVEN
Train status processing is complete
Applied to: 22:Send Terminal Status Messages
WHEN
Train has ACK status and AEI-SEND flag and ENROUTE-REPORTED flag
THEN
The system should send enroute message to AEI Merlin recipients
Context: Message processing activities need to be logged
GIVEN
Message processing activities need to be logged
Applied to: 13:Log Message Processing
WHEN
Creating log entries
THEN
The system should format different log messages for cargo versus train operations, and use special format when status should not be updated
Context: Processing activities require reporting
GIVEN
Processing activities require reporting
Applied to: 26:Send Merlin Reports
WHEN
Sending Merlin reports
THEN
The system should send reports to primary recipients and copy to administrative recipients with appropriate error handling
Context: Special test message is being processed
GIVEN
Special test message is being processed
Applied to: 25:Update Administrative Tables
WHEN
Manifest type is 'P'
THEN
The system should update T1-309-ACK timestamp, or if manifest type is 'H', update T1-353-ACK timestamp, or if manifest type is 'S', update T1-358-ACK timestamp
Context: Message processing is complete or terminated
GIVEN
Message processing is complete or terminated
Applied to: 27:Close MQ Connections
WHEN
Closing MQ resources
THEN
The system should close queue handle and disconnect from MQ manager with appropriate error handling
R-GCX015-cbl-00025 (+11) File: GCX015.cbl Initialize System Configuration Merged 12 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Initialize System Configuration':
  • Context - the system is starting message processing initialization:
    For Clear Working Storage Fields:
    When the initialization process begins, then all working storage fields including train/cargo switches, message counters, key tables, and processing flags are cleared to spaces or initial values.
  • Context - working storage fields have been cleared:
    For Initialize Message Counters and Tables:
    When counter and table initialization is performed, then k1 counter is set to 1, k1 table is initialized, message line counter is set to 1, and all segment found flags are set to not found status.
  • Context - message counters and tables are initialized:
    For Set Administrative Table Parameters:
    When administrative table parameters are configured, then function code is set to 'gu', table id is set to 'ad', sequence id is set to 'adminid', and accept status is set to 'ge'.
  • Context - administrative table parameters are configured:
    For Get Administrative Configuration:
    When table segment retrieval is performed, then system calls table i/o function to get administrative segment data.
  • Context - administrative configuration retrieval has been attempted:
    For Admin Config Found?:
    When return flag indicates successful retrieval (flag equals '0'), then administrative segment data is loaded from table segment, otherwise default merlin id 'om01247' is set.
  • Context - administrative configuration retrieval failed:
    For Load Default Merlin ID:
    When default configuration is applied, then merlin id is set to 'om01247' as the default value.
  • Context - administrative configuration is complete:
    For Initialize Message Queue Parameters:
    When message queue parameters are initialized, then header length, unused entry length, and single entry length are calculated and stored for message processing.
  • Context - message queue parameters are initialized:
    For Connect to MQ Manager:
    When mq connection is attempted, then system calls mqconnc to establish connection with mq manager.
  • Context - mq connection attempt has been made:
    For MQ Connection OK?:
    When connection completion code is evaluated, then if completion code equals mqcc-ok then connection is successful, otherwise connection failed and error handling is triggered.
  • Context - mq manager connection is successful:
    For Open Message Queue for Input:
    When queue open operation is performed, then system calls mqopen with object type set to queue, object name from configuration, and input options.
  • Context - message queue open attempt has been made:
    For Queue Open OK?:
    When queue open completion code is evaluated, then if completion code equals mqcc-ok then queue is ready for processing, if reason code is 2085 then program exits, otherwise error handling is triggered.
  • Context - message queue is successfully opened:
    For System Ready for Processing:
    When all initialization steps are validated, then system is ready to begin processing messages from the queue.
👨‍💻 Technical ACs (Gherkin)
Context: The system is starting message processing initialization
GIVEN
The system is starting message processing initialization
Applied to: Clear Working Storage Fields
WHEN
The initialization process begins
THEN
All working storage fields including train/cargo switches, message counters, key tables, and processing flags are cleared to spaces or initial values
Context: Working storage fields have been cleared
GIVEN
Working storage fields have been cleared
Applied to: Initialize Message Counters and Tables
WHEN
Counter and table initialization is performed
THEN
K1 counter is set to 1, K1 table is initialized, message line counter is set to 1, and all segment found flags are set to not found status
Context: Message counters and tables are initialized
GIVEN
Message counters and tables are initialized
Applied to: Set Administrative Table Parameters
WHEN
Administrative table parameters are configured
THEN
Function code is set to 'GU', table ID is set to 'AD', sequence ID is set to 'ADMINID', and accept status is set to 'GE'
Context: Administrative table parameters are configured
GIVEN
Administrative table parameters are configured
Applied to: Get Administrative Configuration
WHEN
Table segment retrieval is performed
THEN
System calls table I/O function to get administrative segment data
Context: Administrative configuration retrieval has been attempted
GIVEN
Administrative configuration retrieval has been attempted
Applied to: Admin Config Found?
WHEN
Return flag indicates successful retrieval (flag equals '0')
THEN
Administrative segment data is loaded from table segment, otherwise default Merlin ID 'OM01247' is set
Context: Administrative configuration retrieval failed
GIVEN
Administrative configuration retrieval failed
Applied to: Load Default Merlin ID
WHEN
Default configuration is applied
THEN
Merlin ID is set to 'OM01247' as the default value
Context: Administrative configuration is complete
GIVEN
Administrative configuration is complete
Applied to: Initialize Message Queue Parameters
WHEN
Message queue parameters are initialized
THEN
Header length, unused entry length, and single entry length are calculated and stored for message processing
Context: Message queue parameters are initialized
GIVEN
Message queue parameters are initialized
Applied to: Connect to MQ Manager
WHEN
MQ connection is attempted
THEN
System calls MQCONNC to establish connection with MQ manager
Context: MQ connection attempt has been made
GIVEN
MQ connection attempt has been made
Applied to: MQ Connection OK?
WHEN
Connection completion code is evaluated
THEN
If completion code equals MQCC-OK then connection is successful, otherwise connection failed and error handling is triggered
Context: MQ manager connection is successful
GIVEN
MQ manager connection is successful
Applied to: Open Message Queue for Input
WHEN
Queue open operation is performed
THEN
System calls MQOPEN with object type set to queue, object name from configuration, and input options
Context: Message queue open attempt has been made
GIVEN
Message queue open attempt has been made
Applied to: Queue Open OK?
WHEN
Queue open completion code is evaluated
THEN
If completion code equals MQCC-OK then queue is ready for processing, if reason code is 2085 then program exits, otherwise error handling is triggered
Context: Message queue is successfully opened
GIVEN
Message queue is successfully opened
Applied to: System Ready for Processing
WHEN
All initialization steps are validated
THEN
System is ready to begin processing messages from the queue
R-GCX015-cbl-00037 (+13) File: GCX015.cbl Load Incoming Messages Merged 14 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Load Incoming Messages':
  • Context - system needs to process us customs messages from message queue:
    For Connect to MQ Manager:
    When connection to mq manager is attempted, then if connection fails, system generates error message and terminates processing with mq connection failure.
  • Context - mq manager connection is established:
    For Open Message Queue:
    When system attempts to open the message queue, then if queue opening fails, system generates error message and terminates processing with mq open failure.
  • Context - system attempts to open message queue:
    For Queue Available?:
    When queue open operation returns reason code 2085, then system exits processing normally without error.
  • Context - message queue is open and available:
    For Get Message from Queue:
    When system attempts to get message from queue, then message is retrieved and completion code is set based on operation result.
  • Context - message retrieval operation is completed:
    For Message Retrieved Successfully?:
    When completion code equals mqcc-ok, then message is considered successfully retrieved for further processing.
  • Context - message is successfully retrieved from queue:
    For Message Too Short?:
    When completion code is mqcc-ok and calculated message entries count is less than 1, then system terminates processing with user error 355 indicating message is too short.
    For Calculate Message Entries Count:
    When message data length is available, then maximum message entries count is calculated by subtracting header and unused data length from total data length and dividing by single entry length.
  • Context - message is successfully retrieved and has valid length:
    For Check Message Backout Count:
    When message backout count is evaluated, then message processing eligibility is determined based on backout count value.
  • Context - message is successfully retrieved with valid length:
    For Mark as Good Message:
    When completion code is mqcc-ok and message backout count equals 0, then message is marked as good message for processing.
    For Mark as Skip Message:
    When completion code is mqcc-ok and message backout count is not equal to 0, then message is marked as skip message and not processed further.
  • Context - message retrieval operation fails:
    For No Messages Available?:
    When completion code is mqcc-failed and reason code is mqrc-no-msg-available, then system generates mq error message and terminates processing with error code 355.
    For Set End of Queue Flag:
    When completion code and reason code indicate other mq failure conditions, then system sets end of message queue flag and generates error message before terminating with error code 355.
  • Context - mq operation fails with specific reason code:
    For Generate MQ Error Message:
    When error condition is detected, then system calls error message routine to generate descriptive error text and formats complete error message with reason code.
  • Context - critical mq error condition is detected:
    For Abend with Error Code 355:
    When error message is generated and transaction code 355 is set, then system calls error handling routine to terminate processing abnormally.
👨‍💻 Technical ACs (Gherkin)
Context: System needs to process US Customs messages from message queue
GIVEN
System needs to process US Customs messages from message queue
Applied to: Connect to MQ Manager
WHEN
Connection to MQ manager is attempted
THEN
If connection fails, system generates error message and terminates processing with MQ connection failure
Context: MQ manager connection is established
GIVEN
MQ manager connection is established
Applied to: Open Message Queue
WHEN
System attempts to open the message queue
THEN
If queue opening fails, system generates error message and terminates processing with MQ open failure
Context: System attempts to open message queue
GIVEN
System attempts to open message queue
Applied to: Queue Available?
WHEN
Queue open operation returns reason code 2085
THEN
System exits processing normally without error
Context: Message queue is open and available
GIVEN
Message queue is open and available
Applied to: Get Message from Queue
WHEN
System attempts to get message from queue
THEN
Message is retrieved and completion code is set based on operation result
Context: Message retrieval operation is completed
GIVEN
Message retrieval operation is completed
Applied to: Message Retrieved Successfully?
WHEN
Completion code equals MQCC-OK
THEN
Message is considered successfully retrieved for further processing
Context: Message is successfully retrieved from queue
GIVEN
Message is successfully retrieved from queue
Applied to: Message Too Short?
WHEN
Completion code is MQCC-OK and calculated message entries count is less than 1
THEN
System terminates processing with user error 355 indicating message is too short
Applied to: Calculate Message Entries Count
WHEN
Message data length is available
THEN
Maximum message entries count is calculated by subtracting header and unused data length from total data length and dividing by single entry length
Context: Message is successfully retrieved and has valid length
GIVEN
Message is successfully retrieved and has valid length
Applied to: Check Message Backout Count
WHEN
Message backout count is evaluated
THEN
Message processing eligibility is determined based on backout count value
Context: Message is successfully retrieved with valid length
GIVEN
Message is successfully retrieved with valid length
Applied to: Mark as Good Message
WHEN
Completion code is MQCC-OK and message backout count equals 0
THEN
Message is marked as good message for processing
Applied to: Mark as Skip Message
WHEN
Completion code is MQCC-OK and message backout count is not equal to 0
THEN
Message is marked as skip message and not processed further
Context: Message retrieval operation fails
GIVEN
Message retrieval operation fails
Applied to: No Messages Available?
WHEN
Completion code is MQCC-FAILED and reason code is MQRC-NO-MSG-AVAILABLE
THEN
System generates MQ error message and terminates processing with error code 355
Applied to: Set End of Queue Flag
WHEN
Completion code and reason code indicate other MQ failure conditions
THEN
System sets end of message queue flag and generates error message before terminating with error code 355
Context: MQ operation fails with specific reason code
GIVEN
MQ operation fails with specific reason code
Applied to: Generate MQ Error Message
WHEN
Error condition is detected
THEN
System calls error message routine to generate descriptive error text and formats complete error message with reason code
Context: Critical MQ error condition is detected
GIVEN
Critical MQ error condition is detected
Applied to: Abend with Error Code 355
WHEN
Error message is generated and transaction code 355 is set
THEN
System calls error handling routine to terminate processing abnormally
R-GCX015-cbl-00051 (+7) File: GCX015.cbl Determine Message Type Merged 8 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Determine Message Type':
  • Context - a message is being processed and contains message segments:
    For Extract M10 Segment Data:
    When an m10 segment is found in the message, then the system extracts the m10 segment data and marks m10 segment as found.
  • Context - an m10 segment has been extracted from the message:
    For Reference Number Prefix = 'TRAIN'?:
    When the reference number (m10-12-ref-num) starts with 'train', then the system sets the message type as train for processing.
  • Context - an m10 segment has been extracted and the reference number does not start with 'train':
    For Reference Number Prefix = 'CARGO'?:
    When the reference number (m10-12-ref-num) starts with 'cargo', then the system sets the message type as cargo for processing.
  • Context - the message type is unknown after checking m10 segment and an m11 segment is available:
    For Extract SCAC and Bill Number from M11:
    When the system processes the m11 segment, then the system extracts scac code and bill number from m11 segment to build cargo identification key.
  • Context - scac code and bill number have been extracted from m11 segment:
    For Build Cargo Key from M11 Data:
    When the system needs to create a cargo identification key, then the system combines the scac code and bill number into a work cargo key and sets message type as cargo.
  • Context - a message type has been determined (train or cargo):
    For Manifest Type = 'P', 'X', 'Y', 'T', 'S'?:
    When the manifest type code (m10-09-manifest-typ-cde) is 'p', 'x', 'y', 't', or 's', then the system sets the flag to update status during processing.
  • Context - the message type is train and manifest type is not 'p', 'x', 'y', 't', or 's':
    For Manifest Type = 'H' and TRAIN?:
    When the manifest type code (m10-09-manifest-typ-cde) is 'h', then the system sets the flag to delete status during processing.
  • Context - a message type has been determined:
    For Set Should Not Update Status:
    When the manifest type code is not 'p', 'x', 'y', 't', 's' and is not 'h' for train messages, then the system sets the flag to not update status during processing.
👨‍💻 Technical ACs (Gherkin)
Context: A message is being processed and contains message segments
GIVEN
A message is being processed and contains message segments
Applied to: Extract M10 Segment Data
WHEN
An M10 segment is found in the message
THEN
The system extracts the M10 segment data and marks M10 segment as found
Context: An M10 segment has been extracted from the message
GIVEN
An M10 segment has been extracted from the message
Applied to: Reference Number Prefix = 'TRAIN'?
WHEN
The reference number (M10-12-REF-NUM) starts with 'TRAIN'
THEN
The system sets the message type as TRAIN for processing
Context: An M10 segment has been extracted and the reference number does not start with 'TRAIN'
GIVEN
An M10 segment has been extracted and the reference number does not start with 'TRAIN'
Applied to: Reference Number Prefix = 'CARGO'?
WHEN
The reference number (M10-12-REF-NUM) starts with 'CARGO'
THEN
The system sets the message type as CARGO for processing
Context: The message type is unknown after checking M10 segment and an M11 segment is available
GIVEN
The message type is unknown after checking M10 segment and an M11 segment is available
Applied to: Extract SCAC and Bill Number from M11
WHEN
The system processes the M11 segment
THEN
The system extracts SCAC code and bill number from M11 segment to build cargo identification key
Context: SCAC code and bill number have been extracted from M11 segment
GIVEN
SCAC code and bill number have been extracted from M11 segment
Applied to: Build Cargo Key from M11 Data
WHEN
The system needs to create a cargo identification key
THEN
The system combines the SCAC code and bill number into a work cargo key and sets message type as CARGO
Context: A message type has been determined (TRAIN or CARGO)
GIVEN
A message type has been determined (TRAIN or CARGO)
Applied to: Manifest Type = 'P', 'X', 'Y', 'T', 'S'?
WHEN
The manifest type code (M10-09-MANIFEST-TYP-CDE) is 'P', 'X', 'Y', 'T', or 'S'
THEN
The system sets the flag to update status during processing
Context: The message type is TRAIN and manifest type is not 'P', 'X', 'Y', 'T', or 'S'
GIVEN
The message type is TRAIN and manifest type is not 'P', 'X', 'Y', 'T', or 'S'
Applied to: Manifest Type = 'H' and TRAIN?
WHEN
The manifest type code (M10-09-MANIFEST-TYP-CDE) is 'H'
THEN
The system sets the flag to delete status during processing
Context: A message type has been determined
GIVEN
A message type has been determined
Applied to: Set Should Not Update Status
WHEN
The manifest type code is not 'P', 'X', 'Y', 'T', 'S' and is not 'H' for TRAIN messages
THEN
The system sets the flag to not update status during processing
R-GCX015-cbl-00059 (+5) File: GCX015.cbl Process Cargo Manifest Information Merged 6 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Process Cargo Manifest Information':
  • Context - a message is being processed for type identification:
    For Message Type Unknown?:
    When the message type has not been determined as train or cargo, then the system should proceed to check for m11 segment to identify cargo information.
  • Context - a message with unknown type is being processed:
    For M11 Segment Found?:
    When the current message segment has table id equal to 'm11', then the system should process the m11 segment to extract cargo information.
  • Context - an m11 segment is being processed for cargo identification:
    For Extract SCAC Code from M11-12-SCAC:
    When the m11 segment contains scac information in field m11-12-scac, then the system should extract the scac code and store it in the work scac field.
    For Extract Bill Number from M11-01-BOL-WB-NUM:
    When the m11 segment contains bill information in field m11-01-bol-wb-num, then the system should extract the bill number and store it in the work bill number field.
  • Context - scac code and bill number have been extracted from m11 segment:
    For Build Cargo Key from SCAC and Bill Number:
    When both scac and bill number values are available, then the system should combine the scac and bill number into a work cargo key and store it as the m10-12 data for processing.
  • Context - cargo key has been successfully built from m11 segment information:
    For Set Message Type as Cargo:
    When the cargo identification process is complete, then the system should set the message type indicator to cargo for subsequent processing.
👨‍💻 Technical ACs (Gherkin)
Context: A message is being processed for type identification
GIVEN
A message is being processed for type identification
Applied to: Message Type Unknown?
WHEN
The message type has not been determined as TRAIN or CARGO
THEN
The system should proceed to check for M11 segment to identify cargo information
Context: A message with unknown type is being processed
GIVEN
A message with unknown type is being processed
Applied to: M11 Segment Found?
WHEN
The current message segment has table ID equal to 'M11'
THEN
The system should process the M11 segment to extract cargo information
Context: An M11 segment is being processed for cargo identification
GIVEN
An M11 segment is being processed for cargo identification
Applied to: Extract SCAC Code from M11-12-SCAC
WHEN
The M11 segment contains SCAC information in field M11-12-SCAC
THEN
The system should extract the SCAC code and store it in the work SCAC field
Applied to: Extract Bill Number from M11-01-BOL-WB-NUM
WHEN
The M11 segment contains bill information in field M11-01-BOL-WB-NUM
THEN
The system should extract the bill number and store it in the work bill number field
Context: SCAC code and bill number have been extracted from M11 segment
GIVEN
SCAC code and bill number have been extracted from M11 segment
Applied to: Build Cargo Key from SCAC and Bill Number
WHEN
Both SCAC and bill number values are available
THEN
The system should combine the SCAC and bill number into a work cargo key and store it as the M10-12 data for processing
Context: Cargo key has been successfully built from M11 segment information
GIVEN
Cargo key has been successfully built from M11 segment information
Applied to: Set Message Type as Cargo
WHEN
The cargo identification process is complete
THEN
The system should set the message type indicator to CARGO for subsequent processing
R-GCX015-cbl-00065 (+3) File: GCX015.cbl Set Status Update Actions Merged 4 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Set Status Update Actions':
  • Context - an m10 segment is being processed with a manifest type code:
    For Set UPDATE Status Action Types: P, X, Y, T, S:
    When the manifest type code is p, x, y, t, or s, then the system should set the status update action to allow status updates.
    For Set NO UPDATE Status Action Other Types:
    When the manifest type code is not p, x, y, t, or s, then the system should set the status update action to prevent status updates.
  • Context - a train is being processed with an m10 segment containing manifest type code:
    For Set DELETE Status Action Type: H for Trains:
    When the manifest type code is h, then the system should set the delete status action to allow status deletion.
    For Set NO DELETE Status Action Other Types for Trains:
    When the manifest type code is not h, then the system should set the delete status action to prevent status deletion.
👨‍💻 Technical ACs (Gherkin)
Context: An M10 segment is being processed with a manifest type code
GIVEN
An M10 segment is being processed with a manifest type code
Applied to: Set UPDATE Status Action Types: P, X, Y, T, S
WHEN
The manifest type code is P, X, Y, T, or S
THEN
The system should set the status update action to allow status updates
Applied to: Set NO UPDATE Status Action Other Types
WHEN
The manifest type code is not P, X, Y, T, or S
THEN
The system should set the status update action to prevent status updates
Context: A train is being processed with an M10 segment containing manifest type code
GIVEN
A train is being processed with an M10 segment containing manifest type code
Applied to: Set DELETE Status Action Type: H for Trains
WHEN
The manifest type code is H
THEN
The system should set the delete status action to allow status deletion
Applied to: Set NO DELETE Status Action Other Types for Trains
WHEN
The manifest type code is not H
THEN
The system should set the delete status action to prevent status deletion
R-GCX015-cbl-00069 (+7) File: GCX015.cbl Process Message Segments Merged 8 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Process Message Segments':
  • Context - a message segment with table id 'm10' is encountered during message processing:
    For Process M10 Segment:
    When the system processes the m10 segment, then the m10 segment data is stored and the m10 segment found flag is set to true.
  • Context - a message segment with table id 'p4 ' is encountered during message processing:
    For Process P4 Segment:
    When the system processes the p4 segment, then the p4 segment data is stored and the p4 segment found flag is set to true.
  • Context - a message segment with table id 'n10' is encountered during message processing:
    For Process N10 Segment:
    When the system processes the n10 segment, then the line release number from position 09 is extracted and stored in the hold area.
  • Context - a k1 segment is being processed with a message number:
    For Look Up Error Message Text:
    When the system looks up the message number in the ms table with prefix 'a', then if found, the english text from the table is used; if not found, the free-form message from k1 segment is used.
  • Context - a k1 segment with message number '242' is processed and n10 line release number data exists:
    For Build Error Description:
    When the system builds the error description, then an additional message line with 'c4 code=' followed by the line release number is added to the processing log.
  • Context - a message segment with table id 'k3 ' is encountered during message processing:
    For Process K3 Segment:
    When the system processes the k3 segment, then the k3 segment data is stored and the k3 segment found flag is set to true.
  • Context - message segments are being processed sequentially:
    For End of Message?:
    When a segment with table id containing only spaces or low-values is encountered, then the end found flag is set to true and segment processing terminates.
  • Context - a message segment has been processed (except k1 segments which handle their own logging):
    For Add Segment to Processing Log:
    When the segment processing is complete, then the segment data from positions 1-69 is added to the processing log and the line counter is incremented.
👨‍💻 Technical ACs (Gherkin)
Context: A message segment with table ID 'M10' is encountered during message processing
GIVEN
A message segment with table ID 'M10' is encountered during message processing
Applied to: Process M10 Segment
WHEN
The system processes the M10 segment
THEN
The M10 segment data is stored and the M10 segment found flag is set to true
Context: A message segment with table ID 'P4 ' is encountered during message processing
GIVEN
A message segment with table ID 'P4 ' is encountered during message processing
Applied to: Process P4 Segment
WHEN
The system processes the P4 segment
THEN
The P4 segment data is stored and the P4 segment found flag is set to true
Context: A message segment with table ID 'N10' is encountered during message processing
GIVEN
A message segment with table ID 'N10' is encountered during message processing
Applied to: Process N10 Segment
WHEN
The system processes the N10 segment
THEN
The line release number from position 09 is extracted and stored in the hold area
Context: A K1 segment is being processed with a message number
GIVEN
A K1 segment is being processed with a message number
Applied to: Look Up Error Message Text
WHEN
The system looks up the message number in the MS table with prefix 'A'
THEN
If found, the English text from the table is used; if not found, the free-form message from K1 segment is used
Context: A K1 segment with message number '242' is processed and N10 line release number data exists
GIVEN
A K1 segment with message number '242' is processed and N10 line release number data exists
Applied to: Build Error Description
WHEN
The system builds the error description
THEN
An additional message line with 'C4 CODE=' followed by the line release number is added to the processing log
Context: A message segment with table ID 'K3 ' is encountered during message processing
GIVEN
A message segment with table ID 'K3 ' is encountered during message processing
Applied to: Process K3 Segment
WHEN
The system processes the K3 segment
THEN
The K3 segment data is stored and the K3 segment found flag is set to true
Context: Message segments are being processed sequentially
GIVEN
Message segments are being processed sequentially
Applied to: End of Message?
WHEN
A segment with table ID containing only spaces or low-values is encountered
THEN
The end found flag is set to true and segment processing terminates
Context: A message segment has been processed (except K1 segments which handle their own logging)
GIVEN
A message segment has been processed (except K1 segments which handle their own logging)
Applied to: Add Segment to Processing Log
WHEN
The segment processing is complete
THEN
The segment data from positions 1-69 is added to the processing log and the line counter is incremented
R-GCX015-cbl-00077 (+4) File: GCX015.cbl Skip Test Messages Merged 5 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Skip Test Messages':
  • Context - a message queue entry contains an m10 segment with table id 'm10':
    For Test Train Message TRAINCPRSTESTTRAIN0000000000:
    When the m10 table reference number equals 'traincprstesttrain0000000000', then the system performs special check processing, clears the message array, sets end processing flag, and terminates current message processing.
    For Test Cargo Message CARGOCPRS940000000000:
    When the m10 table reference number equals 'cargocprs940000000000', then the system performs special check processing, clears the message array, sets end processing flag, and terminates current message processing.
    For Continue Normal Processing:
    When the m10 table reference number is not 'traincprstesttrain0000000000' and not 'cargocprs940000000000', then the system proceeds with normal m10 segment processing workflow.
  • Context - a test message has been identified with manifest type code:
    For Update Administrative Timestamps:
    When the manifest type code is 'p', 'h', or 's', then the system updates the corresponding acknowledgment timestamp field in the t1 administrative table with current machine date, century, and time.
  • Context - a test message has been processed and administrative timestamps updated:
    For Clear Message Array:
    When the special check processing is completed, then the system moves spaces to the message array and sets the end found flag to true.
👨‍💻 Technical ACs (Gherkin)
Context: A message queue entry contains an M10 segment with table ID 'M10'
GIVEN
A message queue entry contains an M10 segment with table ID 'M10'
Applied to: Test Train Message TRAINCPRSTESTTRAIN0000000000
WHEN
The M10 table reference number equals 'TRAINCPRSTESTTRAIN0000000000'
THEN
The system performs special check processing, clears the message array, sets end processing flag, and terminates current message processing
Applied to: Test Cargo Message CARGOCPRS940000000000
WHEN
The M10 table reference number equals 'CARGOCPRS940000000000'
THEN
The system performs special check processing, clears the message array, sets end processing flag, and terminates current message processing
Applied to: Continue Normal Processing
WHEN
The M10 table reference number is not 'TRAINCPRSTESTTRAIN0000000000' and not 'CARGOCPRS940000000000'
THEN
The system proceeds with normal M10 segment processing workflow
Context: A test message has been identified with manifest type code
GIVEN
A test message has been identified with manifest type code
Applied to: Update Administrative Timestamps
WHEN
The manifest type code is 'P', 'H', or 'S'
THEN
The system updates the corresponding acknowledgment timestamp field in the T1 administrative table with current machine date, century, and time
Context: A test message has been processed and administrative timestamps updated
GIVEN
A test message has been processed and administrative timestamps updated
Applied to: Clear Message Array
WHEN
The special check processing is completed
THEN
The system moves spaces to the message array and sets the end found flag to true
R-GCX015-cbl-00082 (+4) File: GCX015.cbl Validate Required Segments Merged 5 Rules
Validation Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Validate Required Segments':
  • Context - a message is being processed for segment validation:
    For M10 Segment Found?:
    When the system checks for m10 segment presence using the m10 segment found flag, then if m10 segment is not found, generate error message 'm10 segment not found on 355 transaction' and increment line counter.
  • Context - a message is being processed for segment validation and m10 validation is complete:
    For P4 Segment Found?:
    When the system checks for p4 segment presence using the p4 segment found flag, then if p4 segment is not found, generate error message 'p4 segment not found on 355 transaction' and increment line counter.
  • Context - a message is being processed for segment validation and m10 and p4 validations are complete:
    For K3 Segment Found?:
    When the system checks for k3 segment presence using the k3 segment found flag, then if k3 segment is not found, generate error message 'k3 segment not found on 355 transaction' and increment line counter.
  • Context - k3 segment is not found in the message:
    For Create Default K3 Segment with Current Date/Time:
    When the system processes the missing k3 segment condition, then create a default k3 segment by setting k3 segment found flag to true, populate k3-03-date with current machine date, populate k3-04-time with current machine time first 6 positions, and move the constructed k3 data to k3-segment.
  • Context - a default k3 segment has been created with current date and time:
    For Set Final Status Based on Default K3:
    When the system processes the default k3 segment for status determination, then if k3 total reject count equals zero and k3 total accept count is greater than zero, set ack status, else if both counts are zero, set ack status and add warning message 'uscs k3 record has zero counts' to hold messages and increment k1 counter, else set error status.
👨‍💻 Technical ACs (Gherkin)
Context: A message is being processed for segment validation
GIVEN
A message is being processed for segment validation
Applied to: M10 Segment Found?
WHEN
The system checks for M10 segment presence using the M10 segment found flag
THEN
If M10 segment is not found, generate error message 'M10 SEGMENT NOT FOUND ON 355 TRANSACTION' and increment line counter
Context: A message is being processed for segment validation and M10 validation is complete
GIVEN
A message is being processed for segment validation and M10 validation is complete
Applied to: P4 Segment Found?
WHEN
The system checks for P4 segment presence using the P4 segment found flag
THEN
If P4 segment is not found, generate error message 'P4 SEGMENT NOT FOUND ON 355 TRANSACTION' and increment line counter
Context: A message is being processed for segment validation and M10 and P4 validations are complete
GIVEN
A message is being processed for segment validation and M10 and P4 validations are complete
Applied to: K3 Segment Found?
WHEN
The system checks for K3 segment presence using the K3 segment found flag
THEN
If K3 segment is not found, generate error message 'K3 SEGMENT NOT FOUND ON 355 TRANSACTION' and increment line counter
Context: K3 segment is not found in the message
GIVEN
K3 segment is not found in the message
Applied to: Create Default K3 Segment with Current Date/Time
WHEN
The system processes the missing K3 segment condition
THEN
Create a default K3 segment by setting K3 segment found flag to true, populate K3-03-DATE with current machine date, populate K3-04-TIME with current machine time first 6 positions, and move the constructed K3 data to K3-SEGMENT
Context: A default K3 segment has been created with current date and time
GIVEN
A default K3 segment has been created with current date and time
Applied to: Set Final Status Based on Default K3
WHEN
The system processes the default K3 segment for status determination
THEN
If K3 total reject count equals zero and K3 total accept count is greater than zero, set ACK status, else if both counts are zero, set ACK status and add warning message 'USCS K3 RECORD HAS ZERO COUNTS' to hold messages and increment K1 counter, else set ERROR status
R-GCX015-cbl-00087 (+6) File: GCX015.cbl Process Rejection Information Merged 7 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Process Rejection Information':
  • Context - a k3 segment has been received with rejection and acceptance counts:
    For Total Reject = 0?:
    When the total rejection count (k3-11-total-reject) is greater than zero, then set the status to error and generate error processing.
  • Context - a k3 segment has zero rejection counts:
    For Total Accept > 0?:
    When the total acceptance count (k3-12-total-accept) is greater than zero, then proceed to evaluate train-specific status conditions for final status determination.
    For Log Zero Counts Message:
    When the total acceptance count (k3-12-total-accept) is also zero, then log warning message 'uscs k3 record has zero counts' and set ack status.
  • Context - a train record exists with valid acceptance counts and zero rejections:
    For Set PRE-ARRIVAL Status:
    When the train status indicates pre-arrived condition (gcwtl-pre-arrived is true), then set the processing status to pre-arrival.
    For Set REVIEW-COMPLETED Status:
    When the train status indicates review-cmpl condition (gcwtl-review-cmpl is true), then set the processing status to review-completed.
    For Set ACK Status:
    When the train is neither in pre-arrived nor review-cmpl state, then set the processing status to ack (acknowledgment).
  • Context - a k3 segment has been processed:
    For Set ERROR Status:
    When the total rejection count (k3-11-total-reject) is greater than zero, then set the processing status to error.
👨‍💻 Technical ACs (Gherkin)
Context: A K3 segment has been received with rejection and acceptance counts
GIVEN
A K3 segment has been received with rejection and acceptance counts
Applied to: Total Reject = 0?
WHEN
The total rejection count (K3-11-TOTAL-REJECT) is greater than zero
THEN
Set the status to ERROR and generate error processing
Context: A K3 segment has zero rejection counts
GIVEN
A K3 segment has zero rejection counts
Applied to: Total Accept > 0?
WHEN
The total acceptance count (K3-12-TOTAL-ACCEPT) is greater than zero
THEN
Proceed to evaluate train-specific status conditions for final status determination
Applied to: Log Zero Counts Message
WHEN
The total acceptance count (K3-12-TOTAL-ACCEPT) is also zero
THEN
Log warning message 'USCS K3 RECORD HAS ZERO COUNTS' and set ACK status
Context: A train record exists with valid acceptance counts and zero rejections
GIVEN
A train record exists with valid acceptance counts and zero rejections
Applied to: Set PRE-ARRIVAL Status
WHEN
The train status indicates PRE-ARRIVED condition (GCWTL-PRE-ARRIVED is true)
THEN
Set the processing status to PRE-ARRIVAL
Applied to: Set REVIEW-COMPLETED Status
WHEN
The train status indicates REVIEW-CMPL condition (GCWTL-REVIEW-CMPL is true)
THEN
Set the processing status to REVIEW-COMPLETED
Applied to: Set ACK Status
WHEN
The train is neither in PRE-ARRIVED nor REVIEW-CMPL state
THEN
Set the processing status to ACK (acknowledgment)
Context: A K3 segment has been processed
GIVEN
A K3 segment has been processed
Applied to: Set ERROR Status
WHEN
The total rejection count (K3-11-TOTAL-REJECT) is greater than zero
THEN
Set the processing status to ERROR
R-GCX015-cbl-00094 (+7) File: GCX015.cbl Determine Final Status Merged 8 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Determine Final Status':
  • Context - a k3 segment has been processed with total reject and accept counts:
    For Total Rejects = 0?:
    When the system evaluates the total reject count, then if total rejects equal zero, proceed to acceptance validation; otherwise set error status.
  • Context - a k3 segment has zero total rejects:
    For Total Accepts > 0?:
    When the system evaluates the total accept count, then if total accepts are greater than zero, proceed to train status evaluation; if total accepts equal zero, log zero counts message and set ack status.
  • Context - a train transaction has zero rejects and positive accepts:
    For Train Status Check:
    When the system evaluates the current train status flags, then if train is in pre-arrived state, set pre-arrival status; if train is in review-cmpl state, set review-completed status; otherwise set standard ack status.
  • Context - a train transaction has zero rejects, positive accepts, and train is in pre-arrived state:
    For Set PRE-ARRIVAL Status:
    When the system sets the final processing status, then the status is set to pre-arrival to indicate successful pre-clearance processing.
  • Context - a train transaction has zero rejects, positive accepts, and train is in review-cmpl state:
    For Set REVIEW-COMPLETED Status:
    When the system sets the final processing status, then the status is set to review-completed to indicate successful completion of review process.
  • Context - a transaction has zero rejects and positive accepts, and is either cargo or train not in special states:
    For Set ACK Status:
    When the system sets the final processing status, then the status is set to ack to indicate successful transaction acknowledgment.
  • Context - a k3 segment has zero total rejects and zero total accepts:
    For Log Zero Counts Message:
    When the system processes the transaction, then a warning message 'uscs k3 record has zero counts' is logged and ack status is still assigned.
  • Context - a k3 segment has total rejects greater than zero:
    For Set ERROR Status:
    When the system evaluates the transaction results, then the status is set to error to indicate transaction processing failures.
👨‍💻 Technical ACs (Gherkin)
Context: A K3 segment has been processed with total reject and accept counts
GIVEN
A K3 segment has been processed with total reject and accept counts
Applied to: Total Rejects = 0?
WHEN
The system evaluates the total reject count
THEN
If total rejects equal zero, proceed to acceptance validation; otherwise set error status
Context: A K3 segment has zero total rejects
GIVEN
A K3 segment has zero total rejects
Applied to: Total Accepts > 0?
WHEN
The system evaluates the total accept count
THEN
If total accepts are greater than zero, proceed to train status evaluation; if total accepts equal zero, log zero counts message and set ACK status
Context: A train transaction has zero rejects and positive accepts
GIVEN
A train transaction has zero rejects and positive accepts
Applied to: Train Status Check
WHEN
The system evaluates the current train status flags
THEN
If train is in PRE-ARRIVED state, set PRE-ARRIVAL status; if train is in REVIEW-CMPL state, set REVIEW-COMPLETED status; otherwise set standard ACK status
Context: A train transaction has zero rejects, positive accepts, and train is in PRE-ARRIVED state
GIVEN
A train transaction has zero rejects, positive accepts, and train is in PRE-ARRIVED state
Applied to: Set PRE-ARRIVAL Status
WHEN
The system sets the final processing status
THEN
The status is set to PRE-ARRIVAL to indicate successful pre-clearance processing
Context: A train transaction has zero rejects, positive accepts, and train is in REVIEW-CMPL state
GIVEN
A train transaction has zero rejects, positive accepts, and train is in REVIEW-CMPL state
Applied to: Set REVIEW-COMPLETED Status
WHEN
The system sets the final processing status
THEN
The status is set to REVIEW-COMPLETED to indicate successful completion of review process
Context: A transaction has zero rejects and positive accepts, and is either cargo or train not in special states
GIVEN
A transaction has zero rejects and positive accepts, and is either cargo or train not in special states
Applied to: Set ACK Status
WHEN
The system sets the final processing status
THEN
The status is set to ACK to indicate successful transaction acknowledgment
Context: A K3 segment has zero total rejects and zero total accepts
GIVEN
A K3 segment has zero total rejects and zero total accepts
Applied to: Log Zero Counts Message
WHEN
The system processes the transaction
THEN
A warning message 'USCS K3 RECORD HAS ZERO COUNTS' is logged and ACK status is still assigned
Context: A K3 segment has total rejects greater than zero
GIVEN
A K3 segment has total rejects greater than zero
Applied to: Set ERROR Status
WHEN
The system evaluates the transaction results
THEN
The status is set to ERROR to indicate transaction processing failures
R-GCX015-cbl-00102 (+7) File: GCX015.cbl Handle Special Train Status Merged 8 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Handle Special Train Status':
  • Context - a k3 segment is being processed for train or cargo status:
    For Total Rejects = 0?:
    When the k3 total reject count is greater than zero, then the system sets the status to error and stops further acceptance processing.
  • Context - a k3 segment has zero rejection records:
    For Total Accepts > 0?:
    When the k3 total accept count is greater than zero, then the system proceeds to evaluate train status conditions for appropriate status assignment.
    For Log Zero Counts Message:
    When the k3 total accept count is also zero, then the system logs 'uscs k3 record has zero counts' message and sets status to ack.
  • Context - a k3 segment has zero rejections and positive acceptance count:
    For Train Current Status?:
    When the system evaluates the current train status condition, then the system branches to set pre-arrival, review-completed, or ack status based on current train state.
  • Context - a train has positive acceptance count and zero rejections:
    For Set PRE-ARRIVAL Status:
    When the train current status is pre-arrived (gcwtl-pre-arrived is true), then the system sets the working status to pre-arrival-status.
    For Set REVIEW-COMPLETED Status:
    When the train current status is review-cmpl (gcwtl-review-cmpl is true), then the system sets the working status to review-completed-status.
    For Set ACK Status:
    When the train is not in pre-arrived or review-cmpl status, then the system sets the working status to ack-status.
  • Context - a k3 segment is being processed for status determination:
    For Set ERROR Status:
    When the k3 total reject count is greater than zero, then the system sets the working status to error-status.
👨‍💻 Technical ACs (Gherkin)
Context: A K3 segment is being processed for train or cargo status
GIVEN
A K3 segment is being processed for train or cargo status
Applied to: Total Rejects = 0?
WHEN
The K3 total reject count is greater than zero
THEN
The system sets the status to ERROR and stops further acceptance processing
Context: A K3 segment has zero rejection records
GIVEN
A K3 segment has zero rejection records
Applied to: Total Accepts > 0?
WHEN
The K3 total accept count is greater than zero
THEN
The system proceeds to evaluate train status conditions for appropriate status assignment
Applied to: Log Zero Counts Message
WHEN
The K3 total accept count is also zero
THEN
The system logs 'USCS K3 RECORD HAS ZERO COUNTS' message and sets status to ACK
Context: A K3 segment has zero rejections and positive acceptance count
GIVEN
A K3 segment has zero rejections and positive acceptance count
Applied to: Train Current Status?
WHEN
The system evaluates the current train status condition
THEN
The system branches to set PRE-ARRIVAL, REVIEW-COMPLETED, or ACK status based on current train state
Context: A train has positive acceptance count and zero rejections
GIVEN
A train has positive acceptance count and zero rejections
Applied to: Set PRE-ARRIVAL Status
WHEN
The train current status is PRE-ARRIVED (GCWTL-PRE-ARRIVED is true)
THEN
The system sets the working status to PRE-ARRIVAL-STATUS
Applied to: Set REVIEW-COMPLETED Status
WHEN
The train current status is REVIEW-CMPL (GCWTL-REVIEW-CMPL is true)
THEN
The system sets the working status to REVIEW-COMPLETED-STATUS
Applied to: Set ACK Status
WHEN
The train is not in PRE-ARRIVED or REVIEW-CMPL status
THEN
The system sets the working status to ACK-STATUS
Context: A K3 segment is being processed for status determination
GIVEN
A K3 segment is being processed for status determination
Applied to: Set ERROR Status
WHEN
The K3 total reject count is greater than zero
THEN
The system sets the working status to ERROR-STATUS
R-GCX015-cbl-00110 (+8) File: GCX015.cbl Send Error Messages Merged 9 Rules
Validation Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Send Error Messages':
  • Context - an error condition has been detected and requires notification:
    For Set Primary Recipients - OM01247 as FROM and TO:
    When setting up primary error notification recipients, then the system sets om01247 as both the sender (from) and primary recipient (to) for error messages.
  • Context - primary error notification setup is complete:
    For Set Secondary Recipients - From Admin Table Configuration:
    When configuring secondary error notification recipients, then the system retrieves recipient identifiers from administrative table segment ad-dc-p-merlin-1 for to recipient and ad-dc-p-merlin-5 for copy recipient.
  • Context - error notification recipients are configured:
    For Include Merlin Error Report with Message Details:
    When preparing error message content for transmission, then the system includes the merlin subject as the message subject and the complete merlin error report as the message content.
  • Context - error message content is prepared with primary recipients configured:
    For Call EMCSEND2 for Primary Notification:
    When transmitting the primary error notification, then the system calls emcsend2 service with sender, destination filename, recipients, subject, and error report content.
  • Context - primary error notification has been transmitted via emcsend2:
    For Primary Send Successful?:
    When checking the transmission result status, then the system evaluates if the notification was successful based on emi-no-errors status and proceeds to secondary notification if successful.
  • Context - primary error notification was successful and secondary recipients are configured from administrative table:
    For Call EMCSEND2 for Secondary Notification:
    When transmitting the secondary error notification, then the system calls emcsend2 service with administrative table recipients and the same error message content.
  • Context - secondary error notification has been transmitted via emcsend2:
    For Secondary Send Successful?:
    When checking the secondary transmission result status, then the system evaluates if the secondary notification was successful based on emi-no-errors status and completes the error notification process if successful.
  • Context - primary error notification transmission has failed:
    For Handle Primary Send Failure:
    When the emcsend2 service returns a failure status for primary notification, then the system triggers an abend process due to critical send failure for invalid sender, recipient, or filename conditions.
  • Context - secondary error notification transmission has failed:
    For Handle Secondary Send Failure:
    When the emcsend2 service returns a failure status for secondary notification, then the system triggers an abend process due to critical send failure for invalid sender, recipient, or filename conditions.
👨‍💻 Technical ACs (Gherkin)
Context: An error condition has been detected and requires notification
GIVEN
An error condition has been detected and requires notification
Applied to: Set Primary Recipients - OM01247 as FROM and TO
WHEN
Setting up primary error notification recipients
THEN
The system sets OM01247 as both the sender (FROM) and primary recipient (TO) for error messages
Context: Primary error notification setup is complete
GIVEN
Primary error notification setup is complete
Applied to: Set Secondary Recipients - From Admin Table Configuration
WHEN
Configuring secondary error notification recipients
THEN
The system retrieves recipient identifiers from administrative table segment AD-DC-P-MERLIN-1 for TO recipient and AD-DC-P-MERLIN-5 for COPY recipient
Context: Error notification recipients are configured
GIVEN
Error notification recipients are configured
Applied to: Include Merlin Error Report with Message Details
WHEN
Preparing error message content for transmission
THEN
The system includes the Merlin subject as the message subject and the complete Merlin error report as the message content
Context: Error message content is prepared with primary recipients configured
GIVEN
Error message content is prepared with primary recipients configured
Applied to: Call EMCSEND2 for Primary Notification
WHEN
Transmitting the primary error notification
THEN
The system calls EMCSEND2 service with sender, destination filename, recipients, subject, and error report content
Context: Primary error notification has been transmitted via EMCSEND2
GIVEN
Primary error notification has been transmitted via EMCSEND2
Applied to: Primary Send Successful?
WHEN
Checking the transmission result status
THEN
The system evaluates if the notification was successful based on EMI-NO-ERRORS status and proceeds to secondary notification if successful
Context: Primary error notification was successful and secondary recipients are configured from administrative table
GIVEN
Primary error notification was successful and secondary recipients are configured from administrative table
Applied to: Call EMCSEND2 for Secondary Notification
WHEN
Transmitting the secondary error notification
THEN
The system calls EMCSEND2 service with administrative table recipients and the same error message content
Context: Secondary error notification has been transmitted via EMCSEND2
GIVEN
Secondary error notification has been transmitted via EMCSEND2
Applied to: Secondary Send Successful?
WHEN
Checking the secondary transmission result status
THEN
The system evaluates if the secondary notification was successful based on EMI-NO-ERRORS status and completes the error notification process if successful
Context: Primary error notification transmission has failed
GIVEN
Primary error notification transmission has failed
Applied to: Handle Primary Send Failure
WHEN
The EMCSEND2 service returns a failure status for primary notification
THEN
The system triggers an abend process due to critical send failure for invalid sender, recipient, or filename conditions
Context: Secondary error notification transmission has failed
GIVEN
Secondary error notification transmission has failed
Applied to: Handle Secondary Send Failure
WHEN
The EMCSEND2 service returns a failure status for secondary notification
THEN
The system triggers an abend process due to critical send failure for invalid sender, recipient, or filename conditions
R-GCX015-cbl-00119 (+13) File: GCX015.cbl Log Message Processing Merged 14 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Log Message Processing':
  • Context - a message processing operation has completed:
    For Send Error Message via EMCSEND:
    When the processing resulted in an error status condition, then the system sends an error notification message via emcsend service.
  • Context - a message processing operation requires logging:
    For Move Log Information to GCX105:
    When log information needs to be recorded, then the system populates gcx105 structure with security byte, sending transaction code, acf2 user id, processing date from machine century and k3 date, and processing time from k3 segment.
  • Context - a shipment entity needs to be logged:
    For Set Train or Cargo Identifier:
    When the entity type needs to be identified for logging purposes, then the system sets the train or cargo identifier in the gcx105 structure using the work m10-12 data.
  • Context - the entity being processed is identified as a train:
    For Set US-TRAIN Flag:
    When the entity type flag needs to be set for logging, then the system sets the gcx105-us-train flag to true.
  • Context - the entity being processed is identified as cargo:
    For Set US-CARGO Flag:
    When the entity type flag needs to be set for logging, then the system sets the gcx105-us-cargo flag to true.
  • Context - a log entry is being prepared for transmission:
    For Set Action Code to 'ZZZ':
    When the action code needs to be set, then the system sets the gcx105-action-code to 'zzz'.
  • Context - status information needs to be included in log messages:
    For Move Status to Message Fields:
    When message fields are being populated, then the system moves the current ws-status to uscs-message1, uscs-message2, and uscs-message3 fields.
  • Context - a cargo entity is being processed and status should be updated:
    For Use Manifest Reply Message Format:
    When the message format needs to be determined for logging, then the system uses uscs-log-message1 format and moves it to gcx105-message.
  • Context - a train entity is being processed and status should be updated:
    For Use Train Reply Message Format:
    When the message format needs to be determined for logging, then the system uses uscs-log-message2 format and moves it to gcx105-message.
  • Context - an entity is being processed but status should not be updated:
    For Use Other Reply Message Format:
    When the message format needs to be determined for logging, then the system uses uscs-log-message3 format, moves it to gcx105-message, and if the entity is a train with aei-send flag, performs aei status message processing.
  • Context - a log entry has been prepared with all required information:
    For Send Log via GCT1051E Transaction:
    When the primary log needs to be transmitted, then the system calls z300-spawn-gct1051e to send the log entry using gct1051e transaction.
  • Context - k1 error messages are present in the hold-k1-message table:
    For Process Each K1 Error Message:
    When error messages need to be processed for logging, then the system performs a501-send-log for each k1-cnt from 1 by 1 until hold-k1-message is spaces or k1-cnt exceeds 999.
  • Context - a k1 error message exists and is not spaces:
    For Set Message Details for K1 Entry:
    When an individual k1 log entry needs to be prepared, then the system moves log information to gcx105, sets the train or cargo identifier, sets the appropriate entity type flag, sets action code to 'zzz', and moves the specific k1 message to gcx105-message.
  • Context - a k1 error log entry has been prepared:
    For Send K1 Log Entry via GCT1051E:
    When the k1 error log needs to be transmitted, then the system calls z300-spawn-gct1051e to send the k1 error log entry using gct1051e transaction.
👨‍💻 Technical ACs (Gherkin)
Context: A message processing operation has completed
GIVEN
A message processing operation has completed
Applied to: Send Error Message via EMCSEND
WHEN
The processing resulted in an error status condition
THEN
The system sends an error notification message via EMCSEND service
Context: A message processing operation requires logging
GIVEN
A message processing operation requires logging
Applied to: Move Log Information to GCX105
WHEN
Log information needs to be recorded
THEN
The system populates GCX105 structure with security byte, sending transaction code, ACF2 user ID, processing date from machine century and K3 date, and processing time from K3 segment
Context: A shipment entity needs to be logged
GIVEN
A shipment entity needs to be logged
Applied to: Set Train or Cargo Identifier
WHEN
The entity type needs to be identified for logging purposes
THEN
The system sets the train or cargo identifier in the GCX105 structure using the work M10-12 data
Context: The entity being processed is identified as a train
GIVEN
The entity being processed is identified as a train
Applied to: Set US-TRAIN Flag
WHEN
The entity type flag needs to be set for logging
THEN
The system sets the GCX105-US-TRAIN flag to true
Context: The entity being processed is identified as cargo
GIVEN
The entity being processed is identified as cargo
Applied to: Set US-CARGO Flag
WHEN
The entity type flag needs to be set for logging
THEN
The system sets the GCX105-US-CARGO flag to true
Context: A log entry is being prepared for transmission
GIVEN
A log entry is being prepared for transmission
Applied to: Set Action Code to 'ZZZ'
WHEN
The action code needs to be set
THEN
The system sets the GCX105-ACTION-CODE to 'ZZZ'
Context: Status information needs to be included in log messages
GIVEN
Status information needs to be included in log messages
Applied to: Move Status to Message Fields
WHEN
Message fields are being populated
THEN
The system moves the current WS-STATUS to USCS-MESSAGE1, USCS-MESSAGE2, and USCS-MESSAGE3 fields
Context: A cargo entity is being processed and status should be updated
GIVEN
A cargo entity is being processed and status should be updated
Applied to: Use Manifest Reply Message Format
WHEN
The message format needs to be determined for logging
THEN
The system uses USCS-LOG-MESSAGE1 format and moves it to GCX105-MESSAGE
Context: A train entity is being processed and status should be updated
GIVEN
A train entity is being processed and status should be updated
Applied to: Use Train Reply Message Format
WHEN
The message format needs to be determined for logging
THEN
The system uses USCS-LOG-MESSAGE2 format and moves it to GCX105-MESSAGE
Context: An entity is being processed but status should not be updated
GIVEN
An entity is being processed but status should not be updated
Applied to: Use Other Reply Message Format
WHEN
The message format needs to be determined for logging
THEN
The system uses USCS-LOG-MESSAGE3 format, moves it to GCX105-MESSAGE, and if the entity is a train with AEI-SEND flag, performs AEI status message processing
Context: A log entry has been prepared with all required information
GIVEN
A log entry has been prepared with all required information
Applied to: Send Log via GCT1051E Transaction
WHEN
The primary log needs to be transmitted
THEN
The system calls Z300-SPAWN-GCT1051E to send the log entry using GCT1051E transaction
Context: K1 error messages are present in the HOLD-K1-MESSAGE table
GIVEN
K1 error messages are present in the HOLD-K1-MESSAGE table
Applied to: Process Each K1 Error Message
WHEN
Error messages need to be processed for logging
THEN
The system performs A501-SEND-LOG for each K1-CNT from 1 by 1 until HOLD-K1-MESSAGE is spaces or K1-CNT exceeds 999
Context: A K1 error message exists and is not spaces
GIVEN
A K1 error message exists and is not spaces
Applied to: Set Message Details for K1 Entry
WHEN
An individual K1 log entry needs to be prepared
THEN
The system moves log information to GCX105, sets the train or cargo identifier, sets the appropriate entity type flag, sets action code to 'ZZZ', and moves the specific K1 message to GCX105-MESSAGE
Context: A K1 error log entry has been prepared
GIVEN
A K1 error log entry has been prepared
Applied to: Send K1 Log Entry via GCT1051E
WHEN
The K1 error log needs to be transmitted
THEN
The system calls Z300-SPAWN-GCT1051E to send the K1 error log entry using GCT1051E transaction
R-GCX015-cbl-00133 (+14) File: GCX015.cbl Process K1 Error Messages Merged 15 Rules
Validation Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Process K1 Error Messages':
  • Context - a k1 segment is detected in the message processing loop:
    For K1 Segment Detected:
    When the system processes the k1 segment entry, then the k1 segment data should be extracted and prepared for message lookup processing.
  • Context - a k1 segment contains message data in mqs-table-entry format:
    For Extract Message Number from K1-02-MSG-NUMBER:
    When the system processes the k1 segment, then the message number should be extracted from k1-02-msg-number field.
  • Context - a message number has been extracted from k1-02-msg-number:
    For Build Table Key: 'A' + Message Number:
    When the system needs to look up the message in the ms table, then the table key should be constructed by concatenating 'a' with the message number and stored in gcstbrt-key-seqid.
  • Context - a table key has been constructed for message lookup:
    For Look Up Message in MS Table:
    When the system performs the table lookup, then the system should set table id to 'ms', function code to 'gu', accept status to 'ge', clear return flags, and call the table lookup service.
  • Context - a table lookup has been performed for the message number:
    For Message Found in Table?:
    When the lookup return flag is evaluated, then if return flag equals '0' then use english text from table, otherwise use free-form message from k1 segment.
  • Context - the table lookup was successful with return flag '0':
    For Use English Text from GCSTBRT-MS-ENG-TEXT:
    When the system processes the message text, then the english text from gcstbrt-ms-eng-text should be moved to both report lines and work message fields.
  • Context - the table lookup failed with return flag not equal to '0':
    For Use Free-Form Message from K1-02-FREE-FORM-MESSAGE:
    When the system processes the message text, then the free-form message from k1-02-free-form-message should be moved to both report lines and work message fields.
  • Context - message text has been determined from either table lookup or free-form source:
    For Add Message to Report Lines:
    When the system adds the message to the report, then the message should be added to mrln-lines at the current line count position and the line counter should be incremented by 1.
  • Context - a work log message has been formatted from the processed message text:
    For Store Message in K1 Message Array:
    When the system stores the message for logging, then the work log message should be moved to hold-k1-message array at the current k1-cnt position.
  • Context - a k1 message has been processed and stored:
    For Message Number = '242'?:
    When the system checks for special message processing requirements, then if k1-02-msg-number equals '242' then proceed with c4 code processing, otherwise increment k1 counter and end processing.
  • Context - message number '242' has been detected:
    For C4 Code Available?:
    When the system checks for c4 code availability, then if ws-hold-n1009 is not spaces and not low-values then proceed with c4 code message building, otherwise skip c4 processing.
  • Context - c4 code is available in ws-hold-n1009 for message 242:
    For Build C4 Code Message:
    When the system builds the c4 code message, then the message should be constructed by concatenating 'c4 code=' with ws-hold-n1009 value and stored in work-message.
  • Context - a c4 code message has been constructed:
    For Add C4 Code to Report:
    When the system adds the c4 message to the report, then the c4 message should be moved to mrln-lines at the current line count position and the line counter should be incremented by 1.
  • Context - a c4 code message has been added to the report:
    For Store C4 Message in Array:
    When the system stores the c4 message for logging, then the work log message should be moved to hold-k1-message array at the current k1-cnt position, k1-cnt should be incremented, and ws-hold-n1009 should be cleared to spaces.
  • Context - k1 message processing has been completed:
    For Increment K1 Counter:
    When the system finalizes the k1 processing, then the k1-cnt counter should be incremented by 1.
👨‍💻 Technical ACs (Gherkin)
Context: A K1 segment is detected in the message processing loop
GIVEN
A K1 segment is detected in the message processing loop
Applied to: K1 Segment Detected
WHEN
The system processes the K1 segment entry
THEN
The K1 segment data should be extracted and prepared for message lookup processing
Context: A K1 segment contains message data in MQS-TABLE-ENTRY format
GIVEN
A K1 segment contains message data in MQS-TABLE-ENTRY format
Applied to: Extract Message Number from K1-02-MSG-NUMBER
WHEN
The system processes the K1 segment
THEN
The message number should be extracted from K1-02-MSG-NUMBER field
Context: A message number has been extracted from K1-02-MSG-NUMBER
GIVEN
A message number has been extracted from K1-02-MSG-NUMBER
Applied to: Build Table Key: 'A' + Message Number
WHEN
The system needs to look up the message in the MS table
THEN
The table key should be constructed by concatenating 'A' with the message number and stored in GCSTBRT-KEY-SEQID
Context: A table key has been constructed for message lookup
GIVEN
A table key has been constructed for message lookup
Applied to: Look Up Message in MS Table
WHEN
The system performs the table lookup
THEN
The system should set table ID to 'MS', function code to 'GU', accept status to 'GE', clear return flags, and call the table lookup service
Context: A table lookup has been performed for the message number
GIVEN
A table lookup has been performed for the message number
Applied to: Message Found in Table?
WHEN
The lookup return flag is evaluated
THEN
If return flag equals '0' then use English text from table, otherwise use free-form message from K1 segment
Context: The table lookup was successful with return flag '0'
GIVEN
The table lookup was successful with return flag '0'
Applied to: Use English Text from GCSTBRT-MS-ENG-TEXT
WHEN
The system processes the message text
THEN
The English text from GCSTBRT-MS-ENG-TEXT should be moved to both report lines and work message fields
Context: The table lookup failed with return flag not equal to '0'
GIVEN
The table lookup failed with return flag not equal to '0'
Applied to: Use Free-Form Message from K1-02-FREE-FORM-MESSAGE
WHEN
The system processes the message text
THEN
The free-form message from K1-02-FREE-FORM-MESSAGE should be moved to both report lines and work message fields
Context: Message text has been determined from either table lookup or free-form source
GIVEN
Message text has been determined from either table lookup or free-form source
Applied to: Add Message to Report Lines
WHEN
The system adds the message to the report
THEN
The message should be added to MRLN-LINES at the current line count position and the line counter should be incremented by 1
Context: A work log message has been formatted from the processed message text
GIVEN
A work log message has been formatted from the processed message text
Applied to: Store Message in K1 Message Array
WHEN
The system stores the message for logging
THEN
The work log message should be moved to HOLD-K1-MESSAGE array at the current K1-CNT position
Context: A K1 message has been processed and stored
GIVEN
A K1 message has been processed and stored
Applied to: Message Number = '242'?
WHEN
The system checks for special message processing requirements
THEN
If K1-02-MSG-NUMBER equals '242' then proceed with C4 code processing, otherwise increment K1 counter and end processing
Context: Message number '242' has been detected
GIVEN
Message number '242' has been detected
Applied to: C4 Code Available?
WHEN
The system checks for C4 code availability
THEN
If WS-HOLD-N1009 is not spaces and not low-values then proceed with C4 code message building, otherwise skip C4 processing
Context: C4 code is available in WS-HOLD-N1009 for message 242
GIVEN
C4 code is available in WS-HOLD-N1009 for message 242
Applied to: Build C4 Code Message
WHEN
The system builds the C4 code message
THEN
The message should be constructed by concatenating 'C4 CODE=' with WS-HOLD-N1009 value and stored in WORK-MESSAGE
Context: A C4 code message has been constructed
GIVEN
A C4 code message has been constructed
Applied to: Add C4 Code to Report
WHEN
The system adds the C4 message to the report
THEN
The C4 message should be moved to MRLN-LINES at the current line count position and the line counter should be incremented by 1
Context: A C4 code message has been added to the report
GIVEN
A C4 code message has been added to the report
Applied to: Store C4 Message in Array
WHEN
The system stores the C4 message for logging
THEN
The work log message should be moved to HOLD-K1-MESSAGE array at the current K1-CNT position, K1-CNT should be incremented, and WS-HOLD-N1009 should be cleared to spaces
Context: K1 message processing has been completed
GIVEN
K1 message processing has been completed
Applied to: Increment K1 Counter
WHEN
The system finalizes the K1 processing
THEN
The K1-CNT counter should be incremented by 1
R-GCX015-cbl-00148 (+8) File: GCX015.cbl Retrieve Cargo Records Merged 9 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Retrieve Cargo Records':
  • Context - the system is starting cargo record retrieval process:
    For Set Cargo Found Flag:
    When the cargo retrieval operation begins, then the cargo found flag (88-uscargo-train-found) should be set to true.
  • Context - the system needs to retrieve cargo records from the database:
    For Initialize Cargo Segment:
    When the cargo retrieval process is initiated, then the cargo segment (gcsusrt-segment) should be initialized with spaces.
    For Set Database Function to GET:
    When setting up the database operation parameters, then the database function should be set to get (gcwusio-func-gu) and segment type should be set to cargo segment (gcwusio-seg-gcsusrt) and index usage should be set to not used (gcwusio-index-not-used).
  • Context - the system has processed message data containing cargo identification information:
    For Set US-CCN-KEY from Message Data:
    When preparing to search for cargo records in the database, then the cargo search key (gcusrt-us-ccn-key) should be set to the message data value (work-m10-12-data).
  • Context - the database operation parameters are configured and the search key is set:
    For Call Database to Get Cargo Record:
    When executing the cargo record retrieval, then the system should call the database interface (gccusio) with the communication control block, operation parameters, and cargo segment.
  • Context - the database retrieval operation has been executed:
    For Cargo Record Found?:
    When checking the result of the cargo record retrieval, then if the status code (cc-status-code) is not spaces, the cargo record was not found, otherwise the cargo record was found successfully.
  • Context - the cargo record retrieval operation returned a non-space status code indicating record not found:
    For Set Cargo Not Found Flag:
    When processing the failed cargo record lookup, then the cargo not found flag (88-uscargo-train-notfnd) should be set to true.
  • Context - the cargo record was not found in the database:
    For Add Error Message to Report:
    When handling the cargo record not found condition, then an error message 'this us-ccn-key was not found: ' should be added to the report lines and the line count should be incremented by 1.
  • Context - the cargo record has been successfully retrieved from the database:
    For Set Merlin Keys for Reporting:
    When setting up reporting keys for the found cargo record, then the merlin key should be set to the message data value (work-m10-12-data) and the merlin sub-key should be set to the cargo equipment car number (gcusrt-rt081-equipment-car).
👨‍💻 Technical ACs (Gherkin)
Context: The system is starting cargo record retrieval process
GIVEN
The system is starting cargo record retrieval process
Applied to: Set Cargo Found Flag
WHEN
The cargo retrieval operation begins
THEN
The cargo found flag (88-USCARGO-TRAIN-FOUND) should be set to true
Context: The system needs to retrieve cargo records from the database
GIVEN
The system needs to retrieve cargo records from the database
Applied to: Initialize Cargo Segment
WHEN
The cargo retrieval process is initiated
THEN
The cargo segment (GCSUSRT-SEGMENT) should be initialized with spaces
Applied to: Set Database Function to GET
WHEN
Setting up the database operation parameters
THEN
The database function should be set to GET (GCWUSIO-FUNC-GU) and segment type should be set to cargo segment (GCWUSIO-SEG-GCSUSRT) and index usage should be set to not used (GCWUSIO-INDEX-NOT-USED)
Context: The system has processed message data containing cargo identification information
GIVEN
The system has processed message data containing cargo identification information
Applied to: Set US-CCN-KEY from Message Data
WHEN
Preparing to search for cargo records in the database
THEN
The cargo search key (GCUSRT-US-CCN-KEY) should be set to the message data value (WORK-M10-12-DATA)
Context: The database operation parameters are configured and the search key is set
GIVEN
The database operation parameters are configured and the search key is set
Applied to: Call Database to Get Cargo Record
WHEN
Executing the cargo record retrieval
THEN
The system should call the database interface (GCCUSIO) with the communication control block, operation parameters, and cargo segment
Context: The database retrieval operation has been executed
GIVEN
The database retrieval operation has been executed
Applied to: Cargo Record Found?
WHEN
Checking the result of the cargo record retrieval
THEN
If the status code (CC-STATUS-CODE) is not spaces, the cargo record was not found, otherwise the cargo record was found successfully
Context: The cargo record retrieval operation returned a non-space status code indicating record not found
GIVEN
The cargo record retrieval operation returned a non-space status code indicating record not found
Applied to: Set Cargo Not Found Flag
WHEN
Processing the failed cargo record lookup
THEN
The cargo not found flag (88-USCARGO-TRAIN-NOTFND) should be set to true
Context: The cargo record was not found in the database
GIVEN
The cargo record was not found in the database
Applied to: Add Error Message to Report
WHEN
Handling the cargo record not found condition
THEN
An error message 'THIS US-CCN-KEY WAS NOT FOUND: ' should be added to the report lines and the line count should be incremented by 1
Context: The cargo record has been successfully retrieved from the database
GIVEN
The cargo record has been successfully retrieved from the database
Applied to: Set Merlin Keys for Reporting
WHEN
Setting up reporting keys for the found cargo record
THEN
The Merlin key should be set to the message data value (WORK-M10-12-DATA) and the Merlin sub-key should be set to the cargo equipment car number (GCUSRT-RT081-EQUIPMENT-CAR)
R-GCX015-cbl-00157 (+8) File: GCX015.cbl Retrieve Train Records Merged 9 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Retrieve Train Records':
  • Context - a train record retrieval process needs to be started:
    For Start Train Record Retrieval:
    When the train record retrieval section is invoked, then the system should set the train found flag to true and initialize database access parameters.
  • Context - a train record lookup is about to be performed:
    For Set Train Found Flag:
    When the train retrieval process begins, then the system should set the train found flag to true as the default state.
  • Context - a train record needs to be retrieved from the database:
    For Configure Database Access Parameters:
    When database access parameters are being configured, then the system should set the function code to get, set root-only access, set equal search criteria, and assign the appropriate pcb.
  • Context - message data contains a train identifier:
    For Set US-CUST-TRAIN-ID from Message Data:
    When setting up the database search criteria, then the system should move the work message data to the train list us customer train id field.
  • Context - database access parameters are configured and train id is set:
    For Call Database to Get Train Record:
    When the database lookup is executed, then the system should call the database utility program with the common communication area, database parameters, and train list structure.
  • Context - a database lookup for a train record has been executed:
    For Train Record Found?:
    When checking the result of the database call, then the system should evaluate if the status code is not spaces to determine if the record was found.
  • Context - a train database lookup has been performed:
    For Set Train Not Found Flag:
    When the database status code indicates the record was not found, then the system should set the train not found flag to true.
  • Context - a train record lookup has failed:
    For Log Train ID Not Found Error:
    When the train id is not found in the database, then the system should move the message 'this us-train-id was not found: ' to the error report line and increment the line counter.
  • Context - a train record has been successfully retrieved from the database:
    For Set Merlin Keys for Logging:
    When setting up logging information, then the system should move the work message data to the merlin key and move the train id to the merlin sub-key.
👨‍💻 Technical ACs (Gherkin)
Context: A train record retrieval process needs to be started
GIVEN
A train record retrieval process needs to be started
Applied to: Start Train Record Retrieval
WHEN
The train record retrieval section is invoked
THEN
The system should set the train found flag to true and initialize database access parameters
Context: A train record lookup is about to be performed
GIVEN
A train record lookup is about to be performed
Applied to: Set Train Found Flag
WHEN
The train retrieval process begins
THEN
The system should set the train found flag to true as the default state
Context: A train record needs to be retrieved from the database
GIVEN
A train record needs to be retrieved from the database
Applied to: Configure Database Access Parameters
WHEN
Database access parameters are being configured
THEN
The system should set the function code to GET, set root-only access, set equal search criteria, and assign the appropriate PCB
Context: Message data contains a train identifier
GIVEN
Message data contains a train identifier
Applied to: Set US-CUST-TRAIN-ID from Message Data
WHEN
Setting up the database search criteria
THEN
The system should move the work message data to the train list US customer train ID field
Context: Database access parameters are configured and train ID is set
GIVEN
Database access parameters are configured and train ID is set
Applied to: Call Database to Get Train Record
WHEN
The database lookup is executed
THEN
The system should call the database utility program with the common communication area, database parameters, and train list structure
Context: A database lookup for a train record has been executed
GIVEN
A database lookup for a train record has been executed
Applied to: Train Record Found?
WHEN
Checking the result of the database call
THEN
The system should evaluate if the status code is not spaces to determine if the record was found
Context: A train database lookup has been performed
GIVEN
A train database lookup has been performed
Applied to: Set Train Not Found Flag
WHEN
The database status code indicates the record was not found
THEN
The system should set the train not found flag to true
Context: A train record lookup has failed
GIVEN
A train record lookup has failed
Applied to: Log Train ID Not Found Error
WHEN
The train ID is not found in the database
THEN
The system should move the message 'THIS US-TRAIN-ID WAS NOT FOUND: ' to the error report line and increment the line counter
Context: A train record has been successfully retrieved from the database
GIVEN
A train record has been successfully retrieved from the database
Applied to: Set Merlin Keys for Logging
WHEN
Setting up logging information
THEN
The system should move the work message data to the Merlin key and move the train ID to the Merlin sub-key
R-GCX015-cbl-00166 (+4) File: GCX015.cbl Update Train Status Merged 5 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Update Train Status':
  • Context - a train record exists with deleted status and the message contains ack status:
    For Set Status to DELETED:
    When the train status update process is executed, then the train current status should be set to deleted, security fields should be cleared, and the train record should be updated.
  • Context - a train record exists with delete-pending status and the message contains ack status:
    For Set Status to DELETED:
    When the train status update process is executed, then the train current status should be set to deleted and the train record should be updated.
  • Context - a train record exists that is not deleted and not delete-pending:
    For Set Status from Message:
    When the train status update process is executed, then the train current status should be updated with the status from the message and the train record should be updated.
  • Context - a train record has ack status and arrived-pending flag is set:
    For Process Automatic Arrival:
    When the train status update process completes, then the automatic train arrival process should be triggered.
  • Context - a train record has been updated with normal status (not deleted or delete pending):
    For Check AEI Qualification:
    When the train status update process continues, then the system should check if the train meets aei send requirements and process accordingly.
👨‍💻 Technical ACs (Gherkin)
Context: A train record exists with DELETED status and the message contains ACK status
GIVEN
A train record exists with DELETED status and the message contains ACK status
Applied to: Set Status to DELETED
WHEN
The train status update process is executed
THEN
The train current status should be set to DELETED, security fields should be cleared, and the train record should be updated
Context: A train record exists with DELETE-PENDING status and the message contains ACK status
GIVEN
A train record exists with DELETE-PENDING status and the message contains ACK status
Applied to: Set Status to DELETED
WHEN
The train status update process is executed
THEN
The train current status should be set to DELETED and the train record should be updated
Context: A train record exists that is not DELETED and not DELETE-PENDING
GIVEN
A train record exists that is not DELETED and not DELETE-PENDING
Applied to: Set Status from Message
WHEN
The train status update process is executed
THEN
The train current status should be updated with the status from the message and the train record should be updated
Context: A train record has ACK status and ARRIVED-PENDING flag is set
GIVEN
A train record has ACK status and ARRIVED-PENDING flag is set
Applied to: Process Automatic Arrival
WHEN
The train status update process completes
THEN
The automatic train arrival process should be triggered
Context: A train record has been updated with normal status (not deleted or delete pending)
GIVEN
A train record has been updated with normal status (not deleted or delete pending)
Applied to: Check AEI Qualification
WHEN
The train status update process continues
THEN
The system should check if the train meets AEI send requirements and process accordingly
R-GCX015-cbl-00171 (+5) File: GCX015.cbl Update Cargo Status Merged 6 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Update Cargo Status':
  • Context - a cargo status update is being processed and the final status is ack and there is a saved status description in the save area:
    For Restore Previous Status from Save Area:
    When the cargo status update is executed, then the saved status is moved to the current uscargo status and the saved status description is moved to the current uscargo short description.
  • Context - a cargo status update is being processed and the final status is ack and there is no saved status description in the save area:
    For Set Status to USCARGO-ACK:
    When the cargo status update is executed, then the uscargo status flag is set to ack and the uscargo short description flag is set to ack.
  • Context - a cargo status update is being processed and the final status is error and the current uscargo short description is not error and not ack and not ack-r:
    For Save Current Status to Save Area:
    When the cargo status update is executed, then the current uscargo status is moved to the save status area and the current uscargo short description is moved to the save status description area.
  • Context - a cargo status update is being processed and the final status is error and the cpcargo status is not deleted:
    For Set Cargo Status to ERROR:
    When the cargo status update is executed, then the cpcargo status flag is set to error.
  • Context - a cargo status update is being processed and the final status is error:
    For Set US Cargo Status to ERROR:
    When the cargo status update is executed, then the uscargo status flag is set to error and the uscargo short description flag is set to error.
  • Context - cargo status flags have been updated:
    For Update Cargo Record in Database:
    When the cargo record update is requested, then the gcsusrt segment is updated using replace function through the gccusio service.
👨‍💻 Technical ACs (Gherkin)
Context: A cargo status update is being processed AND the final status is ACK AND there is a saved status description in the save area
GIVEN
A cargo status update is being processed AND the final status is ACK AND there is a saved status description in the save area
Applied to: Restore Previous Status from Save Area
WHEN
The cargo status update is executed
THEN
The saved status is moved to the current USCARGO status AND the saved status description is moved to the current USCARGO short description
Context: A cargo status update is being processed AND the final status is ACK AND there is no saved status description in the save area
GIVEN
A cargo status update is being processed AND the final status is ACK AND there is no saved status description in the save area
Applied to: Set Status to USCARGO-ACK
WHEN
The cargo status update is executed
THEN
The USCARGO status flag is set to ACK AND the USCARGO short description flag is set to ACK
Context: A cargo status update is being processed AND the final status is ERROR AND the current USCARGO short description is not ERROR AND not ACK AND not ACK-R
GIVEN
A cargo status update is being processed AND the final status is ERROR AND the current USCARGO short description is not ERROR AND not ACK AND not ACK-R
Applied to: Save Current Status to Save Area
WHEN
The cargo status update is executed
THEN
The current USCARGO status is moved to the save status area AND the current USCARGO short description is moved to the save status description area
Context: A cargo status update is being processed AND the final status is ERROR AND the CPCARGO status is not DELETED
GIVEN
A cargo status update is being processed AND the final status is ERROR AND the CPCARGO status is not DELETED
Applied to: Set Cargo Status to ERROR
WHEN
The cargo status update is executed
THEN
The CPCARGO status flag is set to ERROR
Context: A cargo status update is being processed AND the final status is ERROR
GIVEN
A cargo status update is being processed AND the final status is ERROR
Applied to: Set US Cargo Status to ERROR
WHEN
The cargo status update is executed
THEN
The USCARGO status flag is set to ERROR AND the USCARGO short description flag is set to ERROR
Context: Cargo status flags have been updated
GIVEN
Cargo status flags have been updated
Applied to: Update Cargo Record in Database
WHEN
The cargo record update is requested
THEN
The GCSUSRT segment is updated using replace function through the GCCUSIO service
R-GCX015-cbl-00177 (+8) File: GCX015.cbl Check AEI Train Qualification Merged 9 Rules
Validation Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Check AEI Train Qualification':
  • Context - a train record exists in the system:
    For Train Status = ACK?:
    When the system checks the train's current status for aei qualification, then the train must have ack status to qualify for aei processing, otherwise it does not qualify.
  • Context - a train record with ack status exists:
    For Train Configured for AEI Send?:
    When the system evaluates the train's aei send configuration, then the train must have aei-send flag set to true to proceed with full aei processing.
  • Context - a train with ack status and aei send configuration enabled:
    For Train Enroute Not Yet Reported?:
    When the system checks if the train's enroute status has been reported, then the train must have enroute-not-reported status to qualify for customs transaction processing.
  • Context - a train with ack status, aei send enabled, and enroute not reported:
    For Train ID Suffix = 'T'?:
    When the system examines the train id suffix at position 23, then the train id must end with 't' to qualify for full aei customs transaction processing.
  • Context - a train qualifies for aei processing with all validation criteria met:
    For Set Up Customs Transaction Data:
    When the system sets up customs transaction data, then the system must populate transaction code as 'gct1461e', security as high-values, customer code as 'a', and map train details to customs fields including train id, stations, consist number, date and time.
  • Context - customs transaction data is set up for a qualified train:
    For Load Train Car Information:
    When the system loads car information from the train consist, then the system must process each car excluding container indicators 'c', extract equipment initials and numbers, determine loaded/empty status based on next car's container indicator, map equipment types (lo to l, et to e), and limit processing to maximum 500 cars.
  • Context - train car information has been loaded into the customs transaction:
    For Send AEI Status Message:
    When the system submits the customs transaction, then the system must call cims to change message format, call writmsgl to send the customs transaction with message code 's', and call cims to purge the transaction.
  • Context - a train has aei-send configuration enabled but does not meet all qualification criteria for customs processing:
    For Send AEI Status Message Only:
    When the system processes aei status messaging, then the system must retrieve aei merlin id, format status message with train id and current status, and send via merlin messaging system.
  • Context - a train has ack status, aei send enabled, and enroute already reported:
    For Send AEI Status Message Only:
    When the system processes terminal enroute notifications, then the system must retrieve aei merlin id, format enroute message with train id, and send notification via merlin messaging system.
👨‍💻 Technical ACs (Gherkin)
Context: A train record exists in the system
GIVEN
A train record exists in the system
Applied to: Train Status = ACK?
WHEN
The system checks the train's current status for AEI qualification
THEN
The train must have ACK status to qualify for AEI processing, otherwise it does not qualify
Context: A train record with ACK status exists
GIVEN
A train record with ACK status exists
Applied to: Train Configured for AEI Send?
WHEN
The system evaluates the train's AEI send configuration
THEN
The train must have AEI-SEND flag set to true to proceed with full AEI processing
Context: A train with ACK status and AEI send configuration enabled
GIVEN
A train with ACK status and AEI send configuration enabled
Applied to: Train Enroute Not Yet Reported?
WHEN
The system checks if the train's enroute status has been reported
THEN
The train must have ENROUTE-NOT-REPORTED status to qualify for customs transaction processing
Context: A train with ACK status, AEI send enabled, and enroute not reported
GIVEN
A train with ACK status, AEI send enabled, and enroute not reported
Applied to: Train ID Suffix = 'T'?
WHEN
The system examines the train ID suffix at position 23
THEN
The train ID must end with 'T' to qualify for full AEI customs transaction processing
Context: A train qualifies for AEI processing with all validation criteria met
GIVEN
A train qualifies for AEI processing with all validation criteria met
Applied to: Set Up Customs Transaction Data
WHEN
The system sets up customs transaction data
THEN
The system must populate transaction code as 'GCT1461E', security as HIGH-VALUES, customer code as 'A', and map train details to customs fields including train ID, stations, consist number, date and time
Context: Customs transaction data is set up for a qualified train
GIVEN
Customs transaction data is set up for a qualified train
Applied to: Load Train Car Information
WHEN
The system loads car information from the train consist
THEN
The system must process each car excluding container indicators 'C', extract equipment initials and numbers, determine loaded/empty status based on next car's container indicator, map equipment types (LO to L, ET to E), and limit processing to maximum 500 cars
Context: Train car information has been loaded into the customs transaction
GIVEN
Train car information has been loaded into the customs transaction
Applied to: Send AEI Status Message
WHEN
The system submits the customs transaction
THEN
The system must call CIMS to change message format, call WRITMSGL to send the customs transaction with message code 'S', and call CIMS to purge the transaction
Context: A train has AEI-SEND configuration enabled but does not meet all qualification criteria for customs processing
GIVEN
A train has AEI-SEND configuration enabled but does not meet all qualification criteria for customs processing
Applied to: Send AEI Status Message Only
WHEN
The system processes AEI status messaging
THEN
The system must retrieve AEI Merlin ID, format status message with train ID and current status, and send via Merlin messaging system
Context: A train has ACK status, AEI send enabled, and enroute already reported
GIVEN
A train has ACK status, AEI send enabled, and enroute already reported
Applied to: Send AEI Status Message Only
WHEN
The system processes terminal enroute notifications
THEN
The system must retrieve AEI Merlin ID, format enroute message with train ID, and send notification via Merlin messaging system
R-GCX015-cbl-00186 (+10) File: GCX015.cbl Load Train Car Information Merged 11 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Load Train Car Information':
  • Context - a train equipment record is being processed for aei customs reporting:
    For Is Current Equipment a Container?:
    When the equipment has a container indicator of 'c', then the equipment should be skipped and the processing should move to the next equipment record.
  • Context - a non-container equipment record is being processed:
    For Extract Car Initial from Equipment:
    When the equipment initial field contains valid data, then the equipment initial should be moved to the customs car initial field.
    For Get Loaded/Empty Status from Current Car:
    When the next equipment record is not a container or does not exist, then the current equipment's own loaded/empty status indicator should be used for customs reporting.
  • Context - a non-container equipment record with equipment number is being processed:
    For Extract Car Number from Equipment:
    When the equipment number field contains valid data, then the equipment number should be extracted and converted to a 6-digit car number format for customs output.
  • Context - a non-container equipment record is being processed and there is a next equipment record in the sequence:
    For Is Next Equipment a Container?:
    When the next equipment record has a container indicator of 'c', then the current equipment's loaded/empty status should be set to 'l' (loaded).
  • Context - a non-container equipment record is being processed for customs reporting:
    For Equipment Type = 'LO'?:
    When the equipment type is 'lo', then the car kind should be set to 'l' for locomotive.
    For Set Car Kind as Spaces:
    When the equipment type is neither 'lo' nor 'et', then the car kind should be set to spaces.
  • Context - a non-container equipment record is being processed for customs reporting and the equipment type is not 'lo':
    For Equipment Type = 'ET'?:
    When the equipment type is 'et', then the car kind should be set to 'e' for engine.
  • Context - a non-container equipment record has been processed with all required fields populated:
    For Add Car to Customs Output Table:
    When the car initial, number, loaded/empty status, and car kind have been determined, then the complete car information should be added to the customs output table for transmission.
  • Context - a non-container equipment record has been successfully added to the customs output table:
    For Increment Car Counter:
    When the car information has been stored, then the car counter should be incremented by 1 to maintain accurate count.
  • Context - equipment records are being processed for aei customs reporting:
    For More Equipment to Process?:
    When the current equipment record processing is complete and there are more equipment records in the train consist, then processing should continue with the next equipment record in sequence.
👨‍💻 Technical ACs (Gherkin)
Context: A train equipment record is being processed for AEI customs reporting
GIVEN
A train equipment record is being processed for AEI customs reporting
Applied to: Is Current Equipment a Container?
WHEN
The equipment has a container indicator of 'C'
THEN
The equipment should be skipped and the processing should move to the next equipment record
Context: A non-container equipment record is being processed
GIVEN
A non-container equipment record is being processed
Applied to: Extract Car Initial from Equipment
WHEN
The equipment initial field contains valid data
THEN
The equipment initial should be moved to the customs car initial field
Applied to: Get Loaded/Empty Status from Current Car
WHEN
The next equipment record is not a container or does not exist
THEN
The current equipment's own loaded/empty status indicator should be used for customs reporting
Context: A non-container equipment record with equipment number is being processed
GIVEN
A non-container equipment record with equipment number is being processed
Applied to: Extract Car Number from Equipment
WHEN
The equipment number field contains valid data
THEN
The equipment number should be extracted and converted to a 6-digit car number format for customs output
Context: A non-container equipment record is being processed and there is a next equipment record in the sequence
GIVEN
A non-container equipment record is being processed and there is a next equipment record in the sequence
Applied to: Is Next Equipment a Container?
WHEN
The next equipment record has a container indicator of 'C'
THEN
The current equipment's loaded/empty status should be set to 'L' (Loaded)
Context: A non-container equipment record is being processed for customs reporting
GIVEN
A non-container equipment record is being processed for customs reporting
Applied to: Equipment Type = 'LO'?
WHEN
The equipment type is 'LO'
THEN
The car kind should be set to 'L' for locomotive
Applied to: Set Car Kind as Spaces
WHEN
The equipment type is neither 'LO' nor 'ET'
THEN
The car kind should be set to spaces
Context: A non-container equipment record is being processed for customs reporting and the equipment type is not 'LO'
GIVEN
A non-container equipment record is being processed for customs reporting and the equipment type is not 'LO'
Applied to: Equipment Type = 'ET'?
WHEN
The equipment type is 'ET'
THEN
The car kind should be set to 'E' for engine
Context: A non-container equipment record has been processed with all required fields populated
GIVEN
A non-container equipment record has been processed with all required fields populated
Applied to: Add Car to Customs Output Table
WHEN
The car initial, number, loaded/empty status, and car kind have been determined
THEN
The complete car information should be added to the customs output table for transmission
Context: A non-container equipment record has been successfully added to the customs output table
GIVEN
A non-container equipment record has been successfully added to the customs output table
Applied to: Increment Car Counter
WHEN
The car information has been stored
THEN
The car counter should be incremented by 1 to maintain accurate count
Context: Equipment records are being processed for AEI customs reporting
GIVEN
Equipment records are being processed for AEI customs reporting
Applied to: More Equipment to Process?
WHEN
The current equipment record processing is complete and there are more equipment records in the train consist
THEN
Processing should continue with the next equipment record in sequence
R-GCX015-cbl-00197 (+6) File: GCX015.cbl Send AEI Status Messages Merged 7 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Send AEI Status Messages':
  • Context - a train requires aei status notification and train has a port location in secx field:
    For Get AEI Merlin Recipients:
    When system queries aei email database using the train's port location as the key, then system retrieves list of email recipients associated with that port location.
  • Context - aei email database query returns no recipients for the train's port location or database query fails with no-entry status:
    For Use Default Merlin ID:
    When system processes the empty or failed query result, then system assigns default merlin id as both sender and recipient for the status message.
  • Context - a train has a valid train id and current status that needs to be communicated:
    For Format Train Status Message:
    When system prepares aei status message, then system formats message subject as 'train: [train-id] status: [current-status]' and clears message text content.
  • Context - a formatted train status message with designated recipients:
    For Send Message via Merlin System:
    When system calls merlin send service with message details, then system transmits message and receives confirmation of delivery status.
  • Context - primary merlin message send has failed:
    For Retry Send to Backup Recipients:
    When system detects send failure, then system retries send operation using backup recipient list including aei9999 and om01247 as fallback recipients.
  • Context - both primary and backup merlin message sends have failed:
    For Log Send Failure Error:
    When system detects final send failure, then system logs error message 'send to file of om01247 failed' for operational review.
  • Context - aei email database query fails due to database connection or system error:
    For Get AEI Merlin Recipients:
    When system receives database error response that is not a simple no-entry condition, then system logs database error with sql code information and continues processing using default merlin id.
👨‍💻 Technical ACs (Gherkin)
Context: A train requires AEI status notification and train has a port location in SECX field
GIVEN
A train requires AEI status notification and train has a port location in SECX field
Applied to: Get AEI Merlin Recipients
WHEN
System queries AEI email database using the train's port location as the key
THEN
System retrieves list of email recipients associated with that port location
Context: AEI email database query returns no recipients for the train's port location OR database query fails with no-entry status
GIVEN
AEI email database query returns no recipients for the train's port location OR database query fails with no-entry status
Applied to: Use Default Merlin ID
WHEN
System processes the empty or failed query result
THEN
System assigns default Merlin ID as both sender and recipient for the status message
Context: A train has a valid train ID and current status that needs to be communicated
GIVEN
A train has a valid train ID and current status that needs to be communicated
Applied to: Format Train Status Message
WHEN
System prepares AEI status message
THEN
System formats message subject as 'TRAIN: [train-id] STATUS: [current-status]' and clears message text content
Context: A formatted train status message with designated recipients
GIVEN
A formatted train status message with designated recipients
Applied to: Send Message via Merlin System
WHEN
System calls Merlin send service with message details
THEN
System transmits message and receives confirmation of delivery status
Context: Primary Merlin message send has failed
GIVEN
Primary Merlin message send has failed
Applied to: Retry Send to Backup Recipients
WHEN
System detects send failure
THEN
System retries send operation using backup recipient list including AEI9999 and OM01247 as fallback recipients
Context: Both primary and backup Merlin message sends have failed
GIVEN
Both primary and backup Merlin message sends have failed
Applied to: Log Send Failure Error
WHEN
System detects final send failure
THEN
System logs error message 'SEND TO FILE OF OM01247 FAILED' for operational review
Context: AEI email database query fails due to database connection or system error
GIVEN
AEI email database query fails due to database connection or system error
Applied to: Get AEI Merlin Recipients
WHEN
System receives database error response that is not a simple no-entry condition
THEN
System logs database error with SQL code information and continues processing using default Merlin ID
R-GCX015-cbl-00204 (+7) File: GCX015.cbl Send Terminal Status Messages Merged 8 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Send Terminal Status Messages':
  • Context - a train record exists in the system:
    For Check Terminal Status Conditions:
    When the system evaluates terminal status message requirements, then the train must have ack status and aei send qualification and enroute already reported status to proceed with terminal messaging.
  • Context - a train record is being evaluated for terminal status messaging:
    For Train ACK Status?:
    When the system checks the train's acknowledgment status, then the train must have ack status to continue with terminal status processing, otherwise terminate the process.
  • Context - a train has ack status:
    For AEI Send Qualified?:
    When the system evaluates aei send qualification, then the train must have aei send flag enabled to proceed with terminal status messaging.
  • Context - a train has ack status and aei send qualification:
    For Enroute Already Reported?:
    When the system checks the enroute reporting status, then the train must have enroute already reported status to proceed with terminal status messaging.
  • Context - a train qualifies for terminal status messaging:
    For Get AEI Merlin Distribution List:
    When the system needs to determine message recipients, then the system retrieves the aei merlin distribution list using the train's security port information, defaulting to standard recipients if no specific list is found.
  • Context - a train qualifies for terminal status messaging and distribution list is retrieved:
    For Format Enroute Status Message:
    When the system formats the enroute status message, then the system creates a standardized enroute message format using the predefined enroute message template.
  • Context - an enroute status message is formatted:
    For Set Train ID in Message:
    When the system assigns train identification to the message, then the system sets the train's customer train id as the subject identifier in the enroute status message.
  • Context - an enroute status message is formatted with train id and distribution list is available:
    For Send Status Message to Terminal Systems:
    When the system transmits the terminal status message, then the system sends the enroute status message through the merlin messaging system to the designated recipients.
👨‍💻 Technical ACs (Gherkin)
Context: A train record exists in the system
GIVEN
A train record exists in the system
Applied to: Check Terminal Status Conditions
WHEN
The system evaluates terminal status message requirements
THEN
The train must have ACK status AND AEI send qualification AND enroute already reported status to proceed with terminal messaging
Context: A train record is being evaluated for terminal status messaging
GIVEN
A train record is being evaluated for terminal status messaging
Applied to: Train ACK Status?
WHEN
The system checks the train's acknowledgment status
THEN
The train must have ACK status to continue with terminal status processing, otherwise terminate the process
Context: A train has ACK status
GIVEN
A train has ACK status
Applied to: AEI Send Qualified?
WHEN
The system evaluates AEI send qualification
THEN
The train must have AEI send flag enabled to proceed with terminal status messaging
Context: A train has ACK status and AEI send qualification
GIVEN
A train has ACK status and AEI send qualification
Applied to: Enroute Already Reported?
WHEN
The system checks the enroute reporting status
THEN
The train must have enroute already reported status to proceed with terminal status messaging
Context: A train qualifies for terminal status messaging
GIVEN
A train qualifies for terminal status messaging
Applied to: Get AEI Merlin Distribution List
WHEN
The system needs to determine message recipients
THEN
The system retrieves the AEI Merlin distribution list using the train's security port information, defaulting to standard recipients if no specific list is found
Context: A train qualifies for terminal status messaging and distribution list is retrieved
GIVEN
A train qualifies for terminal status messaging and distribution list is retrieved
Applied to: Format Enroute Status Message
WHEN
The system formats the enroute status message
THEN
The system creates a standardized enroute message format using the predefined enroute message template
Context: An enroute status message is formatted
GIVEN
An enroute status message is formatted
Applied to: Set Train ID in Message
WHEN
The system assigns train identification to the message
THEN
The system sets the train's customer train ID as the subject identifier in the enroute status message
Context: An enroute status message is formatted with train ID and distribution list is available
GIVEN
An enroute status message is formatted with train ID and distribution list is available
Applied to: Send Status Message to Terminal Systems
WHEN
The system transmits the terminal status message
THEN
The system sends the enroute status message through the Merlin messaging system to the designated recipients
R-GCX015-cbl-00212 (+11) File: GCX015.cbl Process Automatic Train Arrival Merged 12 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Process Automatic Train Arrival':
  • Context - a train record exists in the system:
    For Check Train Status Conditions:
    When the system checks the train's status for arrival processing eligibility, then the train is eligible for arrival processing only if it has both ack status and arrived-pending flag set to true.
  • Context - a train is eligible for arrival processing:
    For Initialize Train Arrival Transaction:
    When the system begins creating the arrival transaction, then the train arrival transaction data structure is cleared and prepared for population.
  • Context - a train arrival transaction is being created:
    For Set Action Code to 'TAR':
    When the system sets the transaction type, then the action code is set to 'tar' to indicate train arrival processing.
    For Get Current System Date and Time:
    When the system needs to timestamp the arrival event, then the current machine date and time are captured from the system.
    For Set Security Byte to High-Value:
    When the system sets the security configuration, then the security byte is set to high-value to indicate maximum security level.
    For Set Train Type Flag:
    When the system sets the entity type flag, then the us-train flag is set to true to distinguish this from cargo processing.
  • Context - the current system date has been captured:
    For Set Event Date from Machine Date:
    When the system assigns the event date for the arrival transaction, then the event date is set to the current machine date in yymmdd format.
  • Context - the current system time has been captured:
    For Set Event Time from Machine Time:
    When the system assigns the event time for the arrival transaction, then the event time is set to the first 4 digits of the current machine time (hhmm format).
  • Context - a train record contains a us customer train id:
    For Set Train ID from US-CUST-TRAIN-ID:
    When the system creates the arrival transaction, then the train identifier in the transaction is set to the us customer train id from the train record.
  • Context - all train arrival transaction data has been populated:
    For Build GCT1121E Message:
    When the system prepares the message for transmission, then the complete gct1121e message structure is built with all transaction data.
  • Context - a complete train arrival message has been constructed:
    For Send Train Arrival Message to Queue:
    When the system sends the message for processing, then the message is transmitted to the designated message queue using the writmsgl service.
  • Context - a train arrival message has been sent to the queue:
    For Purge Message Queue:
    When the system completes the message transmission, then the message queue is purged to clean up any temporary message data.
👨‍💻 Technical ACs (Gherkin)
Context: A train record exists in the system
GIVEN
A train record exists in the system
Applied to: Check Train Status Conditions
WHEN
The system checks the train's status for arrival processing eligibility
THEN
The train is eligible for arrival processing only if it has both ACK status and ARRIVED-PENDING flag set to true
Context: A train is eligible for arrival processing
GIVEN
A train is eligible for arrival processing
Applied to: Initialize Train Arrival Transaction
WHEN
The system begins creating the arrival transaction
THEN
The train arrival transaction data structure is cleared and prepared for population
Context: A train arrival transaction is being created
GIVEN
A train arrival transaction is being created
Applied to: Set Action Code to 'TAR'
WHEN
The system sets the transaction type
THEN
The action code is set to 'TAR' to indicate train arrival processing
Applied to: Get Current System Date and Time
WHEN
The system needs to timestamp the arrival event
THEN
The current machine date and time are captured from the system
Applied to: Set Security Byte to High-Value
WHEN
The system sets the security configuration
THEN
The security byte is set to high-value to indicate maximum security level
Applied to: Set Train Type Flag
WHEN
The system sets the entity type flag
THEN
The US-TRAIN flag is set to true to distinguish this from cargo processing
Context: The current system date has been captured
GIVEN
The current system date has been captured
Applied to: Set Event Date from Machine Date
WHEN
The system assigns the event date for the arrival transaction
THEN
The event date is set to the current machine date in YYMMDD format
Context: The current system time has been captured
GIVEN
The current system time has been captured
Applied to: Set Event Time from Machine Time
WHEN
The system assigns the event time for the arrival transaction
THEN
The event time is set to the first 4 digits of the current machine time (HHMM format)
Context: A train record contains a US customer train ID
GIVEN
A train record contains a US customer train ID
Applied to: Set Train ID from US-CUST-TRAIN-ID
WHEN
The system creates the arrival transaction
THEN
The train identifier in the transaction is set to the US customer train ID from the train record
Context: All train arrival transaction data has been populated
GIVEN
All train arrival transaction data has been populated
Applied to: Build GCT1121E Message
WHEN
The system prepares the message for transmission
THEN
The complete GCT1121E message structure is built with all transaction data
Context: A complete train arrival message has been constructed
GIVEN
A complete train arrival message has been constructed
Applied to: Send Train Arrival Message to Queue
WHEN
The system sends the message for processing
THEN
The message is transmitted to the designated message queue using the WRITMSGL service
Context: A train arrival message has been sent to the queue
GIVEN
A train arrival message has been sent to the queue
Applied to: Purge Message Queue
WHEN
The system completes the message transmission
THEN
The message queue is purged to clean up any temporary message data
R-GCX015-cbl-00224 (+5) File: GCX015.cbl Update Acknowledgment Timestamps Merged 6 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Update Acknowledgment Timestamps':
  • Context - a manifest acknowledgment needs to be processed:
    For Get T1 Administrative Table:
    When the system attempts to retrieve the t1 administrative table using table id 't1', then the t1 administrative table segment should be loaded for timestamp updates.
  • Context - the system is attempting to update acknowledgment timestamps:
    For Send Error - Table Not Found:
    When the t1 administrative table retrieval fails with a non-zero return flag, then an error message 't1 check table entry not found' should be sent and processing should terminate.
  • Context - a manifest acknowledgment is being processed and the t1 administrative table is available:
    For Update P-Type Manifest Timestamp Record Current Date/Time in T1-309-ACK:
    When the manifest type code equals 'p', then the current machine date should be recorded in positions 3-6 of t1-309-ack field, the current machine century should be recorded in positions 1-2 of t1-309-ack field, and the current machine time (first 4 digits) should be recorded in positions 9-4 of t1-309-ack field.
    For Update H-Type Manifest Timestamp Record Current Date/Time in T1-353-ACK:
    When the manifest type code equals 'h', then the current machine date should be recorded in positions 3-6 of t1-353-ack field, the current machine century should be recorded in positions 1-2 of t1-353-ack field, and the current machine time (first 4 digits) should be recorded in positions 9-4 of t1-353-ack field.
    For Update S-Type Manifest Timestamp Record Current Date/Time in T1-358-ACK:
    When the manifest type code equals 's', then the current machine date should be recorded in positions 3-6 of t1-358-ack field, the current machine century should be recorded in positions 1-2 of t1-358-ack field, and the current machine time (first 4 digits) should be recorded in positions 9-4 of t1-358-ack field.
  • Context - acknowledgment timestamps have been updated in the t1 administrative table segment:
    For Save Updated Administrative Table:
    When the timestamp update process is complete, then the updated t1 administrative table segment should be saved using the repl function code to persist the changes.
👨‍💻 Technical ACs (Gherkin)
Context: A manifest acknowledgment needs to be processed
GIVEN
A manifest acknowledgment needs to be processed
Applied to: Get T1 Administrative Table
WHEN
The system attempts to retrieve the T1 administrative table using table ID 'T1'
THEN
The T1 administrative table segment should be loaded for timestamp updates
Context: The system is attempting to update acknowledgment timestamps
GIVEN
The system is attempting to update acknowledgment timestamps
Applied to: Send Error - Table Not Found
WHEN
The T1 administrative table retrieval fails with a non-zero return flag
THEN
An error message 'T1 CHECK TABLE ENTRY NOT FOUND' should be sent and processing should terminate
Context: A manifest acknowledgment is being processed and the T1 administrative table is available
GIVEN
A manifest acknowledgment is being processed and the T1 administrative table is available
Applied to: Update P-Type Manifest Timestamp Record Current Date/Time in T1-309-ACK
WHEN
The manifest type code equals 'P'
THEN
The current machine date should be recorded in positions 3-6 of T1-309-ACK field, the current machine century should be recorded in positions 1-2 of T1-309-ACK field, and the current machine time (first 4 digits) should be recorded in positions 9-4 of T1-309-ACK field
Applied to: Update H-Type Manifest Timestamp Record Current Date/Time in T1-353-ACK
WHEN
The manifest type code equals 'H'
THEN
The current machine date should be recorded in positions 3-6 of T1-353-ACK field, the current machine century should be recorded in positions 1-2 of T1-353-ACK field, and the current machine time (first 4 digits) should be recorded in positions 9-4 of T1-353-ACK field
Applied to: Update S-Type Manifest Timestamp Record Current Date/Time in T1-358-ACK
WHEN
The manifest type code equals 'S'
THEN
The current machine date should be recorded in positions 3-6 of T1-358-ACK field, the current machine century should be recorded in positions 1-2 of T1-358-ACK field, and the current machine time (first 4 digits) should be recorded in positions 9-4 of T1-358-ACK field
Context: Acknowledgment timestamps have been updated in the T1 administrative table segment
GIVEN
Acknowledgment timestamps have been updated in the T1 administrative table segment
Applied to: Save Updated Administrative Table
WHEN
The timestamp update process is complete
THEN
The updated T1 administrative table segment should be saved using the REPL function code to persist the changes
R-GCX015-cbl-00230 (+6) File: GCX015.cbl Update Administrative Tables Merged 7 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Update Administrative Tables':
  • Context - a request to update administrative table t1 is initiated:
    For Get T1 Table Segment:
    When the system attempts to retrieve the t1 table segment, then the system must verify the table is found and accessible for updates.
  • Context - a request to update administrative table t1 is made:
    For Send Error - Table Not Found:
    When the t1 table segment cannot be found or accessed, then the system must send an error message indicating the table entry was not found and terminate the update process.
  • Context - a manifest message is being processed for administrative table updates:
    For Manifest Type?:
    When the system evaluates the manifest type code from the message, then the system must identify whether it is p-type, h-type, or s-type manifest to route to appropriate timestamp update.
  • Context - a p-type manifest message has been processed successfully:
    For Update P-Type Manifest Timestamp:
    When the system updates the t1 administrative table, then the system must set the t1-309-ack field with the current system date and time (century, date, and time components).
  • Context - an h-type manifest message has been processed successfully:
    For Update H-Type Manifest Timestamp:
    When the system updates the t1 administrative table, then the system must set the t1-353-ack field with the current system date and time (century, date, and time components).
  • Context - an s-type manifest message has been processed successfully:
    For Update S-Type Manifest Timestamp:
    When the system updates the t1 administrative table, then the system must set the t1-358-ack field with the current system date and time (century, date, and time components).
  • Context - the t1 administrative table segment has been updated with manifest acknowledgment timestamps:
    For Save Updated T1 Table Segment:
    When the system completes the timestamp update process, then the system must save the modified t1 table segment back to the administrative table storage.
👨‍💻 Technical ACs (Gherkin)
Context: A request to update administrative table T1 is initiated
GIVEN
A request to update administrative table T1 is initiated
Applied to: Get T1 Table Segment
WHEN
The system attempts to retrieve the T1 table segment
THEN
The system must verify the table is found and accessible for updates
Context: A request to update administrative table T1 is made
GIVEN
A request to update administrative table T1 is made
Applied to: Send Error - Table Not Found
WHEN
The T1 table segment cannot be found or accessed
THEN
The system must send an error message indicating the table entry was not found and terminate the update process
Context: A manifest message is being processed for administrative table updates
GIVEN
A manifest message is being processed for administrative table updates
Applied to: Manifest Type?
WHEN
The system evaluates the manifest type code from the message
THEN
The system must identify whether it is P-type, H-type, or S-type manifest to route to appropriate timestamp update
Context: A P-type manifest message has been processed successfully
GIVEN
A P-type manifest message has been processed successfully
Applied to: Update P-Type Manifest Timestamp
WHEN
The system updates the T1 administrative table
THEN
The system must set the T1-309-ACK field with the current system date and time (century, date, and time components)
Context: An H-type manifest message has been processed successfully
GIVEN
An H-type manifest message has been processed successfully
Applied to: Update H-Type Manifest Timestamp
WHEN
The system updates the T1 administrative table
THEN
The system must set the T1-353-ACK field with the current system date and time (century, date, and time components)
Context: An S-type manifest message has been processed successfully
GIVEN
An S-type manifest message has been processed successfully
Applied to: Update S-Type Manifest Timestamp
WHEN
The system updates the T1 administrative table
THEN
The system must set the T1-358-ACK field with the current system date and time (century, date, and time components)
Context: The T1 administrative table segment has been updated with manifest acknowledgment timestamps
GIVEN
The T1 administrative table segment has been updated with manifest acknowledgment timestamps
Applied to: Save Updated T1 Table Segment
WHEN
The system completes the timestamp update process
THEN
The system must save the modified T1 table segment back to the administrative table storage
R-GCX015-cbl-00237 (+14) File: GCX015.cbl Send Merlin Reports Merged 15 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Send Merlin Reports':
  • Context - an error condition has been detected during message processing:
    For Prepare Error Report Message:
    When the system needs to send error notifications, then prepare error report message with processing results and error information for transmission to merlin system.
  • Context - error report message is prepared for transmission:
    For Set Primary Merlin Recipients:
    When setting up primary merlin recipients, then set from user code to 'om01247', set primary recipient to 'om01247', and configure subject line with merlin subject information.
  • Context - primary merlin recipients are configured and error report is prepared:
    For Send to Primary Merlin Destination:
    When transmitting to primary merlin destination, then call emcsend2 service with configured parameters including from user code, destination, recipients, subject, and error report content.
  • Context - primary merlin transmission has been attempted:
    For Send Successful?:
    When checking transmission success status, then if emi-no-errors condition is true, consider transmission successful, otherwise handle as failure.
  • Context - primary merlin transmission has failed:
    For Handle Send Failure:
    When handling send failure conditions, then if emi-from-not-found, set error message 'emi - invalid merlin from' and perform abend; if emi-to-or-copy-not-found, set error message 'emi - invalid merlin to or copy' and perform abend; if emi-filename-invalid, set error message 'emi - invalid merlin filename' and perform abend.
  • Context - primary merlin transmission processing is complete:
    For Set Administrative Recipients:
    When setting up administrative recipients for secondary transmission, then clear existing recipient codes, set primary administrative recipient to gcstbrt-ad-dc-p-merlin-1 value, and set copy recipient to gcstbrt-ad-dc-p-merlin-5 value.
  • Context - administrative recipients are configured:
    For Send to Administrative Destination:
    When transmitting to administrative merlin destination, then call emcsend2 service with administrative destination filename (emi-destination-filename2) and configured administrative recipients.
  • Context - administrative merlin transmission has been attempted:
    For Admin Send Successful?:
    When checking administrative transmission success status, then if emi-no-errors condition is true, consider administrative transmission successful, otherwise handle as failure.
  • Context - administrative merlin transmission has failed:
    For Retry with Fallback Recipients:
    When handling administrative send failure conditions, then if emi-from-not-found, set error message 'emi - invalid merlin from' and perform abend; if emi-to-or-copy-not-found, set error message 'emi - invalid merlin to or copy' and perform abend; if emi-filename-invalid, set error message 'emi - invalid merlin filename' and perform abend.
  • Context - train processing is complete and aei send flag is set:
    For Prepare AEI Status Message:
    When preparing aei status message, then format subject line with 'train: ' followed by train id and ' status: ' followed by current status, then prepare message for merlin transmission.
  • Context - aei status message is prepared for transmission:
    For Get AEI Merlin Recipients:
    When retrieving aei merlin recipients, then extract port information from train security data, call aecwrktb with 'cusemail' record type to get email recipients; if successful, set default merlin id as from user and populate recipient list from database results; if no entry found, use default merlin id for both from and to users; if database error occurs, perform db2 abend processing.
  • Context - aei merlin recipients are retrieved and status message is prepared:
    For Send AEI Status to Merlin:
    When transmitting aei status to merlin, then call emcsend3 service with aei recipients, formatted subject line, and message content for transmission.
  • Context - aei status transmission has been attempted:
    For AEI Send Successful?:
    When checking aei transmission success status, then if emi-no-errors condition is true, consider aei transmission successful, otherwise handle as failure.
  • Context - aei status transmission has failed:
    For Retry AEI Send with Fallbacks:
    When retrying aei send with fallback recipients, then clear existing recipients, set fallback recipients to 'aei9999' and 'om01247', retry emcsend3 call with fallback configuration.
  • Context - aei retry transmission has been attempted with fallback recipients:
    For AEI Retry Successful?:
    When checking aei retry success status, then if emi-no-errors condition is true, consider retry successful; if still failing, set error message 'send to file of om01247 failed' and call cerr for error handling.
👨‍💻 Technical ACs (Gherkin)
Context: An error condition has been detected during message processing
GIVEN
An error condition has been detected during message processing
Applied to: Prepare Error Report Message
WHEN
The system needs to send error notifications
THEN
Prepare error report message with processing results and error information for transmission to Merlin system
Context: Error report message is prepared for transmission
GIVEN
Error report message is prepared for transmission
Applied to: Set Primary Merlin Recipients
WHEN
Setting up primary Merlin recipients
THEN
Set from user code to 'OM01247', set primary recipient to 'OM01247', and configure subject line with Merlin subject information
Context: Primary Merlin recipients are configured and error report is prepared
GIVEN
Primary Merlin recipients are configured and error report is prepared
Applied to: Send to Primary Merlin Destination
WHEN
Transmitting to primary Merlin destination
THEN
Call EMCSEND2 service with configured parameters including from user code, destination, recipients, subject, and error report content
Context: Primary Merlin transmission has been attempted
GIVEN
Primary Merlin transmission has been attempted
Applied to: Send Successful?
WHEN
Checking transmission success status
THEN
If EMI-NO-ERRORS condition is true, consider transmission successful, otherwise handle as failure
Context: Primary Merlin transmission has failed
GIVEN
Primary Merlin transmission has failed
Applied to: Handle Send Failure
WHEN
Handling send failure conditions
THEN
If EMI-FROM-NOT-FOUND, set error message 'EMI - INVALID MERLIN FROM' and perform abend; If EMI-TO-OR-COPY-NOT-FOUND, set error message 'EMI - INVALID MERLIN TO OR COPY' and perform abend; If EMI-FILENAME-INVALID, set error message 'EMI - INVALID MERLIN FILENAME' and perform abend
Context: Primary Merlin transmission processing is complete
GIVEN
Primary Merlin transmission processing is complete
Applied to: Set Administrative Recipients
WHEN
Setting up administrative recipients for secondary transmission
THEN
Clear existing recipient codes, set primary administrative recipient to GCSTBRT-AD-DC-P-MERLIN-1 value, and set copy recipient to GCSTBRT-AD-DC-P-MERLIN-5 value
Context: Administrative recipients are configured
GIVEN
Administrative recipients are configured
Applied to: Send to Administrative Destination
WHEN
Transmitting to administrative Merlin destination
THEN
Call EMCSEND2 service with administrative destination filename (EMI-DESTINATION-FILENAME2) and configured administrative recipients
Context: Administrative Merlin transmission has been attempted
GIVEN
Administrative Merlin transmission has been attempted
Applied to: Admin Send Successful?
WHEN
Checking administrative transmission success status
THEN
If EMI-NO-ERRORS condition is true, consider administrative transmission successful, otherwise handle as failure
Context: Administrative Merlin transmission has failed
GIVEN
Administrative Merlin transmission has failed
Applied to: Retry with Fallback Recipients
WHEN
Handling administrative send failure conditions
THEN
If EMI-FROM-NOT-FOUND, set error message 'EMI - INVALID MERLIN FROM' and perform abend; If EMI-TO-OR-COPY-NOT-FOUND, set error message 'EMI - INVALID MERLIN TO OR COPY' and perform abend; If EMI-FILENAME-INVALID, set error message 'EMI - INVALID MERLIN FILENAME' and perform abend
Context: Train processing is complete and AEI send flag is set
GIVEN
Train processing is complete and AEI send flag is set
Applied to: Prepare AEI Status Message
WHEN
Preparing AEI status message
THEN
Format subject line with 'TRAIN: ' followed by train ID and ' STATUS: ' followed by current status, then prepare message for Merlin transmission
Context: AEI status message is prepared for transmission
GIVEN
AEI status message is prepared for transmission
Applied to: Get AEI Merlin Recipients
WHEN
Retrieving AEI Merlin recipients
THEN
Extract port information from train security data, call AECWRKTB with 'CUSEMAIL' record type to get email recipients; If successful, set default Merlin ID as from user and populate recipient list from database results; If no entry found, use default Merlin ID for both from and to users; If database error occurs, perform DB2 abend processing
Context: AEI Merlin recipients are retrieved and status message is prepared
GIVEN
AEI Merlin recipients are retrieved and status message is prepared
Applied to: Send AEI Status to Merlin
WHEN
Transmitting AEI status to Merlin
THEN
Call EMCSEND3 service with AEI recipients, formatted subject line, and message content for transmission
Context: AEI status transmission has been attempted
GIVEN
AEI status transmission has been attempted
Applied to: AEI Send Successful?
WHEN
Checking AEI transmission success status
THEN
If EMI-NO-ERRORS condition is true, consider AEI transmission successful, otherwise handle as failure
Context: AEI status transmission has failed
GIVEN
AEI status transmission has failed
Applied to: Retry AEI Send with Fallbacks
WHEN
Retrying AEI send with fallback recipients
THEN
Clear existing recipients, set fallback recipients to 'AEI9999' and 'OM01247', retry EMCSEND3 call with fallback configuration
Context: AEI retry transmission has been attempted with fallback recipients
GIVEN
AEI retry transmission has been attempted with fallback recipients
Applied to: AEI Retry Successful?
WHEN
Checking AEI retry success status
THEN
If EMI-NO-ERRORS condition is true, consider retry successful; If still failing, set error message 'SEND TO FILE OF OM01247 FAILED' and call CERR for error handling
R-GCX015-cbl-00252 (+4) File: GCX015.cbl Close MQ Connections Merged 5 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Close MQ Connections':
  • Context - message processing is complete and message queue handle exists:
    For Close Message Queue Handle:
    When system initiates message queue closure, then message queue handle is closed and queue resources are released.
  • Context - message queue closure is attempted:
    For Handle Queue Close Error:
    When queue closure fails with error condition, then system captures error details and initiates error handling process.
  • Context - message queue handle has been closed successfully:
    For Disconnect from MQ Manager:
    When system initiates disconnection from mq manager, then connection to mq manager is terminated and messaging resources are freed.
  • Context - mq manager disconnection is attempted:
    For Handle Disconnect Error:
    When disconnection fails with error condition, then system captures error details and initiates error handling process.
  • Context - mq close or disconnect operation has failed:
    For System Abend:
    When error handling determines the error is unrecoverable, then system performs abnormal termination with error details.
👨‍💻 Technical ACs (Gherkin)
Context: Message processing is complete and message queue handle exists
GIVEN
Message processing is complete and message queue handle exists
Applied to: Close Message Queue Handle
WHEN
System initiates message queue closure
THEN
Message queue handle is closed and queue resources are released
Context: Message queue closure is attempted
GIVEN
Message queue closure is attempted
Applied to: Handle Queue Close Error
WHEN
Queue closure fails with error condition
THEN
System captures error details and initiates error handling process
Context: Message queue handle has been closed successfully
GIVEN
Message queue handle has been closed successfully
Applied to: Disconnect from MQ Manager
WHEN
System initiates disconnection from MQ manager
THEN
Connection to MQ manager is terminated and messaging resources are freed
Context: MQ manager disconnection is attempted
GIVEN
MQ manager disconnection is attempted
Applied to: Handle Disconnect Error
WHEN
Disconnection fails with error condition
THEN
System captures error details and initiates error handling process
Context: MQ close or disconnect operation has failed
GIVEN
MQ close or disconnect operation has failed
Applied to: System Abend
WHEN
Error handling determines the error is unrecoverable
THEN
System performs abnormal termination with error details
R-GCX015-cbl-00257 (+3) File: GCX015.cbl Process Special Test Messages Merged 4 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Process Special Test Messages':
  • Context - a message segment is being processed and it is identified as an m10 segment type:
    For Check Reference Number:
    When the m10 segment reference number equals 'traincprstesttrain0000000000' or 'cargocprs940000000000', then the system should clear the message array, set the end processing flag to true, and terminate message processing.
  • Context - a special test message has been identified with reference number 'traincprstesttrain0000000000' or 'cargocprs940000000000':
    For Update Administrative Timestamps:
    When the manifest type code in the m10 segment is 'p', 'h', or 's', then the system should update the corresponding administrative table timestamp field (t1-309-ack for 'p', t1-353-ack for 'h', t1-358-ack for 's') with current machine date, century, and time.
  • Context - a special test message has been detected and administrative timestamps have been updated:
    For Clear Message Array:
    When the special check processing is executed, then the system should move spaces to the mqs-msg-array to clear all message data.
  • Context - a special test message has been processed and the message array has been cleared:
    For Set End Processing Flag:
    When the test message handling is complete, then the system should set ws-end-found to true to indicate end of processing.
👨‍💻 Technical ACs (Gherkin)
Context: A message segment is being processed and it is identified as an M10 segment type
GIVEN
A message segment is being processed and it is identified as an M10 segment type
Applied to: Check Reference Number
WHEN
The M10 segment reference number equals 'TRAINCPRSTESTTRAIN0000000000' or 'CARGOCPRS940000000000'
THEN
The system should clear the message array, set the end processing flag to true, and terminate message processing
Context: A special test message has been identified with reference number 'TRAINCPRSTESTTRAIN0000000000' or 'CARGOCPRS940000000000'
GIVEN
A special test message has been identified with reference number 'TRAINCPRSTESTTRAIN0000000000' or 'CARGOCPRS940000000000'
Applied to: Update Administrative Timestamps
WHEN
The manifest type code in the M10 segment is 'P', 'H', or 'S'
THEN
The system should update the corresponding administrative table timestamp field (T1-309-ACK for 'P', T1-353-ACK for 'H', T1-358-ACK for 'S') with current machine date, century, and time
Context: A special test message has been detected and administrative timestamps have been updated
GIVEN
A special test message has been detected and administrative timestamps have been updated
Applied to: Clear Message Array
WHEN
The special check processing is executed
THEN
The system should move spaces to the MQS-MSG-ARRAY to clear all message data
Context: A special test message has been processed and the message array has been cleared
GIVEN
A special test message has been processed and the message array has been cleared
Applied to: Set End Processing Flag
WHEN
The test message handling is complete
THEN
The system should set WS-END-FOUND to true to indicate end of processing
R-GCX015-cbl-00261 (+5) File: GCX015.cbl Update Administrative Timestamps Merged 6 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Update Administrative Timestamps':
  • Context - the system needs to update administrative timestamps for acknowledgment processing:
    For Get T1 Administrative Table:
    When the system attempts to retrieve the t1 administrative table using table id 't1', then the t1 administrative table segment should be retrieved and made available for timestamp updates.
  • Context - the system is attempting to retrieve the t1 administrative table for timestamp updates:
    For Table Found? -> Log Error - Table Not Found:
    When the t1 administrative table retrieval fails and return flag is not equal to '0', then the system should log an error message 't1 check table entry not found' and terminate the timestamp update process.
  • Context - the t1 administrative table is available and a manifest transaction is being processed:
    For Manifest Type = 'P'? -> Update 309 ACK Timestamp:
    When the manifest type code equals 'p', then the system should update the 309 ack timestamp with current system date (positions 3-6), current century (positions 1-2), and current system time (positions 9-4).
  • Context - the t1 administrative table is available and a manifest transaction is being processed with manifest type not equal to 'p':
    For Manifest Type = 'H'? -> Update 353 ACK Timestamp:
    When the manifest type code equals 'h', then the system should update the 353 ack timestamp with current system date (positions 3-6), current century (positions 1-2), and current system time (positions 9-4).
  • Context - the t1 administrative table is available and a manifest transaction is being processed with manifest type not equal to 'p' or 'h':
    For Manifest Type = 'S'? -> Update 358 ACK Timestamp:
    When the manifest type code equals 's', then the system should update the 358 ack timestamp with current system date (positions 3-6), current century (positions 1-2), and current system time (positions 9-4).
  • Context - the t1 administrative table has been retrieved and acknowledgment timestamps have been updated based on manifest type:
    For Save Updated Timestamps to T1 Table:
    When all timestamp updates are complete, then the system should save the updated t1 table segment back to the administrative table using replace function.
👨‍💻 Technical ACs (Gherkin)
Context: The system needs to update administrative timestamps for acknowledgment processing
GIVEN
The system needs to update administrative timestamps for acknowledgment processing
Applied to: Get T1 Administrative Table
WHEN
The system attempts to retrieve the T1 administrative table using table ID 'T1'
THEN
The T1 administrative table segment should be retrieved and made available for timestamp updates
Context: The system is attempting to retrieve the T1 administrative table for timestamp updates
GIVEN
The system is attempting to retrieve the T1 administrative table for timestamp updates
Applied to: Table Found? -> Log Error - Table Not Found
WHEN
The T1 administrative table retrieval fails and return flag is not equal to '0'
THEN
The system should log an error message 'T1 CHECK TABLE ENTRY NOT FOUND' and terminate the timestamp update process
Context: The T1 administrative table is available and a manifest transaction is being processed
GIVEN
The T1 administrative table is available and a manifest transaction is being processed
Applied to: Manifest Type = 'P'? -> Update 309 ACK Timestamp
WHEN
The manifest type code equals 'P'
THEN
The system should update the 309 ACK timestamp with current system date (positions 3-6), current century (positions 1-2), and current system time (positions 9-4)
Context: The T1 administrative table is available and a manifest transaction is being processed with manifest type not equal to 'P'
GIVEN
The T1 administrative table is available and a manifest transaction is being processed with manifest type not equal to 'P'
Applied to: Manifest Type = 'H'? -> Update 353 ACK Timestamp
WHEN
The manifest type code equals 'H'
THEN
The system should update the 353 ACK timestamp with current system date (positions 3-6), current century (positions 1-2), and current system time (positions 9-4)
Context: The T1 administrative table is available and a manifest transaction is being processed with manifest type not equal to 'P' or 'H'
GIVEN
The T1 administrative table is available and a manifest transaction is being processed with manifest type not equal to 'P' or 'H'
Applied to: Manifest Type = 'S'? -> Update 358 ACK Timestamp
WHEN
The manifest type code equals 'S'
THEN
The system should update the 358 ACK timestamp with current system date (positions 3-6), current century (positions 1-2), and current system time (positions 9-4)
Context: The T1 administrative table has been retrieved and acknowledgment timestamps have been updated based on manifest type
GIVEN
The T1 administrative table has been retrieved and acknowledgment timestamps have been updated based on manifest type
Applied to: Save Updated Timestamps to T1 Table
WHEN
All timestamp updates are complete
THEN
The system should save the updated T1 table segment back to the administrative table using replace function
R-GCX015-cbl-00267 (+8) File: GCX015.cbl Extract M10 Segment Data Merged 9 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Extract M10 Segment Data':
  • Context - an m10 segment is received for processing:
    For Extract Reference Number from M10-12 & Extract Manifest Type Code from M10-09:
    When the system processes the m10 segment, then the reference number is extracted from m10-12-ref-num field and stored in work-m10-12 for further processing and the manifest type code is extracted from m10-09-manifest-typ-cde field for action determination.
  • Context - an m10 segment with manifest type code is processed:
    For Set Update Status Action Types: P, X, Y, T, S:
    When the manifest type code is p, x, y, t, or s, then the system sets should-update-status flag to true indicating status should be updated.
    For Set No Update Action Other Types:
    When the manifest type code is not p, x, y, t, s, or h, then the system sets should-not-update-status flag to true indicating no status update should occur.
  • Context - an m10 segment with manifest type code h is processed and the transaction is identified as train:
    For Set Delete Status Action Type: H for Trains:
    When the manifest type code is h, then the system sets should-delete-status flag to true indicating the train status should be deleted.
  • Context - an m10 segment reference number is extracted:
    For Identify as TRAIN Processing Prefix: 'TRAIN':
    When the reference number prefix equals 'train', then the system sets ws-train flag to true and identifies the transaction for train processing.
    For Identify as CARGO Processing Prefix: 'CARGO':
    When the reference number prefix equals 'cargo', then the system sets ws-cargo flag to true and identifies the transaction for cargo processing.
    For Mark as Unknown Type Other Prefixes:
    When the reference number prefix is neither 'train' nor 'cargo', then the system maintains ws-unknown flag as true indicating unknown transaction type.
  • Context - m10 segment data has been extracted and transaction type identified:
    For Store M10 Data for Processing:
    When the system completes m10 segment analysis, then the reference number data is moved to work-m10-12-data field for use in database operations and logging.
👨‍💻 Technical ACs (Gherkin)
Context: An M10 segment is received for processing
GIVEN
An M10 segment is received for processing
Applied to: Extract Reference Number from M10-12 & Extract Manifest Type Code from M10-09
WHEN
The system processes the M10 segment
THEN
The reference number is extracted from M10-12-REF-NUM field and stored in WORK-M10-12 for further processing AND The manifest type code is extracted from M10-09-MANIFEST-TYP-CDE field for action determination
Context: An M10 segment with manifest type code is processed
GIVEN
An M10 segment with manifest type code is processed
Applied to: Set Update Status Action Types: P, X, Y, T, S
WHEN
The manifest type code is P, X, Y, T, or S
THEN
The system sets SHOULD-UPDATE-STATUS flag to true indicating status should be updated
Applied to: Set No Update Action Other Types
WHEN
The manifest type code is not P, X, Y, T, S, or H
THEN
The system sets SHOULD-NOT-UPDATE-STATUS flag to true indicating no status update should occur
Context: An M10 segment with manifest type code H is processed and the transaction is identified as TRAIN
GIVEN
An M10 segment with manifest type code H is processed and the transaction is identified as TRAIN
Applied to: Set Delete Status Action Type: H for Trains
WHEN
The manifest type code is H
THEN
The system sets SHOULD-DELETE-STATUS flag to true indicating the train status should be deleted
Context: An M10 segment reference number is extracted
GIVEN
An M10 segment reference number is extracted
Applied to: Identify as TRAIN Processing Prefix: 'TRAIN'
WHEN
The reference number prefix equals 'TRAIN'
THEN
The system sets WS-TRAIN flag to true and identifies the transaction for train processing
Applied to: Identify as CARGO Processing Prefix: 'CARGO'
WHEN
The reference number prefix equals 'CARGO'
THEN
The system sets WS-CARGO flag to true and identifies the transaction for cargo processing
Applied to: Mark as Unknown Type Other Prefixes
WHEN
The reference number prefix is neither 'TRAIN' nor 'CARGO'
THEN
The system maintains WS-UNKNOWN flag as true indicating unknown transaction type
Context: M10 segment data has been extracted and transaction type identified
GIVEN
M10 segment data has been extracted and transaction type identified
Applied to: Store M10 Data for Processing
WHEN
The system completes M10 segment analysis
THEN
The reference number data is moved to WORK-M10-12-DATA field for use in database operations and logging
R-GCX015-cbl-00276 (+12) File: GCX015.cbl Process K1 Segment Merged 13 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Process K1 Segment':
  • Context - a k1 segment is being processed:
    For Start K1 Segment Processing:
    When the system processes the k1 segment, then the message number is extracted from the k1 segment and stored for further processing.
  • Context - a k1 message number has been extracted:
    For Build MS Table Key with Message Number:
    When the system builds the ms table lookup key, then the key is constructed with table id 'ms', prefix 'a', and the k1 message number.
  • Context - an ms table key has been constructed with message number:
    For Look Up Error Message Text in MS Table:
    When the system performs a table lookup, then the system retrieves the corresponding english error message text from the ms table.
  • Context - an ms table lookup has been performed for error message text:
    For Message Text Found?:
    When the lookup return flag equals '0', then use the ms table english text as the error message.
    For Use K1 Free Form Message:
    When the lookup return flag does not equal '0', then use the k1 free form message as the error message text.
  • Context - an error message text has been selected (either from ms table or k1 free form):
    For Add Error Message to Report Lines:
    When the system adds the message to the report, then the error message is added to the report lines and the line counter is incremented.
  • Context - an error message has been formatted for display:
    For Store Message in K1 Message Array:
    When the system stores the message for logging, then the formatted log message is stored in the k1 message array and the counter is incremented.
  • Context - a k1 message has been processed:
    For Message Number = 242?:
    When the k1 message number equals '242', then the system initiates special c4 code processing.
  • Context - message number 242 requires c4 code processing:
    For C4 Code Available?:
    When the c4 code holder is not spaces and not low-values, then the system proceeds with c4 code message construction.
  • Context - c4 code data is available for message 242:
    For Build C4 Code Message:
    When the system builds the c4 code message, then a message is constructed with format 'c4 code=' followed by the c4 code value.
  • Context - a c4 code message has been constructed:
    For Add C4 Code to Report Lines:
    When the system adds the c4 message to the report, then the c4 code message is added to the report lines and the line counter is incremented.
  • Context - a c4 code message has been added to the report:
    For Store C4 Message in Array:
    When the system stores the c4 message for logging, then the c4 code log message is stored in the k1 message array and the counter is incremented.
  • Context - c4 code processing has been completed for message 242:
    For Clear C4 Code Holder:
    When the system clears the c4 code holder, then the c4 code holder is set to spaces to prevent reuse in subsequent processing.
👨‍💻 Technical ACs (Gherkin)
Context: A K1 segment is being processed
GIVEN
A K1 segment is being processed
Applied to: Start K1 Segment Processing
WHEN
The system processes the K1 segment
THEN
The message number is extracted from the K1 segment and stored for further processing
Context: A K1 message number has been extracted
GIVEN
A K1 message number has been extracted
Applied to: Build MS Table Key with Message Number
WHEN
The system builds the MS table lookup key
THEN
The key is constructed with table ID 'MS', prefix 'A', and the K1 message number
Context: An MS table key has been constructed with message number
GIVEN
An MS table key has been constructed with message number
Applied to: Look Up Error Message Text in MS Table
WHEN
The system performs a table lookup
THEN
The system retrieves the corresponding English error message text from the MS table
Context: An MS table lookup has been performed for error message text
GIVEN
An MS table lookup has been performed for error message text
Applied to: Message Text Found?
WHEN
The lookup return flag equals '0'
THEN
Use the MS table English text as the error message
Applied to: Use K1 Free Form Message
WHEN
The lookup return flag does not equal '0'
THEN
Use the K1 free form message as the error message text
Context: An error message text has been selected (either from MS table or K1 free form)
GIVEN
An error message text has been selected (either from MS table or K1 free form)
Applied to: Add Error Message to Report Lines
WHEN
The system adds the message to the report
THEN
The error message is added to the report lines and the line counter is incremented
Context: An error message has been formatted for display
GIVEN
An error message has been formatted for display
Applied to: Store Message in K1 Message Array
WHEN
The system stores the message for logging
THEN
The formatted log message is stored in the K1 message array and the counter is incremented
Context: A K1 message has been processed
GIVEN
A K1 message has been processed
Applied to: Message Number = 242?
WHEN
The K1 message number equals '242'
THEN
The system initiates special C4 code processing
Context: Message number 242 requires C4 code processing
GIVEN
Message number 242 requires C4 code processing
Applied to: C4 Code Available?
WHEN
The C4 code holder is not spaces and not low-values
THEN
The system proceeds with C4 code message construction
Context: C4 code data is available for message 242
GIVEN
C4 code data is available for message 242
Applied to: Build C4 Code Message
WHEN
The system builds the C4 code message
THEN
A message is constructed with format 'C4 CODE=' followed by the C4 code value
Context: A C4 code message has been constructed
GIVEN
A C4 code message has been constructed
Applied to: Add C4 Code to Report Lines
WHEN
The system adds the C4 message to the report
THEN
The C4 code message is added to the report lines and the line counter is incremented
Context: A C4 code message has been added to the report
GIVEN
A C4 code message has been added to the report
Applied to: Store C4 Message in Array
WHEN
The system stores the C4 message for logging
THEN
The C4 code log message is stored in the K1 message array and the counter is incremented
Context: C4 code processing has been completed for message 242
GIVEN
C4 code processing has been completed for message 242
Applied to: Clear C4 Code Holder
WHEN
The system clears the C4 code holder
THEN
The C4 code holder is set to spaces to prevent reuse in subsequent processing
R-GCX015-cbl-00289 (+5) File: GCX015.cbl Extract K3 Segment Data Merged 6 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Extract K3 Segment Data':
  • Context - a k3 segment is being processed from the message queue:
    For Extract Total Reject Count:
    When the total rejection count in the k3 segment is greater than zero, then the system should set error status for the transaction.
  • Context - a k3 segment has zero rejection count:
    For Accept Count > 0?:
    When the total acceptance count is greater than zero, then the system should proceed to evaluate train status conditions for appropriate status assignment.
    For Record Zero Counts Message:
    When the total acceptance count is also zero, then the system should record a warning message 'uscs k3 record has zero counts' and set ack status.
  • Context - a k3 segment has valid acceptance counts (zero rejections and positive acceptances) and the entity is a train:
    For Set PRE-ARRIVAL Status:
    When the train status indicates pre-arrived condition, then the system should set pre-arrival status for the train.
    For Set REVIEW-COMPLETED Status:
    When the train status indicates review-cmpl condition, then the system should set review-completed status for the train.
  • Context - a k3 segment has valid acceptance counts (zero rejections and positive acceptances):
    For Set ACK Status:
    When the entity is not in pre-arrived or review-cmpl status conditions, then the system should set standard ack status.
👨‍💻 Technical ACs (Gherkin)
Context: A K3 segment is being processed from the message queue
GIVEN
A K3 segment is being processed from the message queue
Applied to: Extract Total Reject Count
WHEN
The total rejection count in the K3 segment is greater than zero
THEN
The system should set ERROR status for the transaction
Context: A K3 segment has zero rejection count
GIVEN
A K3 segment has zero rejection count
Applied to: Accept Count > 0?
WHEN
The total acceptance count is greater than zero
THEN
The system should proceed to evaluate train status conditions for appropriate status assignment
Applied to: Record Zero Counts Message
WHEN
The total acceptance count is also zero
THEN
The system should record a warning message 'USCS K3 RECORD HAS ZERO COUNTS' and set ACK status
Context: A K3 segment has valid acceptance counts (zero rejections and positive acceptances) and the entity is a train
GIVEN
A K3 segment has valid acceptance counts (zero rejections and positive acceptances) and the entity is a train
Applied to: Set PRE-ARRIVAL Status
WHEN
The train status indicates PRE-ARRIVED condition
THEN
The system should set PRE-ARRIVAL status for the train
Applied to: Set REVIEW-COMPLETED Status
WHEN
The train status indicates REVIEW-CMPL condition
THEN
The system should set REVIEW-COMPLETED status for the train
Context: A K3 segment has valid acceptance counts (zero rejections and positive acceptances)
GIVEN
A K3 segment has valid acceptance counts (zero rejections and positive acceptances)
Applied to: Set ACK Status
WHEN
The entity is not in PRE-ARRIVED or REVIEW-CMPL status conditions
THEN
The system should set standard ACK status
R-GCX015-cbl-00295 (+6) File: GCX015.cbl Update Train Record Merged 7 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Update Train Record':
  • Context - a train record exists with gcwtl-deleted flag set to true:
    For Set Status to DELETED:
    When the message processing results in ws-ack-status being true, then the train current status is set to 'deleted' and security fields are cleared.
  • Context - a train record exists with gcwtl-delete-pending flag set to true:
    For Set Status to DELETED:
    When the message processing results in ws-ack-status being true, then the train current status is set to 'deleted' and security fields are cleared.
  • Context - a train record exists that is not deleted and not delete pending:
    For Set Current Status from Message:
    When the message processing completes with a status update, then the train current status is updated with the message status value.
  • Context - a train record is being updated to deleted status:
    For Clear Security Fields:
    When the status update operation is executed, then the gcwtl-secx security field is initialized to spaces.
  • Context - a train record requires status or field updates:
    For Execute Database Update:
    When the update operation is initiated, then the system calls gccutrio with replacement function and root-only scope using the train pcb.
  • Context - a train record has been updated successfully:
    For Check AEI Train Qualification:
    When the update operation completes, then the system performs aei train send qualification check to determine if additional aei processing is required.
  • Context - a train record has gcwtl-ack status set to true and gcwtl-arrived-pending status set to true:
    For Process Automatic Train Arrival:
    When the train record update is completed, then the system automatically triggers train arrival processing.
👨‍💻 Technical ACs (Gherkin)
Context: A train record exists with GCWTL-DELETED flag set to true
GIVEN
A train record exists with GCWTL-DELETED flag set to true
Applied to: Set Status to DELETED
WHEN
The message processing results in WS-ACK-STATUS being true
THEN
The train current status is set to 'DELETED' and security fields are cleared
Context: A train record exists with GCWTL-DELETE-PENDING flag set to true
GIVEN
A train record exists with GCWTL-DELETE-PENDING flag set to true
Applied to: Set Status to DELETED
WHEN
The message processing results in WS-ACK-STATUS being true
THEN
The train current status is set to 'DELETED' and security fields are cleared
Context: A train record exists that is not deleted and not delete pending
GIVEN
A train record exists that is not deleted and not delete pending
Applied to: Set Current Status from Message
WHEN
The message processing completes with a status update
THEN
The train current status is updated with the message status value
Context: A train record is being updated to DELETED status
GIVEN
A train record is being updated to DELETED status
Applied to: Clear Security Fields
WHEN
The status update operation is executed
THEN
The GCWTL-SECX security field is initialized to spaces
Context: A train record requires status or field updates
GIVEN
A train record requires status or field updates
Applied to: Execute Database Update
WHEN
The update operation is initiated
THEN
The system calls GCCUTRIO with replacement function and root-only scope using the train PCB
Context: A train record has been updated successfully
GIVEN
A train record has been updated successfully
Applied to: Check AEI Train Qualification
WHEN
The update operation completes
THEN
The system performs AEI train send qualification check to determine if additional AEI processing is required
Context: A train record has GCWTL-ACK status set to true and GCWTL-ARRIVED-PENDING status set to true
GIVEN
A train record has GCWTL-ACK status set to true and GCWTL-ARRIVED-PENDING status set to true
Applied to: Process Automatic Train Arrival
WHEN
The train record update is completed
THEN
The system automatically triggers train arrival processing
R-GCX015-cbl-00302 (+9) File: GCX015.cbl Update Cargo Record Merged 10 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Update Cargo Record':
  • Context - a cargo record is being processed for status update:
    For Is Status ACK?:
    When the system evaluates the current status type, then if the status is ack, the system proceeds to check for previously saved status information, otherwise it processes as an error status.
  • Context - a cargo status is being acknowledged:
    For Previous Status Saved?:
    When the system checks the saved status description field, then if the saved status description is not empty, restore the saved status and description, otherwise set default acknowledgment flags.
  • Context - a cargo status is being acknowledged and no previous status is saved:
    For Set Status to USCARGO-ACK:
    When the system processes the acknowledgment, then set both uscargo status flags to acknowledgment state.
  • Context - a cargo status is being acknowledged and a previous status description exists in save fields:
    For Restore Previous Status from Save Fields:
    When the system processes the acknowledgment, then restore the cargo status from the saved status field and restore the status description from the saved description field.
  • Context - a cargo is being processed with error status:
    For Current Status is Error/ACK?:
    When the system evaluates the current uscargo short description status, then if the current status is error, ack, or ack-r, skip saving the current status, otherwise save the current status to backup fields.
    For Cargo Already Deleted?:
    When the system evaluates the cpcargo deletion status, then if the cargo is already marked as cpcargo-deleted, skip setting cpcargo-error flag, otherwise set the cpcargo-error flag.
    For Set Status to USCARGO-ERROR:
    When the system applies error status flags, then set both uscargo status flag and uscargo short description flag to error state.
  • Context - a cargo is being set to error status and current status is not error, ack, or ack-r:
    For Save Current Status to Backup Fields:
    When the system processes the error status, then move the current uscargo status to the saved status field and move the current uscargo short description to the saved description field.
  • Context - a cargo is being set to error status and is not already deleted:
    For Set Status to CPCARGO-ERROR:
    When the system processes the error status, then set the cpcargo status flag to error state.
  • Context - all cargo status fields have been modified according to business rules:
    For Execute Database Update Operation:
    When the system is ready to persist changes, then execute database update operation using gccusio with segment replacement function for the cargo record.
👨‍💻 Technical ACs (Gherkin)
Context: A cargo record is being processed for status update
GIVEN
A cargo record is being processed for status update
Applied to: Is Status ACK?
WHEN
The system evaluates the current status type
THEN
If the status is ACK, the system proceeds to check for previously saved status information, otherwise it processes as an error status
Context: A cargo status is being acknowledged
GIVEN
A cargo status is being acknowledged
Applied to: Previous Status Saved?
WHEN
The system checks the saved status description field
THEN
If the saved status description is not empty, restore the saved status and description, otherwise set default acknowledgment flags
Context: A cargo status is being acknowledged and no previous status is saved
GIVEN
A cargo status is being acknowledged and no previous status is saved
Applied to: Set Status to USCARGO-ACK
WHEN
The system processes the acknowledgment
THEN
Set both USCARGO status flags to acknowledgment state
Context: A cargo status is being acknowledged and a previous status description exists in save fields
GIVEN
A cargo status is being acknowledged and a previous status description exists in save fields
Applied to: Restore Previous Status from Save Fields
WHEN
The system processes the acknowledgment
THEN
Restore the cargo status from the saved status field and restore the status description from the saved description field
Context: A cargo is being processed with error status
GIVEN
A cargo is being processed with error status
Applied to: Current Status is Error/ACK?
WHEN
The system evaluates the current USCARGO short description status
THEN
If the current status is ERROR, ACK, or ACK-R, skip saving the current status, otherwise save the current status to backup fields
Applied to: Cargo Already Deleted?
WHEN
The system evaluates the CPCARGO deletion status
THEN
If the cargo is already marked as CPCARGO-DELETED, skip setting CPCARGO-ERROR flag, otherwise set the CPCARGO-ERROR flag
Applied to: Set Status to USCARGO-ERROR
WHEN
The system applies error status flags
THEN
Set both USCARGO status flag and USCARGO short description flag to ERROR state
Context: A cargo is being set to error status and current status is not ERROR, ACK, or ACK-R
GIVEN
A cargo is being set to error status and current status is not ERROR, ACK, or ACK-R
Applied to: Save Current Status to Backup Fields
WHEN
The system processes the error status
THEN
Move the current USCARGO status to the saved status field and move the current USCARGO short description to the saved description field
Context: A cargo is being set to error status and is not already deleted
GIVEN
A cargo is being set to error status and is not already deleted
Applied to: Set Status to CPCARGO-ERROR
WHEN
The system processes the error status
THEN
Set the CPCARGO status flag to ERROR state
Context: All cargo status fields have been modified according to business rules
GIVEN
All cargo status fields have been modified according to business rules
Applied to: Execute Database Update Operation
WHEN
The system is ready to persist changes
THEN
Execute database update operation using GCCUSIO with segment replacement function for the cargo record
R-GCX015-cbl-00312 (+19) File: GCX015.cbl Set Up Customs Transaction Data Merged 20 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Set Up Customs Transaction Data':
  • Context - a train record exists with status, aei send flag, enroute reporting status, and train identifier:
    For Train Qualifies for AEI?:
    When the system evaluates aei processing eligibility, then the train qualifies for aei processing if it has ack status and aei send flag is enabled and enroute is not yet reported and train identifier ends with 't'.
  • Context - a train qualifies for aei processing:
    For Set Transaction Code to GCT1461E:
    When setting up customs transaction data, then the customs transaction code is set to 'gct1461e'.
  • Context - a customs transaction is being prepared for aei processing:
    For Set Security Level to High:
    When setting security parameters, then the security level is set to high values (high-values).
  • Context - a customs transaction is being configured:
    For Set Customs Code to 'A':
    When setting the customs processing code, then the customs code is set to 'a'.
  • Context - a train record with a valid train identifier:
    For Copy Train ID to Customs Train ID:
    When building the customs transaction, then the train identifier is copied to the customs train id field.
  • Context - a train record with station routing information:
    For Set Station Information:
    When setting up customs transaction routing data, then both origin and destination stations are set to the train's from station.
  • Context - a train record with a consist number:
    For Copy Train Consist Number:
    When building customs transaction data, then the train consist number is copied to the customs consist field.
  • Context - a train record with estimated departure date (eda):
    For Set Event Date from Train Data:
    When configuring customs transaction timing, then the event date is set to the train's p402 eda value.
  • Context - a train record with estimated time of arrival (eta):
    For Set Event Time from Train Data:
    When configuring customs transaction timing, then the event time is set to the train's p405 eta value.
  • Context - starting car information processing for a train:
    For Initialize Car Counter Variables:
    When initializing processing variables, then car counter is set to 1, secondary counter is set to 2, and tertiary counter is set to 2.
  • Context - beginning car data processing for customs transaction:
    For Clear Customs Output Table:
    When preparing the output data structure, then the customs output table is cleared to spaces.
  • Context - processing cars in a train consist:
    For More Cars to Process?:
    When determining whether to continue processing, then continue processing if current car index is within equipment quantity and car counter is 500 or less.
  • Context - a car with container indicator in the train consist:
    For Skip Container Cars:
    When processing individual cars for customs data, then skip the car if its container indicator is 'c'.
  • Context - a non-container car with equipment initials and number:
    For Copy Car Initials and Numbers:
    When building customs car data, then copy equipment initials to customs car initials and convert equipment number to 6-digit format for customs car number.
  • Context - a car being processed with load/empty indicator and information about subsequent cars:
    For Determine Car Load Status:
    When setting the car's load status for customs, then if processing the last car, use its load/empty indicator; otherwise, if the next car is a container, set status to 'l' (loaded); otherwise, use current car's load/empty indicator.
  • Context - a car with equipment type designation:
    For Set Car Type Information:
    When setting customs car type information, then if equipment type is 'lo', set car kind to 'l'; if equipment type is 'et', set car kind to 'e'; otherwise, set car kind to spaces.
  • Context - a non-container car has been processed successfully:
    For Increment Car Counter:
    When completing car data processing, then increment the car counter by 1 and increment the tertiary counter by 1.
  • Context - a completed customs transaction with all car data loaded:
    For Send Transaction to CIMS:
    When submitting the transaction for processing, then call cims with change operation using the customs transaction code.
  • Context - a customs transaction ready for queue processing:
    For Write Message to Queue:
    When submitting the message to the queue, then call writmsgl with send message code, customs transaction data, message length, and module name.
  • Context - a customs transaction has been successfully submitted:
    For Purge Transaction:
    When completing the aei processing, then call cims with purge operation to clean up the transaction.
👨‍💻 Technical ACs (Gherkin)
Context: A train record exists with status, AEI send flag, enroute reporting status, and train identifier
GIVEN
A train record exists with status, AEI send flag, enroute reporting status, and train identifier
Applied to: Train Qualifies for AEI?
WHEN
The system evaluates AEI processing eligibility
THEN
The train qualifies for AEI processing if it has ACK status AND AEI send flag is enabled AND enroute is not yet reported AND train identifier ends with 'T'
Context: A train qualifies for AEI processing
GIVEN
A train qualifies for AEI processing
Applied to: Set Transaction Code to GCT1461E
WHEN
Setting up customs transaction data
THEN
The customs transaction code is set to 'GCT1461E'
Context: A customs transaction is being prepared for AEI processing
GIVEN
A customs transaction is being prepared for AEI processing
Applied to: Set Security Level to High
WHEN
Setting security parameters
THEN
The security level is set to high values (HIGH-VALUES)
Context: A customs transaction is being configured
GIVEN
A customs transaction is being configured
Applied to: Set Customs Code to 'A'
WHEN
Setting the customs processing code
THEN
The customs code is set to 'A'
Context: A train record with a valid train identifier
GIVEN
A train record with a valid train identifier
Applied to: Copy Train ID to Customs Train ID
WHEN
Building the customs transaction
THEN
The train identifier is copied to the customs train ID field
Context: A train record with station routing information
GIVEN
A train record with station routing information
Applied to: Set Station Information
WHEN
Setting up customs transaction routing data
THEN
Both origin and destination stations are set to the train's from station
Context: A train record with a consist number
GIVEN
A train record with a consist number
Applied to: Copy Train Consist Number
WHEN
Building customs transaction data
THEN
The train consist number is copied to the customs consist field
Context: A train record with estimated departure date (EDA)
GIVEN
A train record with estimated departure date (EDA)
Applied to: Set Event Date from Train Data
WHEN
Configuring customs transaction timing
THEN
The event date is set to the train's P402 EDA value
Context: A train record with estimated time of arrival (ETA)
GIVEN
A train record with estimated time of arrival (ETA)
Applied to: Set Event Time from Train Data
WHEN
Configuring customs transaction timing
THEN
The event time is set to the train's P405 ETA value
Context: Starting car information processing for a train
GIVEN
Starting car information processing for a train
Applied to: Initialize Car Counter Variables
WHEN
Initializing processing variables
THEN
Car counter is set to 1, secondary counter is set to 2, and tertiary counter is set to 2
Context: Beginning car data processing for customs transaction
GIVEN
Beginning car data processing for customs transaction
Applied to: Clear Customs Output Table
WHEN
Preparing the output data structure
THEN
The customs output table is cleared to spaces
Context: Processing cars in a train consist
GIVEN
Processing cars in a train consist
Applied to: More Cars to Process?
WHEN
Determining whether to continue processing
THEN
Continue processing if current car index is within equipment quantity AND car counter is 500 or less
Context: A car with container indicator in the train consist
GIVEN
A car with container indicator in the train consist
Applied to: Skip Container Cars
WHEN
Processing individual cars for customs data
THEN
Skip the car if its container indicator is 'C'
Context: A non-container car with equipment initials and number
GIVEN
A non-container car with equipment initials and number
Applied to: Copy Car Initials and Numbers
WHEN
Building customs car data
THEN
Copy equipment initials to customs car initials AND convert equipment number to 6-digit format for customs car number
Context: A car being processed with load/empty indicator and information about subsequent cars
GIVEN
A car being processed with load/empty indicator and information about subsequent cars
Applied to: Determine Car Load Status
WHEN
Setting the car's load status for customs
THEN
If processing the last car, use its load/empty indicator; otherwise, if the next car is a container, set status to 'L' (loaded); otherwise, use current car's load/empty indicator
Context: A car with equipment type designation
GIVEN
A car with equipment type designation
Applied to: Set Car Type Information
WHEN
Setting customs car type information
THEN
If equipment type is 'LO', set car kind to 'L'; if equipment type is 'ET', set car kind to 'E'; otherwise, set car kind to spaces
Context: A non-container car has been processed successfully
GIVEN
A non-container car has been processed successfully
Applied to: Increment Car Counter
WHEN
Completing car data processing
THEN
Increment the car counter by 1 AND increment the tertiary counter by 1
Context: A completed customs transaction with all car data loaded
GIVEN
A completed customs transaction with all car data loaded
Applied to: Send Transaction to CIMS
WHEN
Submitting the transaction for processing
THEN
Call CIMS with change operation using the customs transaction code
Context: A customs transaction ready for queue processing
GIVEN
A customs transaction ready for queue processing
Applied to: Write Message to Queue
WHEN
Submitting the message to the queue
THEN
Call WRITMSGL with send message code, customs transaction data, message length, and module name
Context: A customs transaction has been successfully submitted
GIVEN
A customs transaction has been successfully submitted
Applied to: Purge Transaction
WHEN
Completing the AEI processing
THEN
Call CIMS with purge operation to clean up the transaction
R-GCX015-cbl-00332 (+7) File: GCX015.cbl Get AEI Merlin Recipients Merged 8 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Get AEI Merlin Recipients':
  • Context - a train record with security code (secx) is available:
    For Extract Port from Train Security Code:
    When the system needs to determine the port for aei email lookup, then the system extracts the first 4 characters of the security code as the port identifier.
  • Context - the system needs to query aei email database for distribution list:
    For Set Record Type to CUSEMAIL:
    When setting up database query parameters, then the system sets record type to 'cusemail' and uses extracted port as the record key.
  • Context - database query parameters are set with port and record type:
    For Call AEI Email Database Query:
    When the system executes the aei email database query, then the system calls aecwrktb program to retrieve email distribution information.
  • Context - aei email database query returns success status:
    For Set Default Merlin ID as Sender:
    When processing the successful query response, then the system sets the default merlin id as the message sender.
  • Context - database query was successful and returned email data:
    For Load Retrieved Email Recipients:
    When processing the retrieved email information, then the system iterates through up to 10 email addresses and loads non-blank user ids into the recipient list.
  • Context - database query was successful but no email recipients were found:
    For Use Default Merlin ID as Recipient:
    When all retrieved email addresses are blank or empty, then the system uses the default merlin id as both sender and recipient.
  • Context - aei email database query returns no entry found status:
    For Use Default Merlin ID as Recipient:
    When the specified port has no email distribution configuration, then the system uses the default merlin id as both sender and recipient.
  • Context - aei email database query returns an error status other than no entry found:
    For Send DB2 Error Alert:
    When a database error occurs during email lookup, then the system sends a db2 error alert message and uses the default merlin id as recipient.
👨‍💻 Technical ACs (Gherkin)
Context: A train record with security code (SECX) is available
GIVEN
A train record with security code (SECX) is available
Applied to: Extract Port from Train Security Code
WHEN
The system needs to determine the port for AEI email lookup
THEN
The system extracts the first 4 characters of the security code as the port identifier
Context: The system needs to query AEI email database for distribution list
GIVEN
The system needs to query AEI email database for distribution list
Applied to: Set Record Type to CUSEMAIL
WHEN
Setting up database query parameters
THEN
The system sets record type to 'CUSEMAIL' and uses extracted port as the record key
Context: Database query parameters are set with port and record type
GIVEN
Database query parameters are set with port and record type
Applied to: Call AEI Email Database Query
WHEN
The system executes the AEI email database query
THEN
The system calls AECWRKTB program to retrieve email distribution information
Context: AEI email database query returns success status
GIVEN
AEI email database query returns success status
Applied to: Set Default Merlin ID as Sender
WHEN
Processing the successful query response
THEN
The system sets the default Merlin ID as the message sender
Context: Database query was successful and returned email data
GIVEN
Database query was successful and returned email data
Applied to: Load Retrieved Email Recipients
WHEN
Processing the retrieved email information
THEN
The system iterates through up to 10 email addresses and loads non-blank user IDs into the recipient list
Context: Database query was successful but no email recipients were found
GIVEN
Database query was successful but no email recipients were found
Applied to: Use Default Merlin ID as Recipient
WHEN
All retrieved email addresses are blank or empty
THEN
The system uses the default Merlin ID as both sender and recipient
Context: AEI email database query returns no entry found status
GIVEN
AEI email database query returns no entry found status
Applied to: Use Default Merlin ID as Recipient
WHEN
The specified port has no email distribution configuration
THEN
The system uses the default Merlin ID as both sender and recipient
Context: AEI email database query returns an error status other than no entry found
GIVEN
AEI email database query returns an error status other than no entry found
Applied to: Send DB2 Error Alert
WHEN
A database error occurs during email lookup
THEN
The system sends a DB2 error alert message and uses the default Merlin ID as recipient
R-GCX015-cbl-00340 (+10) File: GCX015.cbl Prepare Error Report Message Merged 11 Rules
Validation Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Prepare Error Report Message':
  • Context - an error report needs to be transmitted via merlin system:
    For Set Merlin From User Code to OM01247:
    When setting up primary transmission parameters, then the from user code should be set to om01247 for sender identification.
  • Context - error report transmission is being configured:
    For Set Primary To User Code to OM01247:
    When setting primary recipient information, then the primary to user code should be set to om01247.
  • Context - error report is being prepared for transmission:
    For Set Subject from Merlin Subject:
    When setting the message subject, then the subject should be assigned from the merlin subject field.
  • Context - error report is formatted and ready for transmission:
    For Call EMCSEND2 for Primary Send:
    When initiating primary send operation, then emcsend2 should be called with configured parameters to transmit the error report.
  • Context - primary error report transmission has been attempted:
    For Primary Send Successful?:
    When checking transmission result status, then if emi-no-errors condition is true, the transmission is considered successful.
  • Context - primary transmission was successful and secondary transmission is required:
    For Set To User Code from Admin Table MERLIN-1:
    When setting up secondary recipient information, then the to user code should be retrieved from admin table field gcstbrt-ad-dc-p-merlin-1.
  • Context - secondary transmission is being configured:
    For Set Copy User Code from Admin Table MERLIN-5:
    When setting copy recipient information, then the copy user code should be retrieved from admin table field gcstbrt-ad-dc-p-merlin-5.
  • Context - secondary transmission is being set up:
    For Use Alternative Destination Filename:
    When configuring destination parameters, then the destination filename should be set to emi-destination-filename2.
  • Context - secondary transmission parameters are configured:
    For Call EMCSEND2 for Secondary Send:
    When initiating secondary send operation, then emcsend2 should be called with alternative destination and recipient configuration.
  • Context - secondary error report transmission has been attempted:
    For Secondary Send Successful?:
    When checking secondary transmission result status, then if emi-no-errors condition is true, the secondary transmission is considered successful.
  • Context - error report transmission has failed:
    For Handle Send Failure Error:
    When evaluating the failure type, then if emi-from-not-found then set error message to 'emi - invalid merlin from', if emi-to-or-copy-not-found then set error message to 'emi - invalid merlin to or copy', if emi-filename-invalid then set error message to 'emi - invalid merlin filename', and perform abend procedure.
👨‍💻 Technical ACs (Gherkin)
Context: An error report needs to be transmitted via Merlin system
GIVEN
An error report needs to be transmitted via Merlin system
Applied to: Set Merlin From User Code to OM01247
WHEN
Setting up primary transmission parameters
THEN
The from user code should be set to OM01247 for sender identification
Context: Error report transmission is being configured
GIVEN
Error report transmission is being configured
Applied to: Set Primary To User Code to OM01247
WHEN
Setting primary recipient information
THEN
The primary to user code should be set to OM01247
Context: Error report is being prepared for transmission
GIVEN
Error report is being prepared for transmission
Applied to: Set Subject from Merlin Subject
WHEN
Setting the message subject
THEN
The subject should be assigned from the Merlin subject field
Context: Error report is formatted and ready for transmission
GIVEN
Error report is formatted and ready for transmission
Applied to: Call EMCSEND2 for Primary Send
WHEN
Initiating primary send operation
THEN
EMCSEND2 should be called with configured parameters to transmit the error report
Context: Primary error report transmission has been attempted
GIVEN
Primary error report transmission has been attempted
Applied to: Primary Send Successful?
WHEN
Checking transmission result status
THEN
If EMI-NO-ERRORS condition is true, the transmission is considered successful
Context: Primary transmission was successful and secondary transmission is required
GIVEN
Primary transmission was successful and secondary transmission is required
Applied to: Set To User Code from Admin Table MERLIN-1
WHEN
Setting up secondary recipient information
THEN
The to user code should be retrieved from admin table field GCSTBRT-AD-DC-P-MERLIN-1
Context: Secondary transmission is being configured
GIVEN
Secondary transmission is being configured
Applied to: Set Copy User Code from Admin Table MERLIN-5
WHEN
Setting copy recipient information
THEN
The copy user code should be retrieved from admin table field GCSTBRT-AD-DC-P-MERLIN-5
Context: Secondary transmission is being set up
GIVEN
Secondary transmission is being set up
Applied to: Use Alternative Destination Filename
WHEN
Configuring destination parameters
THEN
The destination filename should be set to EMI-DESTINATION-FILENAME2
Context: Secondary transmission parameters are configured
GIVEN
Secondary transmission parameters are configured
Applied to: Call EMCSEND2 for Secondary Send
WHEN
Initiating secondary send operation
THEN
EMCSEND2 should be called with alternative destination and recipient configuration
Context: Secondary error report transmission has been attempted
GIVEN
Secondary error report transmission has been attempted
Applied to: Secondary Send Successful?
WHEN
Checking secondary transmission result status
THEN
If EMI-NO-ERRORS condition is true, the secondary transmission is considered successful
Context: Error report transmission has failed
GIVEN
Error report transmission has failed
Applied to: Handle Send Failure Error
WHEN
Evaluating the failure type
THEN
If EMI-FROM-NOT-FOUND then set error message to 'EMI - INVALID MERLIN FROM', if EMI-TO-OR-COPY-NOT-FOUND then set error message to 'EMI - INVALID MERLIN TO OR COPY', if EMI-FILENAME-INVALID then set error message to 'EMI - INVALID MERLIN FILENAME', and perform abend procedure
R-GCX015-cbl-00351 (+9) File: GCX015.cbl Load Car Information Loop Merged 10 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Load Car Information Loop':
  • Context - a train car is being processed for customs reporting:
    For Is Car a Container?:
    When the car has a container indicator of 'c', then the car should be skipped and not included in the customs car records.
  • Context - a non-container car is being processed for customs:
    For Extract Car Initials:
    When the car equipment information is available, then the car initials should be extracted from the equipment initials field and stored in the customs car record.
    For Extract Car Number:
    When the car equipment number is available, then the car number should be extracted and converted to a 6-digit format for the customs car record.
  • Context - a car is being processed and there are more cars in the train sequence:
    For Determine Load/Empty Status from Next Car:
    When the next car in sequence has a container indicator of 'c', then the current car's load/empty status should be set to 'l' (loaded), otherwise use the current car's load/empty status.
  • Context - a car is being processed and it is the last car in the train sequence:
    For Use Current Car Load/Empty Status:
    When no next car is available to check container status, then the current car's own load/empty status indicator should be used for the customs record.
  • Context - a car is being processed for customs reporting:
    For Set Car Kind = 'L' for Locomotive:
    When the equipment type is 'lo', then the car kind should be set to 'l' to indicate locomotive.
    For Set Car Kind = Blank:
    When the equipment type is neither 'lo' nor 'et', then the car kind should be set to blank spaces.
  • Context - a car is being processed for customs reporting and equipment type is not 'lo':
    For Set Car Kind = 'E' for Engine:
    When the equipment type is 'et', then the car kind should be set to 'e' to indicate engine.
  • Context - all car information has been extracted and classified:
    For Build Customs Car Record:
    When car initials, number, load/empty status, and car kind have been determined, then a complete customs car record should be built with all the processed information.
  • Context - a car record has been successfully built for customs:
    For Increment Car Counter:
    When the car processing is complete, then the car counter should be incremented by 1 and the position counter should be incremented by 1.
👨‍💻 Technical ACs (Gherkin)
Context: A train car is being processed for customs reporting
GIVEN
A train car is being processed for customs reporting
Applied to: Is Car a Container?
WHEN
The car has a container indicator of 'C'
THEN
The car should be skipped and not included in the customs car records
Context: A non-container car is being processed for customs
GIVEN
A non-container car is being processed for customs
Applied to: Extract Car Initials
WHEN
The car equipment information is available
THEN
The car initials should be extracted from the equipment initials field and stored in the customs car record
Applied to: Extract Car Number
WHEN
The car equipment number is available
THEN
The car number should be extracted and converted to a 6-digit format for the customs car record
Context: A car is being processed and there are more cars in the train sequence
GIVEN
A car is being processed and there are more cars in the train sequence
Applied to: Determine Load/Empty Status from Next Car
WHEN
The next car in sequence has a container indicator of 'C'
THEN
The current car's load/empty status should be set to 'L' (Loaded), otherwise use the current car's load/empty status
Context: A car is being processed and it is the last car in the train sequence
GIVEN
A car is being processed and it is the last car in the train sequence
Applied to: Use Current Car Load/Empty Status
WHEN
No next car is available to check container status
THEN
The current car's own load/empty status indicator should be used for the customs record
Context: A car is being processed for customs reporting
GIVEN
A car is being processed for customs reporting
Applied to: Set Car Kind = 'L' for Locomotive
WHEN
The equipment type is 'LO'
THEN
The car kind should be set to 'L' to indicate locomotive
Applied to: Set Car Kind = Blank
WHEN
The equipment type is neither 'LO' nor 'ET'
THEN
The car kind should be set to blank spaces
Context: A car is being processed for customs reporting and equipment type is not 'LO'
GIVEN
A car is being processed for customs reporting and equipment type is not 'LO'
Applied to: Set Car Kind = 'E' for Engine
WHEN
The equipment type is 'ET'
THEN
The car kind should be set to 'E' to indicate engine
Context: All car information has been extracted and classified
GIVEN
All car information has been extracted and classified
Applied to: Build Customs Car Record
WHEN
Car initials, number, load/empty status, and car kind have been determined
THEN
A complete customs car record should be built with all the processed information
Context: A car record has been successfully built for customs
GIVEN
A car record has been successfully built for customs
Applied to: Increment Car Counter
WHEN
The car processing is complete
THEN
The car counter should be incremented by 1 and the position counter should be incremented by 1
R-GCX015-cbl-00361 (+7) File: GCX015.cbl Call AEI Email Database Query Merged 8 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Call AEI Email Database Query':
  • Context - aei email database query is requested:
    For Initialize Database Work Area:
    When the system begins the database lookup process, then the database work area aelwrktb is initialized to clear any previous data.
  • Context - a train record with security code gcwtl-secx exists:
    For Extract Train Port from Security Code:
    When the system needs to identify the train port for email lookup, then the train port is extracted from ws-train-secx and moved to the first 4 positions of record-key.
  • Context - aei email database query is being prepared:
    For Set Record Type to CUSEMAIL:
    When the system configures the database lookup parameters, then the record-type is set to 'cusemail' to specify customer email record lookup.
  • Context - database lookup parameters are configured with train port and cusemail record type:
    For Call AECWRKTB Database Function:
    When the system executes the database query, then aecwrktb is called with work area, return code, and db2 sql code parameters.
  • Context - aei email database query returns success code cst-aei-success:
    For Set Default Merlin ID as From User:
    When the system processes the successful query result, then cst-default-merlin-id is set as emi-from-usercode and email recipients are loaded from cusemail-user-id array.
  • Context - database query returned successfully with email user ids:
    For Load Email Recipients from Database:
    When the system processes the email recipient list, then up to 10 non-blank cusemail-user-id entries are moved to emi-to-usercodes array.
  • Context - aei email database query returns cst-aei-no-entry:
    For Use Default Merlin ID for To-User:
    When the system handles the no entry found condition, then cst-default-merlin-id is set as both emi-from-usercode and emi-to-usercode.
  • Context - aei email database query returns error code other than cst-aei-success or cst-aei-no-entry:
    For Send DB2 Error Alert:
    When the system encounters a database error, then b700-db2-abend procedure is performed and cst-default-merlin-id is set as emi-to-usercode.
👨‍💻 Technical ACs (Gherkin)
Context: AEI email database query is requested
GIVEN
AEI email database query is requested
Applied to: Initialize Database Work Area
WHEN
the system begins the database lookup process
THEN
the database work area AELWRKTB is initialized to clear any previous data
Context: a train record with security code GCWTL-SECX exists
GIVEN
a train record with security code GCWTL-SECX exists
Applied to: Extract Train Port from Security Code
WHEN
the system needs to identify the train port for email lookup
THEN
the train port is extracted from WS-TRAIN-SECX and moved to the first 4 positions of RECORD-KEY
Context: AEI email database query is being prepared
GIVEN
AEI email database query is being prepared
Applied to: Set Record Type to CUSEMAIL
WHEN
the system configures the database lookup parameters
THEN
the RECORD-TYPE is set to 'CUSEMAIL' to specify customer email record lookup
Context: database lookup parameters are configured with train port and CUSEMAIL record type
GIVEN
database lookup parameters are configured with train port and CUSEMAIL record type
Applied to: Call AECWRKTB Database Function
WHEN
the system executes the database query
THEN
AECWRKTB is called with work area, return code, and DB2 SQL code parameters
Context: AEI email database query returns success code CST-AEI-SUCCESS
GIVEN
AEI email database query returns success code CST-AEI-SUCCESS
Applied to: Set Default Merlin ID as From User
WHEN
the system processes the successful query result
THEN
CST-DEFAULT-MERLIN-ID is set as EMI-FROM-USERCODE and email recipients are loaded from CUSEMAIL-USER-ID array
Context: database query returned successfully with email user IDs
GIVEN
database query returned successfully with email user IDs
Applied to: Load Email Recipients from Database
WHEN
the system processes the email recipient list
THEN
up to 10 non-blank CUSEMAIL-USER-ID entries are moved to EMI-TO-USERCODES array
Context: AEI email database query returns CST-AEI-NO-ENTRY
GIVEN
AEI email database query returns CST-AEI-NO-ENTRY
Applied to: Use Default Merlin ID for To-User
WHEN
the system handles the no entry found condition
THEN
CST-DEFAULT-MERLIN-ID is set as both EMI-FROM-USERCODE and EMI-TO-USERCODE
Context: AEI email database query returns error code other than CST-AEI-SUCCESS or CST-AEI-NO-ENTRY
GIVEN
AEI email database query returns error code other than CST-AEI-SUCCESS or CST-AEI-NO-ENTRY
Applied to: Send DB2 Error Alert
WHEN
the system encounters a database error
THEN
B700-DB2-ABEND procedure is performed and CST-DEFAULT-MERLIN-ID is set as EMI-TO-USERCODE
R-GCX015-cbl-00369 (+7) File: GCX015.cbl Call EMCSEND2 for Primary Send Merged 8 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Call EMCSEND2 for Primary Send':
  • Context - a merlin message needs to be sent:
    For Set From User to OM01247:
    When setting up the primary message transmission, then the from user code should be set to om01247.
  • Context - a merlin message sender has been configured:
    For Set To User to OM01247:
    When setting up the message recipient, then the to user code should be set to om01247.
  • Context - a merlin message has been configured with sender and recipient:
    For Set Subject to Merlin Subject:
    When setting the message subject, then the subject should be set to the predefined merlin subject content.
  • Context - a merlin message has been fully configured with sender, recipient, and subject:
    For Call EMCSEND2 for Primary Send:
    When executing the message transmission, then the emcsend2 service should be called with all message parameters.
  • Context - a merlin message has been successfully transmitted:
    For Purge Message Queue:
    When the transmission completes without errors, then the message queue should be purged to clean up resources.
  • Context - a merlin message transmission has failed:
    For Send Invalid From User Error:
    When the failure is due to an invalid sender user identification, then an invalid merlin sender error message should be generated and the process should terminate abnormally.
    For Send Invalid To/Copy User Error:
    When the failure is due to an invalid recipient or copy user identification, then an invalid merlin recipient or copy user error message should be generated and the process should terminate abnormally.
    For Send Invalid Filename Error:
    When the failure is due to an invalid filename, then an invalid merlin filename error message should be generated and the process should terminate abnormally.
👨‍💻 Technical ACs (Gherkin)
Context: A Merlin message needs to be sent
GIVEN
A Merlin message needs to be sent
Applied to: Set From User to OM01247
WHEN
Setting up the primary message transmission
THEN
The from user code should be set to OM01247
Context: A Merlin message sender has been configured
GIVEN
A Merlin message sender has been configured
Applied to: Set To User to OM01247
WHEN
Setting up the message recipient
THEN
The to user code should be set to OM01247
Context: A Merlin message has been configured with sender and recipient
GIVEN
A Merlin message has been configured with sender and recipient
Applied to: Set Subject to Merlin Subject
WHEN
Setting the message subject
THEN
The subject should be set to the predefined Merlin subject content
Context: A Merlin message has been fully configured with sender, recipient, and subject
GIVEN
A Merlin message has been fully configured with sender, recipient, and subject
Applied to: Call EMCSEND2 for Primary Send
WHEN
Executing the message transmission
THEN
The EMCSEND2 service should be called with all message parameters
Context: A Merlin message has been successfully transmitted
GIVEN
A Merlin message has been successfully transmitted
Applied to: Purge Message Queue
WHEN
The transmission completes without errors
THEN
The message queue should be purged to clean up resources
Context: A Merlin message transmission has failed
GIVEN
A Merlin message transmission has failed
Applied to: Send Invalid From User Error
WHEN
The failure is due to an invalid sender user identification
THEN
An invalid Merlin sender error message should be generated and the process should terminate abnormally
Applied to: Send Invalid To/Copy User Error
WHEN
The failure is due to an invalid recipient or copy user identification
THEN
An invalid Merlin recipient or copy user error message should be generated and the process should terminate abnormally
Applied to: Send Invalid Filename Error
WHEN
The failure is due to an invalid filename
THEN
An invalid Merlin filename error message should be generated and the process should terminate abnormally
R-GCX015-cbl-00377 (+8) File: GCX015.cbl Call EMCSEND2 for Secondary Send Merged 9 Rules
Action Rules (from EDI)
👔 Business Narrative
Business Logic Rules for 'Call EMCSEND2 for Secondary Send':
  • Context - a secondary merlin send process is initiated:
    For Initialize Secondary Recipients:
    When the system prepares to set up alternative recipients, then all recipient user code fields are cleared to spaces.
  • Context - secondary merlin send is being configured:
    For Set Primary Merlin ID as From User:
    When the from user needs to be established, then the primary merlin id 'om01247' is set as the from user code.
    For Set Secondary Destination File:
    When destination file needs to be specified, then the secondary destination filename (emi-destination-filename2) is used for message delivery.
  • Context - secondary merlin send requires recipient configuration:
    For Get Admin Table Recipients:
    When administrative table recipients need to be assigned, then primary recipient is set from admin table dc-p-merlin-1 field and copy recipient is set from admin table dc-p-merlin-5 field.
  • Context - all secondary send parameters are configured:
    For Call EMCSEND2 for Secondary Send:
    When the secondary merlin send is executed, then emcsend2 service is called with configured parameters including from user, destination file, recipients, subject, and message content.
  • Context - secondary merlin send has been executed:
    For Purge Message Queue:
    When the send operation completes without errors (emi-no-errors), then the message queue is purged using cims with purg function.
    For Handle From User Not Found Error:
    When the send fails due to invalid from user (emi-from-not-found), then system abend is triggered with error message 'emi - invalid merlin from'.
    For Handle To/Copy User Not Found Error:
    When the send fails due to invalid recipient or copy user (emi-to-or-copy-not-found), then system abend is triggered with error message 'emi - invalid merlin to or copy'.
    For Handle Invalid Filename Error:
    When the send fails due to invalid filename (emi-filename-invalid), then system abend is triggered with error message 'emi - invalid merlin filename'.
👨‍💻 Technical ACs (Gherkin)
Context: A secondary Merlin send process is initiated
GIVEN
A secondary Merlin send process is initiated
Applied to: Initialize Secondary Recipients
WHEN
The system prepares to set up alternative recipients
THEN
All recipient user code fields are cleared to spaces
Context: Secondary Merlin send is being configured
GIVEN
Secondary Merlin send is being configured
Applied to: Set Primary Merlin ID as From User
WHEN
The from user needs to be established
THEN
The primary Merlin ID 'OM01247' is set as the from user code
Applied to: Set Secondary Destination File
WHEN
Destination file needs to be specified
THEN
The secondary destination filename (EMI-DESTINATION-FILENAME2) is used for message delivery
Context: Secondary Merlin send requires recipient configuration
GIVEN
Secondary Merlin send requires recipient configuration
Applied to: Get Admin Table Recipients
WHEN
Administrative table recipients need to be assigned
THEN
Primary recipient is set from admin table DC-P-MERLIN-1 field and copy recipient is set from admin table DC-P-MERLIN-5 field
Context: All secondary send parameters are configured
GIVEN
All secondary send parameters are configured
Applied to: Call EMCSEND2 for Secondary Send
WHEN
The secondary Merlin send is executed
THEN
EMCSEND2 service is called with configured parameters including from user, destination file, recipients, subject, and message content
Context: Secondary Merlin send has been executed
GIVEN
Secondary Merlin send has been executed
Applied to: Purge Message Queue
WHEN
The send operation completes without errors (EMI-NO-ERRORS)
THEN
The message queue is purged using CIMS with PURG function
Applied to: Handle From User Not Found Error
WHEN
The send fails due to invalid from user (EMI-FROM-NOT-FOUND)
THEN
System abend is triggered with error message 'EMI - INVALID MERLIN FROM'
Applied to: Handle To/Copy User Not Found Error
WHEN
The send fails due to invalid recipient or copy user (EMI-TO-OR-COPY-NOT-FOUND)
THEN
System abend is triggered with error message 'EMI - INVALID MERLIN TO OR COPY'
Applied to: Handle Invalid Filename Error
WHEN
The send fails due to invalid filename (EMI-FILENAME-INVALID)
THEN
System abend is triggered with error message 'EMI - INVALID MERLIN FILENAME'