View previous topic :: View next topic
|
Author |
Message |
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
Hi,
I am trying to pad zeroes while converting a field using DFSORT.
Code: |
INREC FIELDS=(1:1,3,PD,TO=FS,LENGTH=02) |
How do I make the output to be padded with zeroes when there are one byte value.
Is it possible to use UFF, M11 formatting in INREC FIELDS while converting? |
|
Back to top |
|
|
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
How to handle for more than 2 bytes? For example
Code: |
Input: is Char
1
12
123
Output: should be numeric
001
012
123 |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Use an EDIT nask. |
|
Back to top |
|
|
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
Achieved it through EDIT Function.
Code: |
INREC FIELDS=(1:1,3,PD,EDIT=(TT)) |
Thanks Bill. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
No problem.
I only looked quickly at your control cards before.
Your input is not CH(ar). It is PD (Packed Decimal). It is three bytes long, which for packed decimal means a maximum value of 99999. You may be loosing digits, depending on your data. Also, you know whether or not your data might be negative. If yes, then you are loosing that with your EDIT.
With what you are showing at the moment, you have a potentially signed 5-digit number that you are making, as your entire output, a two-digit unsigned number. |
|
Back to top |
|
|
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
That's True.
In my case, the field will not have a negative value.
The max value will be of 1 byte which I am making into 2 bytes for DFSORT join key purpose. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
The max value will be of 1 byte which I am making into 2 bytes for DFSORT join key purpose. |
Sounds like there is still confusion. . .
If you have 1 packed-decimal byte, it will only have 1 digit (plus the sign). If you have 2 packed-decimal bytes, there will be 3 digits plus the sign. Your example shows 1-3 digit input and the output is 3 bytes. . .
Where does the 2 bytes come into the picture? |
|
Back to top |
|
|
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
I quoted the 3 bytes example for information purpose.
Sign is not of my significance for now. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Sign is not of my significance for now. |
You may not believe it matters now, but it does. . . It IS in the data and you have no control over that. Packed-decimal data always has a sign. . .
Please re-read my previous post and clarify just exactly what you want as output - show some realistic input data and the output you want from that input data. |
|
Back to top |
|
|
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
@dick scherrer, it is always positive, for my case, so I didn't pay heed to it.
Will post the hex value. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
it is always positive, for my case, so I didn't pay heed to it. |
The issue is not so much whether the value is positive or not - it is the issue of how many digits are contained in the value.
A 1-byte packed-decimal value has only 1 digit. A 2-byte packed-decimal value has 3 digits.
Quote: |
The max value will be of 1 byte which I am making into 2 bytes for DFSORT join key purpose. |
This cannot happen as one byte will not give 2 digits . . . |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
HameedAli,
To be certain of getting the correct help, you need to use the correct terminology or more words if you are not sure of the terminology.
You see to be using the word "byte" at times when you mean character/digit.
You have shown a three-byte signed packed-decimal field from which you are creating your output field which is two characters/digits with leading zeros where necessary.
If you are trying to say that the packed-decimal field is unsigned, then look in the manual to see how to define it correctly.
If you are saying the field can only hold a single significant digt, 0-9, then include information like that in your initial post.
When posting requests for help, please use the actual definitions you are interested in, as advice can be very specific and we do not care to waste our time because you haven't taken care to give all the information, and word the request the best you can. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Also, keep in mind that an "unsigned" packed-decimal field still Has a sign. By definition, a packed-decimal field reserves the low-order half-byte (nibble) for the sign - even if it is not needed by the code referencing the field.
Posting some values of your "input" field in hex would also help. |
|
Back to top |
|
|
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
Quote: |
If you are saying the field can only hold a single significant digt, 0-9, then include information like that in your initial post. |
This is what, I should have mentioned. Will take care of it future posts, thank you. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome - good luck
d |
|
Back to top |
|
|
|