05 WS-ALPHA PIC X(10).
WS-ALPHA can have only left justified digits of length varying from 1 to 5(rest filled with spaces) e.g. "1 " "12 " "123 " "1234 " "12345 ".
Now I have to format and display the value of WS-ALPHA in SYSOUD with leading zero if the length is less than 5. so if the value of WS-ALPHA is "1 " it should be displayed as "00001"
I have made many unsuccessful attempt. Please help me know how i can do it.
one of the bad attmepts:
01 WS-VARIABLES.
05 WS-ALPHA-PARM PIC X(10) VALUE '1 '.
05 WS-ALPHA-05-PARM PIC X(05) VALUE SPACES.
05 WS-NUM-05-PARM PIC 9(05) VALUE ZEROES.
05 WS-NUM-05-PARM2 PIC 9(05) VALUE ZEROES.
/
PROCEDURE DIVISION.
MOVE WS-ALPHA-PARM TO WS-ALPHA-05-PARM
MOVE WS-ALPHA-05-PARM TO WS-NUM-05-PARM
MOVE WS-NUM-05-PARM TO WS-NUM-05-PARM2
DISPLAY 'WS-NUM-05-PARM :' WS-NUM-05-PARM
DISPLAY 'WS-NUM-05-PARM2:' WS-NUM-05-PARM2
result: WS-NUM-05-PARM :1 0
WS-NUM-05-PARM2:1 0
05 WS-ALPHA-PARM PIC X(10) VALUE '1 '.
05 WS-ALPHA-05-PARM PIC X(05) VALUE SPACES.
05 WS-NUM-05-PARM PIC 9(05) VALUE ZEROES.
05 WS-NUM-05-PARM2 PIC 9(05) VALUE ZEROES.
/
PROCEDURE DIVISION.
MOVE WS-ALPHA-PARM TO WS-ALPHA-05-PARM
MOVE WS-ALPHA-05-PARM TO WS-NUM-05-PARM
MOVE WS-NUM-05-PARM TO WS-NUM-05-PARM2
DISPLAY 'WS-NUM-05-PARM :' WS-NUM-05-PARM
DISPLAY 'WS-NUM-05-PARM2:' WS-NUM-05-PARM2
result: WS-NUM-05-PARM :1 0
WS-NUM-05-PARM2:1 0