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

Retrieving only one side of hierarchy


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

New User


Joined: 03 Nov 2008
Posts: 60

PostPosted: Tue Dec 16, 2008 11:54 am
Reply with quote

Hi,

I have a Hospital database whose DBD is below.

DBD NAME=HOSPLDBD,ACCESS=(HDAM,VSAM),
RMNAME=(DFSHDC40,010,00000120,00004096)
DATASET DD1=HOSPDD,DEVICE=3390,SIZE=4096
SEGM NAME=PATIENT,BYTES=45,PARENT=0
FIELD NAME=(PATNO,SEQ,U),BYTES=5,START=01,TYPE=C
FIELD NAME=(PATNAME),BYTES=10,START=06,TYPE=C
FIELD NAME=(PADDR),BYTES=30,START=16,TYPE=C
SEGM NAME=ILLNESS,BYTES=18,PARENT=PATIENT
FIELD NAME=(ILLDATE,SEQ),BYTES=8,START=01,TYPE=C
FIELD NAME=ILLNAME,BYTES=10,START=09,TYPE=C
SEGM NAME=TREATMNT,BYTES=32,PARENT=ILLNESS
FIELD NAME=(TRDATE,SEQ),BYTES=8,START=01,TYPE=C
FIELD NAME=MEDICINE,BYTES=10,START=09,TYPE=C
FIELD NAME=QTY,BYTES=4,START=19,TYPE=C
FIELD NAME=DOCTOR,BYTES=10,START=23,TYPE=C
SEGM NAME=BILLING,BYTES=06,PARENT=PATIENT
FIELD NAME=BILLING,BYTES=06,START=01,TYPE=C
SEGM NAME=PAYMENT,BYTES=06,PARENT=BILLING
FIELD NAME=PAYMENT,BYTES=06,START=01,TYPE=C
SEGM NAME=HOUSHOLD,BYTES=18,PARENT=PATIENT
FIELD NAME=(RELNAME,SEQ),BYTES=10,START=01,TYPE=C
FIELD NAME=RELATION,BYTES=08,START=10,TYPE=C
DBDGEN
FINISH
END

My requirement is to retrieve only one side of hierarchy i.e. I want to retrieve all the ILLNESS & TREATMNT segments for one particular patient. I don't want BILLING, PAYMENT & HOUSHOLD segments.

I am a beginner to IMS, could you please help with above?
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


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

PostPosted: Tue Dec 16, 2008 9:02 pm
Reply with quote

It's very easy. Do you want every patient in the database?
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


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

PostPosted: Tue Dec 16, 2008 9:25 pm
Reply with quote

I'll assume you want every patient. Perform loop 1 until done.

loop 1 (patient) - unqualified gn ssa until end of database
load patient key into qualified ssa

perform loop 2a until done
perform loop 2b until done

loop 2a (illness) - use qualified patient ssa and unqualified illness ssa to
retrieve all illness segments under this patient until GE or GB

loop 2b (treatment) - use qualified patient ssa and unqualified
treatment ssa to retrieve all treatment
segments under this patient segment until GE or GB
Back to top
View user's profile Send private message
km_abdullah

New User


Joined: 03 Nov 2008
Posts: 60

PostPosted: Wed Dec 17, 2008 5:38 pm
Reply with quote

Hi Sandy,

I need all ILLNESS & TREATMNT segment occurrences for only one PATIENT.

Logic I implemented is:

STEP1 : GU for a particular PATIENT
STEP2 : Loop1 - GN with PATIENT qualified SSA, ILLNESS unqualified SSA.
STEP3 : Loop2(within Loop1) - GN with PATIENT qualified SSA, ILLNESS unqualified SSA, TREATMNT unqualifed SSA until GE/GB.

But I got only patient, first illness occurrence and all treatmnt occurrences. I am not getting remaining illness occurrences.

Please help.
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 Dec 17, 2008 6:03 pm
Reply with quote

STEP2 : Loop1 - GN with PATIENT qualified SSA, ILLNESS unqualified SSA.

You need to add until GE/GB logic to loop1.

STEP3 : Loop2(within Loop1) - GN with PATIENT qualified SSA, ILLNESS unqualified SSA, TREATMNT unqualifed SSA until GE/GB.

Treatment is a child of illness - once you have an illness segment, you need to load a fully qualified ssa for that illness segment.

Perhaps you will only have 1 illness segment - or perhaps you won't have any. Always code for every possible agenda.

Why are you using GU on the patient segment? Do you already have the key? The reason you are only getting the first patient is because you are using a GU. A get unique - with or without a fully qualified ssa - will always position you on the first segment in the database on your first call.

You need to use 'loop" logic for the patient segment with a GN if you want more than just the first patient segment. Also, don't forget GB logic there.
Once you have a patient segment, then load the key of that patient into a qualified SSA for your loop1[/i]
Back to top
View user's profile Send private message
km_abdullah

New User


Joined: 03 Nov 2008
Posts: 60

PostPosted: Thu Dec 18, 2008 12:42 pm
Reply with quote

I gave GU because i want to display Patient segment as well. Yes i had the key and i am looking for all the Illness and Treatment segment occurrences under the above Patient. And also i have 2 Illness segment occurrences under this Patient.

Quote:


Treatment is a child of illness - once you have an illness segment, you need to load a fully qualified ssa for that illness segment


Hello,

Now i understood that i need to qualify Illness before retrieving Treatmnt segment occurrences. Here is where i went wrong and got only first Illness and not the second one since i was using unqualified Illness SSA in loop2.
Now i got what i needed. Many thanks..
Back to top
View user's profile Send private message
km_abdullah

New User


Joined: 03 Nov 2008
Posts: 60

PostPosted: Thu Dec 18, 2008 1:54 pm
Reply with quote

Hi Sandy,

Many thanks for your help.
Is there any way i can achieve the above requirement using Command Codes?

Please advise.
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 Dec 18, 2008 5:02 pm
Reply with quote

Why do you want to use command codes if you don't need them? And, the answer to your question is no.
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 convert SUPERC compare report to side... CLIST & REXX 5
No new posts How to split a file in 2 with hierarchy SYNCSORT 12
No new posts Retrieving IMS message processing reg... CLIST & REXX 7
No new posts Technical Support Engineer (DB2 on z/... Mainframe Jobs 0
No new posts retrieving envelope information out o... TSO/ISPF 6
Search our Forums:

Back to Top