View previous topic :: View next topic
Author
Message
Santty New User Joined: 20 Nov 2007Posts: 37 Location: USA
Is it possible to Retrive Some segments from a File and to sort a particlar segment?
Code:
Parent1
Child1
Child1
Child1
Child2
Child3
Child2
Child3
Child2
Child4
Child5
Parent2
Child1
Child1
Child1
Child2
Child3
Child2
Child3
Child2
Child5
.
.
.
Output
Parent1
Child1
Child1
Child1
Child2
Child2
Child2
Parent2
Child1
Child1
Child1
Child2
Child2
Child2
Note:Child2 must be in accending order
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
I can get the output you say you want with a DFSORT job that does a simple COPY and INCLUDE like this:
Code:
OPTION COPY
INCLUDE COND=(1,6,SS,EQ,C'Parent,Child1,Child2')
I suspect what you really want to do is more complicated than that and that you can do what you want using the techniques discussed in the "Sort groups of records" and "Include or omit groups of records" Smart DFSORT Tricks at:
Use [URL] BBCode for External Links
If you need more specific help, show an example of your input records and expected output records with actual values that show what you want to do more clearly. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of all relevant fields.
Back to top
Santty New User Joined: 20 Nov 2007Posts: 37 Location: USA
Great Frank
Quote:
But is it possible that a particular segment (Child 2) can be obtained in ascending order
Quote:
Let me Give a sample
Code:
P1 50[Parent1]
C1 20[Child1]
C1 30[Child1]
C1 40[Child1]
C2 60[Child2]
C3 10[Child3]
C2 20[Child2]
C3 90[Child3]
C2 40[Child2]
C4 10[Child4]
C5 10[Child5]
P2 60[Parent1]
C1 10[Child1]
C1 50[Child1]
C1 70[Child1]
C2 90[Child2]
C3 20[Child3]
C2 80[Child2]
C3 30[Child3]
C2 70[Child2]
C4 40[Child4]
C5 50[Child5]
Output
P1 50[Parent1]
C1 20[Child1]
C1 30[Child1]
C1 40[Child1]
C2 20[Child2]
C2 40[Child2]
C2 60[Child2]
P2 60[Parent1]
C1 10[Child1]
C1 50[Child1]
C1 70[Child1]
C2 70[Child2]
C2 80[Child2]
C2 90[Child2]
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
You still haven't given me all the information I need.
What is the RECFM and LRECL of the input file?
Do you want just the Px, C1 and C2 records?
Do you want the C2 records sorted by the second field?
Do you want the C1 fields sorted by the second field, or left in their original order (I can't tell from your example since the C1 records are already in order by the second field)?
Back to top
Santty New User Joined: 20 Nov 2007Posts: 37 Location: USA
Sry Frank ,I was in a hry
Quote:
Let me give you a clear picture
1.RECFM=FB LRECL = 80
2.Yes i need Px,C1,C2 records alone.
3.I need C2 records to be sorted by the second field
4.Regarding C1 ,we dont have to consider about it we just have to get the records which is there in the input (Mostly it 'l be sorted ).
5.Let me give you more app. example
Quote:
Length of the Px second field is 5
Length of the C1 second field is 10
Length of the C2 second field is 11
Code:
P1 1P101
C1 2C10000001
C1 2C10000002
C1 2C10000003
C2 3C200000007
C3 4C300000000
C2 3C200000006
C3 4C300000000
C2 3C200000001
P2 1P201
C1 2C10000004
C1 2C10000005
C1 2C10000006
C2 3C200000050
C3 4C300000000
C2 3C200000040
C3 4C300000000
C2 3C200000030
OUTPUT
P1 1P101
C1 2C10000001
C1 2C10000002
C1 2C10000003
C2 3C200000001
C2 3C200000006
C2 3C200000007
P2 1P201
C1 2C10000004
C1 2C10000005
C1 2C10000006
C2 3C200000030
C2 3C200000040
C2 3C200000050
I need Px and C1 as of it is in the intput and C2 second field must be sorted and the other segments must be filtered as mentioned above.
I think you got me now right?
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Here's a DFSORT/ICETOOL job that will do what you asked for:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DD DSN=... output file (FB/80)
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,1,CH,EQ,C'P',OR,1,2,SS,EQ,C'C1,C2')
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:11X'00',92:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,1,CH,EQ,C'P'),
OVERLAY=(92:SEQNUM,8,ZD)),
IFTHEN=(WHEN=NONE,
OVERLAY=(100:SEQNUM,8,ZD,
92:92,8,ZD,SUB,100,8,ZD,TO=ZD,LENGTH=8))
OUTREC IFTHEN=(WHEN=(1,2,CH,EQ,C'C2'),OVERLAY=(81:5,11))
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(92,8,ZD,A,81,11,CH,A)
OUTREC BUILD=(1,80)
/*
Back to top
Santty New User Joined: 20 Nov 2007Posts: 37 Location: USA
Thanx Frank, I got the desired output
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Here's an easier way to do this with DFSORT's new WHEN=GROUP function available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008):
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//IN DD DSN=... input file (FB/80)
//OUT DD DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION EQUALS
INCLUDE COND=(1,1,CH,EQ,C'P',OR,1,2,SS,EQ,C'C1,C2')
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:11X'00')),
IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'P'),PUSH=(92:ID=8)),
IFTHEN=(WHEN=(1,2,CH,EQ,C'C2'),OVERLAY=(81:5,11))
SORT FIELDS=(92,8,ZD,A,81,11,CH,A)
/*
For complete details on the new WHEN=GROUP function and the other new functions available with PTF UK90013, see:
Use [URL] BBCode for External Links
Back to top
Please enable JavaScript!