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
 

 

Built-in function to convert Char to EBCDIC

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

New User


Joined: 29 Oct 2008
Posts: 2
Location: Chennai

PostPosted: Thu Oct 30, 2008 12:05 pm    Post subject: Built-in function to convert Char to EBCDIC
Reply with quote

There is any buil-in function in VS COBOL II to convert chanracter to EBCDIC?. if so, please help me with peace of sample code or function.
Back to top
View user's profile Send private message

Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Oct 30, 2008 12:20 pm    Post subject:
Reply with quote

Quote:
chanracter to EBCDIC
Shuold I read as ASCII to EBCDIC ?
Back to top
View user's profile Send private message
trbala

New User


Joined: 29 Oct 2008
Posts: 2
Location: Chennai

PostPosted: Thu Oct 30, 2008 12:29 pm    Post subject:
Reply with quote

No, it should be read as Char to EBCDIC.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Oct 30, 2008 12:56 pm    Post subject:
Reply with quote

Quote:

No, it should be read as Char to EBCDIC


with the exception of db2 columns in unicode, everything on IBM Mainframes is in EBCDIC.

suggest you do some reading about your environment.

if you have more questions, post them.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 30, 2008 7:32 pm    Post subject:
Reply with quote

Hello,

Quote:
No, it should be read as Char to EBCDIC.
Please post some of your non-ebcdic chars in hex.
Back to top
View user's profile Send private message
Bob Ream

New User


Joined: 05 Nov 2008
Posts: 7
Location: RI

PostPosted: Thu Nov 06, 2008 10:01 pm    Post subject:
Reply with quote

Funny you should ask this question as I have recently an opportunity to do just that. There are 2 tables you need to put in your program and one line of code.

Code:
 
      *****************************************************************     
      * The following tables are used by the INSPECT statement to do  *
      * the conversion betweeen EBCDIC and ASCII.                     *
      * inspect FIELD-NAME converting EBCDIC-INFO to ASCII-INFO       *
      * inspect FIELD-NAME converting ASCII-INFO  to EBCDIC-INFO      *
      *                                                               *
      * The tables may also be used to convert between lower and      *
      * upper case.         *                                         *
      * inspect FIELD-NAME converting EBCDIC-LOWER to EBCDIC-UPPER    *
      * inspect FIELD-NAME converting ASCII-LOWER  to ASCII-UPPER     *
      *****************************************************************
      *                                                               
      *>   ------------------------------------------------------------
      *>   **  The EBCDIC Table ...                                   
      *>   **  01                             A B C D E F G H I       
      *>   **  02                             J K L M N O P Q R       
      *>   **  03                             S T U V W X Y Z         
      *>   **  04                             a b c d e f g h i       
      *>   **  05                             j k l m n o p q r       
      *>   **  06                             s t u v w x y z         
      *>   **  07                             0 1 2 3 4 5 6 7 8 9     
      *>   **  08                         space . < ( + | & ! $ *     
      *>   **  09                             ) ; - / , % _ > ? `     
      *>   **  10  7D/7F Single/Double quote  : # @7D =7F  { }     
      *>   **  11                             \ ~                        
       01  EBCDIC-DATA.                                               
           05  EBCDIC-UPPER-CASE-DATA.                               
               10  filler  pic X(9)  value X'C1C2C3C4C5C6C7C8C9'.     
               10  filler  pic X(9)  value X'D1D2D3D4D5D6D7D8D9'.     
               10  filler  pic X(8)  value X'E2E3E4E5E6E7E8E9'.       
           05  EBCDIC-UPPER          redefines EBCDIC-UPPER-CASE-DATA
                                     pic X(26).                       
           05  EBCDIC-LOWER-CASE-DATA.                               
               10  filler  pic X(9)  value X'818283848586878889'.     
               10  filler  pic X(9)  value X'919293949596979899'.     
               10  filler  pic X(8)  value X'A2A3A4A5A6A7A8A9'.       
           05  EBCDIC-LOWER          redefines EBCDIC-LOWER-CASE-DATA
                                     pic X(26).                       
           05  EBCDIC-DIGITS.                                         
               10  filler  pic X(10) value X'F0F1F2F3F4F5F6F7F8F9'.
          05  EBCDIC-SPECIAL.                                     
              10  filler  pic X(10) value X'404B4C4D4E4F505A5B5C'.
              10  filler  pic X(10) value X'5D5E60616B6C6D6E6F79'.
              10  filler  pic X(10) value X'7A7B7C7D7E7FADBDC0D0'.
              10  filler  pic X(3)  value X'E0A1B0'.               
      01  EBCDIC-INFO     redefines EBCDIC-DATA pic X(95).         
      01  EBCDIC-TABLE    redefines EBCDIC-DATA.                   
          05  EBCDIC-BYTE pic X     occurs 95 times.               
     *                                                             
     *>   ---------------------------------------------------------
     *>   **  The ASCII Table ...                                 
     *>   **  01                             A B C D E F G H I     
     *>   **  02                             J K L M N O P Q R     
     *>   **  03                             S T U V W X Y Z       
     *>   **  04                             a b c d e f g h i     
     *>   **  05                             j k l m n o p q r     
     *>   **  06                             s t u v w x y z       
     *>   **  07                             0 1 2 3 4 5 6 7 8 9   
     *>   **  08                         space . < ( + | & ! $ *   
    *>   **  09                             ) ; - / , % _ > ? `     
    *>   **  10  27/22 Single/Double quote  : # @27 =22           { }     
    *>   **  11                             \ ~                        
     01  ASCII-DATA.                                               
         05  ASCII-UPPER-CASE-DATA.                                 
             10  filler  pic X(9)  value X'414243444546474849'.     
             10  filler  pic X(9)  value X'4A4B4C4D4E4F505152'.     
             10  filler  pic X(8)  value X'535455565758595A'.       
         05  ASCII-UPPER           redefines ASCII-UPPER-CASE-DATA 
                                   pic X(26).                       
         05  ASCII-LOWER-CASE-DATA.                                 
             10  filler  pic X(9)  value X'616263646566676869'.     
             10  filler  pic X(9)  value X'6A6B6C6D6E6F707172'.     
             10  filler  pic X(8)  value X'737475767778797A'.       
         05  ASCII-LOWER           redefines ASCII-LOWER-CASE-DATA 
                                   pic X(26).                       
         05  ASCII-DIGITS.                                         
             10  filler  pic X(10) value X'30313233343536373839'.   
         05  ASCII-SPECIAL.                                         
            10  filler  pic X(10) value X'202E3C282B7C2621242A'.
            10  filler  pic X(10) value X'293B2D2F2C255F3E3F79'.
            10  filler  pic X(10) value X'3A2340273D225B5D7B7D'.
            10  filler  pic X(3)  value X'5C7E5E'.               
    01  ASCII-INFO      redefines ASCII-DATA pic X(95).         
    01  ASCII-TABLE     redefines ASCII-DATA.                   
        05  ASCII-BYTE  pic X     occurs 95 times.         


The WS-POS-6501-ENCRIP-DATA is the output field. The actual convert code would be:

Code:
 C000-CONVERT-ASCII SECTION.                                     
*>   MOVE ALL X'20' to SYSUT2-RECORD.                             
     MOVE ALL X'20' to WS-POS-6501-ENCRIP-DATA.                   
*>   TransLATE...                                                 
*>   MOVE SYSUT1-RECORD(00001:00080) to SYSUT2-RECORD(00001:00080)
     MOVE WS-POS-IN-REC TO WS-POS-IN-REC-6501                     
     INSPECT WS-POS-6501-ENCRIP-DATA(00001:00080)                 
         CONVERTING ASCII-INFO TO EBCDIC-INFO.             

I have used this and it does work.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Nov 07, 2008 1:52 am    Post subject: Reply to: Built-in function to convert Char to EBCDIC
Reply with quote

Hi Bob,

Thanks for the translator code icon_smile.gif

We're still waiting for trbala to post some of the troublesome non-ebcdic characters. . .

d
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Fri Nov 07, 2008 2:19 am    Post subject: Reply to: Built-in function to convert Char to EBCDIC
Reply with quote

I might be picky icon_biggrin.gif but I feel that the approach is a bit approximate...
or the requirement is a bit generic

the approach shown would work for printable

a truly foolproof approach would be to use a table for all the ascii symbols

two tables really....
a standard ASCII with 128 chars
an extended ASCII with 256 chars

maybe two more for checking...
whose content be a simple flag byte to tell if the translation is possible
carry on the translation raising a condition error whenever a char cannot be translated

the same approach for the other way around

but thats a personal opinion, or the way I would specify the requirement
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 How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am


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