---
title: TrnSegment
summary: API reference for TrnSegment.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common.Files
reference_type: package
---

# TrnSegment

`TrnSegment` models the X12 TRN trace-number segment, used in 835/837 transactions to carry a trace number (e.g. a payment/check number or claim trace identifier) that lets the receiver correlate the transaction back to the sender's originating record. Its two optional trailing elements are written only when populated ([BR-059](../../business-rules.md#br-059-optional-segment-elements-written-only-when-populated)).

## Purpose
- Represents the TRN segment identity via `SegmentId` returning the literal `"TRN"` ([BR-020](../../business-rules.md#br-020-first-element-is-the-segment-identifier)).
- Carries `TraceTypeCode` classifying the trace, paired with `CurrentTransactionTraceNumbers`, the trace number value itself.
- Writes `OriginatingCompanyIdentifier` (TRN03) and `ReferenceIdentification` (TRN04) on `Build()` only when they are non-empty ([BR-059](../../business-rules.md#br-059-optional-segment-elements-written-only-when-populated)).

## Context
- Namespace: `SAIF.Common.Files.Edi.Segments`
- Assembly/package: `SAIF.Framework.Common.Files`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| SegmentId | `string SegmentId { get; }` | Returns the literal X12 segment identifier `"TRN"`. |
| TraceTypeCode | `string TraceTypeCode { get; set; }` | The trace-type qualifier code (TRN01), element 1. |
| CurrentTransactionTraceNumbers | `string CurrentTransactionTraceNumbers { get; set; }` | The trace number value (TRN02), element 2. |
| OriginatingCompanyIdentifier | `string OriginatingCompanyIdentifier { get; set; }` | The originating company's identifier (TRN03), written on `Build()` only when non-empty ([BR-059](../../business-rules.md#br-059-optional-segment-elements-written-only-when-populated)). |
| ReferenceIdentification | `string ReferenceIdentification { get; set; }` | An additional reference identifier for the trace (TRN04), written on `Build()` only when non-empty ([BR-059](../../business-rules.md#br-059-optional-segment-elements-written-only-when-populated)). |
| Build | `IEdiSegment Build()` | Creates a `SegmentBuilder("TRN")`, adds `TraceTypeCode` and `CurrentTransactionTraceNumbers` at elements 1-2 unconditionally, and adds `OriginatingCompanyIdentifier`/`ReferenceIdentification` at elements 3-4 only when non-empty, returning the built segment ([BR-059](../../business-rules.md#br-059-optional-segment-elements-written-only-when-populated)). |
| Fill | `void Fill(IEdiSegment segment)` | Reads elements 1-4 via `GetChildValue` into `TraceTypeCode`, `CurrentTransactionTraceNumbers`, `OriginatingCompanyIdentifier`, and `ReferenceIdentification`. |
| Parse | `static TrnSegment Parse(IEdiSegment segment)` | Instantiates a new `TrnSegment`, calls `Fill(segment)` on it, and returns it. |

## Sources
- Common\SAIF.Common.Files\Edi\Segments\TrnSegment.cs
