View previous topic :: View next topic
|
Author |
Message |
dharmaraok
New User
Joined: 10 Mar 2011 Posts: 45 Location: india
|
|
|
|
I am having field value as
251
I need to convert into BCD format.
05
21
I tried with the below sort card and Im getting the error
1,2,BI,TO=PDF,LENGTH=2 .
Could you please let me know how can we do it. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
dharmaraok wrote: |
I tried with the below sort card and Im getting the error |
If you're really getting "the" error, maybe it's time to buy a ticket for the next Powerbal, you might win "the" prize!
May you can tell us more about "the" error... |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
You have your terms confused.
251 is what is usually thought of as BCD (Binary Coded Decimal).
What you think you want is sometimes called unsigned packed decimal. It's not packed decimal because it does not have a packed decimal sign. True packed decimal would be
or perhaps
Now I won't try to guess what you really want. Unsigned packed decimal is basically useless on an IBM mainframe because the instructions that operate on packed decimal data won't touch unsigned packed decimal. Worse, if it is your intent to send this junk to non IBM mainframe computers it is difficult to mix it with text data.
What you have to do is figure out what you want to do here and tell us. |
|
Back to top |
|
|
dharmaraok
New User
Joined: 10 Mar 2011 Posts: 45 Location: india
|
|
|
|
251 is three byte numeric field. I need to convert into BCD format;The Output Should be
05
21 |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Very well, you want what Mr. Myers calls "unsigned packed decimal: and I would call "packed BCD": one decimal digit per mybble, with no sign or zone.
Subject to correction by Mr. Woodger, whose knowledge of the *sort products is much greater than mine, I believe that you want to specify TO=PD0 on your control card. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If it is a three-character number, why define it as 1,2,BI?
You can't use TO=PD0 (is that your error?).
You need to use 1,3,ZD and then multiply by 10 and use TO=PD (or PDF or PDC, it doesn't matter) and LENGTH=3. That will give you X'02510C' (or F for the sign) and then just use the first two bytes of that.
That will be your BCD.
What do you want that for? Oracle? Be careful if you are including that in data for an external system, as you then can't convert an entire record from EBCDIC to ASCII during the file-transfer. |
|
Back to top |
|
|
boyti ko
New User
Joined: 03 Nov 2014 Posts: 78 Location: Malaysia
|
|
|
|
Hi dharmaraok,
In my shop, sometimes we put a 16-digit number inside PIC X(8) to be used in COBOL program.
In SORT here's how we convert it.
Code: |
//STEP100 EXEC PGM=SORT
//SORTIN DD *
1234567890123456
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,16,ZD,MUL,+10,TO=PD,LENGTH=9)
OUTREC BUILD=(1,8)
|
Code: |
Output:
----+----1----+----2
13579135
24680246 |
Maybe that would help. So for your case, you need to complete an even number of digits. |
|
Back to top |
|
|
|