A few queries on IMS-DB



IBM's hierarchical database management system with a Database Manager (IMS DB) and a Transaction Manager(IMS DC)

A few queries on IMS-DB

Postby ritwik.das » Wed Jul 16, 2008 10:53 am

Hi All,

I'm a new joinee in this forum. I have recently started learning IMS-DB and got stuck up with a query. I do not have mainframe access, hence I can not try it myself. Someone please help me out with this :

Let's take an example of an IMS database where the parent segment is EMPLOYEE and the child segment is DEPENDANTS. Now if an employee does not have any dependants, will the DEPENDANTS segments be created?

My guess is only one occurance of the DEPENDANTS will be created and it will be filled up with spaces. Please rectify me if I'm wrong.

Thanks to all of you in advance!
Ritwik
Thanks & Regards!
Ritwik
ritwik.das
 
Posts: 13
Joined: Wed Jul 16, 2008 10:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: A few queries on IMS-DB

Postby Sandy Zimmer » Thu Jul 17, 2008 1:09 am

No segments will be created automatically. Take a look at the DBD (database definition) and you will see how your database is defined.
Sandy Zimmer
 
Posts: 28
Joined: Mon Jul 30, 2007 8:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: A few queries on IMS-DB

Postby Sandy Zimmer » Thu Jul 17, 2008 1:28 am

Ritwik - I think you are relating segment "occurences" with the term for table "occurences". An IMS database is defined as a physical view - for now, we will assume that the logical view matches. Think about a tree limb. That would be your root - there can be one or there can be many. They are called root occurences. The first root may or may not have an dependent limbs (child segments). Your EMPLOYEE segment exists but may not have any DEPANDANTS. That is OK in IMS. But, a DEPANDANT is always totally dependent on it's parent which is EMPLOYEE. In IMS, if you delete a parent segment all children will be automatically deleted too because they are dependent on that parent. When segments are created in IMS - it sets up pointers. If the parent goes away, then IMS could never resolve the dependent pointers. I hope this gives you a better picture.
Sandy Zimmer
 
Posts: 28
Joined: Mon Jul 30, 2007 8:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: A few queries on IMS-DB

Postby ritwik.das » Thu Jul 17, 2008 12:22 pm

Thanks a lot Sandy for the clarification!

I have another issue with the GN calls. My DB structure is - Organization (root), Department (child of Organization), Employee (child of Department) and Dependants (child of Employee). I need to prepare a report on the employees & their dependants. My code to do so is -

LOOP UNTIL END OF EMPLOYEE
INITIALIZE IMSPCB
CALL 'CBLTDLI' USING GN
IMSPCB
WS-EMPLOYEE-INFO-IO-AREA
ORGANIZATION-SSA-QUALIFIED
DEPARTM ENT-SSA-QUALIFIED
EMPLOYEE-SSA-UNQUALIFIED

IF IMS-STATUS-CODE = SPACES
MOVE WS-IP-EMP-ID EMP-KEY-VALUE
LOOP UNTILL END OF DEPENDANTS
INITIALIZE IMSPCB
CALL 'CBLTDLI' USING GN
IMSPCB
WS-DEPENDANCY-INFO-IO-AREA
ORGANIZATION-SSA-QUALIFIED
DEPARTMENT-SSA-QUALIFIED
EMPLOYEE-SSA-QUALIFIED
DEPENDANCY-SSA-UNQUALIFIED

IF IMS-STATUS-CODE = SPACES
DO THE PROCESSING
END-IF
END-LOOP (for dependants)
END-IF
END-LOOP (for employee)

The question is, after completing processing for all the dependants of employee-1, when control goes back for the 2nd iteration of the outer loop, will it read employee-1 again or will it read employee-2?

Please excuse this lengthy post!

Thanks & Regards!
Ritwik
Thanks & Regards!
Ritwik
ritwik.das
 
Posts: 13
Joined: Wed Jul 16, 2008 10:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: A few queries on IMS-DB

Postby Sandy Zimmer » Thu Jul 17, 2008 4:12 pm

Ritwik - LOOKS GOOD except for just a couple of things.

INITIALIZE IMSPCB ----------------never ever touch anything belonging to IMS You must never touch any area that IMS uses. Your PCB area contains all the info that you need to determine what IMS did.

If you forget little things about IMS, just remember that IMS is positional. You will always be positioned at your last successful call ready for the next call. You can never move backward in an IMS database - you can reposition yourself with a GU.

You need to check for GE (not found) and GB (end of database) after each call. You can also always take a look at other areas in your PCB for valuable info like concatenated keys and your segment level. Where are you getting the key values to load your qualified ssa values?
Sandy Zimmer
 
Posts: 28
Joined: Mon Jul 30, 2007 8:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: A few queries on IMS-DB

Postby ritwik.das » Fri Jul 18, 2008 10:40 am

Thanks Sandy! I just can not believe that an expert like you has taken the pain of going through my scribblings and have corrected them. Thanks a ton for helping me learn IMS effectively. :D

Please have a look at the following pseudo-code and clarify my doubts -

Loop until employee ends
GN (unq for employee)
if GN is successful
Loop until dependants end
GN (unq for dependant)
......
......
a) If I use the same PCB mask in both the calls, then after completing processing for all the dependants of employee-1, when control goes back for the 2nd iteration of the outer loop, will it read employee-1 again or will it read employee-2?

b) What if I use different PCB masks for these two calls?

My guess is if I use different PCB masks, next time employee-2 will be read. If I use the same mask, employee-1 will be reread.

Thanks & Regards!
Ritwik
Thanks & Regards!
Ritwik
ritwik.das
 
Posts: 13
Joined: Wed Jul 16, 2008 10:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: A few queries on IMS-DB

Postby Sandy Zimmer » Fri Jul 18, 2008 4:39 pm

First question from me......where are you getting the key values for ORGANIZATION-SSA-QUALIFIED
DEPARTM ENT-SSA-QUALIFIED?

Using 2 different PCBs is called multiple positioning and this application is not a candidate at all for this. You must use the same PCB because it holds all of your database info from your last successful call and it knows your POSITION. When you loop ends and you are not at the end of the database, you will execute your next GN. Draw yourself a little picture - you already read employee-1 and all of it's dependents. You are now POSITIONED directly after your last successful call ready to ready employee-2 - if you are not at the end of the database.

Look at the field layout for your PCB. The field segment-level tells you the level of your last successful call - 1 is root - 2 is child - 3 is child's child, etc. Your key feedback area contains the concatenated key of your last successful call - from the root all the way down.

I enjoy helping! Over the course of my career, I had many absolutely great people helping me. I'm just passing it along - some day you will too.
Sandy Zimmer
 
Posts: 28
Joined: Mon Jul 30, 2007 8:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: A few queries on IMS-DB

Postby ritwik.das » Mon Jul 21, 2008 10:03 am

First question from me......where are you getting the key values for ORGANIZATION-SSA-QUALIFIED
DEPARTM ENT-SSA-QUALIFIED?


Actually this is not a real-time code but just an assignment. The problem statement says "[i]...prepare a report for all the employees of DEPT1 of the organization NIIT and their dependants[/i]". So I've got Organization name=NIIT & Department-ID=DEPT1. That makes my SSA-s qualified.

At the end of the first unqualified GN (in outer loop) I'm at the end of employee-1. The successive GN-s (in inner loop) puts me at the end of the last dependant of employee-1 after finishing the loop for employee-1. I know IMS keeps track of its position based on the last successful call. So, if I come back to the GN of outer loop (unqualified for employee) how will it read employee-2? My understanding is the successful calls in the nested loop (for dependants) overwrite the contents of the PCB (if I use only one throughout).

Sorry if I was verbose and/or sounded too dumb to understand the basics.

P.S - I've uploaded the DB structure (should've done earlier but didn't find the option, sorry!). The relevant part is highlighted in red.

Thanks & Regards!
Ritwik
You do not have the required permissions to view the files attached to this post.
Thanks & Regards!
Ritwik
ritwik.das
 
Posts: 13
Joined: Wed Jul 16, 2008 10:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: A few queries on IMS-DB

Postby dick scherrer » Mon Jul 21, 2008 11:30 am

Hello,

Please re-post your document as a .txt file. Not everyone has ms-office - especially the newest version that creates the .docx files.

If someone has the newest version, great, but the .txt would be readable by any system.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: A few queries on IMS-DB

Postby Sandy Zimmer » Mon Jul 21, 2008 3:03 pm

Thanks, Dick! Ritwik, I am one of those that cannot view the pic. Let's take a step back - if you write a program to read a database and do not use any SSA in your calls, IMS will read every single segment in the database starting left - going down and then up all segment levels. If you do not check for end of database (GB) it will loop around and start again. IMS knows where it is - you control what it does based on the code you create.

When you finish reading all of the dependents for employee-1, you come out of your dependent loop and issue your get next for the next employee segment - which just happens to be employee-2. Your PCB contains the key for your last successful call. When you issue your next call, IMS will then contain that key if the call is successful.

Perhaps I do not understand?
Sandy Zimmer
 
Posts: 28
Joined: Mon Jul 30, 2007 8:10 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to IMS DB/DC