The picture clause defines the format which the DISPLAY command would output to the console. Is there a means to "output" the formatted string to a variable? Something like the following, but something that works. The following is an arbitrary example of a number, transformed by a picture, and stored in a string in the currency format.
IDENTIFICATION DIVISION.
PROGRAM-ID. Demo1234.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Price Pic $$$,$$9.99.
01 Formated-Output Pic X(10).
PROCEDURE DIVISION.
Move 10.50 to Price.
Display Price Upon Formated-Output.
*> Formated-Output would now contain "$10.50 "
GOBACK.
Add this line to WORKING-STORAGE
.
01 Start-pos Pic 9(4) Binary.
Replace the Display Price
statement with
Move 1 to Start-pos
Inspect Price tallying
Start-pos for leading spaces
Move Price (Start-pos:) to Formated-Output
The result, "$10.50"
, followed by 4 spaces is in Formated-Output
.