Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Selection of BLOCKS OF RECORDS into 2 different Output Files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Subhasish Sarkar

New User


Joined: 21 Oct 2011
Posts: 16
Location: India

PostPosted: Sun Oct 30, 2011 9:44 pm    Post subject: Selection of BLOCKS OF RECORDS into 2 different Output Files
Reply with quote

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
View user's profile Send private message

gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Mon Oct 31, 2011 5:04 am    Post subject:
Reply with quote

Hi,

can you please explain numerous, more than 1 more than 2 ?


Gerry
Back to top
View user's profile Send private message
Subhasish Sarkar

New User


Joined: 21 Oct 2011
Posts: 16
Location: India

PostPosted: Mon Oct 31, 2011 9:12 am    Post subject: Reply to: Selection of BLOCKS OF RECORDS into 2 different Ou
Reply with quote

Hi Gerry,

Let's take more than 5.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Mon Oct 31, 2011 12:47 pm    Post subject: Reply to: Selection of BLOCKS OF RECORDS into 2 different Ou
Reply with quote

Is the ")" valid anywhere in your record?
Back to top
View user's profile Send private message
Subhasish Sarkar

New User


Joined: 21 Oct 2011
Posts: 16
Location: India

PostPosted: Mon Oct 31, 2011 1:01 pm    Post subject: Reply to: Selection of BLOCKS OF RECORDS into 2 different Ou
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Mon Oct 31, 2011 1:15 pm    Post subject:
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Tue Nov 01, 2011 3:15 am    Post subject:
Reply with quote

Hi,

by the way, less than 5 and more than 5 leaves 5 out in the lurch.


Gerry
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Tue Nov 01, 2011 4:51 am    Post subject: Reply to: Selection of BLOCKS OF RECORDS into 2 different Ou
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Tue Nov 01, 2011 5:23 am    Post subject:
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Tue Nov 01, 2011 7:03 am    Post subject:
Reply with quote

Hi,

as pointed out to me by Bill, the number is for a "particular block" and not for a record icon_redface.gif

So the solution provided by me will not work.


Gerry
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Nov 01, 2011 11:38 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Subhasish Sarkar

New User


Joined: 21 Oct 2011
Posts: 16
Location: India

PostPosted: Wed Nov 02, 2011 10:51 pm    Post subject: Reply to: Selection of BLOCKS OF RECORDS into 2 different Ou
Reply with quote

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!!!! icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us