Page 2 of 3

Posted: Thu Feb 20, 2014 10:49 pm
by Vikas.betu
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

Posted: Fri Feb 21, 2014 12:44 am
by William Collins

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.

Posted: Fri Feb 21, 2014 1:10 am
by Vikas.betu
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

Posted: Fri Feb 21, 2014 1:29 am
by DikDude
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.

Posted: Fri Feb 21, 2014 1:36 am
by Vikas.betu
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

Posted: Fri Feb 21, 2014 3:28 am
by DikDude
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.

Posted: Fri Feb 21, 2014 8:30 am
by Vikas.betu
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 :( :( :( :(

Posted: Fri Feb 21, 2014 3:26 pm
by William Collins
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.

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

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

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

Posted: Fri Feb 21, 2014 9:56 pm
by DikDude
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.

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

Posted: Fri Feb 21, 2014 10:26 pm
by NicC
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.

Posted: Fri Feb 21, 2014 10:31 pm
by DikDude
Are you familiar with Easytrieve?

Posted: Sat Feb 22, 2014 12:12 am
by Vikas.betu
No We don't use EASYTRIVE in our project :(