Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Working with EBCDIC values

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

New User


Joined: 02 Mar 2005
Posts: 13
Location: Bangalore

PostPosted: Mon Mar 14, 2005 12:34 pm    Post subject: Working with EBCDIC values
Reply with quote

In COBOL is it possible to work with EBCDIC values?
that means if i want to write a program which will convert a file content from uppercase to lower case,i can do it in C by changin the corresponding ASCII values,is there something like that in COBOL?
or suppose i want to print the EBCDIC value of a character are these things possible in COBOL?
Back to top
View user's profile Send private message

mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Mar 15, 2005 8:40 am    Post subject:
Reply with quote

Hi Kingsuk,

You can do it but it's not easy and/or it's not pretty.

First thing you might check is the Enterprise COBOL intrinsic functions and callable services.

Or you can try stuff like this to go from upper to lower case:

Move the byte to a COMP halfwd (low-ord byte). Add 64 and it's now upper case.

As for printing the HEX value of a field, I've used the code below. The redefines are a bit overdone because I had other uses for the fields. But it should give you an idea of what you can do.
Code:


05  WS-WORK-PACKED         PIC 9(009) COMP-3.
05  REDEFINES WS-WORK-PACKED.
    10  WS-WORK-X5.
        20  WS-WORK-X1     PIC X(001).
        20  WS-WORK-X3     PIC X(003).
05  REDEFINES WS-WORK-PACKED.
    10  WS-WORK-BIN4       PIC 9(009) COMP.

05  WS-WORK-UNPACKED       PIC 9(009).
05  REDEFINES WS-WORK-UNPACKED.
    10  WS-WORK-UNPACKED-8 PIC 9(008).


 100-CONVERT-HEX-DATA.
*--------------------------------------------------     
*  CONVERTS HEX DATA FOR DISPLAY PURPOSES
*  E.G. X'04FB' => X'F0F4C6C2' OR 04FB CHARACTER
*--------------------------------------------------     
 MOVE    WS-WORK-PACKED   TO WS-WORK-UNPACKED
 INSPECT WS-WORK-UNPACKED CONVERTING
         X'FAFBFCFDFEFF'  TO  'ABCDEF'
 DISPLAY WS-WORK-UNPACKED-8
 .
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 attchmvs from rexx subroutine that re... harisukumaran CLIST & REXX 1 Fri Jan 19, 2018 5:29 am
No new posts Regarding the EBCDIC CCSID mapping. sakthikumarT DB2 2 Wed Jan 10, 2018 4:45 pm
No new posts Conversion of UTF-8 to EBCDIC muralikrishnan_new COBOL Programming 1 Tue Nov 21, 2017 5:33 pm
No new posts Can EDCICONV convert EBCDIC to ASCII... natt.sut IBM Tools 3 Fri Nov 17, 2017 8:46 pm
No new posts REXX LISTDSI () SMSINFO is not working upendrasri CLIST & REXX 4 Fri Nov 17, 2017 11:33 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us