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: 313
Location: Inside the SPEW (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: 1349
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: 180
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: 180
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 how to convert Hex String t char hex Martylin PL/I & Assembler 6 Fri Jun 05, 2020 7:45 pm
No new posts Insert System Runtime in HEADER In SY... Rick Ryan SYNCSORT 9 Tue May 26, 2020 9:01 pm
No new posts Get next 5 numeric from a string of '... maxsubrat COBOL Programming 7 Fri Apr 24, 2020 2:30 pm
This topic is locked: you cannot edit posts or make replies. DFSORT-How to convert ZD to ZS in DFSORT useit DFSORT/ICETOOL 2 Thu Mar 26, 2020 10:43 am
No new posts Convert a packed decimal value to zon... Dinesh Mani DB2 6 Mon Mar 16, 2020 6:02 pm

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