Menu

#11 Comp-3 conversion not clear

v1.0_(example)
open
None
1
2017-10-03
2017-10-03
Anonymous
No

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

Discussion

  • Bruce Martin

    Bruce Martin - 2017-10-03

    My first concern is in the code there is no

    iob.setFont("cp037"); // or "IBM037" or some thing similar
    

    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

     System.out.println(
                 cm1.getCndc() + " --->> "
                 + outLine.getFieldValue("GPWYPCO-CNDC").asHex());
    

    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

    • Know which version of JRecord you are using (if possible)
    • more information of what is going on i.e.
      • What happens between where the value is set and when it is checked
      • The overall process
     
  • Bruce Martin

    Bruce Martin - 2017-10-03
    • assigned_to: Bruce Martin
     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.