R command code

To retrieve the first segment occurrence in the subset, your program issues a Get call with the R command code. The R command code does not set or move the pointer. It indicates to IMS that you want to establish position on the first segment occurrence in the subset. The R command code is like the F command code, except that the R command code applies to the subset instead of to the entire segment chain.

Using the passbook account example, suppose that Bob Emery visits the bank and brings his passbook; you want to post all of the unposted transactions. Because subset pointer 1 was previously set to the first unposted transaction, your program uses the following call to retrieve that transaction:
GU     Abbbbbbb(AKEYbbbb=bA1)
       Bbbbbbbb*R1

As shown by the following figure, this call retrieves segment B5. To continue processing segments in the chain, you can issue GN calls as you would if you were not using subset pointers.

If the subset does not exist (subset pointer 1 has been set to 0), IMS returns a GE status code, and your position in the database will be immediately following the last segment in the chain. Using the passbook example, the GE status code tells you that no unposted transactions exist.
Figure 1. Retrieving the first segment in a chain of segments
begin figure description - This figure is described in the surrounding text. end figure description.

You can specify only one R command code for each SSA. If you use more than one R in a SSA, IMS returns an AJ status code to your program.

You can use R with other command codes, except F and Q. Other command codes in a SSA take effect after the R command code has been processed, and after position has been successfully established on the first segment in the subset. If you use the L and R command codes together, the last segment in the segment chain is retrieved. (If the subset pointer that was specified with the R command code, IMS returns a GE status code instead of the last segment in the segment chain.) Do not use the R and F command codes together. If you do, you will receive an AJ status code. The R command code overrides all insert rules, including LAST.