|
View previous topic :: View next topic
|
| Author |
Message |
Subhasish Sarkar
New User
Joined: 21 Oct 2011 Posts: 16 Location: India
|
|
|
|
Hi All,
My Input File is something lke this.
| Code: |
AAP11003029M-MPRMAS616WMKKZSPD2
8368 0727364729211---+++7290
351294236436500)011320780001000
271473034529292918861 121 32250
22///11 111716960264 3194525 52
27515 59471410040104 114229 108
7 404791285 887 945 7003 624147
109 52 839 490 31000044///
71473835094287618762 323 125504
2///11 111716960264 3194532 464
1
AAP11003029M-MPSMAS610WMKKVHHH2
8051 545729220727485---+++7290
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
0
AAP11003029M-MPSMAS610VHHHWMKK22
8055 549729220727485---+++72906
))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))
11481 56641390030004 314250 110
0 34461)))))))))))))))))))))))))
))))))))))))))))))))))))))))))))
51453133719282918520 256 112475
2///11 161016630257 2544497 4850
1 |
Each BLOCK OF RECORD starts with AAP and then followed by 10 records. That is, each BLOCK OF RECORD consists of 11 records.
Also, if you notice the 2nd and 3rd BLOCK OF RECORD, you would see numerous ')'. I am referring to these as BLOCKS OF RECORDS WITH INVALID DATA, whereas, the 1st BLOCK OF RECORD could be referred to as a BLOCK OF RECORD WITH VALID DATA.
My requirement is to: -
(1) Write out a BLOCK OF RECORD WITH VALID DATA to an Output File, say A.
NOTE: - The entire BLOCK OF RECORD WITH VALID DATA (starting with AAP and then followed by 10 records, that is, a total of 11 records constituting the entire block) needs to be written to the Output File A.
(2) Write out a BLOCK OF RECORD WITH INVALID DATA to another Output File, say B.
NOTE: - The entire BLOCK OF RECORD WITH INVALID DATA (starting with AAP and then followed by 10 records, that is, a total of 11 records constituting the entire block) needs to be written to the Output File B.
(3) In short, the Output File A should only have BLOCKS OF RECORDS WITH VALID DATA, whereas the Output File B should only have BLOCKS OF RECORDS WITH INVALID DATA.
POINTS TO REMEMBER ABOUT a BLOCK OF RECORD WITH INVALID DATA: -
1. A BLOCK OF RECORD WITH INVALID DATA contains numerous ')'.
2. The ')' need not always be continuous, as in the 3rd Block.
3. The ')' might also be continuous, as in the 2nd Block.
SOME OTHER POINTS TO REMEMBER: -
1. Input File has LRECL=80 and RECFM=FB.
2. There is no SPACE in between the BLOCKS OF RECORDS in the Input File. For the above-mentioned 3 BLOCKS OF RECORDS, I have deliberately inserted a SPACE in between each BLOCK OF RECORD for clarity of understanding.
3. I would need to use DFSORT.
How could this be acheived using DFSORT? |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
can you please explain numerous, more than 1 more than 2 ?
Gerry |
|
| Back to top |
|
 |
Subhasish Sarkar
New User
Joined: 21 Oct 2011 Posts: 16 Location: India
|
|
|
|
Hi Gerry,
Let's take more than 5. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Is the ")" valid anywhere in your record? |
|
| Back to top |
|
 |
Subhasish Sarkar
New User
Joined: 21 Oct 2011 Posts: 16 Location: India
|
|
|
|
Hi Bill,
Yes, the ")" is valid anywhere in any BLOCK OF RECORD. But, if the count of ")" is more than 5 in number in a paqrticular BLOCK OF RECORD, then that particular BLOCK OF RECORD is treated as a BLOCK OF RECORD WITH INVALID DATA and needs to be written to the Output File B.
On the other hand, if the count of ")" is less than 5 in number in a paqrticular BLOCK OF RECORD, then that particular BLOCK OF RECORD is treated as a BLOCK OF RECORD WITH VALID DATA and needs to be written to the Output File A. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
try this, WHEN=GROUP is untested as my level of DFSORT does not support it
| Code: |
//STEP0010 EXEC PGM=SORT
//SORTIN DD *
AAP11003029M-MPRMAS616WMKKZSPD2
8368 0727364729211---+++7290
351294236436500)011320780001000
271473034529292918861 121 32250
22///11 111716960264 3194525 52
27515 59471410040104 114229 108
7 404791285 887 945 7003 624147
109 52 839 490 31000044///
71473835094287618762 323 125504
2///11 111716960264 3194532 464
1
AAP11003029M-MPSMAS610WMKKVHHH2
8051 545729220727485---+++7290
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
0
AAP11003029M-MPSMAS610VHHHWMKK
8055 549729220727485---+++72906
))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))
11481 56641390030004 314250 110
0 34461)))))))))))))))))))))))))
))))))))))))))))))))))))))))))))
51453133719282918520 256 112475
2///11 161016630257 2544497 4850
1
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=&&OUT1,
// DISP=(,PASS,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(20,10),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
INREC PARSE=(%=(STARTAT=C')'),
%=(STARTAT=C')'),
%=(STARTAT=C')'),
%=(STARTAT=C')'),
%=(STARTAT=C')'),
%1=(STARTAT=C')',FIXLEN=1)),
OVERLAY=(81:SEQNUM,8,ZD,89:%1)
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'AAP'),PUSH=(90:ID=8))
/*
//STEP0020 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&OUT1,
// DISP=SHR
//SORTOUT DD DSN=&&OUT2,
// DISP=(,PASS,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(20,10),RLSE)
//SYSIN DD *
SORT FIELDS=(90,8,BI,A,89,1,BI,D)
OUTREC OVERLAY=(98:SEQNUM,8,ZD,RESTART=(90,8))
/*
//STEP0030 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&OUT2,
// DISP=SHR
//INVALID DD SYSOUT=*
//VALID DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(81,8,BI,A)
INREC IFTHEN=(WHEN=GROUP,BEGIN=(98,8,CH,EQ,C'00000001'),
PUSH=(89:89,1))
OUTFIL FNAMES=INVALID,INCLUDE=(89,1,CH,EQ,C')'),BUILD=(1,80)
OUTFIL FNAMES=VALID,SAVE,BUILD=(1,80)
/*
|
Gerry |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
by the way, less than 5 and more than 5 leaves 5 out in the lurch.
Gerry |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| It's a neat idea, Gerry. To extend it to ?5 per group/"block", can the records be stuck together nose-to-tail and apply the same technique? |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Bill,
yes, for nose to nose you can use this, for 6 consecutive positions
| Code: |
SORT FIELDS=COPY
INREC PARSE=(%1=(STARTAT=C'))))))',FIXLEN=1)),
OVERLAY=(81:SEQNUM,8,ZD,89:%1)
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'AAP'),PUSH=(90:ID=8))
|
Gerry |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
as pointed out to me by Bill, the number is for a "particular block" and not for a record
So the solution provided by me will not work.
Gerry |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Subhasish Sarkar,
See if below works...
I am sure there probably is a better solution but I can't think of a way to do it in a single pass. Trick here is to use JOINKEYs to SORT the same file twice in the same step. Keep in mind, INB needs to have 1 records with SPACES. For testing, I kept INB as 80 byte but that doesn't have to be 80 byte long.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD YOUR INPUT FB/80
//INB DD DUMMY FILE FB/80 WITH 1 RECORD HAVING SPACES
//VALID DD SYSOUT=*
//INVALID DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=INA,FIELDS=(90,8,A,81,1,D)
JOINKEYS F2=INB,FIELDS=(90,8,A,81,1,D),SORTED,NOSEQCK
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,97)
INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(90,8),PUSH=(81:81,1))
SORT FIELDS=(82,8,ZD,A)
OUTFIL FNAMES=INVALID,INCLUDE=(81,1,CH,EQ,C')'),BUILD=(1,80)
OUTFIL FNAMES=VALID,SAVE,BUILD=(1,80)
//*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,PARSE=(%=(STARTAT=C')'),
%=(STARTAT=C')'),
%=(STARTAT=C')'),
%=(STARTAT=C')'),
%=(STARTAT=C')'),
%1=(STARTAT=C')',FIXLEN=1)),
BUILD=(1,80,%1)),
IFTHEN=(WHEN=INIT,OVERLAY=(82:SEQNUM,8,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'AAP'),PUSH=(90:ID=8))
//*
//JNF2CNTL DD *
INREC OVERLAY=(81:C'*',82:16C'9')
//* |
VALID
| Code: |
AAP11003029M-MPRMAS616WMKKZSPD2
8368 0727364729211---+++7290
351294236436500)011320780001000
271473034529292918861 121 32250
22///11 111716960264 3194525 52
27515 59471410040104 114229 108
7 404791285 887 945 7003 624147
109 52 839 490 31000044///
71473835094287618762 323 125504
2///11 111716960264 3194532 464
1 |
INVALID
| Code: |
AAP11003029M-MPSMAS610WMKKVHHH2
8051 545729220727485---+++7290
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))
0
AAP11003029M-MPSMAS610VHHHWMKK22
8055 549729220727485---+++72906
))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))
11481 56641390030004 314250 110
0 34461)))))))))))))))))))))))))
))))))))))))))))))))))))))))))))
51453133719282918520 256 112475
2///11 161016630257 2544497 4850
1 |
Thanks, |
|
| Back to top |
|
 |
Subhasish Sarkar
New User
Joined: 21 Oct 2011 Posts: 16 Location: India
|
|
|
|
Thanks a ton, sqlcode1. Your code is working perfectly fine for me. It was really a great learning experience for me - your DFSORT code.
Thanks again a lot!!!!  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|