JDoodle - Online COBOL Compiler IDE ... ( Ctrl+C, open this link in new panel, Ctrl+V, Submit )
identification division. program-id. ED-A. *> Elementary Data Items - pic X, 9, Z data division. working-storage section. 77 A pic x(7) value "Hi". 77 B pic 9(7) value 17. 77 C pic z(7) value 256. 77 D pic z(6)9 value 8234. 77 E pic zzz,zz9 value 1283. procedure division. display "A=" A " ... X - non numeric, from the LEFT" display "B=" B " ... 9 - numeric, from the RIGHT, if = 0 then all zeros" display "C=" C " ... Z - numeric edited, if = 0 then all spaces" display "D=" D " ... numeric edited, if D = 0 then one zero" display "E=" E " ... numeric edited, fix comma for thousands" display " " display "......v......v......v......v......v" display A B C D E initialize A B C D E display A B C D E stop run.
Note:
INITIALIZE statement was new in ANSI-85
before that it was necessary:
move space to A
move 0 to B C D E
Output:
A=Hi ... X - non numeric, from the LEFT
B=0000017 ... 9 - numeric, from the RIGHT, if = 0 then all zeros
C= 256 ... Z - numeric edited, if = 0 then all spaces
D= 8234 ... numeric edited, if D = 0 then one zero
E= 1,283 ... numeric edited, fix comma for thousands
......v......v......v......v......v
Hi 0000017 256 8234 1,283
0000000 0 0
ČeV - 6.5.2020