Today we're diving into one of the most useful, and clever, keywords in DDS Logical Files: SST (short for Substring)
Think of SST as your “virtual scalpel” it lets you carve out pieces of an existing field and present them as brand-new fields in a logical file, without touching the physical file.
This is pure gold for:
- Creating partial keys
- Splitting names, codes, or dates
- Building cleaner views for programs and reports
How SST Works - The Simple Version
Breaking it down:
| Part | What it means | Example |
|---|---|---|
| newfield | The name of your new derived field | FIRSTNAME |
| length | Optional – length of the new field | 10 |
| SST(...) | The magic keyword | SST(FULLNAME 1 15) |
| sourcefield | Field you are cutting from | FULLNAME |
| start-position | Where to start cutting (1 = first character) | 1 |
| length | Optional – how many characters to take | 15 |
Real-World Examples (with explanations)
1. Splitting a Name Field
Physical file has FULLNAME 30A
→ Creates two clean fields you can use in programs and screens.
2. Partial Key (Super Common & Powerful)
Now you can read all products in the same group with just the first 3 characters. No need to change the physical file!
3. Extracting Parts of a Code
Imagine a 12-character barcode: ABC-12345-XYZ
4. Working with Numbers (The Zoned Trick)
You cannot SST a packed numeric field directly. Solution: Force it to zoned first:
Important Rules You Must Remember
- SST fields are derived → almost always use usage I (Input Only). You can’t update them.
- Works on Character, Hex, and Zoned fields. Not directly on Packed.
- You can substring a field that was itself created by SST (just define it in the right order).
- Starting position is 1-based (position 1 = first byte).
- If you leave out the length, it takes everything to the end of the field.
Something to remember
Always document your SST fields clearly - future you (or the poor soul who maintains your code) will thank you.
Choose meaningful field names such as CUSTNO6 or PRODGRP rather than generic ones like PARTKEY.
SST is an excellent tool for modernizing legacy systems without requiring massive rewrites of the physical files.
For more complex logic, consider using SQL views instead; however, for performance-critical access paths and simple derived keys, the SST keyword remains the king in DDS logical files.
