MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extract group records based on matching file names

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
nbdtrjk_1
Beginner


Joined: 14 Jun 2021
Posts: 16
Topics: 6

PostPosted: Wed Oct 08, 2025 7:43 am    Post subject: Extract group records based on matching file names Reply with quote

I have a requirement to extract group of records when given file name is matched from each group. Every group consists of 4 records, and if a file name matches either FILE1 or FILE2, or FILE4 then I want to write out those group's records to an Output file.

FB 80 bytes
I/P
Code:
22:19:38 SVTM052I COPY08   COPY
22:19:38 SVTM052I      FROM ABC.XYZ.FILE1 
22:19:38 SVTM052I      TO   C:\user\xyz
22:19:38 SVTM052I          COMPLETED  00000000/SCPA000I
22:19:38 SVTM052I COPY09   COPY
22:19:38 SVTM052I      FROM ABC.XYZ.FILE2
22:19:38 SVTM052I      TO   C:\user\xyz
22:19:38 SVTM052I          COMPLETED  00000000/SCPA000I
22:19:40 SVTM052I COPY13   COPY
22:19:40 SVTM052I      FROM ABC.XYZ.FILE3
22:19:40 SVTM052I      TO   C:\user\xyz
22:19:40 SVTM052I          COMPLETED  00000000/SCPA000I
21:41:18 SVTM052I COPY01   COPY
21:41:18 SVTM052I      FROM ABC.XYZ.FILE4
21:41:18 SVTM052I      TO   C:\user\xyz
21:41:18 SVTM052I          COMPLETED  00000000/SCPA000I


O/P
Code:
22:19:38 SVTM052I COPY08   COPY
22:19:38 SVTM052I      FROM ABC.XYZ.FILE1 
22:19:38 SVTM052I      TO   C:\user\xyz
22:19:38 SVTM052I          COMPLETED  00000000/SCPA000I
22:19:38 SVTM052I COPY09   COPY
22:19:38 SVTM052I      FROM ABC.XYZ.FILE2
22:19:38 SVTM052I      TO   C:\user\xyz
22:19:38 SVTM052I          COMPLETED  00000000/SCPA000I
21:41:18 SVTM052I COPY01   COPY
21:41:18 SVTM052I      FROM ABC.XYZ.FILE4
21:41:18 SVTM052I      TO   C:\user\xyz
21:41:18 SVTM052I          COMPLETED  00000000/SCPA000I
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12385
Topics: 75
Location: San Jose

PostPosted: Thu Oct 09, 2025 9:17 pm    Post subject: Re: Extract group records based on matching file names Reply with quote

nbdtrjk_1 wrote:
Every group consists of 4 records, and if a file name matches either FILE1 or FILE2, or FILE4 then I want to write out those group's records to an Output file.


nbdtrjk_1,

Can the file1 , file 2 or file4 names appear anywhere in the file name?

ex:
Code:

abc.file1.def.file3
def.file3.ijk.file4


If you are only looking the LAST qualifier as FILE1, FILE2 or FILE4 then the following untested DFSORT control cards will give you the desired results.

Code:
//SYSIN    DD *                                   
  OPTION COPY                                     
  INREC IFTHEN=(WHEN=GROUP,                       
               BEGIN=(019,04,CH,GT,C' '),         
                PUSH=(081:ID=8,                   
                      091:01,80)),                 
        IFTHEN=(WHEN=(019,61,SS,EQ,C' FROM '),     
               PARSE=(%=(ABSPOS=29,               
                          ENDAT=C' '),             
                     %1=(SUBPOS=9,                 
                         FIXLEN=09)),             
             OVERLAY=(171:%1),HIT=NEXT),           
        IFTHEN=(WHEN=(019,61,SS,EQ,C' FROM '),     
               PARSE=(%2=(ABSPOS=171,             
                        STARTAFT=C'.',             
                          FIXLEN=08)),             
             OVERLAY=(181:%2))                     
                                                   
  OUTREC IFTHEN=(WHEN=GROUP,                       
                BEGIN=(181,8,CH,GT,C' '),         
                 PUSH=(181:181,08),RECORDS=3)     
                                                   
  OUTFIL REMOVECC,BUILD=(01,80),                   
  INCLUDE=(181,08,CH,EQ,C'FILE1',OR,               
           181,08,CH,EQ,C'FILE2',OR,               
           181,08,CH,EQ,C'FILE4'),                 
  SECTIONS=(81,8,                                 
   HEADER3=(91,80))                               
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nbdtrjk_1
Beginner


Joined: 14 Jun 2021
Posts: 16
Topics: 6

PostPosted: Fri Oct 10, 2025 12:50 am    Post subject: Reply with quote

Perfect. Thanks allot. working as expected.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group