[Migrated content. Thread originally posted on 04 June 2003]
I just found a better way to something I was doing and thought I'd share in case this question anyone else has is having this problem.Did you know that if you enter a PIC clause (or PICTURE IS) in the ADDITIONAL PROPERTIES section for an entry field that picture clause is used when the entry field is displayed and accepted on the screen? This will allow you to display a numeric field using a numeric edited picture clause. Also, if the user enters a numeric value (such as 12345.99) into the entry field it will automatically reformat to the numeric edited value (12,345.99) when they exit the field without any additional coding. :D
Note: The AcuCobol-GT User's Guide, Version 6.0, Reference Manual (Book 3), section 5.9.1 specifically states:
1. If the PICTURE clause is specified, then a VALUE clause may not be specified.
Nevertheless, it does work.:rolleyes:
Here's what led to this discovery:
I've got numeric variables coming from data files where they are defined as PIC S9(9)V99. When accepting these variables on the screen I want them to display as a numeric edited value. For example, ZZZ,ZZZ,ZZZ.99-.
When using the screen section to define an entry field on a text screen I can do with the following:
01 NUMBER-DISPLAY PIC ZZZ,ZZZ,ZZZ.99- USING DATA-NUMBER.
However there was no property available in AcuBench that would produce the same results (the VALUE PICTURE property is not used when generating the screen section entries). So when designing a GUI screen I had to create a working storage variable with the numeric edited picture clause, assign that working storage variable as the VALUE VARIABLE when defining the entry field, move my data field to that numeric edited working storage variable, and then move the working storage variable back to the data field before writing the record. For example:
File section:
FD DATA-FILE.
01 DATA-RECORD.
03 DATA-KEY PIC X(7).
03 DATA-NUMBER PIC S9(9)V99.
Working storage section:
01 WS-EDITED-NUMBER PIC ZZZ,ZZZ,ZZZ.99-
Screen section:
01 ENTRY-FIELD, NUMERIC, VALUE WS-EDITED-NUMBER.
Procedure division:
MOVE DATA-NUMBER TO WS-EDITED-NUMBER.
DISPLAY ENTRY-FIELD.
ACCEPT ENTRY-FIELD.
DISPLAY ENTRY-FIELD. [If the user enters 12345.09 I want it to display as 12,345.09 after entry]
MOVE WS-EDITED-NUMBER TO DATA-NUMBER.