IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Padding Zeroes while Conversion


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Sat Jul 07, 2012 8:19 pm
Reply with quote

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.
Code:
1 as
01

Is it possible to use UFF, M11 formatting in INREC FIELDS while converting?
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Sun Jul 08, 2012 12:00 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Jul 08, 2012 4:09 am
Reply with quote

Use an EDIT nask.
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Sun Jul 08, 2012 3:26 pm
Reply with quote

Achieved it through EDIT Function.
Code:
INREC  FIELDS=(1:1,3,PD,EDIT=(TT)) 

Thanks Bill.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Jul 08, 2012 4:25 pm
Reply with quote

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
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Mon Jul 09, 2012 12:46 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2012 7:03 pm
Reply with quote

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
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Mon Jul 09, 2012 8:11 pm
Reply with quote

I quoted the 3 bytes example for information purpose.

Sign is not of my significance for now.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2012 8:44 pm
Reply with quote

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
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Mon Jul 09, 2012 10:36 pm
Reply with quote

@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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2012 11:42 pm
Reply with quote

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 . . . icon_confused.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 10, 2012 5:07 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 10, 2012 8:26 am
Reply with quote

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
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Tue Jul 10, 2012 12:30 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 10, 2012 8:53 pm
Reply with quote

You're welcome - good luck icon_smile.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts Remove leading zeroes SYNCSORT 4
No new posts file manager is doing string conversion IBM Tools 3
No new posts SMF Record Date conversion failing CLIST & REXX 1
Search our Forums:

Back to Top