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
 

 

Byte conversion Algorithm

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 47
Location: Cochin

PostPosted: Tue Dec 11, 2012 12:09 am    Post subject: Byte conversion Algorithm
Reply with quote

Hi All,

I am need of developing a conversion algorithm that will convert a 3 byte numeric value to 2 byte alphanumeric/alphabetic/numeric value and viceversa. Any one of you had a similar requirement ?

For eg.

001 - 01
002 - 02
003 - 03
...
...
...
099 - 99
100 - A1
...
270 - AA

etc...

Something of this sort. Can you please help me out. Also Iam not suppossed to hard code these mapped values with the cobol module nor I can store these values in any lookup file.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue Dec 11, 2012 12:37 am    Post subject:
Reply with quote

You have not been nearly clear enough for anyone to help you. When you say " 2 byte alphanumeric/alphabetic/numeric value" do you mean a 2-byte displayable alphanumeric value? ANY 2-byte alphanumeric value? Something else you have not explained?

Since there are 1000 three-byte numbers (000 to 999), what mapping are you planning on using to go from them to " 2 byte alphanumeric/alphabetic/numeric value"s?

Who assigned this "requirement" anyway -- it sounds more like a homework assignment than an actual work requirement?
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Dec 11, 2012 12:37 am    Post subject:
Reply with quote

Hello,

What if you simply moved the 3-byte numeric to a 2-byte packed-decimal or binary field?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Tue Dec 11, 2012 1:17 am    Post subject:
Reply with quote

I frankly can't think of any algorithm that will give 100 -> A1 and 270 -> AA. Nonetheless, I recommend that you adopt this Rexx fragment to COBOL:
Code:
base36 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
netctr   = substr(base36,netctr36%36+1,1) ||,
           substr(base36,netctr36//36+1,1)   
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Dec 11, 2012 4:52 am    Post subject: Reply to: Byte conversion Algorithm
Reply with quote

Do you need the 3-Byte numeric value (assuming display-numeric) to be represented as a 2-Byte Packed-Unsigned (BCD) value?

For example: 500 (X'F5F0F0') converted to X'0500' or 999 (X'F9F9F9') converted to X'0999'?

A value of 1000 would require a 4-Byte display-numeric sending field.

Dick's suggestion of moving the 3-Byte value to a PL2 or XL2 (S9(03) COMP-3 or S9(04) COMP) seems to be the simplest method.

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Dec 11, 2012 6:00 am    Post subject: Reply to: Byte conversion Algorithm
Reply with quote

You want, in human-readable form, a two character "sequence number" which can represent zero to 999?

What is it that you can't "hard code"? You'll need some data defined for the mapping, unless you only want the solution by calculation (which is going to be more difficult).

I also don't understand the attempt you've made so far.

As Mr A. has suggested, if you go for 0-Z, just done in the way we do counting normally, you have a simple solution. Unless you come up with a really good reason to calculate it, rather than defining a table with those values in, I think you should have enough already.
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 47
Location: Cochin

PostPosted: Tue Dec 11, 2012 7:09 pm    Post subject:
Reply with quote

Folks.. I got the answer.

For converting these 3 bytes to 2 bytes its enough that we convert it to a base 36 variable.

for eg.

the base 36 equalant of decimal 100 is 2S. like wise it can be extended upto 999.
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 -> COBOL Programming 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 Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm
No new posts EBCDIC to ASCII conversion using OCOPY mistah kurtz All Other Mainframe Topics 5 Tue Sep 06, 2016 2:26 pm
No new posts Comparex utility to Syncsort conversion mistah kurtz SYNCSORT 11 Fri Jul 22, 2016 1:53 pm
No new posts changing z/os unicode conversion service meykh2014 All Other Mainframe Topics 0 Tue Jul 12, 2016 10:49 am


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