The SST keyword in IBM-i logical files

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

A newfield [length] [type] SST(sourcefield start-position [length])

Breaking it down:

PartWhat it meansExample
newfieldThe name of your new derived fieldFIRSTNAME
lengthOptional – length of the new field10
SST(...)The magic keywordSST(FULLNAME 1 15)
sourcefieldField you are cutting fromFULLNAME
start-positionWhere to start cutting (1 = first character)1
lengthOptional – how many characters to take15

Real-World Examples (with explanations)

1. Splitting a Name Field

Physical file has FULLNAME 30A

A R CUSTREC         PFILE(CUSTOMER)
A   FIRSTNAME 15A I SST(FULLNAME 1 15)
A   LASTNAME  15A I SST(FULLNAME 16 15)

→ Creates two clean fields you can use in programs and screens.

2. Partial Key (Super Common & Powerful)

A   PRODGRP    I   SST(PRODCODE 1 3)
A K PRODGRP

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

A   PREFIX   3A I   SST(BARCODE 1 3)
A   SERIAL   5A I   SST(BARCODE 5 5)
A   SUFFIX   3A I   SST(BARCODE 11 3)

4. Working with Numbers (The Zoned Trick)

You cannot SST a packed numeric field directly. Solution: Force it to zoned first:

A   ORDERNO   S 7 0
* This makes it zoned
A   YEAR      I       SST(ORDERNO 1 2)
A   MONTH     I       SST(ORDERNO 3 2)

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.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>