pub struct Field20 {
pub transaction_reference: String,
}
Expand description
§Field 20: Transaction Reference
§Overview
Field 20 contains the sender’s reference to identify the related transaction uniquely. This field is mandatory in most SWIFT MT messages and serves as the primary identifier for transaction tracking, reconciliation, and reference purposes throughout the payment processing lifecycle.
§Format Specification
Format: 16x
- 16x: Up to 16 alphanumeric characters
- Character set: A-Z, a-z, 0-9, and limited special characters
- Case sensitivity: Preserved as entered
- Padding: No padding required (variable length up to 16 characters)
§Structure and Content
The transaction reference typically follows institutional naming conventions:
FT21234567890123
│└─────────────┘
│ Reference ID
└── Transaction type prefix (optional)
§Common Reference Patterns
Different institutions use various patterns for transaction references:
- Sequential:
FT000001
,FT000002
,FT000003
- Date-based:
FT20241201001
,FT20241201002
- Branch-based:
NYC001234567
,LON987654321
- System-generated:
TXN1234567890
,REF0987654321
- Customer-based:
CUST12345678
,CLI0000012345
§Usage Context
Field 20 is used in numerous SWIFT MT message types:
- MT103: Single Customer Credit Transfer
- MT202: General Financial Institution Transfer
- MT202COV: Cover for customer credit transfer
- MT900: Confirmation of Debit
- MT910: Confirmation of Credit
- MT950: Statement Message
- MT940: Customer Statement Message
§Business Applications
- Transaction tracking: Unique identification across systems
- Reconciliation: Matching payments with confirmations
- Audit trails: Regulatory compliance and investigation
- Customer service: Reference for inquiries and disputes
- STP processing: Automated transaction processing
- Nostro reconciliation: Account statement matching
§Validation Rules
- Length: Maximum 16 characters
- Character set: Alphanumeric characters and limited special characters
- Uniqueness: Should be unique within sender’s system for the day
- Non-empty: Cannot be empty or contain only whitespace
- Format consistency: Should follow institutional standards
§Network Validated Rules (SWIFT Standards)
- Transaction reference must not exceed 16 characters (Error: T13)
- Must contain valid SWIFT character set (Error: T61)
- Cannot be empty (Error: T18)
- Should be unique per sender per day (Warning: recommended practice)
§Examples
:20:FT21234567890
└─── Wire transfer reference
:20:TXN0000012345
└─── System-generated transaction ID
:20:NYC20241201001
└─── Branch and date-based reference
:20:CUST123456789A
└─── Customer-based reference with check digit
Fields§
§transaction_reference: String
Transaction reference value (maximum 16 characters)
Contains the sender’s unique reference for the transaction. This value is used throughout the payment processing lifecycle for tracking, reconciliation, and audit purposes.
Format: Up to 16 alphanumeric characters Character set: A-Z, a-z, 0-9, and limited special characters Case sensitivity: Preserved as entered Uniqueness: Should be unique within sender’s system per day
§Examples
"FT21234567890"
- Wire transfer reference"TXN0000012345"
- System-generated ID"NYC20241201001"
- Branch and date-based"CUST123456789A"
- Customer-based with check digit
Implementations§
Source§impl Field20
impl Field20
Sourcepub fn new(transaction_reference: String) -> Self
pub fn new(transaction_reference: String) -> Self
Create a new Field20 with comprehensive validation
Creates a new transaction reference field with the provided reference string. The reference is validated for length and character set compliance.
§Arguments
transaction_reference
- The transaction reference string (max 16 chars)
§Examples
use swift_mt_message::fields::Field20;
// Standard wire transfer reference
let field = Field20::new("FT21234567890".to_string());
// System-generated transaction ID
let field = Field20::new("TXN0000012345".to_string());
// Date-based reference
let field = Field20::new("20241201001".to_string());
§Validation
The constructor performs basic validation but full validation
occurs when calling validate()
method or during SWIFT message processing.
Sourcepub fn transaction_reference(&self) -> &str
pub fn transaction_reference(&self) -> &str
Get the transaction reference value
Returns the transaction reference string that uniquely identifies this transaction within the sender’s system.
§Returns
A string slice containing the transaction reference
§Example
let field = Field20::new("FT21234567890".to_string());
assert_eq!(field.transaction_reference(), "FT21234567890");
Sourcepub fn reference_pattern(&self) -> &'static str
pub fn reference_pattern(&self) -> &'static str
Check if the reference follows a common pattern
Analyzes the transaction reference to determine if it follows common institutional patterns for reference generation.
§Returns
A string describing the detected pattern, or “Custom” if no pattern is detected
§Example
let ft_ref = Field20::new("FT21234567890".to_string());
assert_eq!(ft_ref.reference_pattern(), "Wire Transfer");
let txn_ref = Field20::new("TXN0000012345".to_string());
assert_eq!(txn_ref.reference_pattern(), "Transaction ID");
Sourcepub fn is_date_based(&self) -> bool
pub fn is_date_based(&self) -> bool
Check if the reference appears to be date-based
Determines if the transaction reference contains date information based on common date patterns in reference strings.
§Returns
true
if the reference appears to contain date information
§Example
let date_ref = Field20::new("20241201001".to_string());
assert!(date_ref.is_date_based());
let simple_ref = Field20::new("FT12345".to_string());
assert!(!simple_ref.is_date_based());
Sourcepub fn sequence_number(&self) -> Option<u32>
pub fn sequence_number(&self) -> Option<u32>
Extract potential sequence number from reference
Attempts to extract a sequence number from the transaction reference, which is commonly found at the end of structured references.
§Returns
Some(number)
if a sequence number is found, None
otherwise
§Example
let seq_ref = Field20::new("FT001".to_string());
assert_eq!(seq_ref.sequence_number(), Some(1));
let no_seq = Field20::new("CUSTOMREF".to_string());
assert_eq!(no_seq.sequence_number(), None);
Sourcepub fn description(&self) -> String
pub fn description(&self) -> String
Sourcepub fn is_well_formed(&self) -> bool
pub fn is_well_formed(&self) -> bool
Validate reference format according to institutional standards
Performs additional validation beyond the standard SWIFT field validation, checking for common institutional reference format requirements.
§Returns
true
if the reference follows good practices, false
otherwise
§Example
let good_ref = Field20::new("FT21234567890".to_string());
assert!(good_ref.is_well_formed());
let poor_ref = Field20::new("x".to_string());
assert!(!poor_ref.is_well_formed());