Highlighted
Contributor.
Contributor.
609 views

Can PIC S9(12) be stored in a line sequential file?

Jump to solution

The MicroFocus documentation in https://supportline.microfocus.com/documentation/books/oc41books/fhform.htm, in section 3.1.1.1, says that line sequential files "correspond to simple text files as produced by the standard editor provided with your operating system".

I've created a line-sequential file whose records are PIC S9(12) OCCURS 1600.  When I look at the output in Notepad, I see that the number -999999999999 appears to be stored as 99999999999y.

Do I need to change my organization from "line sequential" to "sequential", or can a program reading that line-sequential file actually convert the 99999999999y back to -999999999999 ???

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Contributor.
Contributor.

RE: Can PIC S9(12) be stored in a line sequential file?

Jump to solution
Excellent! Thank you, Chris.

View solution in original post

2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Can PIC S9(12) be stored in a line sequential file?

Jump to solution

COBOL signed numeric fields specified with an S for the sign are stored by default in a format where the last digit of the number is stored as a value that indicates the sign of the field as well as the last digit.

Please see the docs here for an explanation.

If you wish the sign to actually be stored as a "-" or "+" sign then you should also specify the SIGN SEPARATE clause on the data item.

This is how COBOL stores these numbers internally and as long as you are only using the line sequential file in COBOL it will read these back in fine as the original value. If you wish to read the file with a text editor or print it then you should be using numeric edited fields instead, i.e. PIC +9(12).

Thanks

0 Likes
Highlighted
Contributor.
Contributor.

RE: Can PIC S9(12) be stored in a line sequential file?

Jump to solution
Excellent! Thank you, Chris.

View solution in original post

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.