Select records based on some condition

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
bath3fly
Member
Posts: 6
Joined: Fri Apr 17, 2009 5:43 pm
Location: Chennai

Select records based on some condition

Post by bath3fly » Mon Jun 29, 2009 5:12 pm

Hi,

Here is my requirement.

I'm having a file with 1000's of records.

If a value at particular position is matched then I wants to pick the successive 7 records from my input. Can any one suggest a way to achive it other than cobol. Thanks in advance.
Thanks,
Bathri

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon Jun 29, 2009 7:52 pm

You need to give more details of what you want to do.
If a value at particular position is matched
What is the starting position, length and format of the field to be matched. What is the value for the match?

What is the RECFM and LRECL of the input file?

Do you want just one group of 7 records or multiple groups of 7 records?

Do you want the matching record plus the next 7 records, or the matching record plus the next 6 records, or just the next 7 records without the matching record?

An example of the input records and expected output records would help.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

bath3fly
Member
Posts: 6
Joined: Fri Apr 17, 2009 5:43 pm
Location: Chennai

Post by bath3fly » Wed Jul 01, 2009 3:12 pm

Here is my answers to your clarifications:

The field starts at 21st position with length 8, alphanumeric
RECFM is FB and LRECL 80
I want multiple group of 7 records
I want the matching record plus the next 7 records

For example
I'm having the patient details in a file with MRN#(Length=8) at start position 21.

01 HENRY F FORD 98272323
03 XXXXXXXXXXXXXXX XXXXX XXXXXXXXXXX
03 XXXXXXXXXXXXXXX XXXXX XXXXXXXXXXX
03 XXXXXXXXXXXXXXX XXXXX XXXXXXXXXXX
03 XXXXXXXXXXXXXXX XXXXX XXXXXXXXXXX
03 XXXXXXXXXXXXXXX XXXXX XXXXXXXXXXX
03 XXXXXXXXXXXXXXX XXXXX XXXXXXXXXXX
03 XXXXXXXXXXXXXXX XXXXX XXXXXXXXXXX

So if this MRN value in '01' type of record is matched '98272323' then i have to fetch the 01 record and it successive seven '03' type records into my output.
Thanks,
Bathri

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed Jul 01, 2009 8:48 pm

Here's a DFSORT job that will do what you asked for:

Code: Select all

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,
    BEGIN=(1,2,CH,EQ,C'01',AND,21,8,CH,EQ,C'98272323'),
    RECORDS=8,PUSH=(81:ID=1))
  OUTFIL INCLUDE=(81,1,CH,NE,C' '),BUILD=(1,80)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

bath3fly
Member
Posts: 6
Joined: Fri Apr 17, 2009 5:43 pm
Location: Chennai

Post by bath3fly » Thu Jul 02, 2009 2:37 pm

Hi Frank,

I tried out your option getting syntax error. I'm using SYNCSORT FOR Z/OS 1.2.3.0
Thanks,
Bathri

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu Jul 02, 2009 7:51 pm

The job works fine with DFSORT. I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.

In the future, if you want a Syncsort solution, please state that in your initial post.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

User avatar
arcvns
Member
Posts: 28
Joined: Sat May 30, 2009 10:19 pm
Location: Chennai, India

Post by arcvns » Fri Jul 03, 2009 7:28 pm

Bathri,

The below SYNCTOOL job should work for your requirement.

Code: Select all

//STEP0100 EXEC PGM=SYNCTOOL                                        
//DFSMSG   DD SYSOUT=*                                              
//TOOLMSG  DD SYSOUT=*                                              
//IN       DD DSN= Input  file ---> FB/LRECL=80                     
//OUT      DD DSN= Output file ---> FB/LRECL=80                     
//TOOLIN   DD *                                                     
 SPLICE FROM(IN) TO(OUT)  ON(89,8,CH) WITH(1,96) WITHALL -          
        KEEPBASE KEEPNODUPS USING(CTL1)                             
//CTL1CNTL DD *                                                     
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),                 
       IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),                              
       OVERLAY=(89:SEQNUM,8,ZD),HIT=NEXT),                          
       IFTHEN=(WHEN=(21,8,CH,EQ,C'98272323'),                       
       OVERLAY=(97:C'Y'),HIT=NEXT),                                 
       IFTHEN=(WHEN=NONE,                                           
       OVERLAY=(89:SEQNUM,8,ZD,89:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
 OUTREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(89,8))                     
 OUTFIL FNAMES=OUT,BUILD=(1,80),                                    
        INCLUDE=(97,1,CH,EQ,C'Y',AND,81,8,ZD,LE,8)                  
Arun

Alissa Margulies
Member
Posts: 25
Joined: Tue Apr 28, 2009 10:53 pm
Location: USA
Contact:

Post by Alissa Margulies » Tue Jul 07, 2009 2:10 am

Bathri,

Support for WHEN=GROUP was included in SyncSort for z/OS 1.3.2. Since you are running an earlier release, I would recommend referring to the alternate solution posted by arcvns.
Alissa Margulies
SyncSort Mainframe Product Services
zos_tech@syncsort.com
201-930-8260

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others