Right-Justify function
The right-justify function will set the alignment of an alphanumeric field in either the form or in the input/output section of the COBOL form working storage.
This function can only be used in the FORM-TO-WS or WS-TO-FORM logic of a CobolForm.
By setting a field to be right-justified, the value within the alphanumeric field will be moved to the right side of the field and the remainder will be filled with leading spaces.
For example, when using the right-justify function on a PIC X(5) containing the value 'AB ', the new value will be ' AB'.
See also: Left-Justify function.
The syntax for this function is as follows:
FUNCTION RIGHT-JUSTIFY(<FieldName>)
Parameter | Description |
<FieldName> | The name of an alphanumeric field in either the (screen copy) working-storage or a form field. |
Example:
PROCEDURE DIVISION.
WS-TO-FORM SECTION.
INIT-WS-TO-FORM.
MOVE ZERO TO FORM-STATUS.
IF NOT FORM-ERROR
IF NOT ((ADDR-MORE-FLD = 'N' OR 'Y') OR (ADDR-MORE-FLD = SPACES))
DISPLAY "ILLEGAL CHARACTER - FIELD MUST BE IN ['N', 'Y']"
CALL "SETCURSOR" USING ADDR-MORE-FLD
MOVE 1 TO FORM-STATUS
END-IF
END-IF.
MOVE FUNCTION RIGHT-JUSTIFY(ADDR-NUMBER-SELECTED-FLD) TO ADDR-NUMBER-SELECTED OF ADDR-SEARCH-SCREEN.
EXIT-WS-TO-FORM-END.
EXIT.
...