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

Treat the character as hex and convert it to binary


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
marpana

New User


Joined: 10 Jun 2005
Posts: 13
Location: London, UK

PostPosted: Thu Jan 25, 2007 10:22 pm
Reply with quote

I have a a PIC X(4) field containg (for example X?F0F0F2F6?. ? character ?0026?. I need to be able to take this as the Hex value X?0026? and ?convert? it to a binary values of 38.

basically with HEX ON, the i/p would look like
FFFF
0026

This should be treated as
02
06

is there a way to convey DFSORT/ICETOOL to treat i/p character as hex value and convert it ZD value of 38? .
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Jan 25, 2007 11:11 pm
Reply with quote

If you packed the four bytes into three bytes, I think that the first two digits could be referenced by 3,y2v and the second two by 3,y2y....
But you would have to stick them together again.....
If you have the manual, take a look, appendix C I think, Data Format Descriptions.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jan 25, 2007 11:56 pm
Reply with quote

Here's a DFSORT job that does what you asked for with simple arithmetic:

Code:

//S1    EXEC  PGM=ICEMAN                                           
//SYSOUT    DD  SYSOUT=*                                           
//SORTIN DD *                                                       
0026                                                               
1111                                                               
0001                                                               
9999                                                               
//SORTOUT DD SYSOUT=*                                               
//SYSIN    DD    *                                                 
  OPTION COPY                                                       
  INREC BUILD=(((1,1,ZD,MUL,+4096),ADD,(2,1,ZD,MUL,+256),ADD,       
    (3,1,ZD,MUL,+16),ADD,4,1,ZD),TO=ZD,LENGTH=5)                   
/*


SORTOUT would have:

Code:

00038
04369
00001
39321


I assumed you only had 0-9 in your input and not A-F.
Back to top
View user's profile Send private message
marpana

New User


Joined: 10 Jun 2005
Posts: 13
Location: London, UK

PostPosted: Fri Jan 26, 2007 12:12 am
Reply with quote

That works. Thank you Frank. I would not have thought on those lines.
Back to top
View user's profile Send private message
marpana

New User


Joined: 10 Jun 2005
Posts: 13
Location: London, UK

PostPosted: Mon Jan 29, 2007 3:59 pm
Reply with quote

Frank ,

just got to know the input hex string can consist of A-F also along with 1-9 in which case the above arithmatic fails. Any ideas about how to achive the conversion in this case ?
e.g.
input 01E0
o/p 480
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Jan 29, 2007 10:38 pm
Reply with quote

Here's a DFSORT job that will do that. The trick is to convert '0'-'9' to X'00'-X'09' and 'A'-'F' to X'0A'-X'0F' and use those BI values for the arithmetic.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file (FB/4)
//SORTOUT DD DSN=...  output file (FB/5)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(1,1,BI,GE,+240),
          OVERLAY=(5:1,1,BI,SUB,+240,TO=BI,LENGTH=1),HIT=NEXT),
        IFTHEN=(WHEN=(1,1,BI,LT,+240),
          OVERLAY=(5:1,1,BI,SUB,+183,TO=BI,LENGTH=1),HIT=NEXT),
        IFTHEN=(WHEN=(2,1,BI,GE,+240),
          OVERLAY=(6:2,1,BI,SUB,+240,TO=BI,LENGTH=1),HIT=NEXT),
        IFTHEN=(WHEN=(2,1,BI,LT,+240),
          OVERLAY=(6:2,1,BI,SUB,+183,TO=BI,LENGTH=1),HIT=NEXT),
        IFTHEN=(WHEN=(3,1,BI,GE,+240),
          OVERLAY=(7:3,1,BI,SUB,+240,TO=BI,LENGTH=1),HIT=NEXT),
        IFTHEN=(WHEN=(3,1,BI,LT,+240),
          OVERLAY=(7:3,1,BI,SUB,+183,TO=BI,LENGTH=1),HIT=NEXT),
        IFTHEN=(WHEN=(4,1,BI,GE,+240),
          OVERLAY=(8:4,1,BI,SUB,+240,TO=BI,LENGTH=1),HIT=NEXT),
        IFTHEN=(WHEN=(4,1,BI,LT,+240),
          OVERLAY=(8:4,1,BI,SUB,+183,TO=BI,LENGTH=1))
  OUTREC BUILD=(((5,1,BI,MUL,+4096),ADD,(6,1,BI,MUL,+256),ADD,
    (7,1,BI,MUL,+16),ADD,8,1,BI),TO=ZD,LENGTH=5)
/*
Back to top
View user's profile Send private message
marpana

New User


Joined: 10 Jun 2005
Posts: 13
Location: London, UK

PostPosted: Mon Jan 29, 2007 11:05 pm
Reply with quote

Frank, Thank you very much.

I get it that you are trying to convert
X'F2' (242) to X'02'(002) similarly X'C1' (193 or c'A') to X'0A'(10) and so on .

Thanks again for the solution.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts Convert HEX to Numeric DB2 3
Search our Forums:

Back to Top