---
title: "Recommended Segment Life Cycle 3.0"
id: "recommended-segment-life-cycle-3-0"
project: "Knowledge Base"
url: "https://docs.sepasoft.com/articles/knowledge-base/recommended-segment-life-cycle-3-0"
updated: 2026-07-23T18:08:39Z
---

# Recommended Segment Life Cycle 3\.0

## Overview

Life cycle and tips while scripting with the segment functions.

### Applies To and Version Info

This feature applies to the Track & Trace module and is available in all versions.

## Scripting

Code

```
#Create the segment
seg = system.mes.createSegment('Unload-Test_1234', '[global]\Enterprise\Site\Area\Unload Station 1', True)
seg.setMaterial('New Material', 'Raw Material A', '[global]\Enterprise\Site\Area\Raw Storage Tanks\Raw Storage Tank 1', 'Lot Test_1236', 100)
 
#Begin the segment
seg = seg.begin()
seg.setMaterial('New Material', 'Raw Material A', '[global]\Enterprise\Site\Area\Raw Storage Tanks\Raw Storage Tank 1', 'Lot Test_1237', 100)
 
#After material is changed, update() should be called before the end() call
seg = seg.update()
seg.end()
```


## References

[setMaterial](/docs/display/MHD/Response-Segment)

[Segment Functions](/docs/display/MHD/Response-Segment)

## Keywords

None