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
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
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Wed Mar 29, 2023 7:03 pm Post subject: Re: Read IMS child segment whose parent has no key
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
www.linkedin.com/in/kolusu
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
Posted: Thu Mar 30, 2023 12:38 am Post subject:
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
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