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
 

 

EBCDIC to ASCII through COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: EBCDIC to ASCII through COBOL
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    Post subject:
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    Post subject:
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: 7996
Location: Bellevue, IA

PostPosted: Fri Jun 19, 2009 4:43 pm    Post subject:
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    Post subject:
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: 7996
Location: Bellevue, IA

PostPosted: Fri Jun 19, 2009 5:26 pm    Post subject:
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    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 SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


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