Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Convert string to packed format

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Convert string to packed format
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: 292
Location: Cincinnati OH USA

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

https://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    Post subject:
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: 1329
Location: Israel

PostPosted: Sun Sep 22, 2019 12:59 pm    Post subject:
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    Post subject:
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: 147
Location: United States

PostPosted: Fri Oct 04, 2019 11:52 pm    Post subject:
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: 147
Location: United States

PostPosted: Thu Oct 10, 2019 10:05 pm    Post subject:
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    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 String to ASCII conversion JPLMARTINS COBOL Programming 4 Sun Sep 29, 2019 12:00 am
No new posts Convert from 1/1/2019 to 01/01/2019 sudhakarraju DFSORT/ICETOOL 3 Fri Sep 20, 2019 1:16 am
No new posts Convert Numeric to Packed decimal and... anand1204 DFSORT/ICETOOL 5 Thu Aug 08, 2019 3:53 am
No new posts Converting a copybook value into Json... srikant314 COBOL Programming 1 Mon Jun 03, 2019 11:17 am
No new posts Alphanumeric to Packed Decimal Conver... Vijay_Sirisha COBOL Programming 2 Mon May 27, 2019 2:52 am

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