The INREC is the record layout; the Sort is the sort sequence (obviously). Where I am screwing up is the OUTREC. The HEX 00 BYTE fields must appear in each record, but where the CUSTOMER NUMBER/CUSTOMER DOB and CUSTOMER NAME are the same as the previous record, these fields should be spaces.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
I've put together an example I think you can apply.
I'm assuming that if the account number is the same, there is no need to check name/dob.
There is code to insert your "low-value", I'm not sure if it is in your input, if so, ditch the obvious. Also, I've set the value of the low-value to an asterisk, to show up on the test.
I'm assuming the input file is sorted. If not, whack your SORT statement back in place of the OPTION COPY.
Code:
//BLANKDUP EXEC PGM=SORT
//SYMNAMES DD *
LOW-VALUE-LIT,X'5C'
//SYSOUT DD SYSOUT=*
//SYMNOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=INIT,
OVERLAY(81:SEQNUM,5,ZD,RESTART=(1,5))),
IFTHEN=(WHEN=INIT,
OVERLAY(06:LOW-VALUE-LIT,
12:LOW-VALUE-LIT,
18:LOW-VALUE-LIT)),
IFTHEN=(WHEN=(81,5,ZD,NE,1),
OVERLAY=(01:5X,
07:5X,
13:5X))
//*
//SORTIN DD *
11111 11111 11111 SOME OTHER DATA TO REMAIN INTACT
22222 22222 22222 SOME OTHER DATA TO REMAIN INTACT
22222 22222 22222 SOME OTHER DATA TO REMAIN INTACT
33333 33333 33333 SOME OTHER DATA TO REMAIN INTACT
44444 44444 44444 SOME OTHER DATA TO REMAIN INTACT
55555 55555 55555 SOME OTHER DATA TO REMAIN INTACT
55555 55555 55555 SOME OTHER DATA TO REMAIN INTACT
55555 55555 55555 SOME OTHER DATA TO REMAIN INTACT
Output is:
Code:
11111*11111*11111*SOME OTHER DATA TO REMAIN INTACT
22222*22222*22222*SOME OTHER DATA TO REMAIN INTACT
* * *SOME OTHER DATA TO REMAIN INTACT
33333*33333*33333*SOME OTHER DATA TO REMAIN INTACT
44444*44444*44444*SOME OTHER DATA TO REMAIN INTACT
55555*55555*55555*SOME OTHER DATA TO REMAIN INTACT
* * *SOME OTHER DATA TO REMAIN INTACT
* * *SOME OTHER DATA TO REMAIN INTACT
Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
Almost got it! Of course, when we get close, they change requirements! When the key is the same as the previous record, make the first 55 bytes spaces. Not a problem, but the key is always set to 000001, even though the lowest key is 0000007 (can never be null or low values).
Could that be because there are two WHEN=INIT, statements?
The key is actually in columns 2 thru 9, so I modified the SYSIN a bit:
This gets me this output (don't worry, the names & numbers are all fake):
Code:
*0000001*09/06/50*TAYLOR, WESLEY RAYMOND *03/11/96
*0000001*10/25/46*BOOHER, NOAH JAMES *02/12/02
*0000001*11/04/45*FRISON, EUGENE *09/22/98
*0000001*05/21/43*GILPIN, DOLORES JANE *01/23/98
*0000001*04/25/46*KLINGER, GLENN WILLIAM *08/04/98
*0000001*03/01/46*SPROED, EDWARD DOUGLAS *03/20/98
*0000001*08/01/43*CLEMO, FREDERICK LINN *03/02/98
*0000001*08/25/39*KRETTINGER, RONALD GLEN *05/05/98
*0000001*06/20/37*HEINRICH, CLARENCE THEODORE *03/23/94
04/25/94
*0000001*08/09/41*TUTTLE, LYLE EDWARD *04/10/98
*0000001*08/09/21*BAILEY, JAMES GUY *02/07/94
02/02/94
*0000001*08/02/17*MILLETT, KATHLEEN NORTON *03/06/98
*0000001*08/31/43*BENNETT, ROBERT MELVIN *01/25/96
01/12/96
08/29/96
*0000001*05/08/44*ASLIN, STANISLAUS ELTON *11/19/93
11/26/93
05/05/94
How do I get the key field (columns 2 - 9) to show the right values?
The Column 81:, should change to the first byte after the end of your record. The technique is to temporarily "extend" the record with a sequence number, the sequence number will re-set to one on change of the specified key (yours is 2,7).
Then, later, chop off the extension as it is no longer needed. No working-storage is Sort, so use the record :-)
In my example I forgot to do the chop-off.
One way is with "BUILD", so BUILD=(1,length-of-your-original) would do it, another way is IFOUTLEN=length-of-your-original, which just hangs around the IFTHENS and tells the sort what the output record length is.