Issues evaluating the Legstar mapping facilities

17 views
Skip to first unread message

Alexandre MOOTASSEM

unread,
Jun 16, 2009, 9:38:27 AM6/16/09
to legstar-user
Hi,

We are evaluating the Legstar mapping facilities (version 1.2.5)

We have faced two kind of issues :
1- how do we indicate a particular Charset on a cobol field ? For
instance, having EBCDIC as a general charset and ASCII or UTF-8 on
specific fields
2- default value not assigned when unmarshaling Jaxb bean to copybook
data

Example of case 2 :

For the following copybook field
05 TEST1-ZZ PIC XX VALUE LOW-VALUE.

Say the generated XSD is :

<xs:element name="Test1Zz">
<xs:annotation>
<xs:appinfo>
<cb:cobolElement levelNumber='05' cobolName='TEST1-ZZ'
type='ALPHANUMERIC_ITEM' picture='XX' usage='DISPLAY' value='0x0000'
srceLine='14'/>
</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value='2'/>
</xs:restriction>
</xs:simpleType>
</xs:element>

And the matching Bean is :

@XmlElement(name = "Test1Zz", required = true)
@CobolElement(cobolName = "TEST1-ZZ", type =
CobolType.ALPHANUMERIC_ITEM, levelNumber = 5, picture = "XX", usage =
"DISPLAY", value = "0x0000", srceLine = 14)
protected String test1Zz = "";

But during runtime if you pass null or an empty string to the setter
of test1Zz you will get 0x4040 as value instead of the LOW-VALUE (ie
0x0000).

Did we get it wrong somewhere ?

Rgs,

A.M.

Fady Moussallam

unread,
Jun 16, 2009, 11:25:58 AM6/16/09
to legsta...@googlegroups.com
Hi Alexandre,

>1- how do we indicate a particular Charset on a cobol field ? For
>instance, having EBCDIC as a general charset and ASCII or UTF-8 on
>specific fields


As a general rule you cannot specify a charset at the field level. The
mainframe charset that you set on the transformer affects all fields
marked ALPHANUMERIC_ITEM. This being said, there are 2 things you might try:

For fields you want to keep in ASCII, you can change their type in the
XSD from ALPHANUMERIC_ITEM to OCTET_STREAM_ITEM and their XSD
restriction base from string to hexBinary. This is an example:

<xs:element name="Test1Ascii">
<xs:annotation>
<xs:appinfo>
<cb:cobolElement levelNumber='05' cobolName='TEST1-ASCII'
type='OCTET_STREAM_ITEM' picture='XX' usage='DISPLAY' srceLine='4'/>
</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:hexBinary">
<xs:length value='2'/>
</xs:restriction>
</xs:simpleType>
</xs:element>

This will translate to a byte[] JAXB member variable. LegStar does not
attempt to convert such fields.

Otherwise, there is no direct support for UTF-8 in COBOL but there is
support for UTF-16. IF the COBOL field is defined as NATIONAL. For example:

05 C-NATIONAL PIC N(9).

These are normally handled by LegStar (The COBOL program receives UTF-16).

>2- default value not assigned when unmarshaling Jaxb bean to copybook
>data

This is a limitation we have with LOW_VALUES or HIGH_VALUES. The issue
is that field initialization and setting is handled at the JAXB level at
the moment. There is no equivalent to LOW_VALUES and HIGH_VALUES in java.

This being said, we could recognize specific string content such as
"LOW_VALUES" which is unlikely to conflict with actual string values.
Please file an enhancement request at
http://code.google.com/p/legstar/issues/list if this is of interest to you.

Let us know how your testing goes.

Fady


Alexandre MOOTASSEM

unread,
Jun 22, 2009, 11:43:26 AM6/22/09
to legsta...@googlegroups.com
Thank you for your quick reply. It's now fixed!

Best regards,
--
Alexandre MOOTASSEM

Alexandre MOOTASSEM

unread,
Jun 22, 2009, 12:03:21 PM6/22/09
to legstar-user
Hi again,

During our testing we encountered another kind of issue, here's an
example :

Cobol structure :

(...)
05 SOMEFIELD PIC 9(2) COMP VALUE 16.
(...)

Generated XSD :

<xs:element name="Somefield">
<xs:annotation>
<xs:appinfo>
<cb:cobolElement levelNumber='05' cobolName='SOMEFIELD'
type='BINARY_ITEM' picture='9(2)' usage='BINARY' signed='false'
totalDigits='2' value='16' srceLine='37'/>
</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:unsignedShort">
<xs:minInclusive value='0'/>
<xs:maxInclusive value='99'/>
</xs:restriction>
</xs:simpleType>
</xs:element>

Jaxb bean :

@XmlElement(name = "Somefield")
@CobolElement(cobolName = "SOMEFIELD", type =
CobolType.BINARY_ITEM, levelNumber = 5, isSigned = false, totalDigits
= 2, picture = "9(2)", usage = "BINARY", value = "16", srceLine = 37)
protected int mode = 16;

When Unmarshalling Jaxb bean to copybook data the specified field is
written over 2-bytes instead of 1-byte.

Is there something wrong ?

Regards,
> Please file an enhancement request athttp://code.google.com/p/legstar/issues/listif this is of interest to you.

Fady Moussallam

unread,
Jun 22, 2009, 3:41:20 PM6/22/09
to legsta...@googlegroups.com
Hello Alexandre,

I am not sure a 9(2) COMP occupies a single byte of memory, unless I
missed a compiler option somewhere.

This is from IBM Enterprise COBOL v3r4 Programming Reference:

[COMPUTATIONAL or COMP (binary) This is the equivalent of BINARY. The
COMPUTATIONAL phrase is synonymous with BINARY.
BINARY Specified for binary data items. Such items have a decimal
equivalent consisting of the decimal digits 0 through 9, plus a sign.
Negative numbers are represented as the two’s complement of the positive
number with the same absolute value. The amount of storage occupied by a
binary item depends on the number of decimal digits defined in its
PICTURE clause:
Digits in PICTURE clause
Storage occupied
1 through 4 2 bytes (halfword)
5 through 9 4 bytes (fullword)
10 through 18 8 bytes (doubleword)]

Maybe you are targeting another OS?

Fady




Reply all
Reply to author
Forward
0 new messages