In DFSORT, FS (also written CSF) stands for signed numeric with optional leading floating sign. Unlike ZD (zoned decimal), where the sign is fixed in the last byte, or PD (packed decimal), where the sign is in the rightmost nibble, FS allows the sign character to appear anywhere to the left of the digits. DFSORT finds the first character that is not a decimal digit (0–9) when scanning from right to left and treats it as the sign: "-" means negative, and any other character (e.g. "+" or blank) means positive. Everything to the left of that sign is ignored. This format matches data produced by FORTRAN, PL/I, and COBOL display formats such as PIC ++9, PIC +999, PIC ---9, and PIC ZZZZ. This page explains what FS is, how the sign is determined, when to use it instead of ZD or PD, and how to specify it in SORT FIELDS, INCLUDE/OMIT, and build statements.
FS tells DFSORT: "this field is a signed number, but the sign is not in a fixed position." The format is often shown as s d…d: an optional sign s to the left of the digits d…d. The key rule: the first non–decimal digit (i.e. not 0–9) found when scanning from right to left is treated as the sign. If that character is "-", the value is negative; otherwise (including "+", blank, or any other character) the value is positive. Any characters to the left of that sign are ignored when forming the numeric value. So the sign "floats" in the sense that it can appear in different column positions depending on how many leading blanks or plus signs are present.
DFSORT parses the field from right to left. It collects decimal digits (0–9) and stops when it hits the first non-digit. That character is the sign indicator. Only "-" (minus) is treated as negative; everything else—including "+", blank, space, or any other character—is treated as positive. So:
| Value in field | Treated as |
|---|---|
| 34 | +34 (blank or + to left of digits = positive) |
| +34 | +34 |
| 00034 | +34 |
| -003 | -3 |
| --1234 | -1234 |
| 1234 | +1234 |
| +01234 | +1234 |
| 0 | +0 |
This behavior allows one format to handle FORTRAN-style fixed columns, PL/I edited pictures, and COBOL display fields where the sign might be leading separate, leading overpunch, or in a dedicated position that varies by implementation.
Use FS (or CSF) wherever you specify a format for a numeric field:
1SORT FIELDS=(start,length,FS,direction)
Example: sort by a 10-byte field at position 20 that contains values like " +123" or " -456", ascending:
1SORT FIELDS=(20,10,FS,A)
You can use FS in INCLUDE/OMIT when comparing the field to a constant, and in INREC/OUTREC when the build refers to a floating-sign field. The length you give is the full length of the area that contains the number and its optional sign and padding.
Choosing the right format avoids wrong sort order or comparison results:
| Format | Meaning | Typical use |
|---|---|---|
| FS (CSF) | Signed numeric, sign can float (first non-digit from right = sign). | FORTRAN, PL/I, COBOL display with separate or floating sign (PIC ++9, PIC ---9, etc.). |
| ZD | Zoned decimal: one digit per byte, sign in last byte (low-order 4 bits). | COBOL PIC S9(n) DISPLAY, standard EBCDIC zoned. |
| PD | Packed decimal: two digits per byte (except last has sign nibble). | COBOL COMP-3, binary-packed decimal. |
If your data has a fixed zoned layout with sign in the last byte, use ZD. If it is packed decimal, use PD. If the sign can appear in a variable position with leading blanks or plus/minus, use FS so that DFSORT parses the value correctly.
IBM documentation states that FS (CSF) encompasses data produced by several FORTRAN, PL/I, and COBOL formats. Examples (with a width of 4 for illustration):
In these cases the numeric value may have a leading or embedded sign (plus, minus, or blank for positive) and possibly leading zeros or spaces. FS interprets them consistently by the right-to-left rule.
| Use case | Reason |
|---|---|
| FORTRAN fixed-column numeric output | Sign and leading spaces vary by value; FS parses right-to-left. |
| PL/I edited numeric (e.g. P'SSS9') | Sign position can vary; FS handles it. |
| COBOL PIC with floating sign (++, +999, ---9, ZZZZ) | Display format with optional leading sign; FS matches. |
| Legacy files with variable sign position | When you cannot rely on fixed zoned (ZD) or packed (PD) layout. |
When you filter records with INCLUDE or OMIT and the condition involves a numeric comparison, specify the format of the field. If that field has a floating sign, use FS so that the comparison uses the parsed numeric value. For example, to include only records where the value in positions 1–10 is greater than zero:
1INCLUDE COND=(1,10,FS,GT,+0)
The constant +0 is the numeric zero; GT means greater than. DFSORT will parse each record's 1–10 as FS and compare the result to 0.
Imagine a number written on a whiteboard with a plus or minus in front, but sometimes there are extra spaces. We read from the right: we find the digits (0–9), and the first thing that isn't a digit is the sign. If it's a minus, the number is negative; if it's a plus or a space, the number is positive. We ignore any extra stuff to the left. FS is the rule that tells the sort program to read numbers that way—so " +34" and " 34" and "00034" all count as the same positive number 34, and "-003" is minus 3. That way we can sort them in the right order even when the sign and spaces are in different places.
1. What does FS (or CSF) mean in DFSORT?
2. How does FS determine whether a value is positive or negative?
3. Which COBOL or language data types does FS handle?
4. When should you use FS instead of ZD?
5. What value does FS treat " 00034 " as?