CA IDMS IUA EIUA

Expand all | Collapse all

IDMS DMLO Question

  • 1.  IDMS DMLO Question

    Posted 06-12-2018 02:48 PM

    Hello All:

     

    I'm a fairly new DBA learning IDMS. Is there a way to retrieve a record using the DBKEY thru DMLO?



  • 2.  Re: IDMS DMLO Question

    Posted 06-12-2018 03:07 PM

    The DMLO help (PF1) is pretty good and gives you the complete syntax for all verbs, but this is what you need. 

     

    OBTAIN DB-KEY dbkey

     

    E.g. 

    OBTAIN DB-KEY 20199-002

     

    You can include record name if you wish

     

    OBTAIN record DB-KEY dbkey



  • 3.  Re: IDMS DMLO Question

    Posted 06-12-2018 03:08 PM

    example:

     

    OBTAIN EMPLOYEE DB-KEY 075010-0010



  • 4.  Re: IDMS DMLO Question

    Posted 06-13-2018 01:51 AM

    DMLO also has a facility where 10 dbkeys can be saved in a kind of scratch-pad where they can be referenced logically as KEY0 through KEY9.

     

    For example, issue these commands in sequence:

    OBTAIN FIRST EMPLOYEE WITHIN EMP-DEMO-REGION (get the first physical EMPLOYEE record)
    ACCEPT KEY0 FROM EMPLOYEE CURRENCY (save the dbkey of the first record in KEY0)
    OBTAIN LAST EMPLOYEE WITHIN EMP-DEMO-REGION (just to get a different EMPLOYEE)
    OBTAIN EMPLOYEE DB-KEY KEY0 (get the first one again)

    The most recently ACCEPTed KEYn value is shown on the right hand side of the fourth bottom line:-

     

    RECORD=EMPLOYEE STATUS=0000 DBKEY=0000075007-0001 KEY0=0000075007-0001 <=== see here
    ACCEPT KEY0 FROM EMPLOYEE CURRENCY
    -OK-
    SUBSCHEMA=EMPSS01 SCHEMA=EMPSCHM VER=0100 COL 001-080 LINE 0001 OF 0026

     

    The SHOW KEYPADS command will display the current values of the 10 KEYn values.

    Docops link:
    https://docops.ca.com/ca-idms/19/en/using/using-dml-online/ca-idms-dmlo-features
    (scroll down to "Extensive DBKEY Capabilities")



  • 5.  Re: IDMS DMLO Question

    Posted 06-13-2018 08:38 AM

    Thanks for the input..

     

    To further explain my issue

     

    Our DBKEYS are PIC S9(8) COMP SYNC. How would get the true value of that to use DMLO?  Or format it to

    20199-002 that its requiring.

     

    For example I have a value in the COMP SYNC field of 0242195992.

     

    Thanks again for everyone's input.



  • 6.  Re: IDMS DMLO Question

    Posted 06-13-2018 09:54 AM

    DB-keys are four byte values. PIC S9(8) COMP is just a convenient way to represent that in COBOL.

     

    A DB-Key will consist of a page number and a line index number. Usually the first three bytes are the page number and the last byte the line index. This is controlled by the "MAXIMUM RECORDS PER PAGE" clause on the SEGMENT. If you have this set at the default 255, then this is the case. If it is something different, then you will have to adjust this accordingly.

     

    One way to convert your 0242195992 number to a DB-Key is to divide by 256. The resulting quotient is the page number and the remainder the line index.

     

    0242195992 / 256 = 946078 remainder 24 - so your DB-Key is therefore 946078-24

     

    Another way is to convert the number to hexadecimal and convert the page and line numbers portions back to decimal individually. 

     

    0242195992 in hex is 0E6F9E18. The first three bytes are the page number and the last byte the line index. Convert these individually back to decimal.

     

    Hex value 0E6F9E is 946078 in decimal.
    Hex value 18 is 24 in decimal.

     

    Your DB-key is therefore 946078-24

     

    Again, if are not using the standard 255 records per page, this will need adjustment (and the hex way of do it is not as simple). 

     

    You can do this conversion in COBOL, but you have to be a bit careful because COBOL can truncate the raw DB-Key number as it more than 8 digits. A better way would be to call IDMSIN01 to convert the DB-Key. See the Callable services manual for details on how to do this.

     

    Hope this helps.



  • 7.  Re: IDMS DMLO Question

    Posted 06-15-2018 11:58 AM

    Hi Kevin,

     

    You don't need to convert to Page and Line index if you don't need to know that information.

     

    You can use the HEX value in DMLO to retrieve the record

    EG: Convert the numeric value 0242195992  to Hex = 0E6F9E18

    Then

    OBTAIN DB-KEY IS X'0E6F9E18'

    and that'll get the same as

    OBTAIN DB-KEY IS  946078-24

     

     

    Hope that is useful.

     

    Steve



  • 8.  Re: IDMS DMLO Question

    Posted 06-13-2018 01:06 PM

    Does the IDMSIN01 have a function to convert back the formatted DB-key? Also Can we use the formatted key instead in the program as well instead of the COMP SYNC field?



  • 9.  Re: IDMS DMLO Question

    Posted 06-13-2018 01:52 PM

    The only reason to take an internal format hex DBKEY, such as the DBKEY field in SUBSCHEMA-CTRL that is populated after any DML that accessed a record on the database,  and pass it to IDMSIN01 to convert it to decimal page:lineindex is if you need to display it in that format somewhere for human eyes to see. 

      The call to IDMSIN01 does not alter the original hex DBKEY field that you passed for conversion, so you would never need to convert it back.

      To use a DBKEY in a DML command such as OBTAIN DB-KEY dbkeyfld  you must use the internal hex format DBKEY. 

      For example after obtaining a record you MOVE DBKEY to WORK-DBKEY where WORK-DBKEY is defined S9(8) COMP just as the SUBSCHEMA-CTRL field DBKEY is defined.  Then later to get that record back to current using the saved DBKEY you can OBTAIN DB-KEY WORK-DBKEY. 



  • 10.  Re: IDMS DMLO Question

    Posted 06-13-2018 02:52 PM

    No, there is no convert back feature. The formatted DB-Key returned is just a text field and as Brian says it is really only useful for display purposes. You can't use it instead of the COMP SYNC field. 

     

     

    Converting DB-key values to separate page and line index numbers directly in COBOL can be done, but it is a bit tricky. The problem is that the 4 byte DB-Key field is defined as S9(8) COMP but the actual numbers involved can be 10 digits long and COBOL has a problem with that. The way around it to move the DB-Key field to a five byte 9(10) COMP field before doing the arithmetic on it.

     

    Converting back is even more tricky.

     

    I have examples of doing both of these functions somewhere. If you really need to do it, let me know and I'll see if I can dig them out.



  • 11.  Re: IDMS DMLO Question

    Posted 06-13-2018 04:34 PM

    A good question would be: Why is the DBKey defined as S9(8) comp? There really is no reason why it could not be X(4), or rather:

    01 DBKEY.

        03 DBKEY-PAGE PIC X(3).

        03 DBKEY-LINE PIC X(1).

    It would of course work only when you use the default 1 byte line index that supports 255 records per page.

     

    Anyway, the first 3 bytes is the page number and the last byte is the line index so in addition to the above DBKEY field, I define the following structure:

     

    01 DBKEY-CONV.

        03  DBKEY-CONV-PAGE PIC S9(8) COMP.

        03  FILLER REDEFINES DBKEY-CONV-PAGE

          05 FILLER PIC X(1)

          05 DBKEY-CONV-PAGE-X PIC X(3).

        03  DBKEY-CONV-LINE PIC S9(8) COMP.

        03  FILLER REDEFINES DBKEY-CONV-LINE.

          05 FILLER PIC X(3).

          05 DBKEY-CONV-LINE-X PIC X(1).

     

    And the code to convert it to page number and line index should be:

    MOVE LOW-VALUES TO DBKEY-CONV.

    MOVE DBKEY-PAGE TO DBKEY-CONV-PAGE- X.

    MOVE DBKEY-LINE TO DBKEY-CONV-LINE-X.

    MOVE DBKEY-CONV-PAGE TO DBKEY-PAGE-DISPLAY.

    MOVE DBKEY-CONV-LINE TO DBKEY-LINE-DISPLAY.

     

    If you need to go the other way..

     

    MOVE LOW-VALUES TO DBKEY-CONV.

    MOVE DBKEY-PAGE-DISPLAY TO DBKEY-CONV-PAGE.

    MOVE DBKEY-LINE-DISPLAY TO DBKEY-CONV-LINE.

    MOVE DBKEY-CONV-PAGE-X TO DBKEY-PAGE.

    MOVE DBKEY-CONV-LINE-X TO DBKEY-LINE.

     

    There really isn’t an easy way if you want to be able to go both ways.