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

GNP call (revised by Bitneuker)


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

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:31 pm
Reply with quote

The original topic expanded; now the requirement is clearer so this topic is cleaned and ready for a fresh start. Relevant posts from the original topic will be added.


hi
i have a situation where i have two segments product and order..
the product segment is the parent of order segment..
The product segment has the following fields
product id
category id
the order segment has the following fields
product id
total cost

now im reading a category id from the file and checking for the corresponding product id in the product segment
im doing this using a gn call

now for that product id i have to fetch the total cost from order segment.
im using a gnp call for this

now my problem is that when im issuing a gnp call and checking for the segment name it is taking product segment rather than order segment

could anyone help me on this please

thanks in advance
girish
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:33 pm
Reply with quote

The IMS calls

gn call for the product segment...
CALL 'CBLTDLI' USING DLI-GN
DB-PCB-MASK
PROD-DB-AREA
PROD-ID-SSA.
01 PROD-ID-SSA.
05 FILLER PIC X(9) VALUE 'PRODUCT ('.
05 FILLER PIC X(10) VALUE 'PRODCAID ='.
05 PROD-CAT-CID PIC X(5).
05 FILLER PIC X VALUE ')'.
gnp call for order segment
CALL 'CBLTDLI' USING DLI-GNP
DB-PCB-MASK
ORDR-DB-AREA
ORDR-ID-SSA.
01 ORDR-ID-SSA.
05 FILLER PIC X(9) VALUE 'ORD ('.
05 FILLER PIC X(10) VALUE 'ORDPID ='.
05 ORDR-PID-VALUE PIC 9(5).
05 FILLER PIC X VALUE ')'.
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:37 pm
Reply with quote

this is my dbd...

SEGM NAME=PRODUCT,PARENT=CUSTOMER,BYTES=82
FIELD NAME=(PRODID,SEQ,U),BYTES=5,START=1,TYPE=P
FIELD NAME=PRODNAME,BYTES=25,START=6,TYPE=C
FIELD NAME=PRODSID,BYTES=5,START=31,TYPE=P
FIELD NAME=PRODCAID,BYTES=5,START=36,TYPE=P
FIELD NAME=PRODCANM,BYTES=25,START=41,TYPE=C
FIELD NAME=PRODUPR,BYTES=7,START=66,TYPE=P
FIELD NAME=PRODUSTK,BYTES=5,START=73,TYPE=P
FIELD NAME=PRODUORD,BYTES=5,START=78,TYPE=P
SEGM NAME=ORD,PARENT=PRODUCT,BYTES=72
FIELD NAME=(ORDID,SEQ,U),BYTES=5,START=1,TYPE=P
FIELD NAME=ORDCID,BYTES=5,START=6,TYPE=P
FIELD NAME=ORDEID,BYTES=5,START=11,TYPE=P
FIELD NAME=ORDPID,BYTES=5,START=16,TYPE=P
FIELD NAME=ORDQTY,BYTES=5,START=21,TYPE=C
FIELD NAME=ORDDT,BYTES=10,START=26,TYPE=C
FIELD NAME=ORDRDT,BYTES=10,START=36,TYPE=C
FIELD NAME=ORDSDT,BYTES=10,START=46,TYPE=C
FIELD NAME=ORDCST,BYTES=5,START=56,TYPE=C
FIELD NAME=ORDTOT,BYTES=12,START=61,TYPE=C
DBDGEN
FINISH
END
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:40 pm
Reply with quote

here,i need all the product ids that correspond to a single category id...so now how wud i accomplish that with a qualified ssa..? and i am to read the category ids one by one from a file and then get all the product ids that correspond to every category id listed in the file...
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:40 pm
Reply with quote

hi sandy,
i want each ordtot to be printed and the grand total of all the orders also to be printed for each category id...
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:42 pm
Reply with quote

Hi Girish,

When designing a system, you need to FIRST take a good look at what the end result should be. Then work backwards to the input. It would help us a lot if we knew FIRST what the end result should be. You never-ever start coding and then decide.

For instance.... Quote:
i want each ordtot to be printed and the grand total of all the orders also to be printed for each category id.


Do you have a visual for the report? Show us the layout. Also, how many categories are there? If not a lot, you could load an internal array at the beginning of your process and then accumulate your totals into the table based on the category retrieved. The process as defined now will not work for category totals.
_________________
SandyZ
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 9:08 pm
Reply with quote

Let's try to describe the business process first.

You are supposed to create a list containing the following:

For a number of categories list all individual order totals and an accumulated total per category. The list should look like this....

----your list----

Relations:
Category contains 0 : n products
Product contains 0 : n orders
Order contains the order total

First confirm or adjust this. After that we will look after your access path and how to retrieve the information needed.





[/img]
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 11:35 pm
Reply with quote

BTW:

Quote:
now my problem is that when im issuing a gnp call and checking for the segment name it is taking product segment rather than order segment


Did you check on your status code and was it AC?
Back to top
View user's profile Send private message
girish_s

New User


Joined: 31 Jul 2007
Posts: 45
Location: india

PostPosted: Fri Dec 07, 2007 12:54 pm
Reply with quote

the status code GE because its trying to fetch from the prod segment... and
Quote:
Relations:
Category contains 0 : n products
Product contains 0 : n orders
Order contains the order total


the relations are right..
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Fri Dec 07, 2007 4:31 pm
Reply with quote

Status code GE means that the required segment was not found.

First the relations were important. Now let's look at your DBD and the required data.

You posted a DBD where product is not the root but a dependent of customer.
Code:
SEGM NAME=PRODUCT,PARENT=CUSTOMER,BYTES=82


When looking at the releationship between the entities (you confirmed them) I would expect the following structure:
Code:

SEGM NAME=CUSTOMER,PARENT=0
SEGM NAME=CATEGORY,PARENT=CUSTOMER
SEGM NAME=PRODUCT,PARENT=CATEGORY
SEGM NAME=ORDER,PARENT=PRODUCT



Your database has the following structure::
Code:

SEGM NAME=CUSTOMER,PARENT=0
SEGM NAME=PRODUCT,PARENT=CUSTOMER
SEGM NAME=ORDER,PARENT=PRODUCT
Is this an existing database you must use?

This way in the database there is no hierarchical relationship between CATEGORY and PRODUCT; the data-item CATEGORY may exist in a number of PRODUCTS and therefore scattered all over the database.

In the database I notice a hierarchical releationship between PRODUCT and ORDER. This should imply that the ORDERS are from the same parent PRODUCT? Is this correct?
Back to top
View user's profile Send private message
girish_s

New User


Joined: 31 Jul 2007
Posts: 45
Location: india

PostPosted: Fri Dec 07, 2007 5:02 pm
Reply with quote

Quote:
Code:

SEGM NAME=CUSTOMER,PARENT=0
SEGM NAME=PRODUCT,PARENT=CUSTOMER
SEGM NAME=ORDER,PARENT=PRODUCT

this is the database i am using...

but category is not a separate segment...
if you see the dbd that i have posted, it contains a procaid field in the product segment...
so my requirement is that i hard code all the categories in a file and then read it one by one and check the corresponding prod ids for that category using that category in the ssa.
and then fetch the ord tot cost for that prod id in the order segment...
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Fri Dec 07, 2007 5:19 pm
Reply with quote

Quote:
and then fetch the ord tot cost for that prod id in the order segment...


When I look at your DBD the ORDER is the child of PRODUCT so all ORDERS are of the same PRODUCT.

And.........if you MUST use this database regarding the scattered CATEGORY you'd better follow the advise Sandy has for you; else your program may be running for hours depending on the size of 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: Fri Dec 07, 2007 5:37 pm
Reply with quote

Are there any categories that you would NOT want? Or, any categories that will not be included on your input file? How is the category input file built?
Back to top
View user's profile Send private message
girish_s

New User


Joined: 31 Jul 2007
Posts: 45
Location: india

PostPosted: Fri Dec 07, 2007 6:01 pm
Reply with quote

i want all the categories that are there in the database... the basic idea here is to find the total cost under each category....

and my input file is just a PS in which i am hardcoding all the category that are present 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: Fri Dec 07, 2007 6:06 pm
Reply with quote

OK - stop hard coding your category file. I want you to think about writing an extract program against the database. You would extract all the info that you need. You would write that to a sequential file - then sort that file as input into a regular non-IMS program. You would code break logic for your totals. It would run much-much-much faster and would be so very much easier. What do you think?
Back to top
View user's profile Send private message
girish_s

New User


Joined: 31 Jul 2007
Posts: 45
Location: india

PostPosted: Fri Dec 07, 2007 6:24 pm
Reply with quote

could u please be a bit more descriptive about the extract program.. i mean, how to go about this....
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 Dec 07, 2007 6:32 pm
Reply with quote

There are a couple of ways you could do it. You can use part of the logic I gave you before. You will be going thru every product on the database - but first, let's think about any and all information you will need on your extract file - better more than not enough. You will have no "select" logic in your IMS program. You will just be interested in pulling off product, category, order number, order total. You can also pull off customer number which you will see in your key feedback area.
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 Dec 07, 2007 6:41 pm
Reply with quote

Here it is - any questions?

perform 1000-gn-prod thru 1999-exit until GB (end of database)

1000-gn-prod.
move space to prod-left-paren - this will make the call unqualified. Issue your GN. Check for spaces or GB - spaces indicates a successful call - GB indicates the end of the database. If GB - go to 1999-exit.

move '(' to prod-left-paren. Move the PRODID from the segment to PROD-ID of the PROD-ID-SSA.

The key feedback area from your PCB always contains the concatenated key values for all segments up the chain. For instance, when you get a product within the correct category, take a look at the KFA in your pcb. You will then look at the portion that has the key value for the customer root. You will then need to add that qualified SSA in your calls to reposition to the product and to go thru the orders.

CALL 'CBLTDLI' USING DLI-GN
DB-PCB-MASK
ORDR-DB-AREA
CUST-ID SSA - qualified with customer id
PROD-ID-SSA - qualified with product id
ORDR-ID-SSA. - unqualified

make sure the ord-left-paren is spaces.

perform 1100-get-orders thru 1199-exit until GE or GB.

If not GB - you will need to issue a qualified GU on the product to reposition yourself back to the product segments (assuming that you do not need any info from the customer segment - you have the key in your key feedback area)

1999-exit.

1100-get-orders.

CALL 'CBLTDLI' USING DLI-GN
DB-PCB-MASK
ORDR-DB-AREA
CUST-ID SSA - qualified with customer id from your key feed back area
PROD-ID-SSA - qualified with product id
ORDR-ID-SSA. - unqualified

If not GB or GE - there is a problem - abend
If not spaces - go to the exit

write to extract file

1199-exit.
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Fri Dec 07, 2007 8:03 pm
Reply with quote

I will explain why Sandy wants you to extract.

Since you want to retrieve information per category you have to go trhough the database for each category from the beginning to the end. This is because the categories are present in multiple products, scattered over the database. So for one category you have to retrieve all products until there are no more products found with this category (GE). You will receive only the products you want but the I/O is still hierarchical sequential.

For the second category you will have to reposition at the beginning of the database and perform the same. This goes for each category.

Reason is that the category in the product is not a sequence field (secondary index).
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 Dec 07, 2007 8:08 pm
Reply with quote

Exactly!!! If there are 1,000 different categories, he would need to read the database from beginning to end 1,000 times. And, what if more categories are added? The most efficient, simplistic approach is always the best. Oh - also the most easily maintainable.
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Fri Dec 07, 2007 8:17 pm
Reply with quote

icon_pai.gif
Back to top
View user's profile Send private message
girish_s

New User


Joined: 31 Jul 2007
Posts: 45
Location: india

PostPosted: Mon Dec 10, 2007 9:58 am
Reply with quote

ok guys thanks a lot for all the input that you have given... i got the concept now and i am going to implement it... and will shoot a lot of questions once i start coding.... looking forward for your suggestions and help.... icon_rolleyes.gif

thanks
girish
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 Dec 10, 2007 8:34 pm
Reply with quote

Happy Monday, girish!

The more I think about it, you should really add the customer number to your output file. The main reason is that product and order number will not be unique within the database and you may need to distinquish that.
Back to top
View user's profile Send private message
girish_s

New User


Joined: 31 Jul 2007
Posts: 45
Location: india

PostPosted: Tue Dec 11, 2007 9:50 am
Reply with quote

hi sandy,
but product id is unique in product segment and so is order id in order segment... then why should i include my customer number???
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Tue Dec 11, 2007 3:18 pm
Reply with quote

girish,

The key of product might be unique but there are more than one products belonging to one category. That's what's meant. And.......did you ever think about the next requirement of your customer? Once he got the first report he will ask you for a list showing the behaviour of the clients.

Anyway: develop your application and when you have serious IMS questions post them. We will judge them and if relevant answer; we did the redesign you build icon_wink.gif

Good luck with your quest.
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 Error while running web tool kit REXX... CLIST & REXX 5
No new posts Call program, directly from panel CLIST & REXX 9
No new posts Batch call online program, EXCI task ... CICS 3
No new posts CSQBGET - Call giving completion code... COBOL Programming 3
No new posts CICS DPL call CICS 6
Search our Forums:

Back to Top