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
 

 

Enterprise Cobol function working like HEX DB2 function

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

New User


Joined: 13 Mar 2010
Posts: 5
Location: ITALY

PostPosted: Mon Mar 15, 2010 4:19 am    Post subject: Enterprise Cobol function working like HEX DB2 function
Reply with quote

I'm using Cobol Enterprise 3.4.
I wish to convert data (display purpose) from char to their hexadecimal value. I know there's a program, in the forum I have found the code.
I search for a function like HEX DB2 function.(The HEX function returns a hexadecimal representation of a value.)
I ask if there is a way to do this with intrinsic function of Enterprise Cobol (ORD, CHAR, DISPLAY-OF) o Language Environment services (CEE.....)
Thanks
icon_biggrin.gif
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: Mon Mar 15, 2010 5:37 am    Post subject:
Reply with quote

Hello and welcome to the forum,

Quote:
I ask if there is a way to do this with intrinsic function of Enterprise Cobol
Unfortunately no. . . Maybe someday if this is accepted by the language developers.

There are a couple of ways posted in the forum - so you at least have a choice. What i have seen several places is that there is a common callable routine rather than including the code in-line whenever it is wanted.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Mar 15, 2010 7:06 am    Post subject: Reply to: Enterprise Cobol function working like HEX DB2 fun
Reply with quote

For example, if you had a 4-Byte field which equals 'ABCD' you need to convert this to its 8-Byte EBCDIC equivalent of 'C1C2C3C4'?

I'm unaware of a COBOL Intrinsic Function which will do this.

As Dick has said, a canned in-house sub-program is your best option.

The conversion process in COBOL can convert 15-Bytes to 30-Bytes in one fell swoop, using the ARITH(EXTEND) compiler option. Otherwise, the maximum is 8-Bytes to 16-Bytes without this ARITH option.

Bill
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon Mar 15, 2010 2:46 pm    Post subject:
Reply with quote

If you are using DB2 in your module already, it might be an option to let the DB HEX function do it:
Code:
EXEC SQL.
SET :hex-output = HEX(:binary-input)
END-EXEC.

It might be quicker than a home-cooked hex function.
Back to top
View user's profile Send private message
Ermy

New User


Joined: 13 Mar 2010
Posts: 5
Location: ITALY

PostPosted: Mon Mar 15, 2010 5:17 pm    Post subject:
Reply with quote

dick scherrer wrote:
Hello and welcome to the forum,

Quote:
I ask if there is a way to do this with intrinsic function of Enterprise Cobol
Unfortunately no. . . Maybe someday if this is accepted by the language developers.

There are a couple of ways posted in the forum - so you at least have a choice. What i have seen several places is that there is a common callable routine rather than including the code in-line whenever it is wanted.


Thanks for greetings !
I found a very 'odd' function like REVERSE (!) and might not find a HEX funtion. Sorry for my criticism (I joke) . (I must be polite, othrwhise admin bans me).
thank you

Erasmo
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon Mar 15, 2010 6:04 pm    Post subject:
Reply with quote

Quote:
found a very 'odd' function like REVERSE (!) and might not find a HEX funtion.

Yes, it is odd, as PL/1 has 2(!) functions, HEX and HEXIMAGE that supposedly do what you want. But these functions are probably not implemented using Language Environment routines.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Mar 15, 2010 7:47 pm    Post subject: Reply to: Enterprise Cobol function working like HEX DB2 fun
Reply with quote

You could use the following as a basis for a callable routine -

http://www.ibmmainframes.com/viewtopic.php?p=174662&highlight=#174662

If your compiler supports ARITH(EXTEND) then WS-NBR can be defined as PIC 9(30), WS-PACKED can be defines as PIC 9(30)V9 COMP-3 and WS-DISPLAY can be defined as PIC 9(30)V9. Note that regardless of the ARITH option, all three numeric definitions must be defined as unsigned (as illustrated).

Also, in a callable routine scenario, you may want to consider passing the length of the data to be converted as a binary halfword. So, the length of the converted (returned) data will be this halfword value, doubled.

The INSPECT CONVERTING (with literals and/or figurative constants) generates a in-line TR assembler instruction, providing that you're not using reference modification. Otherwise, a BALR is issued to a COBOL run-time routine.

Bill
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 RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
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


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