Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Treat the character as hex and convert it to binary

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Treat the character as hex and convert it to binary
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: 3158
Location: Tucson AZ

PostPosted: Thu Jan 25, 2007 11:11 pm    Post subject:
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 Moderator


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

PostPosted: Thu Jan 25, 2007 11:56 pm    Post subject:
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    Post subject:
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    Post subject: Re: Treat the character as hex and convert it to binary
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 Moderator


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

PostPosted: Mon Jan 29, 2007 10:38 pm    Post subject:
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    Post subject: Re: Treat the character as hex and convert it to binary
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts Convert CLIST to REXX cvnlynn CLIST & REXX 12 Tue Jun 27, 2017 2:06 am
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am

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