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

EBCDIC to ASCII through COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Fri Jun 19, 2009 12:46 pm
Reply with quote

Do you have any pointers (COBOL Program) for conversion of EBCDIC data to ASCII and vice-versa.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jun 19, 2009 1:04 pm
Reply with quote

normally the transport media (from one computer to another) handles this conversion.

mqs will do the conversion.

ascii stored values in db2 columns will convert on the select.

where/why do you have ascii data on the mainframe?

(n is chat room, which this site is not)
(vice versa)

I imagine that GOOGLE would return some hits on a "COBOL" module to perform the translation.
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Fri Jun 19, 2009 2:26 pm
Reply with quote

I have heard that some built-in functions are available in COBOL that will perform above conversion but I'm unable to find it

Actually we're getting data through MQ in two different formats ( Base64 and ASCII) So while doing get MQ, we are not specifying any conversion format.

After getting data, we are calling Assembler routine to convert Base64 into ASCII.

That’s why we have data in ASCII format and want to convert it into EBCDIC.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Jun 19, 2009 4:43 pm
Reply with quote

There is a link to Manuals at the top of the page. Find the COBOL Language Reference manual and research functions DISPLAY-OF and NATIONAL-OF.

You could also bring up the manual, click on the Search icon, enter EBCDIC ASCII and click the Search button. You would also find the data this way.
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Fri Jun 19, 2009 4:58 pm
Reply with quote

I tried below program .... It's getting executed but it's doing nothing..

IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-AREA PICTURE N(50).
01 WS-CCSID PICTURE 9(5).
01 WS-ASCII PICTURE X(50).
01 WS-EBCDIC PICTURE X(50).
PROCEDURE DIVISION.
MOVE "ABCDE"
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.
DISPLAY "Now let's convert that WS-ASCII back to EBCDIC".
MOVE FUNCTION NATIONAL-OF(WS-ASCII,819 )
TO WS-AREA.
DISPLAY " WS-AREA = " WS-AREA.
MOVE 1140 TO WS-CCSID.
MOVE FUNCTION DISPLAY-OF(WS-AREA, WS-CCSID)
TO WS-EBCDIC.
DISPLAY " WS-EBCDIC = " WS-EBCDIC.
STOP RUN.


The output of program

WS-EBCDIC = ABCDE
WS-AREA =
WS-ASCII =
NOW LET'S CONVERT THAT WS-ASCII BACK TO EBCDIC
WS-AREA =
WS-EBCDIC = ABCDE
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Jun 19, 2009 5:26 pm
Reply with quote

Your code runs fine for me:
Code:
 WS-EBCDIC = ABCDE
4EE6CCCCCC474CCCCC
06205234930E012345
----------------------------------
 WS-AREA = . .â.ä.à.á.............
4EE6CDCC47404040404040202020202020
062019510E001020304050000000000000
----------------------------------
 WS-ASCII =  âäàá.................
4EE6CECCC4744444422222222222222222
0620123990E01234500000000000000000
----------------------------------
NOW LET'S CONVERT THAT WS-ASCII BA
DDE4DCE7E4CDDECDE4ECCE4EE6CECCC4CC
5660353D20365559303813062012399021
----------------------------------
 WS-AREA = . .â.ä.à.á.............
4EE6CDCC47404040404040202020202020
062019510E001020304050000000000000
----------------------------------
 WS-EBCDIC = ABCDE
4EE6CCCCCC474CCCCC
06205234930E012345
----------------------------------
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top