Need help - SORT



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

Need help - SORT

Postby tonu1986 » Fri Aug 07, 2009 12:46 pm

I have an input flat file which has "CODENO" in column 1 to6 and in the next line a corresponding "LEVEL" in column 1 to 5.

Sample entries in PS file is like:

CODENO 1234567
LEVEL A
CODENO 2345906
LEVEL B
CODENO 0987567
LEVEL A

I need to fetch all those "CODENO" for which LEVEL should be "A" in the next line. Is this possible through SORT?
Here the two fields which are to be checked dont exist in the same line.
Please suggest?
tonu1986
 
Posts: 3
Joined: Tue Aug 04, 2009 1:22 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need help - SORT

Postby Bill Dennis » Fri Aug 07, 2009 7:22 pm

If there are always 2 records AND the records are a fixed length (ex. 80 bytes), you could read the file into a sort and specify LRECL=160 on SORTIN. Now the second record is in positions 81 -160 for comparing.
Regards,

Bill Dennis

Disclaimer: My comments on this forum are my own and do not represent the opinions or suggestions of any other person or business entity.
Bill Dennis
 
Posts: 278
Joined: Thu May 15, 2008 9:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need help - SORT

Postby Frank Yaeger » Fri Aug 07, 2009 8:31 pm

tonu1986,

You can use a DFSORT job like the following to do what you asked for:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
CODENO 1234567
LEVEL    A
CODENO 2345906
LEVEL    B
CODENO 0987567
LEVEL    A
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(15:1,14))
  OUTFIL INCLUDE=(10,1,CH,EQ,C'A'),BUILD=(15,14)
/*
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


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post