Select records based on some condition
Moderators: Frank Yaeger, Moderator Group
Select records based on some condition
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.
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
Bathri
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
You need to give more details of what you want to do.
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.
What is the starting position, length and format of the field to be matched. What is the value for the match?If a value at particular position is matched
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
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.
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
Bathri
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
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.
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Bathri,
The below SYNCTOOL job should work for your requirement.
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
-
- Member
- Posts: 25
- Joined: Tue Apr 28, 2009 10:53 pm
- Location: USA
- Contact:
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page