bit to 8 different char
Moderators: Frank Yaeger, Moderator Group
-
- Member
- Posts: 29
- Joined: Tue Feb 18, 2014 9:13 pm
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/10)
//SORTOUT DD DSN=... output file (FB/10)
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=10,
IFTHEN=(WHEN=INIT,BUILD=(8C'0',9:9,2,11:1,1)),
IFTHEN=(WHEN=(11,1,BI,BO,X'80'),OVERLAY=(1:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'40'),OVERLAY=(2:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'20'),OVERLAY=(3:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'10'),OVERLAY=(4:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'08'),OVERLAY=(5:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'04'),OVERLAY=(6:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'02'),OVERLAY=(7:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'01'),OVERLAY=(8:C'1'))
There is a 10-byte input record, of which only three bytes are significant (for the original TS/OP). These are bytes 1, and 9/10.
What is required for the output is the bit-pattern of byte 1, in character format. This must be in the first eight bytes of the output. Bytes 9/10 are also required, unchanged, in the output.
IFOUTLEN sets the length of the records for when all IFTHEN processing is complete. It is set to 10.
The BUILD makes a new record consisting of eight zeros, bytes 9/10 and byte 1, now moved to byte 11.
Byte 11 is then interrogated, bit by bit, and the corresponding byte from 1-8 is set to C'1' if the bit is on.
The HIT=NEXT is because otherwise the IFTHEN processing will stop, as it normally does once a record has matched an IFTHEN=(WHEN=(logical expression).
When all the IFTHENs are processed, the excess 11th byte is dropped off due to the IFOUTLEN having set the length to 10.
This will work, but is perhaps overcomplicated for what you need, due to the relocation of the byte being converted.
Exactly how to apply it in your case, we don't know. If you still have a problem, post your actual requirement, with sample input and expected output and what you have tired.
-
- Member
- Posts: 29
- Joined: Tue Feb 18, 2014 9:13 pm
Thanks William
I am trying to understand your explanation and try to modify as per my requirement. Please find below mention requirement and input
This is my input file
This is my input file
This is my requirement
The reimb code contains 7 years of information about an reimb status. Need to decode the C(1) field to 8 bits whose output will be shown as below. I need to extract/decode first column
Kinda Code'd
I am trying to understand your explanation and try to modify as per my requirement. Please find below mention requirement and input
This is my input file
This is my input file
Code: Select all
REIMB-CODE SERIAL SERIAL-SEQ SERSEQ SUCCESSOR
C(1) (1-1) C(5) (2-6) PS(9) (2-6) PS(6,3) (2-6) PS(1) (7-7)
------------- -KEY----------- -KEY--------- -KEY----------- ------------
********************************* TOP OF DATA *****************************
. ..... +2000 +2.000 +1
. ..... +2001 +2.001 +1
. ..... +3000 +3.000 +0
. ..... +4000 +4.000 +0
. ..... +7000 +7.000 +1
..... +7001 +7.001 +1
The reimb code contains 7 years of information about an reimb status. Need to decode the C(1) field to 8 bits whose output will be shown as below. I need to extract/decode first column
Code: Select all
1st - Bit 2nd - Bit 3rd - Bit 4rth - Bit 5th - Bit 6th - Bit 7th - Bit 8th - Bit
0 or 1 0 or 1 0 or 1 0 or 1 0 or 1 0 or 1 0 or 1 0 or 1
Suggest you practice with the Code tag - it can be your friend . . .
I took a shot at "Coding" your info, but it works better if you do this and adjust for alignment.
Once we are clear about what you want, Syncsort can get the result needed.
I took a shot at "Coding" your info, but it works better if you do this and adjust for alignment.
Once we are clear about what you want, Syncsort can get the result needed.
Last edited by DikDude on Fri Feb 21, 2014 9:46 pm, edited 1 time in total.
Have a good one
-
- Member
- Posts: 29
- Joined: Tue Feb 18, 2014 9:13 pm
I have tried but what I am not getting is
IFTHEN=(WHEN=INIT,BUILD=(8C'0',9:9,2,11:1,1)),
How it work ? Can some tell me how it work?
OUTPUT should be look like
REIMB-CODE SERIAL SEQ SUCC
C(1) (1-1) C(5) (2-6) PS(9) (2-6) PS(6,3) (2-6) PS(1) (7-7)
------------- -KEY----------- -KEY--------- -KEY----------- ------------
********************************* TOP OF DATA *****************************
00101010 ..... +2000 +2.000 +1
01100010 ..... +2001 +2.001 +1
NOTE : REIMB-CODE should be extracted like this, however it's just a example so value would be different or vary for another rows
IFTHEN=(WHEN=INIT,BUILD=(8C'0',9:9,2,11:1,1)),
How it work ? Can some tell me how it work?
OUTPUT should be look like
REIMB-CODE SERIAL SEQ SUCC
C(1) (1-1) C(5) (2-6) PS(9) (2-6) PS(6,3) (2-6) PS(1) (7-7)
------------- -KEY----------- -KEY--------- -KEY----------- ------------
********************************* TOP OF DATA *****************************
00101010 ..... +2000 +2.000 +1
01100010 ..... +2001 +2.001 +1
NOTE : REIMB-CODE should be extracted like this, however it's just a example so value would be different or vary for another rows
Last edited by Vikas.betu on Wed Feb 26, 2014 12:28 am, edited 1 time in total.
Do take a few minutes and practice with the Code Tag! It is not available on the Quick Reply editor. If you are in Quick Reply, click preview and all of the editing features become visable.
The line of code is the "first-time" thru and sets up an area of all zeros. Later, as bits are used, the ones are populated. Suggest you do it on paper with a pencil and see how it goes.
The line of code is the "first-time" thru and sets up an area of all zeros. Later, as bits are used, the ones are populated. Suggest you do it on paper with a pencil and see how it goes.
Have a good one
-
- Member
- Posts: 29
- Joined: Tue Feb 18, 2014 9:13 pm
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
You seem to have seven-byte input records. There is no indication of where you want the expanded bits to appear:
If that does not suit, you have to describe what your output is to look like.
Code: Select all
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(8:8C'0')),
IFTHEN=(WHEN=(1,1,BI,BO,X'80'),OVERLAY=(8:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'40'),OVERLAY=(9:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'20'),OVERLAY=(10:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'10'),OVERLAY=(11:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'08'),OVERLAY=(12:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'04'),OVERLAY=(13:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'02'),OVERLAY=(14:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'01'),OVERLAY=(15:C'1'))
-
- Member
- Posts: 29
- Joined: Tue Feb 18, 2014 9:13 pm
Thank you William
But my requirement is
I need to extract only first column, whose values are '.'
----------------------------
REIMB-CODE
C(1)
-----
****
.
.
.
.
.
-----------------------
The reimb code contains 7 years of information about an reimb status. Need to decode the C(1) field to 8 bits whose output will be shown as below.
--------------------------------
REIMB-CODE
--------
********
00101010
01100010
-------------------------------
NOTE : REIMB-CODE should be extracted like this, however it's just a example so value would be different or vary for another rows.
But my requirement is
I need to extract only first column, whose values are '.'
----------------------------
REIMB-CODE
C(1)
-----
****
.
.
.
.
.
-----------------------
The reimb code contains 7 years of information about an reimb status. Need to decode the C(1) field to 8 bits whose output will be shown as below.
--------------------------------
REIMB-CODE
--------
********
00101010
01100010
-------------------------------
NOTE : REIMB-CODE should be extracted like this, however it's just a example so value would be different or vary for another rows.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Code: Select all
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(2:7C'0')),
IFTHEN=(WHEN=(1,1,BI,BO,X'40'),OVERLAY=(2:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'20'),OVERLAY=(3:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'10'),OVERLAY=(4:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'08'),OVERLAY=(5:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'04'),OVERLAY=(6:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'02'),OVERLAY=(7:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'01'),OVERLAY=(8:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BO,X'80'),OVERLAY=(1:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,BI,BZ,X'80'),OVERLAY=(1:C'0'))
-
- Member
- Posts: 29
- Joined: Tue Feb 18, 2014 9:13 pm
Thanks William
I have used your code and now I sent data to test whether decoded information is coming in this is correct or not. I'll let you know once I'll get the result.
Thanks Dik
I am in coading and dont know much about cobol thats why I was trying with JCL. If you have any link where I can find cobol code for this type of requirement then pls share with me so that I can try that. Thanks
I have used your code and now I sent data to test whether decoded information is coming in this is correct or not. I'll let you know once I'll get the result.
Thanks Dik
I am in coading and dont know much about cobol thats why I was trying with JCL. If you have any link where I can find cobol code for this type of requirement then pls share with me so that I can try that. Thanks
-
- Member
- Posts: 29
- Joined: Tue Feb 18, 2014 9:13 pm
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