Page 1 of 1

Program Bug - F COMMAND CODE

PostPosted: Sat Nov 13, 2010 3:06 pm
by Quasar
Folks -

I am coding COBOL-IMS DBIO Programs to get my hands wet. The snapshot below, shows the DBD Database Structure of the IMS Database.

DBD Database Structure :

Image

Data Stored :

001 INDUS CHEMICALS       PETERS ROAD,ROYAPETTAH        CHENNAI TN 600001   4466004332 8097415095
     00011       SODIUM, PALMITATE     15500.00     4600.00
          DEL         1500          300          450    160204
          MUM         1000          200          400    230510
     00012       METHYL ORANGE          17255.00     3230.00
          CHN         1750          350          650    140106
002 AMAR PHARMACEUTICALS  CARTER ROAD,BANDRA            MUMBAI  MH 400103   2228941365 9821065010
     00021       ACETIC ACID           10500.00     4600.00
          BAN         2500          350          850    120507
          GUR         2750          950          685    170306
          KOL         3600          550          900    050301
     00022       TINCTURE IODINE       12500.00     6800.00         

Note : The Level of indentation corresponds to the level in the IMS-DB Hierarchical Structure. First level-of-indentation : VENDRSEG Segment, Second Level-of-Indentation : ITEMSSEG, Third Level-of-indentation : STLOCSEG

Problem : I have coded a COBOL Program that PERFORMs the Following Tasks :

1. 520-ESTABLISH-PARENTAGE at the VENDOR Segment, By Executing the following CALL

     MOVE 'VENDRSEG*- ' TO UNQUALIFIED-SSA

     CALL 'CBLTDLI' USING DLI-GN                                 
                          INVENTORY-PCB-MASK                     
                          INVENTORY-VENDOR-SEGMENT               
                          UNQUALIFIED-SSA                         

After the CALL was executed, the PCB Storage Area dump was,

PCB DUMP :
  * * * * * * PCB STORAGE DUMP * * * * * *
 DBD NAME                        : INVDBD
 LAST SEGMENT LEVEL              : 01
 IMS STATUS CODE                 :
 PROCESSING OPTIONS              : G
 LAST VISITED SEGMENT            : VENDRSEG
 KEY OF THE LAST VISITED DATA    : 001
 LAST VISITED DATA KEY LENGTH    : 00003
 SEGMENT SENSITIVITY             : 00003
  * * * * * * * * * * * * * * * * * * * * *


2. 550-GOTO-LAST-LOCATION traverses through the STOCK-LOCATION Segment Occurrences, UNTIL STATUS-CODE='GE'.
     MOVE 'STLOCSEG*- ' TO UNQUALIFIED-SSA

     PERFORM UNTIL SEGMENT-OCCURRENCE-NOT-FND                     
*----------------------------------------------------------------*
        CALL 'CBLTDLI' USING DLI-GNP                             
                             INVENTORY-PCB-MASK                   
                             INVENTORY-STOCK-LOC-SEGMENT         
                             UNQUALIFIED-SSA                     
*----------------------------------------------------------------*
        MOVE IPCB-STATUS-CODE TO DLI-STATUS-CODE                 
     END-PERFORM                                                 


After the PERFORM Block was executed, the PCB Storage Area dump was,

PCB DUMP :
  * * * * * * PCB STORAGE DUMP * * * * * *
 DBD NAME                        : INVDBD
 LAST SEGMENT LEVEL              : 02
 IMS STATUS CODE                 : GE
 PROCESSING OPTIONS              : G
 LAST VISITED SEGMENT            : ITEMSSEG
 KEY OF THE LAST VISITED DATA    : 00100012CHN
 LAST VISITED DATA KEY LENGTH    : 00008
 SEGMENT SENSITIVITY             : 00003
  * * * * * * * * * * * * * * * * * * * * *


3. 570-RESET-POSITION SHOULD reset the Database Position, back to square one - the First STOCK LOCATION Segment Occurrence, by executing a GNP CALL, with Command-Code F.

     MOVE 'STLOCSEG*F ' TO UNQUALIFIED-SSA

*----------------------------------------------------------------*
     CALL 'CBLTDLI' USING DLI-GNP                                 
                          INVENTORY-PCB-MASK                     
                          INVENTORY-STOCK-LOC-SEGMENT             
                          UNQUALIFIED-SSA                         
*----------------------------------------------------------------*


After the GNP CALL with F Command-code was executed, the PCB Storage Area dump was,

PCB DUMP :
  * * * * * * PCB STORAGE DUMP * * * * * *
 DBD NAME                        : INVDBD
 LAST SEGMENT LEVEL              : 03
 IMS STATUS CODE                 :
 PROCESSING OPTIONS              : G
 LAST VISITED SEGMENT            : STLOCSEG
 KEY OF THE LAST VISITED DATA    : 00100012CHN
 LAST VISITED DATA KEY LENGTH    : 00011
 SEGMENT SENSITIVITY             : 00003
  * * * * * * * * * * * * * * * * * * * * *


When I print the contents of the Segment IO-Area, it displays the INCORRECT Output.
 LOCATION : CHN
 ON HAND  : 0001750
 REORD PT : 0000350
 ON ORDER : 0000650
 REORDER DT:140106

The correct and expected Output after resetting the Database-Pointer to the FIRST Stock-Location under the established Parent, should be 'DEL 1500 300 450 160204'.


Attached herewith, please find 1) Program Source-Code 2) Compile-Listing with the expanded Copy-books and 3) Output-Listing obtained after running the Program. Kindly advise, as to what changes should I make, to get the Expected Result.

Thank you very much.

Re: Program Bug - F COMMAND CODE

PostPosted: Sat Nov 13, 2010 5:28 pm
by NicC
You have not reset parentage to ITEMSEG=11 so you are at ITEMSEG=12 and the first STLOCSEG here is for the segment returned.

Re: Program Bug - F COMMAND CODE

PostPosted: Sat Nov 13, 2010 8:32 pm
by Quasar
Hi Nick -

I believe that would have been the case, if I had set the Parentage at ITEM SEGMENT Level. However, I am setting the Parentage at the VENDOR SEGMENT Level, and not the ITEM SEGMENT Level.

Here is the CALL, which establishes the Parentage once again -
     MOVE 'VENDRSEG*- ' TO UNQUALIFIED-SSA
*----------------------------------------------------------------*
     CALL 'CBLTDLI' USING DLI-GN                                 
                          INVENTORY-PCB-MASK                     
                          INVENTORY-VENDOR-SEGMENT               
                          UNQUALIFIED-SSA                         
*----------------------------------------------------------------*


Thanks and appreciate your help. Expecting your comments and thoughts on the same.

Re: Program Bug - F COMMAND CODE

PostPosted: Mon Nov 22, 2010 10:19 am
by abhi.d.leo
Hi Quasar,

I am not very much familiar with the IMS traversing but I agree with Nic. Though you established parentage initially but since you processed all the STLOCSEG segments under VENDRSEG using unqualified calls and STLOCSEG is at level three. I think GNP call with 'STLOCSEG*F ' will try to get first child under the current parent i.e. parent at level 2.
That is my understanding and I tried to make it by the description you have given.

I am new to IMS please correct if I am wrong.

Regards,
~Abhi

Re: Program Bug - F COMMAND CODE

PostPosted: Thu Feb 24, 2011 12:29 am
by Ed Goodman
I'm guessing you've worked around this by now...

I think that the F command code will back up to the parent of the segment, not the "parent" that you established with the call to the root. Those are two different things.

Establishing parentage is more often concerned with keeping track of where you are in a list of twin segments. In your example, the place of interest would be the ITEM segments.

The good news is that using a GU to back up to the root again will almost certainly NOT require additional I/O. The database record is still in memory, and IMS will just use the buffer.

Re: Program Bug - F COMMAND CODE

PostPosted: Sun Feb 27, 2011 5:08 pm
by Quasar
Hello Ed -

I am still confused and haven't really worked this out. I know, that the F Command Code is used to back up in the database. I do not understand, how the Parentage is lost.

Background
1. GU Call to Establish Parentage at [001 INDUS CHEMICALS] - Vendor
MOVE 'VENDRSEG*-(VENDRCOD =001)' TO VENDR-QSSA
CALL 'CBLTDLI' USING GU
                     INVENTORY-PCB-MASK
           SEGMENT-IO-AREA
           VENDR-QSSA


2. GNP Calls with unqualified SSA at STLOCSEG - Stock Segment Level 3, until Status-code='GE'
PERFORM UNTIL PCB-STATUS-CODE = 'GE'   
   MOVE 'STLOCSEG ' TO STLOC-USSA
   CALL 'CBLTDLI' USING GNP
                     INVENTORY-PCB-MASK
                     SEGMENT-IO-AREA
                     STLOC-USSA
END-PERFORM


Database Position
At this point, 3 GNP Calls were executed successfully, the 4th GNP Call sets STATUS-CODE='GE'. The below picture shows, what I feel is the established parentage, and my position in the Database. Correct me, if I am wrong.
Image

My Question
What according to you should be the result of a GNP CALL, Unqualified SSA at Level 3, STLOCSEG, with the Command Code F?
MOVE 'STLOCSEG*F ' TO STLOC-FSSA
CALL 'CBLTDLI' USING GNP
                     INVENTORY-PCB-MASK
                     SEGMENT-IO-AREA
                     STLOC-FSSA

Re: Program Bug - F COMMAND CODE

PostPosted: Sun Mar 13, 2011 7:56 am
by DFSHDC40
The GNP shouldnt alter parentage unless you have a *P ....but you have taken a GE
KFB area will show what IMS was able to do .
Why not just qualify the root in the SSA then you know exactly what will happen

Re: Program Bug - F COMMAND CODE

PostPosted: Sun Mar 13, 2011 10:46 pm
by Quasar
Hello -
Thank you everybody. It took me a couple of months, and several e-mails to understand that Parentage, is not the same as Parent.

As the F command code is for Level 3, the CALL will look at its PARENT at the LEVEL 2. It will then retrieve the First LEVEL 3 CHILD segment sub-ordinate to the current LEVEL 2 PARENT(Again, current is not the same as parentage).

PARENTAGE is still set at the ROOT Segment, and will not move to another ROOT, unless I issue another GN or GU CALL.

Thank you very much.