Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

GNP call (revised by Bitneuker)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> IMS DB/DC
View previous topic :: :: View next topic  
Author Message
Bitneuker

CICS Moderator


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

PostPosted: Thu Dec 06, 2007 7:31 pm    Post subject: GNP call (revised by Bitneuker)
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:33 pm    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:37 pm    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:40 pm    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:40 pm    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 7:42 pm    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 9:08 pm    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Dec 06, 2007 11:35 pm    Post subject:
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    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Fri Dec 07, 2007 4:31 pm    Post subject:
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    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Fri Dec 07, 2007 5:19 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Fri Dec 07, 2007 8:03 pm    Post subject:
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    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> IMS DB/DC All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Cobol EZASOKET call to SETSOCKOPT fails Andi1982 COBOL Programming 6 Thu Oct 06, 2016 7:12 pm
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Is possible to call subprogram from c... cmsmoon COBOL Programming 3 Fri Aug 05, 2016 6:46 pm
No new posts PCOMM macro to call another PCOMM macro boyti ko All Other Mainframe Topics 4 Tue Jul 12, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us