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

Conversion from Numeric to BCD format


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

New User


Joined: 10 Mar 2011
Posts: 45
Location: india

PostPosted: Mon Jan 11, 2016 9:27 pm
Reply with quote

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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Mon Jan 11, 2016 9:57 pm
Reply with quote

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

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Mon Jan 11, 2016 10:12 pm
Reply with quote

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
Code:
21
5C
or perhaps
Code:
21
5F
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
View user's profile Send private message
dharmaraok

New User


Joined: 10 Mar 2011
Posts: 45
Location: india

PostPosted: Mon Jan 11, 2016 10:44 pm
Reply with quote

251 is three byte numeric field. I need to convert into BCD format;The Output Should be

05
21
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Mon Jan 11, 2016 11:22 pm
Reply with quote

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

Moderator Emeritus


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

PostPosted: Mon Jan 11, 2016 11:51 pm
Reply with quote

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

New User


Joined: 03 Nov 2014
Posts: 78
Location: Malaysia

PostPosted: Tue Jan 12, 2016 8:35 am
Reply with quote

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
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
Search our Forums:

Back to Top