Highlighted
Absent Member.
Absent Member.
2193 views

[archive] Assigning a numeric edited picture clause to graphical entry fields

[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. 😄

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.
0 Likes
5 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Assigning a numeric edited picture clause to graphical entry fields

That's neat. Does the runtime still warn you if enter non-numeric edited characters, like most alphabetical characters, into one of these fields?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Assigning a numeric edited picture clause to graphical entry fields

That notification message is triggered by the NUMERIC property for the entry field control. If you set the property to True you will get a notification regardless of the PIC associated with the data variable.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Assigning a numeric edited picture clause to graphical entry fields

I assumed you were using the NUMERIC style. Since what you are using is apparently an undocumented feature, I was curious if any of the entry-field styles and properties were affected. Sounds like they are ok. This should come in handy. 🙂
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Assigning a numeric edited picture clause to graphical entry fields

Originally posted by LTyson
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).


I believe there is a property for this available in AcuBench: You can also put your edited picture in the 'Format Picture' field of the property window. AcuBench generates something like this:

03 Screen1-Ef-1, Entry-Field,
COL 48,50, LINE 22,50, LINES 2,60 CELLS,
SIZE 18,20 CELLS,
BOXED, COLOR IS 1, FONT IS Small-Font,
PIC zz.zzz.zz9,99-, ID IS 7, VALUE ws-num-value.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Assigning a numeric edited picture clause to graphical entry fields

A difference between "Format Picture" and "Additional Properties" is that in "Additional Properties" you can use the "Blank When Zeroes" phrase.

Another tip:
If you have a variable e.g

01 myvar pic 999.

and you want to display leading zeroes ("001" instead of "1")
put in "Additional Properties" : pic Z999
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.