View previous topic :: View next topic
|
Author |
Message |
ajaydwivedi4u
New User
Joined: 21 Sep 2019 Posts: 4 Location: India
|
|
|
|
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 |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 418 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
Back to top |
|
|
ajaydwivedi4u
New User
Joined: 21 Sep 2019 Posts: 4 Location: India
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
ajaydwivedi4u
New User
Joined: 21 Sep 2019 Posts: 4 Location: India
|
|
|
|
Right...i need it in X'3082010a0282010100be' format to supply it as input to another assembler program. |
|
Back to top |
|
|
John Poulakos
Active User
Joined: 13 Jun 2012 Posts: 178 Location: United States
|
|
|
|
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 |
|
|
John Poulakos
Active User
Joined: 13 Jun 2012 Posts: 178 Location: United States
|
|
|
|
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 |
|
|
|