AMT Help Files

Left-Justify function

The left-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 left-justified, the value within the alphanumeric field will be moved to the left side of the field and the remainder will be filled with trailing spaces.

For example, when using the left-justify function on a PIC X(5) containing the value '   AB', the new value will be 'AB   '.
See also: Right-Justify function.

The syntax for this function is as follows:

FUNCTION LEFT-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 FUNCTION LEFT-JUSTIFY(ADDR-NUMBER-SELECTED OF ADDR-SEARCH-SCREEN) TO ADDR-NUMBER-SELECTED-FLD.
     IF ADDR-LINE-25-TEXT-FLD NOT = SPACES
        DISPLAY ADDR-LINE-25-TEXT-FLD
        MOVE SPACES TO ADDR-LINE-25-TEXT-FLD
     END-IF.
    
EXIT-WS-TO-FORM-END.
     EXIT.

...