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 

Copy set of records contain particular record.

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


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Tue Oct 06, 2009 1:29 pm    Post subject: Copy set of records contain particular record. Reply with quote

Hi,

I have a file (LRECL=1050, RECFM=FB) as shown below and want copy only those set (01 to 99) of records that contain "Invalid" starting at 16th position. The key starts at 10th position with length of 6 bytes.

Code:

----+----1----+----2----+----3----+----4
01PR8    MTX1R8SUPRAS                   
02PR8    MTX1R816CUBE  2009    000001898
06PR8    MTX1R82078000012008-02-18-21.16
10PR8    MTX1R8Indian Child star       
12PR8    MTX1R8Invalid Charge ON BUS BUG
99PR8    MTX1R8                         
011P1    MKX1P1VIEWTY                   
031P1    MKX1P116CxvE  2009    000001898
071P1    MKX1P12078000012008-02-18-21.16
111P1    MKX1P1Indian Ahald punt       
991P1    MKX1P1                         
01CUT    YMTXCUTCHARUS                   
02CUT    YMTXCUT16KIMS  2009    000001898
08CUT    YMTXCUT2078000012008-02-18-21.16
13CUT    YMTXCUTIndian Milkh aoly       
12CUT    YMTXCUTInvalid Charge ON FAT SIT
99CUT    YMTXCUT                         


Expected Output:

Code:

01PR8    MTX1R8SUPRAS                   
02PR8    MTX1R816CUBE  2009    000001898
06PR8    MTX1R82078000012008-02-18-21.16
10PR8    MTX1R8Indian Child star       
12PR8    MTX1R8Invalid Charge ON BUS BUG
99PR8    MTX1R8                         
01CUT    YMTXCUTCHARUS                   
02CUT    YMTXCUT16KIMS  2009    000001898
08CUT    YMTXCUT2078000012008-02-18-21.16
09CUT    YMTXCUTIndian Milkh aoly       
12CUT    YMTXCUTInvalid Charge ON FAT SIT
99CUT    YMTXCUT                         


Please help.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Oct 06, 2009 3:08 pm    Post subject: Reply with quote

mf_user,

The following DFSORT JCL will give you the desired results. Btw the string INVALID for the key YMTXCUT does not start in pos 16 , but I assumed it is a typo

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=Your input 1050 FB file,DISP=SHR
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//SYSIN    DD *                                             
  INCLUDE COND=(16,7,CH,EQ,C'INVALID')                     
  SORT FIELDS=COPY                                         
  OUTFIL REMOVECC,NODETAIL,                                 
  SECTIONS=(10,6,TRAILER3=(01:'00',10:10,6))               
//*                                                         
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=&&T1,DISP=SHR                             
//         DD DSN=Your input 1050 FB file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  SORT FIELDS=(10,6,CH,A),EQUALS                           
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'00'),       
  END=(1,2,CH,EQ,C'99'),PUSH=(1051:1,2))                   
  OUTFIL OMIT=(1051,2,CH,EQ,C' ',OR,1,2,CH,EQ,C'00')       
//* 

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


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Wed Oct 07, 2009 10:22 am    Post subject: Thanks Reply with quote

Kolusu, Thank you....Yes. It was a typo Wink
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Wed Oct 07, 2009 10:24 am    Post subject: Reply with quote

I wonder if it was achievable in single step with the latest SORT tools available bonk Rolling Eyes
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Oct 07, 2009 11:34 am    Post subject: Reply with quote

mf_user,

If you don't mind the Invalid record being the first record of the group , then it can be done in 1 pass .

Remember one pass of data is different from 1 step
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Mon Oct 12, 2009 6:44 am    Post subject: Reply with quote

Kolusu, Our program is designed to read the entries based on type of record (first two digits) in sorted order. So, invalid record (12) being the first record in output file would not work for us. But, I am interested to know the solution.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Oct 12, 2009 4:54 pm    Post subject: Reply with quote

mf_user,

Here is a 1 pass solution which keeps the order of records as is and give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=Your input 1050 FB file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=INIT,                                           
  OVERLAY=(1051:C'1',SEQNUM,8,ZD,RESTART=(10,6))),                   
  IFTHEN=(WHEN=(16,7,CH,EQ,C'INVALID'),OVERLAY=(1051:C'0'))           
                                                                     
  SORT FIELDS=(10,6,CH,A,1051,1,CH,A),EQUALS                         
                                                                     
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,1050,1052,8)),                   
  IFTHEN=(WHEN=INIT,OVERLAY=(1059:SEQNUM,8,ZD,RESTART=(10,6))),       
  IFTHEN=(WHEN=GROUP,BEGIN=(1059,8,ZD,EQ,1,AND,1,2,CH,NE,C'01'),     
  END=(1,2,CH,EQ,C'99'),PUSH=(1067:1051,8,1,1050)),                   
  IFTHEN=(WHEN=(1067,1,CH,GT,C' '),                                   
  OVERLAY=(1059:1067,8,ZD,SUB,1051,8,ZD,ZD,LENGTH=8))                 
                                                                     
  OUTFIL INCLUDE=(1067,1,CH,GT,C' '),IFOUTLEN=1050,                   
  IFTHEN=(WHEN=(1059,8,ZD,EQ,1),BUILD=(1,1050,/,1075,1050))           
//*

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


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Tue Oct 13, 2009 4:54 am    Post subject: Reply with quote

Wonderful......thanks a lot.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
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