Menu

Leading signed field

2017-12-15
2017-12-17
  • Richard Moore

    Richard Moore - 2017-12-15

    I have data in my input file - {0000000000
    the copybook defines it - 10 EDIIVC-IVCH-CASH-DISC PIC S9(7)V9999.

    The following causes a java.lang.NumberFormatException when the following line is executed -
    System.out.println(((FieldValueLine) inputRecord.getFieldValue("EDIIVC-IVCH-CASH-DISC")).asBigDecimal());

    Executing the following shows - {0000000000
    System.out.println(((FieldValueLine) inputRecord.getFieldValue("EDIIVC-IVCH-CASH-DISC")));

    Here is how I have the reader configured -

        CobolIoProvider ioProvider = CobolIoProvider.getInstance();
        CommonBits.setDefaultCobolTextFormat(Cb2xmlConstants.USE_STANDARD_COLUMNS);
        AbstractLineReader reader = ioProvider.getLineReader(
                //Constants.IO_TEXT_LINE
                Constants.IO_FIXED_LENGTH
                , ICopybookDialects.FMT_OPEN_COBOL_MVS
                , CopybookLoader.SPLIT_01_LEVEL 
                , copybook.toString()
                , input.toString()
            );
    

    What am I doing wrong?

     
  • Bruce Martin

    Bruce Martin - 2017-12-15

    Is the copybook

        10 EDIIVC-IVCH-CASH-DISC PIC S9(7)V9999
    

    or is it some thing like (with a sign leading option):

        10 EDIIVC-IVCH-CASH-DISC PIC S9(7)V9999 sign leading
    

    for 10 EDIIVC-IVCH-CASH-DISC PIC S9(7)V9999 I would expect 0000000000{ with the sign at the end and not the start.

    At the moment JRecord would not handle the sign leading option as it is extremly rare. If you do have the sign leading option, I will update JRecord.

    So please let me know exactly what is in the Copybook. I will make the changes to JRecord.

     
  • Richard Moore

    Richard Moore - 2017-12-15

    The copybook has -

    10 EDIIVC-IVCH-CASH-DISC PIC S9(7)V9999

    This is being generated by our EDI vendor and I am not sure how it is being created. But they are using the copybook to read it with the mainframe, we need to now process it within Java.

     
  • Bruce Martin

    Bruce Martin - 2017-12-15

    Just sent you an e-mail (with my e-mail address); can you send me the full copybook please.
    There is 2 reasons:

    • I want to check the field position is being calculated correctly (i.e. the } belongs to the field
    • In Cobol attributes can be specified at the Group level and the fields inherit these attribute. I would like to see the context.

    Full data also would be good

     
  • Bruce Martin

    Bruce Martin - 2017-12-15

    Never seen sign leadingf used before. I will update JRecord:

    • Add a new Cobol dialect Mainframe-Leading-Sign
    • Add new sign leading Type

    Should have a new version in a couple of days

     
  • Bruce Martin

    Bruce Martin - 2017-12-17

    After wasting a bit of time, I have finally worked out what is going on.

    The file is not a valid Cobol Data file.

    For a s9(8) field with a value of 3210 should be stored a
    0000321{ but in the file it is stored as 321{0000.
    i.e. leading zero's have become trailing zero's.

    I am presuming the mainframe programs correct the file
    before processing it.
    Please comfirm this by checking mainframe !!!!

    If I am correct, it will be easy to handle with JRecord, I will show you how

     

    Last edit: Bruce Martin 2017-12-17

Log in to post a comment.