How to select one group of records



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

How to select one group of records

Postby Irene Ioujanina » Fri Jul 10, 2009 12:23 am

Good afternoon, all. Good afternoon, Frank
Long time no see:) I hope you all are well.

May I please ask again.
I have a file with group of records, each group has a header and the trailer. I need to extract one group.
For instance:

001HEADER
111 DATA 1
222 DATA 2
Trailer
002HEADER
333 DATA 3
111 DATA 1
Trailer
005HEADER
555 DATA 5
Trailer

After I run the SORT -> I need to have the file with the followng data ( extract the group with the header value '002':
002HEADER
333 DATA 3
111 DATA 1
Trailer
( it means based on the header value '002' I extracted the header, all the item records in the same order and the trailer).

Thanking so much in advance,
Irene.
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to select one group of records

Postby Frank Yaeger » Fri Jul 10, 2009 1:18 am

Irene,

You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
001HEADER
111 DATA 1
222 DATA 2
Trailer
002HEADER
333 DATA 3
111 DATA 1
Trailer
005HEADER
555 DATA 5
Trailer
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'002H'),
    END=(1,7,CH,EQ,C'Trailer'),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
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: How to select one group of records

Postby Irene Ioujanina » Fri Jul 10, 2009 1:44 am

Thank you so much :)
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post