I am trying to convert the EBCDIC COMP-3 fields to ASCII values but which is not working.But Binary COMP-3 fields could be converted to ASCII values.Please help me to understand is this possible or not? Even using any other java library is ok for me.I tried and searched may but no concrete answer I could see.
Update:
In my previous one binary should be the one which will work.This what I received as answer but there was no clarity about EBCDIC COMP-3.
COPYBOOK:
001700 01 EMP-RECORD.
001900 10 EMP-NO PIC 9(10).
002000 10 EMP-NAME PIC X(30).
002100 10 EMP-ADDRESS PIC X(30).
002200 10 EMP-SALARY PIC S9(8)V9(2) COMP-3.
002200 10 EMP-ZIPCODE PIC 9(4).
BINARY COMP-3 file: could be converted
ËÍ>ÁÁ% ,Í_/Ê Ê Â/>Å/%?ÊÁ Á~ ¢|ëá&ç ïçñèá ãñá<à ÊÊ>
EBCDIC COMP-3:not able to convert
0000001001suneel kumar r city e¡5671
Program:
public static void main(String args[]) throws Exception {
String salesFile = "empcompnewbinary.txt";
String copybookName = "EMPCOPYBOOK.txt";
AbstractLine saleRecord;
int fileStructure = Constants.IO_FIXED_LENGTH;
CobolIoProvider ioProvider = CobolIoProvider.getInstance();
AbstractLineReader reader = ioProvider.getLineReader(fileStructure, Convert.FMT_MAINFRAME,
CopybookLoader.SPLIT_NONE, copybookName, salesFile);
while ((saleRecord = reader.read()) != null) {
System.out.print(saleRecord.getFieldValue("EMP-NO").asString() + "-"
+ saleRecord.getFieldValue("EMP-NAME").asString() + "-"
+ saleRecord.getFieldValue("EMP-ADDRESS").asString() + "-"
+ saleRecord.getFieldValue("EMP-SALARY").asDouble() + "-"
+ saleRecord.getFieldValue("EMP-ZIPCODE").asString());
}
reader.close();
}