Aproach to Convert EBCDIC to ASCII for HEX values in COBOL



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Aproach to Convert EBCDIC to ASCII for HEX values in COBOL

Postby PRMOHANTY » Sun Aug 05, 2012 5:40 pm

Hello All ,

We have a specific situation where we have to port/migrate all existing COBOL applications currently running on Mainframe environment to Linux Environment. ( going ahead the application would run in Linux environment )
Most of the COBOL programs are having inbuilt HEX constants defined in the program which are subsequently used in the program for data comparison.

EX ; 05 VAR-XYZ PIC X VALUE X'C2'.

We know that this HEXADECIMAL is of EBCDIC Collating Sequence in Mainframe.

Now after migrating these COBOL codes to LINUX , we have to convert these constants to HEX equivalent of ASCII.

What is the best approach to translate all these HEX constants in EBCDIC to equivalent ASCII .( On avearge we have 300+ programs in our set-up which has HEX constants defined in them )

Thanks in advance!!
PRMOHANTY
 
Posts: 3
Joined: Sat Aug 04, 2012 12:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COBOL

 

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COB

Postby enrico-sorichetti » Sun Aug 05, 2012 5:49 pm

unfortunately You will you will have to do it by hand with a cheat sheet to look for correspondences

but probably wiser top review the application to convert everything to good old plain chars
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COB

Postby Robert Sample » Sun Aug 05, 2012 6:58 pm

A manual approach is probably the best way, and depending upon the code may be the ONLY way.

A more important question to answer, however, is WHY are there hexadecimal constants in the COBOL programs? If the application is parsing network messages, for example, you'd run into a host of issues in attempting to do that on a Linux system. And since there are multiple variants of EBCDIC, as well as different variations of ASCII, somebody needs to build the character conversion table in advance to prevent confusion.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COB

Postby PRMOHANTY » Sun Aug 05, 2012 7:15 pm

Thanks a Lot Enrico & Robert for quick response .

I am still wondering that many installations must have already faced this challenge and must have overcome this problem.

Apart from knowing the best approach to resolve this situation , I am also interseted in knowing the various challenges this situation would potentially pose and things I have to consider before applying any solution/approach.
PRMOHANTY
 
Posts: 3
Joined: Sat Aug 04, 2012 12:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COB

Postby enrico-sorichetti » Sun Aug 05, 2012 7:24 pm

I am still wondering that many installations must have already faced this challenge and must have overcome this problem.


the specific problem is due, sorry to say, to a poor application design/programming standards
why use HEX constants ???
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COB

Postby Robert Sample » Sun Aug 05, 2012 8:21 pm

I have heard of very few sites that use hexadecimal constants in COBOL. Hence, your statement that many installations have already faced this problem is incorrect -- almost no sites would have the issues your site has since they don't use hexadecimal constants.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COB

Postby Monitor » Sun Aug 05, 2012 8:24 pm

Probably a programmer without training on COmmon Business Oriented Language with C or Assembler knowledge!
Why not give him a GoBack or in worst case a Stop Run.
Monitor
 
Posts: 98
Joined: Wed Jan 18, 2012 8:59 pm
Has thanked: 0 time
Been thanked: 7 times

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COB

Postby dick scherrer » Mon Aug 06, 2012 1:15 am

Hello,

In tha case of the x'C2', how is the value used? Is this to be the letter B when used or is this just a pattern of ones and zeros that represent bits that are on or off? Where/how did the x'C2' originate?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COB

Postby PRMOHANTY » Wed Aug 08, 2012 12:59 am

The usage of X'C2' would be letter B instead of on or off representation for bits.
PRMOHANTY
 
Posts: 3
Joined: Sat Aug 04, 2012 12:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Aproach to Convert EBCDIC to ASCII for HEX values in COB

Postby dick scherrer » Wed Aug 08, 2012 1:21 am

Hello,

Then it would be far better to use "B" as the value instead of x'C2'. . .

It should not be too difficult to identify where the x'..' values are specified and then change them to the appropriate character(s). You really don't want to deal with ascii/ebcdic flip-flops . . . imho.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post