Hexadecimal to decimal conversion - SORT JCL INREC OUTREC
Moderators: Frank Yaeger, Moderator Group
Hexadecimal to decimal conversion - SORT JCL INREC OUTREC
Need a help in converting hexadecimal to decimal using SORT.
e.g 30E0 should be converted to 12512
I tried the following jcl but I am getting the output 4092642800 instead of 12512.
//STEP020 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
30E0
//*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1,4,BI,ZDF)
//*
e.g 30E0 should be converted to 12512
I tried the following jcl but I am getting the output 4092642800 instead of 12512.
//STEP020 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
30E0
//*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1,4,BI,ZDF)
//*
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
jathampy,
//SORTIN DD *
30E0
would be treated as F3F0C5F0
you have to hex on your JOB JCL (since you have instream data) and as MrSpock said,
enter the 30E0 in two bytes.
Good Catch MrSpock!
//SORTIN DD *
30E0
would be treated as F3F0C5F0
you have to hex on your JOB JCL (since you have instream data) and as MrSpock said,
enter the 30E0 in two bytes.
Good Catch MrSpock!
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
jathampy,
As Dick says, C'30E0' is X'F3F0C5F0', so you can't use BI,TO=ZDF to convert it. You have to do an actual conversion of the binary equivalent of the EBCDIC value.
Here's one way to do what you asked for with DFSORT:
SORTOUT will have:
As Dick says, C'30E0' is X'F3F0C5F0', so you can't use BI,TO=ZDF to convert it. You have to do an actual conversion of the binary equivalent of the EBCDIC value.
Here's one way to do what you asked for with DFSORT:
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
30E0
1234
5678
9ABC
DEF0
//*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:C'0',1,1,C'0',2,1,C'0',3,1,C'0',4,1)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=81,
INOUT=(C'0A',C'10',C'0B',C'11',C'0C',C'12',
C'0D',C'13',C'0E',C'14',C'0F',C'15'))),
IFTHEN=(WHEN=INIT,
BUILD=((81,2,ZD,MUL,+4096),ADD,
(83,2,ZD,MUL,+256),ADD,
(85,2,ZD,MUL,+16),ADD,(87,2,ZD),TO=ZDF,LENGTH=5))
/*
Code: Select all
12512
04660
22136
39612
57072
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct,2010), you can use DFSORT's new TRAN=UNHEX function to do this more easily like this:
For complete details on the new functions for DFSORT and DFSORT's ICETOOL available with the Oct, 2010 PTF, see:
http://www.ibm.com/support/docview.wss? ... g3T7000242
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
30E0
1234
5678
9ABC
DEF0
//*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,4,TRAN=UNHEX)
OUTREC BUILD=(1,2,BI,TO=ZD)
/*
http://www.ibm.com/support/docview.wss? ... g3T7000242
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Member
- Posts: 7
- Joined: Sat Mar 31, 2012 8:16 am
HEX to CHAR Representation
Hi Frank,
I only have SYNCSORT installed. Can we do this (TRAN=UNHEX) using ICETOOL?
Bharath
I only have SYNCSORT installed. Can we do this (TRAN=UNHEX) using ICETOOL?
Bharath
Frank is a DFSORT developer and does not support Syncsort.
Suggest you refer to the Syncsort documentation for your release of the product.
You might also open an issue with Syncsort support as they will be able to quickly tell you if your release supports this or if there is a workaround.
Suggest you refer to the Syncsort documentation for your release of the product.
You might also open an issue with Syncsort support as they will be able to quickly tell you if your release supports this or if there is a workaround.
Have a good one
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Member
- Posts: 7
- Joined: Sat Mar 31, 2012 8:16 am
Hi,
I did open this issue seperately in SyncSort Support Area. http://www.mainframegurukul.com/ibmmain ... ght=#15557
I am using Syncsort V 1.3.02R. I guess mine did not support UNHEX. I tried running a example and it gave me a syntax error.
More details on i/p o/p can be found in the above link.
Thanks
Bharath
I did open this issue seperately in SyncSort Support Area. http://www.mainframegurukul.com/ibmmain ... ght=#15557
I am using Syncsort V 1.3.02R. I guess mine did not support UNHEX. I tried running a example and it gave me a syntax error.
More details on i/p o/p can be found in the above link.
Thanks
Bharath
-
- Member
- Posts: 7
- Joined: Sat Mar 31, 2012 8:16 am
I did try Frank's IFTHEN solution using my SyncSort. Below is what I got:
Code: Select all
SYNCSORT FOR Z/OS 1.3.0.2R
SYSIN :
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:C'0',1,1,C'0',2,1,C'0',3,1,C'0',4,1)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=81,
*
INOUT=(C'0A',C'10',C'0B',C'11',C'0C',C'12',
C'0D',C'13',C'0E',C'14',C'0F',C'15'))),
IFTHEN=(WHEN=INIT,
BUILD=((81,2,ZD,MUL,+4096),ADD,
(83,2,ZD,MUL,+256),ADD,
(85,2,ZD,MUL,+16),ADD,(87,2,ZD),TO=ZDF,LENGTH=5))
WER268A INREC STATEMENT : SYNTAX ERROR
Thanks
Bharath
Bharath
Frank Yaeger wrote:jathampy,
As Dick says, C'30E0' is X'F3F0C5F0', so you can't use BI,TO=ZDF to convert it. You have to do an actual conversion of the binary equivalent of the EBCDIC value.
Here's one way to do what you asked for with DFSORT:
SORTOUT will have:Code: Select all
//S1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD * 30E0 1234 5678 9ABC DEF0 //* //SORTOUT DD SYSOUT=* //SYSIN DD * OPTION COPY INREC IFTHEN=(WHEN=INIT, OVERLAY=(81:C'0',1,1,C'0',2,1,C'0',3,1,C'0',4,1)), IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=81, INOUT=(C'0A',C'10',C'0B',C'11',C'0C',C'12', C'0D',C'13',C'0E',C'14',C'0F',C'15'))), IFTHEN=(WHEN=INIT, BUILD=((81,2,ZD,MUL,+4096),ADD, (83,2,ZD,MUL,+256),ADD, (85,2,ZD,MUL,+16),ADD,(87,2,ZD),TO=ZDF,LENGTH=5)) /*
Code: Select all
12512 04660 22136 39612 57072
Hi Frank,
I tried your conversion and it worked very good.
The question is my input file has record till 35th position and in that 1-4 is hexadecimal that I need to convert. when I used the above sort card, 1-4 got converted and sortout has the decimal values in 1-4. but last 31 byte i.e., 05-35 is not appearing in output. the file is having 999 million records so I could nt download into excel and merge. Please let me know what should I use in the above sort card to copy 05-35 bytes as is.
If you want to wait for Frank to reply then so be it - you will wait a very long time as he retired some time ago. Lesson to be learnt? Do not address posts to particular people.
Also, you should really have started a new topic as this one is old. You can link to this one or cut and paste the relevant bit.
Also, you should really have started a new topic as this one is old. You can link to this one or cut and paste the relevant bit.
Regards
Nic
Nic
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page