Name field is from position 1 - 10
Subject1 from 1 - 10
Subject2 from 15-25
Subject3 from 30-40
Remarks from 50-80(but the data under Remarks doesnt start always from 50 , it keps varying anywhere from 50-80)
Other activities from 1 - 10
Optional subject from 1-20
The i/p file based on the above layout is given below :
Name : Anu
Subject1 Subject2 Subject3
Eng maths physics
Remarks
Good
Name : Anu
Other activities
Painting
Name : Asha
Subject1 Subject2 Subject3
hist science geography
Remarks
Excellent
Name : Asha
Other Activities
Singing
Name : Asha
Optional subject
French
The data under Remarks varies anywhere from 50th col to 80th col(i.e.it's position is not fixed).
Now my requirement is to get the first Name(as Name appears at least twice for each student) and it's corresponding Remarks field. Here the i/p file shows details of two students Anu and Asha. Lets say they are the details of 2 students . For each student , the Name field appears at least twice. (Say for Anu - The second Name field indicates that it's a continuation,similar is the case with the second student i.e Asha where the Name field appears 3 times showing that details of student Asha is continued) . But as per my requirement i need only the first Name for each student and the Remarks field(that comes in 5th line only from the 1st Name field for each student and note that there's no Remarks field for the continued Name fields until a fresh student detail appears) that is present only for the first Name field of each student.
So my o/p should be
Anu - Good
Asha - Excellent
Is this possible through DFSORT ? If so please explain.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Some questions:
Do the groups for the same name always appear consecutively?
You say that the name appears at least twice for each student. Can the name appear more than twice for a student?
You say the remarks value record is the 5th record of the group. Is the "Remarks" record always the 4th record of the group? Does "Remarks" in the 4th record of the group always start in position 50 or can it start anywhere in 50-80?
Is the remarks value limited to a certain set of words (e.g. Good, Excellent, etc) or can it be anything? If it's a certain set of words, what are all of the possible values?
Please find my answers for your questions in blue.
Do the groups for the same name always appear consecutively?
I think you are asking if the data for a student will appear randomly anywhere in the file or will all the information for a student be grouped together.If you meant the same then , yes for the same name the groups will appear consecutively.
You say that the name appears at least twice for each student. Can the name appear more than twice for a student?
Yes it can appear more than twice as shown in the e.g for student Asha.
You say the remarks value record is the 5th record of the group. Is the "Remarks" record always the 4th record of the group -
Yes "Remarks" record if present is the 4th record of the group . For some student this "Remarks" will not appear,in such cases i don't want those student details in my output.
Does "Remarks" in the 4th record of the group always start in position 50 or can it start anywhere in 50-80?
Remarks in 4th record will start from 50 but the value under Remarks can start anywhere between 50-80.
Is the remarks value limited to a certain set of words (e.g. Good, Excellent, etc) or can it be anything? If it's a certain set of words, what are all of the possible values?
No it's not only a set of words but also has sentences like ' You should improve' , 'The performance is fair' etc.
The solution you have provided has worked . Could you please explain the syntax
INCLUDE=(89,8,ZD,EQ,+1,OR,89,8,ZD,EQ,+4,OR,89,8,ZD,EQ,+5) .
Also for e.g say if for student Asha i have 2 data under remarks (i.e 'You should improve' and 'God work' ) both are present and i want both in the o/p then how do i get that ?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
The solution you have provided has worked . Could you please explain the syntax
INCLUDE=(89,8,ZD,EQ,+1,OR,89,8,ZD,EQ,+4,OR,89,8,ZD,EQ,+5) .
Code:
OUTREC OVERLAY=(89:SEQNUM,8,ZD,RESTART=(81,8))
This gives a sequence number, starting with +1, to each record in a group. So the Name record in each group is +1, the 'Remarks' record in each group is +4 and the remarks value record in each group is +5. The INCLUDE statement uses +1, +4 and +5 to include only those three records from each group.
Quote:
Also for e.g say if for student Asha i have 2 data under remarks (i.e 'You should improve' and 'Good work' ) both are present and i want both in the o/p then how do i get that ?
You mean you have two remark value records? For example:
Code:
Remarks
You should improve
Good work
Is it always two, or is it one or two, or is it one to n (what is n), or what? Please describe this part of the requirement completely.
Thanks for the explanation. That was really helpful. For each student the value under Remarks varies. Say for some it's 1 for some it's 3. So it's from 1 to n as it keeps on varying. In such a situation for each student i want all the values under Reamarks column.
n varies from 1 to 20. Also tell me what max value of n can be accepted by DFSORT.
the o/p should be the same as shown in your previous JCL(the only difference being all the value under Remarks should come in o/p instead of only the first value under Remarks). It should be as follows :
Code:
Anu - You should improve
Good work
Try harder
Asha - You should improve
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You've changed the requirement several times now. I've lost track of what the input vs output looks like. Can you please show a good example of the input records and the expected output records.
Name field is from position 1 - 10
Subject1 from 1 - 10
Subject2 from 15-25
Subject3 from 30-40
Remarks from 50-80(but the data under Remarks doesnt start always from 50 , it keps varying anywhere from 50-80)
Other activities from 1 - 10
Optional subject from 1-20
The i/p file based on the above layout is given below :
Name : Anu
Subject1 Subject2 Subject3
Eng maths physics
Remarks
Good work
Try harder
You should improve
Name : Anu
Other activities
Painting
Name : Asha
Subject1 Subject2 Subject3
hist science geography
Remarks
Excellent
Name : Asha
Other Activities
Singing
Name : Asha
Optional subject
French
The data under Remarks varies anywhere from 50th col to 80th col(i.e.it's position is not fixed).
Now my requirement is to get the first Name(as Name appears at least twice for each student) and it's corresponding Remarks field. Here the i/p file shows details of two students Anu and Asha. Lets say they are the details of 2 students . For each student , the Name field appears at least twice. (Say for Anu - The second Name field indicates that it's a continuation,similar is the case with the second student i.e Asha where the Name field appears 3 times showing that details of student Asha is continued) . But as per my requirement i need only the first Name for each student and the Remarks field(that comes in 5th line only from the 1st Name field for each student and note that there's no Remarks field for the continued Name fields until a fresh student detail appears) that is present only for the first Name field of each student.
So my o/p should be
Anu - Good work
- try harder
- You should improve
Asha - Excellent
The JCL you provided (is given below)gave me the above o/p. But now i want the o/p to have the data under subject1 and subject2 for each student along with the above o/p.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
Frank i tried the JCL but no records were there in o/p datatset.
That doesn't give me anything to go on.
Here's the input I used for my test.
Code:
Name : Anu
Subject1 Subject2 Subject3
Eng maths physics
Remarks
Another remark
A third remark
Name : Anu
Other activities
Painting
Name : Asha
Subject1 Subject2 Subject3
hist science geography
Remarks
You should improve
Name : Asha
Other Activities
Singing
Name : Asha
Optional subject
French
Comment1
Comment2
Here's the output I got for my test:
Code:
Anu - Eng Good
maths Another remark
A third remark
Asha - hist You should improve
science
I guess you need to tell me what's different in your case. You could use a step like this to display each intermediate output (&&T1, &&T2, &&T3 and &&T4):