Skip to content

Justified Clause

This clause causes a SOURCE, SUM, COUNT, VALUE, or FUNCTION clause whose operand is shorter or longer than the target report field to fill the report field with excess spaces, or perform truncation, on the left instead of the right.

justified clause

Justified Clause: Coding Rules

  • If you code JUSTIFIED RIGHT in an elementary entry, the entry must have an alphanumeric PICTURE.

  • This clause acts on elementary-level fields, but you may also code it in a group-level entry, including 01, where it applies to all the alphanumeric elementary entries in the group.

Justified Clause: Operation

  • The JUSTIFIED clause is retained for compatibility with ANS COBOL and acts on an elementary field in the same way as in basic COBOL. It cannot be used for right-flushing variable-length fields, for which COLUMN RIGHT should be used. (See 3.4 COLUMN clause.) This is because JUSTIFIED does not consider the contents of the sending field.

  • The JUSTIFIED clause takes effect when your alphanumeric SOURCE field is of a different size from the PICTURE. The padding out with spaces or the truncation (if the PICTURE is smaller than the field) then takes place on the left instead of the right. In the following example, we want to output either MONTH-NUMBER (2 characters) in columns 12 and 13 or YEAR-NUMBER (4 characters) in columns 10 through 13:

       05 COL 10 PIC X(4) JUSTIFIED RIGHT 
               SOURCE MONTH-NUMBER WHEN MONTH-IND = 1 
               YEAR-NUMBER WHEN OTHER.
    

Compatibility

OS/VS and DOS/VS COBOL allow this clause only in elementary entries, but in all other respects new Report Writer and the older compilers treat it identically.

Back to top