IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Writing next records after a match and repeat


IBM Mainframe Forums -> Compuware & Other Tools
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kris_madras

New User


Joined: 04 Jul 2005
Posts: 37

PostPosted: Wed Mar 12, 2025 8:40 pm
Reply with quote

Need help on the logic. I have a file-aid code like this

Code:
//S010    EXEC PGM=FILEAID                     
//DD01     DD DSN=TEST.INPUTFL,               
//            DISP=SHR                         
//SYSOUT   DD SYSOUT=*                         
//SYSUDUMP DD SYSOUT=*                         
//SYSPRINT DD SYSOUT=*                         
//SYSLIST  DD SYSOUT=*                         
//SYSTOTAL DD SYSOUT=*                         
//DD01O    DD SYSOUT=*                         
//SYSIN    DD *                               
$$DD01 SPACE STOP=(1,0,C'XYZ')                 
$$DD01 LIST  IN=6                             
/*                                             


My input file is like this.

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
XYZ
1111111
2222222
3333333
4444444
5555555
6666666
7777777
XYZ
1111111
2222222
XYZ
3333333


(1) The above file-aid code is printing the next 6 records as soon as it hits XYZ but only one time. Rest all 'XYZ' and next records are not processed.
But I wanted to repeat the search for 'N' number of times.

(2) The output is showing in SYSLIST. Can we write to the output file name pointed in $DD01O? The SYSLIST is showing FILE-AID version and other messages.

Thanks,
Krish
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1379
Location: Bamberg, Germany

PostPosted: Thu Mar 13, 2025 1:16 am
Reply with quote

While it might be interesting to see your final solution on this, however it's much quicker to do this simple task with a SORT product of your choice.
Back to top
View user's profile Send private message
kris_madras

New User


Joined: 04 Jul 2005
Posts: 37

PostPosted: Thu Mar 13, 2025 7:00 am
Reply with quote

Hi,

I am interested to know SORT solution. But I don't want to read entire input file in sort. As soon as 'XYZ' and group records under XYZ are read 'n' number of times, I want to stop the process.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1379
Location: Bamberg, Germany

PostPosted: Thu Mar 13, 2025 9:37 am
Reply with quote

Sample for a SORT
Code:
OPTION COPY                                               
INREC IFTHEN=(WHEN=GROUP,                                 
  BEGIN=(1,3,CH,EQ,C'XYZ'),PUSH=(20:ID=4,SEQ=1),RECORDS=7)
OUTFIL FNAMES=(SORTOUT),                                 
  INCLUDE=(20,4,ZD,LE,+2,AND,24,1,ZD,EQ,NUM),             
  REMOVECC,BUILD=(1,10)                                   
END

This will only print the first 'N'=2 groups up to a max of 6 records each.
Back to top
View user's profile Send private message
kris_madras

New User


Joined: 04 Jul 2005
Posts: 37

PostPosted: Thu Mar 13, 2025 2:44 pm
Reply with quote

Thank You.

But the problem is the SORT processes file from first record to end of the file and for matching XYZ, pads ID and SEQ. And then OUTFIL INCLUDE filters the records, write to the output file.
Any feature available in SYNCSORT to stop reading records as soon as it hits first 'N=2' groups?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1379
Location: Bamberg, Germany

PostPosted: Thu Mar 13, 2025 2:53 pm
Reply with quote

Of course you will have to put ID and SEQ at positions where they don't disturb. The padding, if any, is irrelevant for the problem.

For the 'N' you will have the same problem in FILEAID with putting in a stop as you will have with SORT, but a bit more worse.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Compuware & Other Tools

 


Similar Topics
Topic Forum Replies
No new posts 3 File Match Method - Useful across a... COBOL Programming 2
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
No new posts Repeat n times by substuting SEQNUM i... DFSORT/ICETOOL 2
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
Search our Forums:

Back to Top