View previous topic :: View next topic
|
Author |
Message |
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
girish_s
New User
Joined: 31 Jul 2007 Posts: 45 Location: india
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
girish_s
New User
Joined: 31 Jul 2007 Posts: 45 Location: india
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
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 |
|
|
girish_s
New User
Joined: 31 Jul 2007 Posts: 45 Location: india
|
|
|
|
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 |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
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 |
|
|
girish_s
New User
Joined: 31 Jul 2007 Posts: 45 Location: india
|
|
|
|
could u please be a bit more descriptive about the extract program.. i mean, how to go about this.... |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
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 |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
Back to top |
|
|
girish_s
New User
Joined: 31 Jul 2007 Posts: 45 Location: india
|
|
|
|
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....
thanks
girish |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
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 |
|
|
girish_s
New User
Joined: 31 Jul 2007 Posts: 45 Location: india
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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
Good luck with your quest. |
|
Back to top |
|
|
|