Comp-3 conversion not clear
Read Cobol data files in Java
Status: Beta
Brought to you by:
bruce_a_martin
Hy Bruce,
i'm working with this code
iob = CobolIoProvider.getInstance() .newIOBuilder(CicsMpsUtil.COBOL_DIRECTORY + IConstants.GPWYPCO_filename); iob.setDialect(Convert.FMT_MAINFRAME); iob.setSplitCopybook(CopybookLoader.SPLIT_NONE); iob.setFileOrganization(Constants.IO_FIXED_LENGTH); ..... OutputStream datastream = new ByteArrayOutputStream(); AbstractLineWriter writer = iob.newWriter(datastream); AbstractLine outLine = iob.newLine(); outLine.getFieldValue("GPWYPCO-CNDC").set(cm1.getCndc());
Only with some value like 6881463 the value insert on byte[] returned become 0000683f463.
the field is defined
Long gpwypco-cndc = 683f463 // pos=105, len=6, decimal=0, type=31 Mainframe Packed Decimal (comp-3), numeric=true
and on byte[] i have correct
0000683F463C
if i put 6882463
result is correct
Long gpwypco-cndc = 6882463 // pos=105, len=6, decimal=0, type=31 Mainframe Packed Decimal (comp-3), numeric=true
and on byte[] i have correct
00006882463C
What could be?
Thanks in advance, m
Anonymous
My first concern is in the code there is no
If you are transfering the file to the mainframe you need to write the file as EBCDIC and do a binary transfer.
You can do
immediately after
outLine.getFieldValue("GPWYPCO-CNDC").set(cm1.getCndc());
to see the value being assigned to the line actually is.I just did a quick test and 6881463 looks to be assigned correctly
Befor doing more work, I would like to