RJUST: Right-Justifying a Character String

How to:

Available Languages: reporting

The RJUST function right-justifies a character string. All trailing blacks become leading blanks. This is useful when you display alphanumeric fields containing numbers.

RJUST does not have any visible effect in a report that uses StyleSheets (SET STYLE=ON) unless you center the item. Also, if you use RJUST on a platform on which StyleSheets are turned on by default, issue SET STYLE=OFF before running the request.

There is a version of the RJUST function that is available only in the Maintain language. For information on this function, see RJUST: Right-Justifying a Character String (Maintain).

Syntax: How to Right-Justify a Character String

RJUST(length, source_string, output)

where:

length

Integer

Is the number of characters in source_string and output, or a field that contains the length. Their lengths must be the same to avoid justification problems.

source_string

Alphanumeric

Is the character string to right justify, or a field or variable that contains the character string enclosed in single quotation marks.

output

Alphanumeric

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.

Example: Right-Justifying a String

RJUST right-justifies the LAST_NAME field and stores the result in RIGHT_NAME:

SET STYLE=OFF
TABLE FILE EMPLOYEE
PRINT LAST_NAME AND COMPUTE
RIGHT_NAME/A15 = RJUST(15, LAST_NAME, RIGHT_NAME);
WHERE DEPARTMENT EQ 'MIS';
END

The output is:

LAST_NAME        RIGHT_NAME
---------        ----------
SMITH                 SMITH
JONES                 JONES
MCCOY                 MCCOY
BLACKWOOD         BLACKWOOD
GREENSPAN         GREENSPAN
CROSS                 CROSS