How to handle the case of blank spaces in host data for the group with fields with level 88 during xml ?

28 views
Skip to first unread message

Sridhar

unread,
May 6, 2013, 5:19:18 AM5/6/13
to legsta...@googlegroups.com

  Hi,

         I am working on some host data to create XML from  generated transformers,  The host data  has some blank spaces for some of the fields with level 88. I am getting Host exception. I  know that the group containing 88 level fields is converted to ENUMS and the "fromValue(String)" method throws exception as empty space does not match the ENUM values.

         So, is there a configuration element/ property I can use in this case, so that it will accept blank space. or if there is no such element, where can I tweak the code to  work with my data. Thanks


    
   

Fady

unread,
May 6, 2013, 5:27:54 AM5/6/13
to legsta...@googlegroups.com
Hello Sridhar,

Can you provide an  exception StackTrace?

Also what does the COBOL 88 statement look like and what data is actually being sent by the mainframe?

Thanks

Fady

Sridhar

unread,
May 6, 2013, 6:32:44 AM5/6/13
to legsta...@googlegroups.com

Thanks for quick reply. below are the details.


Layout
---------------------------
01  WS-OUT-DATA.                                                       08910099
           05  HDR.                                                     08920099
               10 HDR-ID                       PIC X(03) VALUE '##H'.   08930099
               10 HDR-INFO.                                             08940099
                  15 HDR-CIRC7                 PIC X(06) VALUE SPACES.  08950099
                  15 HDR-BOARD-ID              PIC X(04) VALUE SPACES.  08960099
                  15 HDR-CRFT                  PIC X(03) VALUE SPACES.  08970099
                     88 HDR-CRFT-EXTRA                   VALUE 'XTR'.   08980099
                     88 HDR-CRFT-ENM                     VALUE 'ENM'.   08990099
                     88 HDR-CRFT-TNM                     VALUE 'TNM'.   09000099
                  15 HDR-SEQ-TYPE              PIC X(01) VALUE SPACES.  09010099
                     88 HDR-SEQ-TAT-ODT                  VALUE '1'.     09020099
                     88 HDR-SEQ-LEFT-HM                  VALUE '2'.     09030099
                     88 HDR-SEQ-LAST-STRT                VALUE '3'.     09040099
                     88 HDR-SEQ-BASIC-SEQ                VALUE '4'.     09050099
                  15 HDR-HAHT-TYPE             PIC X(02) VALUE SPACES.  09060099
                     88 HDR-HAHT-TYPE-16                 VALUE '16'.    09070099
                     88 HDR-HAHT-TYPE-12                 VALUE '12'.    09080099
                     88 HDR-HAHT-TYPE-08                 VALUE '08'.    09090099
                  15 HDR-HOME-AWAY-FL          PIC X(01) VALUE SPACES.  09100099
                     88 HDR-HOME                         VALUE 'H'.     09110099
                     88 HDR-AWAY                         VALUE 'A'.     09120099
                  15 HDR-RATIO-MBR             PIC X(01) VALUE SPACES.  09130099
                     88 HDR-RATIO-EXTRA                  VALUE 'X'.     09140099
                     88 HDR-RATIO-ROTATING               VALUE 'R'.     09150099
                     88 HDR-RATIO-MEMBER                 VALUE 'I'.     09160099
                     88 HDR-RATIO-ASSIGNED               VALUE 'A'.     09170099
                     88 HDR-RATIO-CARDED-POOL            VALUE 'C'.     09180099
                     88 HDR-RATIO-WINDOW-POOL            VALUE 'W'.     09190099

HostData
------------------

        "##HOP500 RE61ENM116 ROZ512 RE611PN ............................. "

     The orange colored space is blank.

   (Actually, it should be 'H' or 'A' as per layout element  HDR-HOME-AWAY-FL which has two COBOL88 fields HDR-HOME & HDR-AWAY
    
      corresponding generated code:

       @XmlType(name = "")
    @XmlEnum
    public enum HdrHomeAwayFl {

        @XmlEnumValue("H")
        VALUE_H("H"),
        @XmlEnumValue("A")
        VALUE_A("A");
        private final String value;

        HdrHomeAwayFl(String v) {
            value = v;
        }

        public String value() {
            return value;
        }

        public static HdrInfo.HdrHomeAwayFl fromValue(String v) {
            for (HdrInfo.HdrHomeAwayFl c: HdrInfo.HdrHomeAwayFl.values()) {
                if (c.value.equals(v)) {
                    return c;
                }
            }
            throw new IllegalArgumentException(v);  // ""  is not equal to H or A, So getting exception
        }

    }

   ...... )

STACK TRACE
----------------------------
com.legstar.coxb.transform.HostTransformException: java.lang.reflect.InvocationTargetException
    at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:273)
    at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:195)
    at com.legstar.coxb.transform.AbstractHostToXmlTransformer.transform(AbstractHostToXmlTransformer.java:86)
    at com.legstar.coxb.transform.AbstractHostToXmlTransformer.transform(AbstractHostToXmlTransformer.java:105)
    at com.legstar.coxb.transform.AbstractHostToXmlTransformer.transform(AbstractHostToXmlTransformer.java:121)
    at com.legstar.coxb.transform.AbstractXmlTransformers.toXml(AbstractXmlTransformers.java:122)
    at com.crp.test.TestXMLTransform.testXMLTransform(TestXMLTransform.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.reflect.InvocationTargetException
    at com.legstar.coxb.impl.AbstractAlphaNumericBinding.getObjectValue(AbstractAlphaNumericBinding.java:79)
    at com.legstar.test.coxb.hdr.bind.HdrInfoBinding.setPropertyValue(HdrInfoBinding.java:435)
    at com.legstar.coxb.impl.visitor.CobolUnmarshalVisitor.visit(CobolUnmarshalVisitor.java:92)
    at com.legstar.coxb.common.CComplexBinding.accept(CComplexBinding.java:72)
    at com.legstar.coxb.impl.visitor.CobolUnmarshalVisitor.visit(CobolUnmarshalVisitor.java:91)
    at com.legstar.coxb.common.CComplexBinding.accept(CComplexBinding.java:72)
    at com.legstar.coxb.impl.visitor.CobolUnmarshalVisitor.visit(CobolUnmarshalVisitor.java:91)
    at com.legstar.coxb.common.CComplexBinding.accept(CComplexBinding.java:72)
    at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:253)
    ... 29 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.legstar.coxb.impl.AbstractAlphaNumericBinding.getObjectValue(AbstractAlphaNumericBinding.java:71)
    ... 37 more
Caused by: java.lang.IllegalArgumentException:
    at com.legstar.test.coxb.hdr.HdrInfo$HdrWrkRstApplyCd.fromValue(HdrInfo.java:1015)
    ... 42 more

Fady

unread,
May 6, 2013, 7:36:00 AM5/6/13
to legsta...@googlegroups.com
Thanks for the detailed info. This helps a lot.

You are facing one of these cases where level 88 cannot be safely mapped to an Enum. In COBOL, level 88 is not a restriction. It means the content of the field is not restricted to the values specified as levels 88. So the space character is actually valid.

My first reaction was to change the COBOL structure like so:

                  15 HDR-HOME-AWAY-FL          PIC X(01) VALUE SPACES.
                     88 HDR-FL-SPACE                  VALUE ' '.
                     88 HDR-HOME                         VALUE 'H'.
                     88 HDR-AWAY                         VALUE 'A'.

Unfortunately that did not fix it because there is code in com.legstar.coxb.impl.AbstractAlphaNumericBinding around line 71 that trims the value.

I believe the trimming is unnecessary. Maybe you can give that a try?

Let us know how it goes.

Sridhar

unread,
May 6, 2013, 8:22:20 AM5/6/13
to legsta...@googlegroups.com

 Thanks Fady, for the solution.  I will try that. But are you planning on some configuration property which if set can add enum value with space in the binding classes.

Fady

unread,
May 6, 2013, 8:54:39 AM5/6/13
to legsta...@googlegroups.com
I am not sure because again, space is just one possibility. The host can send low-values, high-values or pretty much any characters.

Maybe we should systematically add a generic enum value called UNRECOGNIZED which would be set if the mainframe does not send one of the expected level 88 values. That would be better than an exception...

Sridhar

unread,
May 8, 2013, 7:00:15 AM5/8/13
to legsta...@googlegroups.com
I tried the approach and I was able to generate extra enum with space. I did not test it against the data.
But, I also tried by not generating Enum using the property element 'level88mappingtofacet' false.

Sridhar

unread,
May 8, 2013, 7:02:06 AM5/8/13
to legsta...@googlegroups.com

And that worked in my case also.
Reply all
Reply to author
Forward
0 new messages