Joinkey or Sort find the Parent company

JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...
Bala_mainframe
Posts: 2
Joined: Tue May 17, 2022 7:54 pm
Skillset: Mainframe
Referer: Online

Joinkey or Sort find the Parent company

Postby Bala_mainframe » Tue May 17, 2022 8:27 pm

Hi All,

I would like to perform below task using joinkey or Sort.

I am trying to find the Ultimate parent company.

Example :

Input file:

Code: Select all

Company             Immediate Parent Company
   
  A                          A                              
  B                          A
  C                          A
  D                          B
  E                          B
  F                          E
  G                          E
  Z                          Z
 

Expected output file:

Code: Select all

Company                                            Immediate Parent Company                       Ultimate Parent Company
   
  A                                                                  A                                               A
  B                                                                  A                                               A
  C                                                                  A                                               A
  D                                                                  B                                               A
  E                                                                  B                                               A
  F                                                                  E                                               A
  G                                                                  E                                               A
  Z                                                                  Z                                               Z  
 

 


Basically Company and Immediate parent company are same ,then it can be considered as Ultimate parent company.
and if Company and Immediate parent company not same then ,need to search in Company field column using the Immediate Parent company value
to find the ultimate parent company

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Joinkey or Sort find the Parent company

Postby sergeyken » Wed May 18, 2022 1:26 am

Can be done in SORT only with a predefined reasonable limit of allowed predecessors for each company.
Javas and Pythons come and go, but JCL and SORT stay forever.

Bala_mainframe
Posts: 2
Joined: Tue May 17, 2022 7:54 pm
Skillset: Mainframe
Referer: Online

Re: Joinkey or Sort find the Parent company

Postby Bala_mainframe » Wed May 18, 2022 1:48 pm

Thanks !!
Could you please confirm best possible option to complete this

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Joinkey or Sort find the Parent company

Postby sergeyken » Wed May 18, 2022 4:40 pm

Bala_mainframe wrote:Thanks !!
Could you please confirm best possible option to complete this

Did you mean: can I do your job for you?
Yes, I can. But have no desire to do it in this manner.

This forum exists to help people doing their jobs, and to help them fix their mistakes, but not for doing their job from top to bottom.

One of possible options is, the JOIN operation supported by SORT utilities.

First of all, please try to do at least something by yourself.
Javas and Pythons come and go, but JCL and SORT stay forever.


  • Similar Topics
    Replies
    Views
    Last post