View previous topic :: View next topic |
Author |
Message |
srinivasan_srisailan Beginner
Joined: 18 May 2004 Posts: 11 Topics: 3
|
Posted: Wed Nov 24, 2004 11:02 pm Post subject: Syncsort Help needed |
|
|
Hi all,
My input file is basically an IMS DB unload file. It is a VB file. The first six bytes of the input
file represents the segment name. Every CHILD1 segment record has 4 digit number starting at column 20.
I want to extract only the PARENT segment record and the corresponding the CHILD1 segment record.
The other CHILD segment records are not needed. The condition for extracting is - CHILD1 segment
records with values other than 1111 and 2222 beginning at column 20.
Input file:
Code: | PARENT.....DETAIL1.......
CHILD1.............1111...
CHILD2....................
CHILD3....................
PARENT.....DETAIL2.......
CHILD1.............2222...
CHILD3....................
PARENT.....DETAIL3.......
CHILD1.............3333...
CHILD2....................
CHILD3....................
PARENT.....DETAIL4.......
CHILD1.............4444...
CHILD3....................
PARENT.....DETAIL5.......
CHILD1.............1111...
CHILD2....................
PARENT.....DETAIL6.......
CHILD1.............1111...
CHILD2....................
CHILD3.................... |
Output file desired:
Code: | PARENT.....DETAIL3.......
CHILD1.............3333...
CHILD2....................
CHILD3....................
PARENT.....DETAIL4.......
CHILD1.............4444...
CHILD3.................... |
Can this be achieved by SORT or should I go for a COBOL program?
I have SYNCSORT/EASYTRIEVE in my shop. DFSORT is not available.
Thanks,
Srini |
|
Back to top |
|
 |
srinivasan_srisailan Beginner
Joined: 18 May 2004 Posts: 11 Topics: 3
|
Posted: Wed Nov 24, 2004 11:37 pm Post subject: |
|
|
A small correction in the output file. It should be as specified below:
Code: | PARENT.....DETAIL3.......
CHILD1.............3333...
PARENT.....DETAIL4.......
CHILD1.............4444... |
Please suggest a solution.
Thanks,
Srini |
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Thu Nov 25, 2004 1:25 am Post subject: |
|
|
Srinivasan,
Please give us the following info.
1. Will a parent ALWAYS have 3 child segments ?
2. Is there a way to Identify a PARENT segment. Does it start with 'PARENT' or is it just an example ?
3. You said ur output is of VB type. Can there be any record with LRECL less than 20 ?
Thanks,
Phantom |
|
Back to top |
|
 |
srinivasan_srisailan Beginner
Joined: 18 May 2004 Posts: 11 Topics: 3
|
Posted: Thu Nov 25, 2004 12:23 pm Post subject: |
|
|
Phantom,
Here are the answers:
1. No the parent need not have 3 child segment records. For Ex: it can also be without a CHILD1 segment record.
2. Yes the PARENT segment can be identified with the word 'PARENT'.
3. The input file is a VB file. A CHILD1 segment record will always have LRECL greater than 24. But the other CHILD segment records can have LRECL < 20.
I have missed out one more condition, there can be more than one CHILD1 segment records within a PARENT segment record.
I hope the requirements are clear.
Thanks,
Srini |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Mon Nov 29, 2004 12:38 am Post subject: |
|
|
Kolusu,
Is there a traditional way to solve this problem without using SPLICE? I could not think of any. The problem is easy to solve if the no. of child1 records does not vary.
Srinivasan,
Kolusu's solution (in the link) requires latest version of Syncsort to support SPLICE. What version of Syncsort do you have at your shop ?
Kolusu,
I could rearrange the records in this order. I dont know how to proceed further. Let me know if you get an idea (without SPLICE).
Input:
Code: |
PARENT.....DETAIL1.......
CHILD1.............1111...
CHILD1.............3333
CHILD1.............5555
CHILD3....................
PARENT.....DETAIL2.......
CHILD1.............2222...
CHILD3....................
PARENT.....DETAIL3.......
CHILD1.............3333...
CHILD2....................
CHILD3....................
PARENT.....DETAIL4.......
CHILD1.............4444...
CHILD3....................
PARENT.....DETAIL5.......
CHILD1.............1111...
CHILD2....................
PARENT.....DETAIL6.......
CHILD1.............1111...
CHILD2....................
|
Output:
Code: |
PARENT.....DETAIL1.......
CHILD1.............3333
CHILD1.............5555
PARENT.....DETAIL2.......
PARENT.....DETAIL3.......
CHILD1.............3333...
PARENT.....DETAIL4.......
CHILD1.............4444...
PARENT.....DETAIL5.......
PARENT.....DETAIL6.......
|
Now I need to remove the PARENT records if it has no sub-ordinate CHILDs following it. In the above case I need to delete PARENT-DETAIL2 & PARENT-DETAIL5. Can you think of a way to do this using the OLD Syncsort ? (that I have !!!)
Thanks,
Phantom |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Mon Nov 29, 2004 6:34 am Post subject: |
|
|
phantom,
I don't think there is a way to solve this with the traditional features available in sort. If I find out a way I will let you know
Thanks
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
srinivasan_srisailan Beginner
Joined: 18 May 2004 Posts: 11 Topics: 3
|
Posted: Tue Nov 30, 2004 2:14 am Post subject: |
|
|
Phantom,
SYNCSORT in my shop doesn't support SPLICE .
I was able to get the same output as you had obtained with SORT but couldn't proceed further. So I finally wrote a COBOL program to achieve this. Still wondering if there's a SORT solution to achieve this .
Thanks Phantom and Kolusu. |
|
Back to top |
|
 |
|
|