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

Convert string to packed format


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

New User


Joined: 21 Sep 2019
Posts: 4
Location: India

PostPosted: Sat Sep 21, 2019 5:01 pm
Reply with quote

Hi,
I need to convert a 256 bytes hex string to packed format in Cobol.

Eg:

Input :-

3082010a0282010100be42eb0d03abee94da5f68dffc7157baa555426473a049a008ba96abd454a65d55dcd397ea814e58c77ecbeadc6997c097

Output :-

380008000b
021a22110e...………….

Any clue how this can be achieved?

thanks in anticipation.
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 319
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Sat Sep 21, 2019 7:06 pm
Reply with quote

www.ibm.com/support/knowledgecenter/en/SSQ2R2_14.1.0/com.ibm.ent.cbl.zos.doc/PGandLR/ref/rlinfhextc.html
Back to top
View user's profile Send private message
ajaydwivedi4u

New User


Joined: 21 Sep 2019
Posts: 4
Location: India

PostPosted: Sun Sep 22, 2019 12:34 pm
Reply with quote

Hi dneufarth - thanks for the above link, however HEX-TO-CHAR function doesnt work in my installation is it a bespoke function?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1348
Location: Israel

PostPosted: Sun Sep 22, 2019 12:59 pm
Reply with quote

Did you mean you need to convert C'3082010a0282010100be' to X'3082010a0282010100be' ?
If yes, using the words "packed format" is misleading, nothing to do with COMP-3 format.

Function HEX-TO-CHAR apparently is introduced in COBOL 6.
It does not exist in the COBOL 5.2 that we have here, for example.
Back to top
View user's profile Send private message
ajaydwivedi4u

New User


Joined: 21 Sep 2019
Posts: 4
Location: India

PostPosted: Sun Sep 22, 2019 2:08 pm
Reply with quote

Right...i need it in X'3082010a0282010100be' format to supply it as input to another assembler program.
Back to top
View user's profile Send private message
John Poulakos

Active User


Joined: 13 Jun 2012
Posts: 180
Location: United States

PostPosted: Fri Oct 04, 2019 11:52 pm
Reply with quote

What you have appears to be a string of data that was converted from hex to display (Char) format. So C'3082010a0282010100be' is actually 'F3F0F8F2F0F1F081F0F2F8F2F0F1F0F1F0F08285' in memory. I assume my assumption is correct, because hex can only contain 0 thru 9 and A thru F. If the data string contains characters greater than F, it can not be converted the way you envision.
Back to top
View user's profile Send private message
John Poulakos

Active User


Joined: 13 Jun 2012
Posts: 180
Location: United States

PostPosted: Thu Oct 10, 2019 10:05 pm
Reply with quote

Just to clarify, hex data does not contain lower case alpha characters. What you have provided is how hex characters appear when they are displayed. Your data string is nothing but bytes that has no meaning.
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 Negative value - packed field - Natur... Java & MQSeries 0
No new posts How to replace a string dynamically i... CLIST & REXX 16
No new posts Control M features to check string in... Compuware & Other Tools 1
No new posts Printing a dataset in DUMP format wit... ABENDS & Debugging 2
No new posts How to convert RESP code 12 to text? CICS 9
Search our Forums:

Back to Top