View previous topic :: View next topic
|
Author |
Message |
AJAYREDDY
New User
Joined: 17 Feb 2007 Posts: 52 Location: USA
|
|
|
|
I have IMS DB structure as below.
ROOT (parent of CHILD1)
CHILD1 (parent of CHILD2)
CHILD2
I am reading ROOT segment with GU and Qualified SSA using Full Key as below.
CALL 'CBLTDLI' USING GU
A-PCB
ROOT-RECORD
ROOT-SSA.
I am putting in a Loop CHILD1 to get ALL the segments with Unqualified CHILD1 SSA as below.
CALL 'CBLTDLI' USING GN
A-PCB
CHILD1-RECORD
ROOT-SSA
CHILD1-UNQ-SSA.
After getting "Freight Bill" value from CHILD1 moving it as Qualified CHILD1 SSA.
Putting in a Loop CHILD2 to get ALL the segments with QUALIFIED CHILD1 SSA and Unqualified CHILD2 SSA.
CALL 'CBLTDLI' USING GN
A-PCB
CHILD2-RECORD
ROOT-SSA
CHILD1-QUAL-SSA
CHILD2-UNQ-SSA.
Here is my requirement. After reading ALL CHILD2 segments with first occurence of "Freight Bill" from CHILD1, I need to get NEXT "Freight Bill" from CHILD1 Segment and continue reading CHILD2 again.
This should go until end of DB. With the above code I am always getting only first occurence of "Freight Bill".
Please let me know where I am doing wrong. The NEXT "Freight bill" segment is not getting from CHILD1 (After reading all CHILD2) though there are multiple "Freight Bill" segments in CHILD1. |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
You do not need to establish parentage unless you do not use ssa's for the child segments. Setting parentage does NOT retain position. |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
Do not forget to load your qualfied SSAs all the way down. You will be checking for GE or GB. Have you looked at your key feedback area? It will tell you the last successful call. |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
OK - you have not responded so I will tell you that your coding is correct - so far. Look at it this way - you will be reading all child1 and child2 segments under each root segment until you reach the end of the database.
When you successfully retrieve a child1 segment beneath the root, you will then read all child2 setments beneath that child1 segment.
If you get a GB - you have reached the end of the database, you are done with your process.
If you get a GE - you have read all child2 segments beneath that child1 segment. You then need to reposition yourself at the next child1 segment beneath that root and read it's child2 segments.
Once you get a GE on the child1 segment beneath that root, you need to reposition yourself and get the next root. |
|
Back to top |
|
|
AJAYREDDY
New User
Joined: 17 Feb 2007 Posts: 52 Location: USA
|
|
|
|
Thanks Sandy for the response. What is happening is after reading all the child2 segments until GE "for first value of child1", Then reading GN Child1, I am getting GE for Child1 also (though there is another segment value).
When I checked (displayed) PCB (while GN in Child1) the value inside PCB is changing to ROOT segment after reading first Child1 and all Child2.
I tried this way. I removed reading loop of Child2. This time I am getting (displaying) all Child1 segments properly. So there is something I should do to read next segment in child1 after reading all Child2. I should not get GE. |
|
Back to top |
|
|
AJAYREDDY
New User
Joined: 17 Feb 2007 Posts: 52 Location: USA
|
|
|
|
Please see attached for data information.
After reading all values for ABC01 (88, 22, 44, 55), the program is not reading DEF05. Instead I am getting GE.
Note: The values ABC01, DEF05, MGH09 are not key fields. So how should I code to read all these values.
Thanks |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
You need to RE-POSITION yourself. Remember that IMS is positioned at your last successful call. In other words....
A0012 ABC01 55 You are postioned HERE... you need to reposition yourself. And.....yes, DEF05 must have a key field. Please show us your DBD and your actual code. |
|
Back to top |
|
|
AJAYREDDY
New User
Joined: 17 Feb 2007 Posts: 52 Location: USA
|
|
|
|
Thanks Sandy. I did some program logic change. First I read all the CHILD1 and CHILD2 with Unqualified SSA and while reading I kept track of CHILD1 records in working storage. Then I read CHILD1 with qualified SSA to get the record which I needed. |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
Back to top |
|
|
smile_rajeev
New User
Joined: 22 Apr 2005 Posts: 24
|
|
|
|
hi,
The logic seems to be okay. But i think instead of giving GN in the child2. you can try with GNP( get next within parent) in a loop.
What it does is Under child1 segment it will fetch al the child2 values and again it will come to child1 and fetches next record and fetches all values from child2 and so on.
So, i have done with such a requirement long back. Had a thought of suggesting you.
Thanks
Rajeev |
|
Back to top |
|
|
smile_rajeev
New User
Joined: 22 Apr 2005 Posts: 24
|
|
|
|
hi,
The logic seems to be okay. But i think instead of giving GN in the child2. you can try with GNP( get next within parent) in a loop.
What it does is Under child1 segment it will fetch al the child2 values and again it will come to child1 and fetches next record and fetches all values from child2 and so on.
So, i have done with such a requirement long back. Had a thought of suggesting you.
Thanks
Rajeev |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
GN - unqualified with an SSA is better than setting parentage with no SSA GNP - you will still do a loop. As I have said many times, GNP does not retain position. |
|
Back to top |
|
|
|