Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Conversion from Numeric to BCD format

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
dharmaraok

New User


Joined: 10 Mar 2011
Posts: 30
Location: india

PostPosted: Mon Jan 11, 2016 9:27 pm    Post subject: Conversion from Numeric to BCD format
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

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Mon Jan 11, 2016 9:57 pm    Post subject: Re: Conversion from Numeric to BCD format
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 User


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

PostPosted: Mon Jan 11, 2016 10:12 pm    Post subject:
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: 30
Location: india

PostPosted: Mon Jan 11, 2016 10:44 pm    Post subject: Reply to: Conversion from Numeric to BCD format
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: 1738
Location: Bloomington, IL

PostPosted: Mon Jan 11, 2016 11:22 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Jan 11, 2016 11:51 pm    Post subject: Reply to: Conversion from Numeric to BCD format
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us