bit to 8 different char

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Vikas.betu
Member
Posts: 29
Joined: Tue Feb 18, 2014 9:13 pm

Post by Vikas.betu » Thu Feb 20, 2014 10:49 pm

Thanks Dik
But I need alternative as I am stuck with ifthen / overlay
I am not sure what changes needs to be done in below mention code to work for 1 character field to 8 bit
If you can help in this then pls

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Feb 21, 2014 12:44 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')) 
An explanation then.

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.

Vikas.betu
Member
Posts: 29
Joined: Tue Feb 18, 2014 9:13 pm

Post by Vikas.betu » Fri Feb 21, 2014 1:10 am

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

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          
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

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
Kinda Code'd

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Feb 21, 2014 1:29 am

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.
Last edited by DikDude on Fri Feb 21, 2014 9:46 pm, edited 1 time in total.
Have a good one

Vikas.betu
Member
Posts: 29
Joined: Tue Feb 18, 2014 9:13 pm

Post by Vikas.betu » Fri Feb 21, 2014 1:36 am

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
Last edited by Vikas.betu on Wed Feb 26, 2014 12:28 am, edited 1 time in total.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Feb 21, 2014 3:28 am

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.
Have a good one

Vikas.betu
Member
Posts: 29
Joined: Tue Feb 18, 2014 9:13 pm

Post by Vikas.betu » Fri Feb 21, 2014 8:30 am

Thanks for the help Dik, but unfortunatly I am not able to modify this code as per my requirement(either abend or not logical). This forum is my last hope to get some info. If some one can give me some code as per requirment then It would be great.. as I have to resolve this issue by today itself :( :( :( :(

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Feb 21, 2014 3:26 pm

You seem to have seven-byte input records. There is no indication of where you want the expanded bits to appear:

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')) 
If that does not suit, you have to describe what your output is to look like.

Vikas.betu
Member
Posts: 29
Joined: Tue Feb 18, 2014 9:13 pm

Post by Vikas.betu » Fri Feb 21, 2014 7:55 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.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Feb 21, 2014 8:22 pm

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')) 
Since your input is seven bytes long, the first OVERLAY will naturally change the length to eight. Bits 2-8 are dealt with first, so that your data in byte one can be used up until then end. Then byte one is dealt with, which also gets set to zero when the first bit is zero (BZ) not one (BO) - note that if that bit has already tested true for one, X'F1' will be inposition one, so testing it for zero will be false. The test for zero can only be true if the orginal byte is still in position one, unchanged. Then it will become X;F0',

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Feb 21, 2014 9:56 pm

as I have to resolve this issue by today itself
If time is so constrained, you might consider COBOL . . . The coding would not be the same, but is rather straightforward.

I suspect it is already rather late in the day there.
Have a good one

Vikas.betu
Member
Posts: 29
Joined: Tue Feb 18, 2014 9:13 pm

Post by Vikas.betu » Fri Feb 21, 2014 9:59 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

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Fri Feb 21, 2014 10:26 pm

I was trying with JCL.
No you were not. You were trying with sort. Sort is not JCL. JCL is JCL and it is completely different. You would also need JCKL if you did the task in COBOL - or any other language/utility progtam.
Regards
Nic

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Feb 21, 2014 10:31 pm

Are you familiar with Easytrieve?
Have a good one

Vikas.betu
Member
Posts: 29
Joined: Tue Feb 18, 2014 9:13 pm

Post by Vikas.betu » Sat Feb 22, 2014 12:12 am

No We don't use EASYTRIVE in our project :(

Post Reply

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



Other References
Mainframe Tools and others