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
 
how to convert Hex String t char hex

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
Martylin

New User


Joined: 08 Mar 2016
Posts: 13
Location: Taiwan

PostPosted: Fri Jun 05, 2020 7:45 pm    Post subject: how to convert Hex String t char hex
Reply with quote

If I have a hex string, how to how to convert to a char hex

DCL HEX_STRING CHAR(4) INIT('A02F');
DCL CHAR_2B CHAR(2);

CHAR_2B would like be

A2
0F
Back to top
View user's profile Send private message

Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1073
Location: Dublin, Ireland

PostPosted: Fri Jun 05, 2020 8:14 pm    Post subject:
Reply with quote

The description does not make sense.

A hex string A02F would be declared as
Code:
 DCL HEX_STRING     CHAR(2) INIT('A02F'X);

and would not be a CHAR(4) string.

What is described as the desired result looks like what would be displayed for the declare statement I've given when in TSO browse/view/edit with HEX ON.

What are you trying to achieve?

Garry.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1206
Location: Vilnius, Lithuania

PostPosted: Sat Jun 06, 2020 12:27 am    Post subject: Re: how to convert Hex String t char hex
Reply with quote

Martylin wrote:
If I have a hex string, how to how to convert to a char hex

DCL HEX_STRING CHAR(4) INIT('A02F');
DCL CHAR_2B CHAR(2);

CHAR_2B would like be

A2
0F


Why don't you actually RTFM, like experts (this is a forum for experts, you know?) do? PL/I has builtin functions to do this!
Back to top
View user's profile Send private message
Martylin

New User


Joined: 08 Mar 2016
Posts: 13
Location: Taiwan

PostPosted: Sat Jun 06, 2020 5:42 am    Post subject:
Reply with quote

Garry Carroll wrote:
The description does not make sense.

A hex string A02F would be declared as
Code:
 DCL HEX_STRING     CHAR(2) INIT('A02F'X);

and would not be a CHAR(4) string.

What is described as the desired result looks like what would be displayed for the declare statement I've given when in TSO browse/view/edit with HEX ON.

What are you trying to achieve?

Garry.


no, I mean if I read a dataset, there are some hex string format, I have to convert to char hex, i don't know how to do it ?
 
 
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1206
Location: Vilnius, Lithuania

PostPosted: Sat Jun 06, 2020 1:03 pm    Post subject:
Reply with quote

Maybe you can show os some of those "hex string format lines", by viewing the dataset, giving the command "hex" and cutting and pasting some of the data between {code} {/code} tags (use square brackets!)

We do not want to see images!
Back to top
View user's profile Send private message
Martylin

New User


Joined: 08 Mar 2016
Posts: 13
Location: Taiwan

PostPosted: Mon Jun 08, 2020 1:40 pm    Post subject: Reply to: how to convert Hex String t char hex
Reply with quote

I solved the problem, but I still don't know how to transform hex string to char hex.

my solution is tell the provider (open system), give me the decimal string range will be 0 ~ 65535. The input format is complex, I just pick some fields

Code:

DCL                                                               
  1 TB_IN,                      /* FOR TEST ONLY */               
    5 GK_ID          CHAR(4)    INIT('ABCD'),                     
    5 GK_TAB1        CHAR(1)    INIT('05'X),                     
    5 GK_DEC_STRING  PIC'99999' INIT(16545); /* HEXADECIMAL 40A1 */
    /* originall is this  5 GK_HEX_STRING  CHAR(4)  */

 DCL                                                               
   1 TB_OUT,                                                       
     5 GK_ID         CHAR(4),                                       
     5 GK_TAB1       CHAR(1),                                       
     5 GK_CHARS      CHAR(2);                                       
                                                                   
 DCL  GK_BIN   FIXED BIN(31);                                       
 DCL  GK_BIT   BIT(32);                                             
 DCL  GK_TEMP  CHAR(4) BASED(ADDR(GK_BIT));                         
                                                                   
 GK_BIN  = TB_IN.GK_DEC_STRING;                                           
 GK_BIT = UNSPEC(GK_BIN);                                           
                                                                   
 TB_OUT.GK_ID    = TB_IN.GK_ID;                                     
 TB_OUT.GK_TAB1  = TB_IN.GK_TAB1;                                   
 TB_OUT.GK_CHARS = SUBSTR(GK_TEMP,3,2);             
                                                   
 PUT SKIP LIST('TB_OUT=' || STRING(TB_OUT));


----+----1----+
***************
TB_OUT=ABCD  ~   
EC6DEE7CCCC04A
32D643E1234501


if is GK_HEX_STRING = '40A1';

how to transform like:

Code:

----+----1----+
***************
 ~   
4A
01
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 801
Location: Maryland

PostPosted: Mon Jun 08, 2020 5:15 pm    Post subject: Re: Reply to: how to convert Hex String t char hex
Reply with quote

Martylin wrote:
I solved the problem, but I still don't know how to transform hex string to char hex.


1) Do you speak English?

2) Do you know what Google.com is?

3) Do you have a computer?

4) Are you able to use Internet?

Quote:
HEX(x)
HEX returns a character string that is the hexadecimal representation of the storage that contains x.
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 -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Insert System Runtime in HEADER In SY... Rick Ryan SYNCSORT 9 Tue May 26, 2020 9:01 pm
No new posts how to do bit operations from CHAR Martylin PL/I & Assembler 3 Wed May 13, 2020 8:27 pm
No new posts Get next 5 numeric from a string of '... maxsubrat COBOL Programming 7 Fri Apr 24, 2020 2:30 pm
No new posts comparasion between BIN FIXED(63) an... javen777 PL/I & Assembler 10 Wed Apr 22, 2020 5:11 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

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