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 

Include header only if there is a match

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


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Fri Sep 22, 2017 8:03 pm    Post subject: Include header only if there is a match Reply with quote

Hi All,

Thought I would never come back but here I am. Smile

Input: concatenated GDG base having around 20 generations each having one header and several hundred detailed records.

Output: If the string that I am searching for is found then the header and the detailed records should be be in the output. The header should be output if and only if there is a match found in that file.

Sample input:
Code:

GDG (0)
HEADER20170101
......ABC......
......123.......
......ABC.......
GDG (1)
HEADER20170208
......123......
......456......
GDG (2)
HEADER20170904
......ABC.......
......789.......


Search string "ABC"

Expected output:
Code:
HEADER20170101
......ABC......
......ABC.......
HEADER20170904
......ABC.......


or even better

Code:
20170101......ABC......
20170101......ABC......
20170904......ABC.......


There is no restriction on method. I can use either superc / ISRSUPC or DFSORT. I tried superc and ISRSUPC but didn't get the exact output I want consistently. Any help would be much appreciated.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Sep 22, 2017 11:26 pm    Post subject: Reply with quote

bade_miya,

Assuming your GDG generations LRECL=80 and RECFM=FB, then use the following DFSORT JCL. Untested code

Code:

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DISP=SHR,DSN=Your GDG base
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  OPTION COPY                                           
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'), 
          PUSH=(81:7,8))                                 
                                                         
  OUTFIL INCLUDE=(7,3,CH,EQ,C'ABC'),                     
  BUILD=(81,8,1,80)                                     
/*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Mon Sep 25, 2017 12:59 pm    Post subject: Reply with quote

Worked perfectly. Thanks Kolusu!!
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