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
thanks for the input srihari
i have established parentage for the product segment but im still getting that error.. the gnp call is not recognising the order segment...
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
Always remember that IMS calls are based on POSITION. You can NEVER go backwards - only forwards. You can re-position yourself with a GU. The first thing I would do is to load your key for the prod segment into the prod-cat-cid. I would then issue a GU - not a GN. Behind the scenes - with a GN - even a qualified, IMS reads each prod segment until it satisfies the loaded key. With a GU, IMS looks at the CI splits to determine where the key may be. (Just in case you wanted to know). I hope you are checking for successful call when you issue the call for the prod. If you don't get it, you should have some sort of error routine for the result of your call depending on what the status code is - anything other the spaces or GE (not found) will be very bad.
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 ')'.
Once you have the parent, you will need to retrieve the child - or children. Do you have a key for the order? How do you know which order you are looking for? You cannot issue a qualified call under the root unless you know. You need to explain what you are looking for. It cannot and must not be a qualified call unless you know. Remember that the reason this is a child segment is that there can be 1 to many.
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 ('. ---------------------------you will need to make this spaces unless you know the order number.....
05 FILLER PIC X(10) VALUE 'ORDPID ='.
05 ORDR-PID-VALUE PIC 9(5).
05 FILLER PIC X VALUE ')'.
hi sandy thanks for the input it was really valuable....
i have given a qualified ssa to the order segment because i want only those product id that are present in the order segment... so the product id im getting from the product segment after the gn call i am using it in the ordr ssa and checking if that product id is also present in the order segment....
hope wat i have used is correct... and any suggestions would be appreciated...
i was able to solve that problem...
now another issue is that the gn call for the product segment is not working...
i have given a gn call for the product segment, if this call is successful then i am giving gu call for the product segment to establish parentage for the next gnp call that i have given to the order segment...
after the gnp call is satisfied it goes back to the gn call but its not fetching the next product id...
can someone help
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
Please read again what I said. Do you have a DBD map? Please show it to us. From what you said first, the order is the child of the product. If you can show us the logical view of the database that will help.
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
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
You need to do a GU for the product root - where is the key coming from? It would really help if we knew what you are trying to do. Are you reading ALL the products in the database and then retrieving their child segments? You should not be issuing 2 calls for the product segment. If you will answer these questions, then I will explain the best way to solve your problem.
SEGM NAME=PRODUCT,PARENT=CUSTOMER,BYTES=82 --ROOT
FIELD NAME=(PRODID,SEQ,U),BYTES=5,START=1,TYPE=P key
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 ?????
How are you loading a key for this child segment?
SEGM NAME=ORD,PARENT=PRODUCT,BYTES=72 CHILD of Product
FIELD NAME=(ORDID,SEQ,U),BYTES=5,START=1,TYPE=P key
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
thanks for that input sandy...
i am using the prodcaid as the key to the ssa that i am using for the gn call. now one prodcaid(product category id) can have more than i prodid(product id)... so the first prodid corresponding to the prodcaid is got from the gn call from the product segment....
now i need to check whether this prodid exists in the order segment.. so i am passing this prodid to the ordr ssa and using a gnp call to check if it is present by using ordpid field.. if the call is successfull then i retrieve the corresponding ordtot and print this.....
now after we are done with the first prodid i need to get the second prodid that matches the prodcaid from the product segment... this is not happening...
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
Well, your first problem is that you are using a qualified SSA for both segments. A qualified SSA is used when you already know the key value. Using an unqualified SSA to read sequentially thru the database is the correct avenue.
I am using the prodcaid FIELD NAME=PRODCAID,BYTES=5,START=36,TYPE=P - This field is NOT a key field.
Also, you cannot use a qualified SSA to get the child ORDER segment. There can be several ORDER segments under that product.
So, lets make sure we are on the same page. You need to retrieve all products that have a specific category on their segment - correct?
Then you need to retrieve all order segments beneath that product printing the order totalsthe - correct? You realize that there could be hundreds of order segments beneath that product - correct?
hi sandy,
your understanding of the problem statement is right... and as you said the procaid is not the key field.. so how do i go about it..
this is where i am stuck...
Girsh.....If I understood your requirement correctly, you can try this out.
1) Issue GU call with unqualified SSA for Product segment
2) check if it contains the Prodcaid, if it presents then do a GNP for Order segment processing.
3) Do a GN to proceed with the next product segment.
1) Issue GU call with unqualified SSA for Product segment
2) check if it contains the Prodcaid
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...
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
OK - I will get you started. But - you really need to think about the ORDER segment. Did they want each ORDTOT printed or do they want to see the GRAND TOTAL of ALL orders? This is how I would do it - this is the way I used to do it. You will be sequentially reading the root segments - checking if they match the category - then retrieving the child order segments - once they are retrieved - you will use the qualified GU to re-position yourself back on the prod segment - then you will continue with going thru the database.
I will give you an overview and you will do the coding - unless you really get stuck. Then we will help - OK?
perform 1000-gn-prod thru 1999-exit until GB.
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.
Check the category to see if it matches - if not go to 1999-exit.
If it does - move '(' to prod-left-paren. Move the PRODID from the segment to PROD-ID of the PROD-ID-SSA.
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 root.
1999-exit.
1100-get-orders.
CALL 'CBLTDLI' USING DLI-GN
DB-PCB-MASK
ORDR-DB-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
Print and/or accumulate the order total......
1199-exit.
01 PROD-ID-SSA.
05 filler PIC X(9) VALUE 'PRODUCT '.
05 prod-left-paren Pic x.
05 FILLER PIC X(10) VALUE 'PRODCAID ='.
05 PROD-ID PIC 9(5). - make this numeric
05 FILLER PIC X VALUE ')'.
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... i will take all the inputs that you have given and try coding... hope it works...
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
SEGM NAME=PRODUCT,PARENT=CUSTOMER,BYTES=82
Do you need the customer for anything? This was just brought to my attention. Going thru the database with an unqualified SSA for segment type will work - GN for Product. However, to reposition yourself you will need the key to the customer segment which is really the ROOT - NOT the Product.
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
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
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.
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
I opened a new top (GNP call revised) because the requirements kept changing and this topic is hard to follow. A fresh start for this topic. Proceed in the revised topic.