IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sorting the records in parent child relationship


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
manoopatil

New User


Joined: 07 Dec 2003
Posts: 56
Location: Montreal

PostPosted: Wed Dec 03, 2008 1:55 am
Reply with quote

I need to sort the input given in the following format.

Code:

ACCENURE1 1847709                         ACCENURE1
ACCENURE1 0222139                         ACCENURE1
ACCENURE1 41T6020707                      ACCENURE1
ACCENURE1 70N6037226                      ACCENURE1
ACCENURE1 08SQCA101384NBWK                0222139
ACCENURE1 5064449120             847709   1847709
ACCENURE1 05DHAT858102BLCA       285250   41T6020707
ACCENURE1 999                    285250   41T6020707
ACCENURE1 05DHAT858103BLCA       285250   41T6020707
ACCENURE1 999                    354035   70N6037226
ACCENURE1 01IPCD875986           354035   70N6037226
ACCENURE1 DG0054                 285250   999
ACCENURE1 DG0060                 285250   999
ACCENURE1 DG0001                 354035   999


The records in input are sorted by first column - Master Cust. and fourth column Parent Name. second and third columns are Child Name and Sequence Number respectively.

The output is required in the following format with following rules

Code:

ACCENURE1 0222139                         ACCENURE1
ACCENURE1 08SQCA101384NBWK                0222139
ACCENURE1 1847709                         ACCENURE1
ACCENURE1 5064449120             847709   1847709
ACCENURE1 41T6020707                      ACCENURE1
ACCENURE1 05DHAT858102BLCA       285250   41T6020707
ACCENURE1 05DHAT858103BLCA       285250   41T6020707
ACCENURE1 999                    285250   41T6020707
ACCENURE1 DG0054                 285250   999
ACCENURE1 DG0060                 285250   999
ACCENURE1 70N6037226                      ACCENURE1
ACCENURE1 01IPCD875986           354035   70N6037226
ACCENURE1 999                    354035   70N6037226
ACCENURE1 DG0001                 354035   999


1. In output first record is sorted child with parent same as master cust.

2. The next record should one where parent is same as child in previous
record i.e. 0222139

3. If there is no record with parent equal to child in previous record then
record with parent equal to parent in previous record should come.

4. Also note '999' is a child under two different parents. In one place
sequence number is - 285250 where as in another place the sequence
number is 354035. As we can see the records with same sequence
number should be in sequence subject to the parent child relationship.

5. There can be multiple master cust in the input file. So records for each
master cust should be together with the sequence as above.

I know its a bit complicated to understand. Please let me know if you have some ideas to make it simpler

Thank you
-Manohar
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Dec 03, 2008 9:59 am
Reply with quote

Quote:
I know its a bit complicated to understand
Manohar,

You feel that as "a bit"?. One really need to be patient to understand your requirement. What process is generating this file? Is it not possible to enforce these rules while writing the file?

Referring to your 3rd point, if 0222139 was not present as a "Parent Name" for any other records, what would be your 2nd record in output?
Back to top
View user's profile Send private message
manoopatil

New User


Joined: 07 Dec 2003
Posts: 56
Location: Montreal

PostPosted: Wed Dec 03, 2008 9:15 pm
Reply with quote

Hi Arun,

I agree with you that one has to be really patient to understand the requirement. And thank you for taking interest in the post.

The file is getting generated from the SQL query in a program. The changes to the program are going to be costly and hence the option of using SORT or other utility is being explored.

Referring to the 3rd point, if 0222139 was not present as a "Parent Name" in any other records, then following would be 2nd record in the output.

Code:

ACCENURE1 1847709                         ACCENURE1


Please let me know in case of any question

Appreciate your help

Thanks
-Manohar
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
Search our Forums:

Back to Top