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

Reading 2 segments down


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

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Thu May 07, 2009 3:46 pm
Reply with quote

I have a database structure like this..

A
|
v
B
|
v
C

I need to sequentially read this database:
I wrote the following calls...

GN on segment A until END OF SEGMENT A
GNP on B unitl END OF SEGMENT B
GNP on C until END of SEGMENT C

Problem faced:

First time it reads fine. i.e first occurence of B under A is read fine. All occurences of C is also read fine.
But when, END of C is reached and again contol returns to do a GNP on B, it gives GE and does not return the next occurence of B under A.

Can anyone help me with this loop!
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Thu May 07, 2009 9:07 pm
Reply with quote

You could just do a GN on A, B & C and get all 3 at the same time.
This would be done with 1 loop instead of 3 nested loops (I think that is what you meant to show). This would be more efficient.

Or you could use 3 different PCBs
Back to top
View user's profile Send private message
dominickim

New User


Joined: 28 Feb 2007
Posts: 65
Location: NS, CA

PostPosted: Fri May 08, 2009 12:47 am
Reply with quote

It looks like you used QSSA. If you specified QSSA on "B" level, then GNP with QSSA is acting like that.
Back to top
View user's profile Send private message
Srileka

New User


Joined: 21 Jun 2007
Posts: 19
Location: India

PostPosted: Mon May 11, 2009 3:43 pm
Reply with quote

Hi,
Basically a GNP call should always be preceeded by a GN or GU call because a GNP cannot establish the parentage.
Your GN call will set the parentage at A. So GNP for B will fetch all ocurences of B with A as parent. And this GNP will not set the parentage to B for issuing GNP for C. The parent is still A. So you will get all the occurences of C with A as parent. It cannot limit the fetch of C with parent as each occurence of B. That is why at the end of C you get GE instead of fetching the next occurence of B.

Now let us see how to get the expected result.
Procedure 1:
1) GN call for A
2) GNP call for B
3) GNP call for C with 2 SSAs as below
segmentB *U
segmentC

* at position 9

The command code U will set the parentage at B. So the GNP call for C will limit the search for C with parent as that particular occurence of B.
But using command codes is not advisable always if you consider performance.
In that case follow this.
Procedure 2:
1) GN call for A
2) GNP call for B
3) GN call for C with qualified SSA's for A and B and unqualified SSA for C i.e get the key from A and B and qualify those segments and then call segment C.

Please let me know if you need more info.

Thanks,
Srileka.V
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 Reading dataset in Python - New Line ... All Other Mainframe Topics 22
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Rexx program reading a DSN then write... CLIST & REXX 4
No new posts Reading subsequent rows in a query. DB2 12
No new posts COBOL reading from SYSIN COBOL Programming 1
Search our Forums:

Back to Top