MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
sneha_mf Beginner Joined: 24 Oct 2005 Posts: 4 Topics: 4
Posted: Mon Jan 23, 2006 7:14 am Post subject: Interview question on SORT
Hi,
can you please send me the answers for these questions.
1)In a single input file we have data for 2002, 2003 and 2004 model years, how to make three separate files, having 2002, 2003 and 2004 data.
2)If the columns in the input are like NAME, FATHER NAME, ADDRESS. How can we create a output file in the format FATHER NAME, NAME , ADDRESS
3)How to create a fixed block file when the input is variable block?
4)How to avoid duplicates to the output using sort.
5)How to copy only duplicates to the output?
6)If s9(13) comp-3 field starting in 1st position, how to write the include condition
7)How to copy the records matching specific selection criteria?
8)If an input file have 30 records, how to make three output files each having 10 records.
Thanks,
Sneha.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Jan 23, 2006 8:25 am Post subject:
Quote:
1)In a single input file we have data for 2002, 2003 and 2004 model years, how to make three separate files, having 2002, 2003 and 2004 data.
Answer : Use INCLUDE cond on OUTFIL
ex:
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
2002 RECORD - 01
2002 RECORD - 02
2003 RECORD - 01
2004 RECORD - 01
2005 RECORD - 01
//D2002 DD SYSOUT=*
//D2003 DD SYSOUT=*
//D2004 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=D2002,INCLUDE=(1,4,CH,EQ,C'2002')
OUTFIL FNAMES=D2003,INCLUDE=(1,4,CH,EQ,C'2003')
OUTFIL FNAMES=D2004,INCLUDE=(1,4,CH,EQ,C'2004')
/*
Quote:
2)If the columns in the input are like NAME, FATHER NAME, ADDRESS. How can we create a output file in the format FATHER NAME, NAME , ADDRESS
Answer : Use OUTREC FIELDS to interchange the columns
ex:
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAAAAAAA BBBBBBBBBBB CCCCCCCCCCCC
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(15,15, $ FATHER NAME
01,15, $ NAME
30,15) $ ADDRESS
/*
Quote:
3)How to create a fixed block file when the input is variable block?
Use VTOF or CONVERT
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=YOUR VB FILE,
// DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL VTOF,OUTREC=(5,N) $ N = lrecl of your fb file
/*
Quote:
4)How to avoid duplicates to the output using sort.
Answer: Use SUM FILEDS=NONE
ex:
Code:
//STEP0400 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABC
ABC
ABC
DEF
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=NONE
/*
Quote:
5)How to copy only duplicates to the output?
Use ALLDUPS parm on the SELECT operator
ex:
Code:
//STEP0500 EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//IN DD *
ABC
ABC
ABC
DEF
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,3,CH) ALLDUPS
/*
Quote:
6)If s9(13) comp-3 field starting in 1st position, how to write the include condition
Answer : S9(13) comp-3 occupies 7 bytes of storage. so your Include condition should
Code:
INCLUDE COND=(1,7,PD,EQ,N) $ N = ANY NUMERIC NUMBER)
Quote:
7)How to copy the records matching specific selection criteria?
Answer : Use INCLUDE COND . refer question 1 and question 6 for examples.
Quote:
8)If an input file have 30 records, how to make three output files each having 10 records.
Answer : Check this topic of splitting records
http://mvsforums.com/helpboards/viewtopic.php?t=12&highlight=split
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
Frank Yaeger Sort Forum Moderator Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Jan 23, 2006 11:44 am Post subject:
Sneha,
Rather than just having somebody answer these interview or test questions for you (since the next test or interview might have different questions), I'd suggest you actually learn how to use the various DFSORT control statements yourself. A good way to start doing that is to read through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
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