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

Where should I establish Parentage


IBM Mainframe Forums -> IMS DB/DC
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
AJAYREDDY

New User


Joined: 17 Feb 2007
Posts: 52
Location: USA

PostPosted: Wed Jan 02, 2008 11:29 pm
Reply with quote

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
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Thu Jan 03, 2008 5:49 am
Reply with quote

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
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Thu Jan 03, 2008 5:51 am
Reply with quote

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
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Thu Jan 03, 2008 10:24 pm
Reply with quote

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
View user's profile Send private message
AJAYREDDY

New User


Joined: 17 Feb 2007
Posts: 52
Location: USA

PostPosted: Fri Jan 04, 2008 12:32 am
Reply with quote

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
View user's profile Send private message
AJAYREDDY

New User


Joined: 17 Feb 2007
Posts: 52
Location: USA

PostPosted: Fri Jan 04, 2008 12:46 am
Reply with quote

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
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Fri Jan 04, 2008 1:00 am
Reply with quote

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
View user's profile Send private message
AJAYREDDY

New User


Joined: 17 Feb 2007
Posts: 52
Location: USA

PostPosted: Mon Jan 07, 2008 8:36 pm
Reply with quote

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
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Mon Jan 07, 2008 9:17 pm
Reply with quote

Happy to hear you are progressing! I am adding a link from a similar problem - perhaps it will help even more.

ibmmainframes.com/viewtopic.php?t=26539
Back to top
View user's profile Send private message
smile_rajeev

New User


Joined: 22 Apr 2005
Posts: 24

PostPosted: Wed Jan 30, 2008 2:49 pm
Reply with quote

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
View user's profile Send private message
smile_rajeev

New User


Joined: 22 Apr 2005
Posts: 24

PostPosted: Wed Jan 30, 2008 4:09 pm
Reply with quote

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
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Wed Jan 30, 2008 6:14 pm
Reply with quote

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
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 -> IMS DB/DC

 


Similar Topics
Topic Forum Replies
No new posts Getting Error while trying to establi... DB2 3
No new posts Establish DTB for a CICS transaction CICS 1
No new posts Regarding Pipe Allocation to Establis... CICS 4
No new posts How to establish MQ REXX INTERFACE All Other Mainframe Topics 1
No new posts Establish hypersocket between two LPA... CICS 1
Search our Forums:

Back to Top