Problem:
How can you convert data/string from EBCDIC to ASCII or vice versa?
Resolution:
Converting between EBCDIC and ASCII
Generally, when you want to do a translation between ASCII and EBCDIC, you should use the callable interface to the GUI File Converter (DFConv). For more information about using DFCONV and the command line interface, see the chapter File Conversion Utilities.
There is another function which enables fast translation between ASCII and EBCDIC strings within a Micro Focus COBOL program. This is called "_CODESET".
Its usage is:
call "_codeset" using function-code, length, string
where:
function-codePIC 9(2) COMP-X
0=convert EBCDIC to ASCII
1=convert ASCII to EBCDIC
lengthPIC 9(9) COMP-X
string PIC X(n)
Note that "_codeset" cannot work from a program that is compiled with the reserved word directives for one of the mainframe COBOL compilers (for example, OSVS for OS/VS COBOL and VSC2 for VS COBOL II) because it uses COMP-X data types, which are not supported on the mainframe.