Problem:
The CODE-SET clause can be used to equate a sequential or line sequential file with an alphabet-name like ASCII or EBCDIC as follows:
$SET MF
program-id. testebc.
environment division.
special-names.
alphabet EBC is EBCDIC.
input-output section.
file-control.
select test-file assign to "testfile.dat"
organization is line sequential.
data division.
file section.
fd test-file
code-set is EBC.
01 test-record.
05 test-name pic x(30).
05 test-company pic x(30).
05 test-address pic x(30).
05 test-amount pic 9(9) comp.
05 test-comment pic x(30).
When the records are read they are converted to ASCII in the program area.
The problem is that the data defined as COMP is also being converted to ASCII and thus becomes an invalid value.
How can EBCDIC data files be read correctly when they contain non-DISPLAY data?
Resolution:
The CODE-SET clause can be used to equate a sequential or line sequential file with an alphabet-name like ASCII or EBCDIC which contains non-DISPLAY data by using the Micro Focus extension of the CODE-SET clause which is the FOR phrase as follows:
$SET MF
program-id. testebc.
environment division.
special-names.
alphabet EBC is EBCDIC.
input-output section.
file-control.
select test-file assign to "testfile.dat"
organization is line sequential.
data division.
file section.
fd test-file
code-set is EBC FOR test-name test-company test-address test-comment.
01 test-record.
05 test-name pic x(30).
05 test-company pic x(30).
05 test-address pic x(30).
05 test-amount pic 9(9) comp.
05 test-comment pic x(30).
Fields defined as non-DISPLAY like test-amount are left out of the list and therefore will not be converted.
The FOR can also specify group items and all elementary items of the group will be ignored.