Author |
Message
|
rajbuddha |
Posted: Tue Aug 14, 2012 6:20 am Post subject: Handling datatypes in DFDL |
|
|
 Apprentice
Joined: 02 Aug 2011 Posts: 47 Location: chennai
|
Hi,
For the message model using DFDL,when the datatype of the local element is integer and the fieldlength is made explicit, for example
Let stud_no be the local element with integer datatype and the fieldlength is given as 10. When I give the input as 0000056789, after the test-serialize view I get as 56789. But I require the output as 0000056789 even after serialization.
I have set the properties of padding characters to 0 but in vain.
What should be done to acheive the above??
Thanks in advance.. _________________ -----------
Raju Buddha
Never Wait for your 2nd Opportunity..!Becoz it may be harder than the 1st One... |
|
Back to top |
|
 |
lancelotlinc |
Posted: Tue Aug 14, 2012 6:24 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Your trying to treat an integer datatype like a string datatype. You cannot have it both ways. Either it is a string (with leading zeros) or it is an integer (empirical value with no leading zeros). Which one do you want? You cannot have both. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 14, 2012 6:49 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
lancelotlinc wrote: |
Your trying to treat an integer datatype like a string datatype. You cannot have it both ways. Either it is a string (with leading zeros) or it is an integer (empirical value with no leading zeros). Which one do you want? You cannot have both. |
lancelotlinc - There are a lot of good solid reasons why a field might need to always be a fixed length.
Rajbuddha - So you've set the Length Kind to 'explicit' and set Length and set length units to characters?
You have to set the Text Number Representation to include a Number Pattern that will force the output of 0's. You likely have it set to '#0' right now, and need to set it to somehting like '0000000000' (one 0 for each digit). |
|
Back to top |
|
 |
rajbuddha |
Posted: Thu Aug 16, 2012 3:43 am Post subject: |
|
|
 Apprentice
Joined: 02 Aug 2011 Posts: 47 Location: chennai
|
lancelotlinc - I am trying for an integer datatype with leading zeros..
mqjeff - Ya, I have set the Length Kind to 'explicit' and set Length and set length units to characters. How to set the Text Number Representation?? I find two options- standard and zoned, which should I opt to include a Number Pattern??
Thanks.. _________________ -----------
Raju Buddha
Never Wait for your 2nd Opportunity..!Becoz it may be harder than the 1st One... |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Aug 16, 2012 5:13 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It shows up for both types, underneath the 'Text Number Representation' (which is part of Text Content).
I.e. you have to click the little plus button to expand the field to show the sub-properties. |
|
Back to top |
|
 |
rajbuddha |
Posted: Thu Aug 16, 2012 6:34 am Post subject: |
|
|
 Apprentice
Joined: 02 Aug 2011 Posts: 47 Location: chennai
|
ya i could find that.. the number pattern is already set to '#0'.
should I give any specified values under text format within the sub properties ie., should i apply any pattern if so what should be given??
Thanks.. _________________ -----------
Raju Buddha
Never Wait for your 2nd Opportunity..!Becoz it may be harder than the 1st One... |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Aug 16, 2012 6:45 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
rajbuddha wrote: |
ya i could find that.. the number pattern is already set to '#0'. |
Yes. That's the source of the problem. The # does not force the output of a digit. The 0 does. You need to put in as many 0's as you need to force digits to appear.
As I said "need to set it to something like '0000000000' (one 0 for each digit)." |
|
Back to top |
|
 |
kimbert |
Posted: Tue Aug 21, 2012 11:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
At minimum, you need to set three DFDL properties:
- textPadKind should be set to 'padChar'
- textStringPadCharacter should be set to '0'
- textStringJustification should be set to 'right' |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 21, 2012 12:01 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
kimbert wrote: |
At minimum, you need to set three DFDL properties:
- textPadKind should be set to 'padChar'
- textStringPadCharacter should be set to '0'
- textStringJustification should be set to 'right' |
Oh, sure, the easy way...  |
|
Back to top |
|
 |
rajbuddha |
Posted: Mon Aug 27, 2012 1:27 am Post subject: |
|
|
 Apprentice
Joined: 02 Aug 2011 Posts: 47 Location: chennai
|
@mqjeff : Thanks a lot
@kimbert : Thanks.. _________________ -----------
Raju Buddha
Never Wait for your 2nd Opportunity..!Becoz it may be harder than the 1st One... |
|
Back to top |
|
 |
|