MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Read IMS child segment whose parent has no key

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
misi01
Advanced


Joined: 02 Dec 2002
Posts: 618
Topics: 172
Location: Stockholm, Sweden

PostPosted: Wed Mar 29, 2023 9:14 am    Post subject: Read IMS child segment whose parent has no key Reply with quote

The simplest way to explain this I think is to show an overview of the database using FMI.
Code:

___ 1     SFPBPNR    95411132698     29   20100903   Root segment                 
___  2    SFPBFALL  Key=..                                           
___   3   SFPBSJP   4 segments                                       
___  2    SFPBFALL  Key=..                                           
___   3   SFPBSJP   6 segments                                       
___  2    SFPBATB   No key                                           
___   3   SFFNR     1 segment                                       
___  2    SFPBATB   No key                                           
___   3   SFFNR     1 segment                                       
___ 1     SFPBPNR    96607132385     21   20040209    Next root segment

We have a utility that shows the database and this is what the results look like.
Code:

| -------- | -------- | -------- |
| SEGMENT  | PARENT   | KEY      |
| -------- | -------- | -------- |
| SFPBPNR  | ROOT     | PNR      |
| SFPBFALL | SFPBPNR  | SJNR     |
| SFPBSJP  | SFPBFALL | TILLDAT  |
| SFPBATB  | SFPBPNR  |          |
| SFFNR    | SFPBATB  | FNR      |

Now, my problem (from a programming point of view) is how do I access each SFPBATB with the root as well as the SFFNR segments (in this example, there is only 1 SFFNR under each SFPBATB, but there could be multiple occurrences)
In the example I'm using, the last 4 segments contain
Code:

  2    SFPBATB         3       6856       2057
   3   SFFNR     1 segment                     
  2    SFPBATB        10        799        240
   3   SFFNR     1 segment                     

My problem is that I can read the first SFPBATB segment with no problem (using GNP on a qualified root SSA). If I then do a GNP on the SFFNR segment, I can fetch that. Trouble is, if I do another GNP on the SFFNR segment, I don't get a GE, rather, I simply get the second SFFNR without ever fetching the SFPBATB with the values 10, 799 etc.
My code for the fetch of the SFPBATB segment is
Code:

*                                                           
     move 'CFFPB'                to pcb-namn in aib         
     move length of ws-sfpbatb   to ioarea-lengd in aib     
     set gnp in aib              to true                   
*                                                           
     call 'AIBTDLI'           using mcmaib-fun             
                                    aib                     
                                    ws-sfpbatb             
                                    afpbpnr                    <--- qualified SSA containing the key value 95411132698
                                    sfpbatb-unqual-ssa    <---- unqualified SSA 
*                                                           

and the code for the GNP of the SFFNR segment is
Code:

*                                                           
     move 'CFFPB'                to pcb-namn in aib         
     move length of ws-sffnr     to ioarea-lengd in aib         
     set gnp in aib              to true                                       
*                                                           
     call 'AIBTDLI'           using mcmaib-fun               
                                    aib                     
                                    ws-sffnr                       
                                    afpbpnr                 
                                    afpbatb                  <---- unqualified SSA
                                   sffnr-unqual-ssa         <---- unqualified SSA

I've tried every variation I can think of, but whatever I do, I never get a GE after the first SFFNR, and I never see the SFPBATB segment with the 10 in it.
Any suggestions gratefully tested.
_________________
Michael
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12367
Topics: 75
Location: San Jose

PostPosted: Wed Mar 29, 2023 7:03 pm    Post subject: Re: Read IMS child segment whose parent has no key Reply with quote

misi01 wrote:

Now, my problem (from a programming point of view) is how do I access each SFPBATB with the root as well as the SFFNR segments (in this example, there is only 1 SFFNR under each SFPBATB, but there could be multiple occurrences)



Misi01,

My IMS knowledge is rusty, but i think you can solve it with the following

Since SFPBATB is twin segment. so you do the following

1. Issue GU on the root (SFPBPNR)
2. Now GNP on the root itself.(you would get the level 2 children sequentially.)
3. Check if the level 2 child is SFPBATB and if so store the KEY values in an array. ex:
Code:

SFPBATB         3       6856       2057
SFPBATB        10        799        240

4. Once you are done getting all the level 2 childs within the root, now do a Qualified SSA calls(root + array value 1 at a time) to get level 3 child SFFNR directly using the information in the array that your stored.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
misi01
Advanced


Joined: 02 Dec 2002
Posts: 618
Topics: 172
Location: Stockholm, Sweden

PostPosted: Thu Mar 30, 2023 12:38 am    Post subject: Reply with quote

Thanks for your suggestion.
I talked to a colleague yesterday and this was his solution.
When it's time to read the SFPBATB segment, you need to do it using GN and set parentage via the unqualified SSA.

In reality, it never occurred to me that you can do this (and I don't think I've ever seen this variation used. I'm going to assume it's only (?) relevant for a segment that is a parent and has no key fields).

Since you've been reading all the segments under SFPBPNR using GNP, once all the SFPBFALL/SFPBSJP segments are read, positioning is pointing at the (potential) first SFPBATB segment.
All that's needed now is to ensure that parentage is established for SFPBATB vis-a-vis SFFNR. So the code becamse the following (for SFPBATB)

Code:

     move 'CFFPB'                to pcb-namn in aib     
     move length of ws-sfpbatb   to ioarea-lengd in aib
     set gn in aib               to true               
     move 'P '     to CC-PBATB in AFPBatb    <--- Set the parentage           
*                                                       
     call 'AIBTDLI'           using mcmaib-fun         
                                    aib                 
                                    ws-sfpbatb         
                                    afpbpnr             
                                    AFPBatb             

where AFPBPNR is the qualified SSA and AFPBatb is defined as

Code:

 01  AFPBATB.                                             
     05 SEGM-PBATB           PIC X(08) VALUE 'SFPBATB'.   
*                SEGMENTNAMN                             
     05 CCA-PBATB            PIC X(01) VALUE '*'.         
*                COMMAND CODE ASTERISK                   
     05 CC-PBATB             PIC X(02) VALUE '--'.       
*                COMMAND CODE                             
     05 LP-PBATB             PIC X(01) VALUE ' '.         
*                LEFT PARENTHESIS                         

_________________
Michael
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12367
Topics: 75
Location: San Jose

PostPosted: Thu Mar 30, 2023 7:45 am    Post subject: Reply with quote

misi01,

well that is another way as basically you need to reset the parent.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group