ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Signed COBOL fields with DFDL

Post new topic  Reply to topic
 Signed COBOL fields with DFDL « View previous topic :: View next topic » 
Author Message
EnOne
PostPosted: Wed Oct 08, 2014 8:53 am    Post subject: Signed COBOL fields with DFDL Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

I am trying to create DFDL fields for COBOL where the input fields are Signed integers. I created the following sample COBOL file and input file to show my issues. What I have found is that the Test Parser is unable to understand signed integers and I am wondering if this is a limitation of the Test Parser or if I am creating the DFDL incorrectly.

TESTSIGN.cpy COBOL copybook
Code:

       01  SNINE-TESTSIGN.
           05  SNINE-DILEID                PIC X(08).
           05  SNINE-THREE                 PIC S9(3).
           05  SNINE-FIVE                  PIC S9(5).
           05  SNINE-NINE                  PIC S9(9).
           05  SNINE-NINEVNINE             PIC S9(9)V99.


TEST Input
Code:
TESTSIGN00A0000B00000000C0000000000D


Expected Result
Code:

<SNINETESTSIGN xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SNINE_DILEID xsi:type="xs:string">TESTSIGN</SNINE_DILEID>
  <SNINE_THREE xsi:type="xs:short">1</SNINE_THREE>
  <SNINE_FIVE xsi:type="xs:int">2</SNINE_FIVE>
  <SNINE_NINE xsi:type="xs:int">3</SNINE_NINE>
  <SNINE_NINEVNINE xsi:type="xs:decimal">0.04</SNINE_NINEVNINE>
  </SNINETESTSIGN>


I created a DFDL Library and it fails as soon as it attempts to parse the SNINE_THREE field.

Error Messge
Code:
CTDP3053E: Zoned text to number conversion error for element 'SNINE_THREE': A
         ParsedDataRegion[SimpleContent, startOffset = 8, length = 3, scd = #xscd(/type::SNINETESTSIGN/model::sequence/schemaElement::SNINE_THREE)]


this is the TESTSIGN.xsd
Code:

<xsd:schema xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:dfdlCobolFmt="http://www.ibm.com/dfdl/CobolDataDefinitionFormat" xmlns:ibmDfdlExtn="http://www.ibm.com/dfdl/extensions" xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:import namespace="http://www.ibm.com/dfdl/CobolDataDefinitionFormat" schemaLocation="IBMdefined/CobolDataDefinitionFormat.xsd"/>
   <xsd:complexType name="SNINETESTSIGN">
      <xsd:sequence>
         <xsd:element name="SNINE_DILEID" default=" " dfdl:length="8">
            <xsd:annotation>
               <xsd:appinfo source="http://www.wsadie.com/appinfo">
                  <initialValue kind="SPACE"/>
               </xsd:appinfo>
               <xsd:documentation>PIC X(8) display</xsd:documentation>
            </xsd:annotation>
            <xsd:simpleType>
               <xsd:restriction base="dfdlCobolFmt:PICX__string">
                  <xsd:maxLength value="8"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
         <xsd:element name="SNINE_THREE" default="0" dfdl:decimalSigned="yes" dfdl:length="3" dfdl:textNumberPattern="000+">
            <xsd:annotation>
               <xsd:documentation>PIC S9(3) display</xsd:documentation>
            </xsd:annotation>
            <xsd:simpleType>
               <xsd:restriction base="dfdlCobolFmt:PICS9-Display-Zoned__short">
                  <xsd:minInclusive value="-999"/>
                  <xsd:maxInclusive value="999"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
         <xsd:element name="SNINE_FIVE" default="0" dfdl:decimalSigned="yes" dfdl:length="5" dfdl:textNumberPattern="00000+">
            <xsd:annotation>
               <xsd:documentation>PIC S9(5) display</xsd:documentation>
            </xsd:annotation>
            <xsd:simpleType>
               <xsd:restriction base="dfdlCobolFmt:PICS9-Display-Zoned__int">
                  <xsd:minInclusive value="-99999"/>
                  <xsd:maxInclusive value="99999"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
         <xsd:element name="SNINE_NINE" default="0" dfdl:decimalSigned="yes" dfdl:length="9" dfdl:textNumberPattern="000000000+">
            <xsd:annotation>
               <xsd:documentation>PIC S9(9) display</xsd:documentation>
            </xsd:annotation>
            <xsd:simpleType>
               <xsd:restriction base="dfdlCobolFmt:PICS9-Display-Zoned__int">
                  <xsd:minInclusive value="-999999999"/>
                  <xsd:maxInclusive value="999999999"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
         <xsd:element name="SNINE_NINEVNINE" default="0" dfdl:decimalSigned="yes" dfdl:length="11" dfdl:textNumberPattern="000000000V00+">
            <xsd:annotation>
               <xsd:documentation>PIC S9(9)V9(2) display</xsd:documentation>
            </xsd:annotation>
            <xsd:simpleType>
               <xsd:restriction base="dfdlCobolFmt:PIC9-Display-Zoned__decimal">
                  <xsd:minInclusive value="-999999999.99"/>
                  <xsd:maxInclusive value="999999999.99"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
      </xsd:sequence>
   </xsd:complexType>
   <xsd:annotation>
      <xsd:appinfo source="http://www.ogf.org/dfdl/">
         <dfdl:format binaryFloatRep="{$dfdl:binaryFloatRep}" byteOrder="{$dfdl:byteOrder}" encoding="{$dfdl:encoding}" ignoreCase="yes" leadingSkip="0" occursCountKind="fixed" ref="dfdlCobolFmt:CobolDataFormat" textNumberPadCharacter="0" textStringJustification="left" textStringPadCharacter="%SP;" textZonedSignStyle="asciiStandard" trailingSkip="0"/>
      </xsd:appinfo>
   </xsd:annotation>
   <xsd:annotation>
      <xsd:documentation>
   This XSD was created by importing COBOL copybook.

   Source file:   TESTSIGN.cpy

   Import options:
      EXT_DECIMAL_SIGN=ASCII
      QUOTE=DOUBLE
      NUMPROC=PFD
      FLOATING_POINT_FORMAT=0
      NSYMBOL=NATIONAL
      ENDIAN=Little
      EXTENSION_CPY=DS
      CODEPAGE=ISO-8859-1
      TRUNC=STD
      EXTENSION_CBL=FP
      EXTENSION_CCP=FP
      PLATFORM_SELECTION=0
      REMOTE_ENDIAN=Little
      EXTENSION_COB=FP
      SCHEMA_TARGET_NAMESPACE_URI=null
      CREATE_DEFAULT_VALUES_FROM_INITIAL_VALUES=true
      CREATE_FACETS_FROM_LEVEL_88_VALUE_CLAUSES=false
      CREATE_NULL_VALUES_FOR_FIELDS=false
      NULL_CHARACTER_FOR_STRING=%SP;
      NULL_CHARACTER_FOR_NUMBER=%#x00;
      STRING_PADDING_CHARACTER=%SP;
      NUMBER_PADDING_CHARACTER=0
      DEFAULT_FOR_STRING=
      DEFAULT_FOR_NUMBER=0

</xsd:documentation>
   </xsd:annotation>
   <xsd:element name="SNINETESTSIGN" type="SNINETESTSIGN" dfdl:lengthKind="implicit" ibmSchExtn:docRoot="true"/>
</xsd:schema>
Back to top
View user's profile Send private message
EnOne
PostPosted: Wed Oct 08, 2014 8:54 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

Forgot to include my Broker version

WebSphere Message Broker Toolkit - Message Broker

Version: 8.0.0.4
Build id: 8.0.0.4-20140321-1310
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Oct 08, 2014 7:34 pm    Post subject: Re: Signed COBOL fields with DFDL Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

EnOne wrote:

TEST Input
Code:
TESTSIGN00A0000B00000000C0000000000D



Very carefully described problem. However your data does not match the content of your copy book.

PIC S9(3) does not match 00A
PIC S9(5) does not match 0000B
PIC S9(9) does not match 00000000C
PIC S9(9)V99 does not match 0000000000D

Remember this is a GIGO system... Garbage in => garbage out....

So your error shows merely that the DFDL parser is working as designed. It protests the value A for 00A as not being part of the data description...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
EnOne
PostPosted: Thu Oct 09, 2014 5:13 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

I think that one of us might not be understanding what a signed field from a COBOL copybook is.

Quote:
Signed Fields
There is a common numeric data type used in COBOL on IBM mainframes called "Signed" (also called "IBM Signed", or "Zoned"). COBOL represents this type of field by an "S" in the picture clause of a display format field, e.g. PIC S9(6). A Signed field is composed of regular EBCDIC numeric characters, one character per byte, for all digits except the one that holds the sign, either the most-significant (sign leading) or the least-significant (sign trailing) digit -- usually the least-significant digit. The digit that holds the sign combines, or "over punches" the sign of the number onto that digit. This saves one byte that the sign would otherwise occupy. The value of that digit is stored as a binary value, and is OR'd with the sign code, which is D0 hex for negative numbers, C0 hex for positive values, and F0 hex for "unsigned" values.

Because of the overpunch, the digit that holds the sign will not appear as a number when the field is viewed in EBCDIC character mode. If you have the field

05 ACCOUNT-BALANCE PIC S9(6)V99.

and view a value of 1.23 with an EBCDIC editor, it will read "0000012C".


http://www.3480-3590-data-conversion.com/article-packed-fields.html
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Oct 09, 2014 7:28 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

EnOne wrote:
I think that one of us might not be understanding what a signed field from a COBOL copybook is.


Yes - it's you!

The link you posted exactly describes a signed decimal number in COBOL. The title of the page is "COBOL Comp-3" so your copybook:

Code:

       01  SNINE-TESTSIGN.
           05  SNINE-DILEID                PIC X(08).
           05  SNINE-THREE                 PIC S9(3).
           05  SNINE-FIVE                  PIC S9(5).
           05  SNINE-NINE                  PIC S9(9).
           05  SNINE-NINEVNINE             PIC S9(9)V99.


has no such numbers. If it had, it would be:

Code:

       01  SNINE-TESTSIGN.
           05  SNINE-DILEID                PIC X(08).
           05  SNINE-THREE                 PIC S9(3) COMP-3.
           05  SNINE-FIVE                  PIC S9(5) COMP-3.
           05  SNINE-NINE                  PIC S9(9) COMP-3.
           05  SNINE-NINEVNINE             PIC S9(9)V99 COMP-3.

_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
EnOne
PostPosted: Thu Oct 09, 2014 8:10 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

well then let me rephrase my question.

I have this input

Code:
TESTSIGN00A0000B00000000C0000000000D


I am trying to parse it into

Code:
<SNINETESTSIGN xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SNINE_DILEID xsi:type="xs:string">TESTSIGN</SNINE_DILEID>
  <SNINE_THREE xsi:type="xs:short">1</SNINE_THREE>
  <SNINE_FIVE xsi:type="xs:int">2</SNINE_FIVE>
  <SNINE_NINE xsi:type="xs:int">3</SNINE_NINE>
  <SNINE_NINEVNINE xsi:type="xs:decimal">0.04</SNINE_NINEVNINE>
  </SNINETESTSIGN>


How would I create a COBOL copybook that would work with the DFDL parser. I've tried

Code:
       01  SNINE-TESTSIGN.
           05  SNINE-DILEID                PIC X(08).
           05  SNINE-THREE                 PIC S9(3).
           05  SNINE-FIVE                  PIC S9(5).
           05  SNINE-NINE                  PIC S9(9).
           05  SNINE-NINEVNINE             PIC S9(9)V99.


and

Code:
       01  SNINE-TESTSIGN.
           05  SNINE-DILEID                PIC X(08).
           05  SNINE-THREE                 PIC S9(3) COMP-3.
           05  SNINE-FIVE                  PIC S9(5) COMP-3.
           05  SNINE-NINE                  PIC S9(9) COMP-3.
           05  SNINE-NINEVNINE             PIC S9(9)V99 COMP-3.


and neither of the DFDLs created understand that A,B,C,D in the last position stand for a positive 1,2,3,4 value.

list of character to number values for S9 fields

Code:
Value    Character    EBCDIC Hex code    ASCII Hex code

  +0         {              C0               7B
  +1         A              C1               41
  +2         B              C2               42
  +3         C              C3               43
  +4         D              C4               44
  +5         E              C5               45
  +6         F              C6               46
  +7         G              C7               47
  +8         H              C8               48
  +9         I              C9               49

  -0         }              D0               7D
  -1         J              D1               4A
  -2         K              D2               4B
  -3         L              D3               4C
  -4         M              D4               4D
  -5         N              D5               4E
  -6         O              D6               4F
  -7         P              D7               50
  -8         Q              D8               51
  -9         R              D9               52
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Oct 09, 2014 8:22 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

EnOne wrote:
How would I create a COBOL copybook that would work with the DFDL parser. I've tried

Code:
       01  SNINE-TESTSIGN.
           05  SNINE-DILEID                PIC X(08).
           05  SNINE-THREE                 PIC S9(3).
           05  SNINE-FIVE                  PIC S9(5).
           05  SNINE-NINE                  PIC S9(9).
           05  SNINE-NINEVNINE             PIC S9(9)V99.


and

Code:
       01  SNINE-TESTSIGN.
           05  SNINE-DILEID                PIC X(08).
           05  SNINE-THREE                 PIC S9(3) COMP-3.
           05  SNINE-FIVE                  PIC S9(5) COMP-3.
           05  SNINE-NINE                  PIC S9(9) COMP-3.
           05  SNINE-NINEVNINE             PIC S9(9)V99 COMP-3.


and neither of the DFDLs created understand that A,B,C,D in the last position stand for a positive 1,2,3,4 value.


Ok, both of those copybooks "work" with the DFDL parser. The one with the COMP-3 clause matches your data.

For the record, you shouldn't need to create a copybook. The data you're pasing has been written by something, we can assume COBOL and they have either a copybook or a data definition you can use.

EnOne wrote:
list of character to number values for S9 fields

Code:
Value    Character    EBCDIC Hex code    ASCII Hex code

  +0         {              C0               7B
  +1         A              C1               41
  +2         B              C2               42
  +3         C              C3               43
  +4         D              C4               44
  +5         E              C5               45
  +6         F              C6               46
  +7         G              C7               47
  +8         H              C8               48
  +9         I              C9               49

  -0         }              D0               7D
  -1         J              D1               4A
  -2         K              D2               4B
  -3         L              D3               4C
  -4         M              D4               4D
  -5         N              D5               4E
  -6         O              D6               4F
  -7         P              D7               50
  -8         Q              D8               51
  -9         R              D9               52


This isn't the right list of hex values for an overpunched COMP-3 field unless you're not using mainframe.

Next steps:

- create a DFDL schema by importing any copybook that includes the COMP-3 clauses (which your previously posted schema was not)
- test parse the data against this schema and post the trace (not just the error)

Then we'll see what we'll see.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
EnOne
PostPosted: Thu Oct 09, 2014 11:21 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

here is the error and the input is not packed decimal.

Code:
********************* DFDL Parser Starting *********************
Data = C:\Temp2\TESTSIGN_Test.txt
Message = SNINETESTSIGN (/TESTSIGN_DFDL_Library/TESTSIGN.xsd)
****************************************************************

Oct 9, 2014 12:02:10 PM   info: Offset: 0. Parsing will start from root element 'SNINETESTSIGN'.
                         [dfdl = /TESTSIGN_DFDL_Library/TESTSIGN.xsd, scd = #xscd(/schemaElement::SNINETESTSIGN), 72]

Oct 9, 2014 12:02:10 PM   info: The default value of '%LF;' was assigned to variable 'outputNewLine' in namespace 'http://www.ogf.org/dfdl/dfdl-1.0/'.       
                         [dfdl = /TESTSIGN_DFDL_Library/TESTSIGN.xsd, scd = , 133]

Oct 9, 2014 12:02:10 PM   info: Offset: 0. Starting to process element 'SNINETESTSIGN'.
                         [dfdl = /TESTSIGN_DFDL_Library/TESTSIGN.xsd, scd = #xscd(/schemaElement::SNINETESTSIGN), 63]

Oct 9, 2014 12:02:10 PM   info: Offset: 0. Starting to process element 'SNINE_DILEID'.
                         [dfdl = /TESTSIGN_DFDL_Library/TESTSIGN.xsd, scd = #xscd(/type::SNINETESTSIGN/model::sequence/schemaElement::SNINE_DILEID), 62]

Oct 9, 2014 12:02:10 PM   info: Offset: 0. Found fixed length value: 'TESTSIGN' for element 'SNINE_DILEID'.
                         [dfdl = /TESTSIGN_DFDL_Library/TESTSIGN.xsd, scd = #xscd(/type::SNINETESTSIGN/model::sequence/schemaElement::SNINE_DILEID), 83]

Oct 9, 2014 12:02:10 PM   info: Offset: 8. Finished processing element 'SNINE_DILEID'.
                         [dfdl = /TESTSIGN_DFDL_Library/TESTSIGN.xsd, scd = #xscd(/type::SNINETESTSIGN/model::sequence/schemaElement::SNINE_DILEID), 62]

Oct 9, 2014 12:02:10 PM   info: Offset: 8. Starting to process element 'SNINE_THREE'.
                         [dfdl = /TESTSIGN_DFDL_Library/TESTSIGN.xsd, scd = #xscd(/type::SNINETESTSIGN/model::sequence/schemaElement::SNINE_THREE), 61]

Oct 9, 2014 12:02:10 PM   info: Offset: 8. Found fixed length value: 'A' for element 'SNINE_THREE'.
                         [dfdl = /TESTSIGN_DFDL_Library/TESTSIGN.xsd, scd = #xscd(/type::SNINETESTSIGN/model::sequence/schemaElement::SNINE_THREE), 75]

Oct 9, 2014 12:02:10 PM   error: CTDP3053E: Zoned text to number conversion error for element 'SNINE_THREE': A

Oct 9, 2014 12:02:10 PM   fatal: CTDP3053E: Zoned text to number conversion error for element 'SNINE_THREE': A
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Oct 09, 2014 11:49 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

EnOne wrote:
here is the error and the input is not packed decimal.


So what exactly is the input? Post it, ideally as the actual hex being fed to the DFDL parser.

Also post the DFDL schema that trace was produced against.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Oct 09, 2014 12:38 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

COBOL external decimals (also known as 'zoned decimals) are not as 'standard' as you might think. Especially if they have been converted from EBCDIC to ASCII without being, errrm, converted.

Please consult this: http://www.ogf.org/dfdl/DFDL_1.0_Web/dfdl_13_5.html
The final section deals with the textZonedSignStyle property. You have not mentioned what encoding your text is in ( which is probably why Vitor asked for the byte values in your input message), but you may find the asciiTranslatedEBCDIC option interesting.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
EnOne
PostPosted: Fri Oct 10, 2014 7:28 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

that was exactly the link I needed

I added the dfdl:textZonedSignStyle="asciiTranslatedEBCDIC" to the elements and the Test Parser was able to interpret the input I made the same changes to the other elements as well with similar results.

BEFORE
Code:
      <xsd:element default="0" dfdl:decimalSigned="yes" dfdl:length="3" dfdl:textNumberPattern="000+" name="SNINE_THREE">
        <xsd:annotation>
          <xsd:documentation>PIC S9(3) display</xsd:documentation>
        </xsd:annotation>
        <xsd:simpleType>
          <xsd:restriction base="dfdlCobolFmt:PICS9-Display-Zoned__short">
            <xsd:minInclusive value="-999"/>
            <xsd:maxInclusive value="999"/>
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:element>


AFTER
Code:
      <xsd:element default="0" dfdl:decimalSigned="yes" dfdl:length="3" dfdl:textNumberPattern="000+" dfdl:textZonedSignStyle="asciiTranslatedEBCDIC" name="SNINE_THREE">
        <xsd:annotation>
          <xsd:documentation>PIC S9(3) display</xsd:documentation>
        </xsd:annotation>
        <xsd:simpleType>
          <xsd:restriction base="dfdlCobolFmt:PICS9-Display-Zoned__short">
            <xsd:minInclusive value="-999"/>
            <xsd:maxInclusive value="999"/>
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:element>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Signed COBOL fields with DFDL
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.