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

EBCDIC and ASCII


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abhijit.nayak01

Active User


Joined: 22 Mar 2009
Posts: 161
Location: South Africa

PostPosted: Fri Jun 24, 2022 3:40 pm
Reply with quote

Hi,
I am having trouble converting between ascii to ebcdic and vice versa.
Frontend team converts the ascii 47EAACED1948CABF to ebcdic x'c752b05519c872ab' and sends the ebcdic/hex value to mainframe. And in mainframe I need to convert it back to actual ascii value but I don't get the desired result. In one scenario I got the desired result but in the below scenario i didn't. Please assist.

Code:
01  WS-AREA          PICTURE N(08).                 
01  WS-CCSID         PICTURE 9(5).                   
01  WS-ASCII         PICTURE 9(08) USAGE IS DISPLAY.
01  WS-EBCDIC        PICTURE X(08).                 
01  WS-PIN           PICTURE X(16).                 
MOVE X"c752b05519c872ab"                     
     TO WS-EBCDIC.                           
     DISPLAY " WS-EBCDIC   = " WS-EBCDIC.     
MOVE FUNCTION NATIONAL-OF(WS-EBCDIC)         
     TO WS-AREA.                             
     DISPLAY " WS-AREA     = " WS-AREA.       
MOVE 819     TO WS-CCSID.                     
MOVE FUNCTION DISPLAY-OF(WS-AREA, WS-CCSID)   
     TO WS-ASCII.                             
   DISPLAY " WS-ASCII    = " WS-ASCII.       
   MOVE FUNCTION HEX-OF(WS-ASCII)             
                        TO WS-PIN             
   DISPLAY " WS-PIN      = " WS-PIN.         

getting below result
WS-EBCDIC   = G    H         
EE6CCCCCC44474C5B51C7A44444444
620523493000E07205982B00000000
------------------------------
WS-AREA     =      ;         
EE6CDCC4444474040E050E01040C0B
620195100000E0070A0E0D09080A0F
------------------------------
WS-ASCII    =   ;             
EE6CECCC4444744E5E14CB44444444
620123990000E07AED98AF00000000
------------------------------
WS-PIN      = 47EA5EED1948CABF
EE6DCD44444474FFCCFCCCFFFFCCCC
620795000000E04751555419483126


But I am expecting 47EAACED1948CABF.
difference between two output is "5E" and "AC'
Back to top
View user's profile Send private message
abhijit.nayak01

Active User


Joined: 22 Mar 2009
Posts: 161
Location: South Africa

PostPosted: Fri Jun 24, 2022 4:43 pm
Reply with quote

this one coming correctly as expected
Code:
MOVE X"ae857b539cc31419"                 
     TO WS-EBCDIC.                       
     DISPLAY " WS-EBCDIC   = " WS-EBCDIC.
MOVE FUNCTION NATIONAL-OF(WS-EBCDIC)     
     TO WS-AREA.                         
     DISPLAY " WS-AREA     = " WS-AREA.   
MOVE 819     TO WS-CCSID.                 
MOVE FUNCTION DISPLAY-OF(WS-AREA, WS-CCSID
     TO WS-ASCII.                         
   DISPLAY " WS-ASCII    = " WS-ASCII.   
   MOVE FUNCTION HEX-OF(WS-ASCII)         
                        TO WS-PIN         
   DISPLAY " WS-PIN      = " WS-PIN.     

output
Code:
WS-EBCDIC   =  e#  C         
EE6CCCCCC44474A8759C1144444444
620523493000E0E5B3C34900000000
------------------------------
WS-AREA     =          W     
EE6CDCC44444740D06020E0E040901
620195100000E00E05030B06030D09
------------------------------
WS-ASCII    =     W           
EE6CECCC444474D62EE49144444444
620123990000E0E53B63D900000000
------------------------------
WS-PIN      = DE6523EBE6439D19
EE6DCD44444474CCFFFFCCCFFFFCFF
620795000000E04565235256439419
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8651
Location: Dubuque, Iowa, USA

PostPosted: Sat Jun 25, 2022 1:04 am
Reply with quote

Your first problem is that EBCDIC does not have "a" collating sequence. There are multiple versions of EBCDIC, and characters are not all the same in every version. For example, the square brackets [] can be X'BA' and X'BB' or X'AD' and X'BD' depending upon the version of EBCDIC. I've seen both pairs of characters being used on the same mainframe at different points, so it is not a matter of saying what is right and what is wrong -- both are right in some circumstances.

You need to find out code page is being used in the ASCII-to-EBCDIC translation and use that same code page with what you're doing. This won't necessarily resolve all your problems but it should get you close.
Back to top
View user's profile Send private message
abhijit.nayak01

Active User


Joined: 22 Mar 2009
Posts: 161
Location: South Africa

PostPosted: Tue Jun 28, 2022 11:30 am
Reply with quote

Thanks Robert.
I have asked the team to find what code page they are using.
Meanwhile I got an solution to convert this
Say for example I want to convert the x'c7'

Then first find the decimal value of x'c7' which is 199.
Then there is a ebcdic to ascii conversion file given 199 decimal value becomes decimal 71 according to that conversion file.

Then convert the decimal 71 to hexadecimal value which is 47.
So, 47 is the ascii value.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8651
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 28, 2022 6:24 pm
Reply with quote

X'C7' in EBCDIC is an upper case G. If your conversion process does not give you an ASCII upper case G, then either you're doing the process wrong or you're using the wrong process.

X'71' in ASCII is an upper case G. So your conversion of 71 to hex 47 is the wrong part of the process -- the 71 is ALREADY in hex.
Back to top
View user's profile Send private message
abhijit.nayak01

Active User


Joined: 22 Mar 2009
Posts: 161
Location: South Africa

PostPosted: Wed Jun 29, 2022 11:21 am
Reply with quote

Hi Rob,
I think we are on same page.
Front end got x'47' and converted to x'c7' and sent to mainframe.
Mainframe need to convert the x'c7' to x'47' and send it to another system.
how x'47' converted to x'c7'
x'47' numeric/decimal value is 071.
071 ascii to ebcdic numeric is 199 ( conversion table from frontend)
199 hex value is x'c7'
how x'c7' converted to x'47'
x'c7' numeric/decimal value is 199
199 ascii numeric to ebcdic numeric is 071( conversion table from frontend)
071 converted to hex is x'47' (enter 071 as dec in calculator programmer mode will get hex value as 47)
This value comes perfectly using national and display function in my first post. You are correct regarding the value of "G".
Code:
WS-EBCDIC   = G    H         
EE6CCCCCC44474C5B51C7A44444444
620523493000E07205982B00000000
------------------------------
WS-AREA     =      ;         
EE6CDCC4444474040E050E01040C0B
620195100000E0070A0E0D09080A0F
------------------------------
WS-ASCII    =   ;             
EE6CECCC4444744E5E14CB44444444
620123990000E07AED98AF00000000
------------------------------
WS-PIN      = 47EA5EED1948CABF
EE6DCD44444474FFCCFCCCFFFFCCCC
620795000000E04751555419483126


The whole conversion I have to follow because I don't know what code page is being used but i got now the conversion table.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Wed Jun 29, 2022 4:41 pm
Reply with quote

There is no need to involve decimal conversion anywhere in this process of translation.

It only increases the whole mess up to 2 or more times higher; there are no other "benefits".
Back to top
View user's profile Send private message
abhijit.nayak01

Active User


Joined: 22 Mar 2009
Posts: 161
Location: South Africa

PostPosted: Fri Jul 01, 2022 10:28 am
Reply with quote

Thanks for your suggestion. Created a table below
'0101'.
'0202'.
'0303'.
'049C'.
'0509'.
'0686'.
'077F'.
'0897'.
'098D'.
'0A8E'.
'0B0B'.
.
.
occurs 256 times
ebc-key pic x(02)
asc-key pic x(02)

So, like you suggested no more complexity of too many conversion
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 -> CICS

 


Similar Topics
Topic Forum Replies
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts include cond ascii constant DFSORT/ICETOOL 4
No new posts XYplorer - EBCDIC to ASCII translatio... All Other Mainframe Topics 0
No new posts EBCDIC to ASCII conversion help All Other Mainframe Topics 1
No new posts EBCDIC (0037) to/from UTF-8 (1208) CLIST & REXX 2
Search our Forums:

Back to Top