This chapter contains these topics:
A user index is an object that will:
Store data
Allow search functions
Automatically sort data based on its value
When you use a user index you must have a key to retrieve the information placed in the index. The key must be unique and you can only retrieve data using the key in ascending or descending order.
When you enter data into a user index, it is placed in order according to its key value.
A user index can store up to 4 gigabytes of information. Each key and record within a user index can be 1 to 999 bytes long.
Note:
To see the contents of a user index, enter the command DMPOBJ (Dump Object) from any command line after the index has been loaded. You should place your user indices in library QTEMP so that it will be deleted automatically when you sign off.To work with user indices, perform the following tasks:
Create a User Index
Write to a User Index
Retrieve from a User Index
When you load data into your user index, it is automatically sorted for you. Based on your key for the index, the information is arranged according to its value. This will help streamline table searches, cross referencing, and the ordering of data.
The size flexibility of a user index is much better than an array because arrays have a fixed size. A user index is only as big as the information it contains at one time. User indices expand as you add data to them.
For example: @EX 999 30
The array @EX has a fixed size of approximately 3 kilobytes. Each record must be 30 bytes long and up to 999 records can be loaded. If you have 300 records loaded into @EX, you will waste approximately 2 kilobytes. On the other hand, if you have 1500 records to load, the program will error when record number 1000 is loaded. A user index would be able to accommodate both situations.
A user index is able to retrieve records faster than an array.
Although a user index may expand to hold more records, it will not contract when records are removed. If you load 100 records into a user index and then remove 50 of them, the user index will remain at the 100 record level size.
You may retrieve data from a user index in ascending order or descending order. When data is loaded into a user index, it is loaded in ascending order. This does not restrict you to retrieving it in this order.
A user index stores data and allows you to retrieve it by a key, which must be unique. The data it stores is made up of a data structure that consists of several fields that you wish to store. A user index is capable of expanding when you add data to it.
JD Edwards World leaves the first byte in the user index blank for clearing purposes.
When using a user index you can create it, add data to it, remove data from it, and delete it.
User indices, like user spaces, should be created in your QTEMP library so you do not have to worry about deleting them.
Before you actually create a user index, check to see if one already exists using the JD Edwards World program J98CKOBJ.
PARM (Length) | Description |
---|---|
PSOBJ (10) | The name of your user index. |
PSLIB (10) | The name of the library in which you wish to check for the existence of the user index. Generally, this is *LIBL to check all of the libraries in the library list. |
PSTYPE (8) | The type of object you are checking for. Generally, this is *USRIDX for a user index. |
PSMID (10) | The member if you are checking for a database file. Generally, this is *NONE. |
PSAUT (10) | The authority or authorization list to be checked for the user. Generally, this is *NONE. |
If a user index exists, clear it and write your new information over the old.
Figure 25-3 Clearing All Records with a Blank Key
Note:
The above code deletes (clears) every record with a key of *Blank in position one.If the user index did not exist, you can now create your user index.
Use the QUSCRTUI (Create User Index) command.
PARM (Length) | Description |
---|---|
#IDNAM (20) | The first 10 characters contain your user index name, and the second 10 characters contain the name of the library where your user index is located. Remember to place your user index in library QTEMP to automatically delete your index when you sign off. |
#IDATT (10) | The extended attribute of your user index. You may use this field to classify your user index. For example, JD Edwards World uses this field to label all of the user indexes with JD Edwards World. |
#IDENT (1) | Whether the records you are loading into your user index are Fixed-length (F) or Variable-length (V). Generally, this is set to 'F'. |
#IDLEN (4 binary) | The length of the records to be entered into your user index. For fixed-length records valid values are 1 to 999. For variable-length records, enter 0 for a key length of 1 to 120, or 1 for a key length of 1 to 999. |
#IDINS (1) | Whether you are loading your user index by a key or not. Generally, this is set to 1 to load your index by a key. A value of 0 means you are not loading your index by a key. |
#IDKEY (4 binary) | The length of your key. The first byte in your record must be the beginning of your key. The values are 1 to 999 or 0 for no key. |
#IDUPD (1) | Whether or not the data in your user index will be immediately updated. Each data change to your index is written to auxiliary storage. The values are 0 for no immediate update or 1 for immediate update. Generally, this is 0. |
#IDOPT (1) | The type of access in which to optimize your index. The values are 0 to optimize for random references or 1 to optimize for sequential references. Generally, this is 1. |
#SPAUT (10) | The authority you give users to your user index. Generally, this is *ALL. |
#SPTXT (50) | The text description of your user index. |
Note:
You may want to define data structures containing some of the information required for the parameters to avoid having to enter values. The user index name, record length, key length, and user index text are good examples.JD Edwards World provides an external program called User Index Server (X00IDX) to manipulate data for user index entries.
PARM (Length) | Description |
---|---|
#0XNAM (20) | The first 10 characters contain your user index name, and the second 10 characters contain the name of the library where your user index is located. Remember to place your user index in library QTEMP to automatically delete you index when you sign off. |
#0XACT (1) | The action you want to perform on your user index. The valid values are:
I – Inquire A – Add C – Change D – Delete |
#0XRUL (2) | The rule used to search your user index depending on the action to be performed. The valid values are:
EQ – Equal to GT – Greater than LT – Less than GE – Greater than or Equal to LE – Less than or Equal to |
#0XKLN (3,0) | The length of your key. The first byte in your record must be the beginning of your key. The values are 1 to 999 or 0 for no key. |
#0XKEY (120) | The fields that make up the key to your user index. *FIRST (first record) and *LAST (last record) are allowed. |
#0XRLN (3,0) | The length of your record. The values are 1 to 999. |
#0XREC (120) | The record you are entering or deleting from your user index. This parameter will also receive the record when you inquire on your user index. |
#0XSTA (1) | The error status of the manipulation. The possible values are:
0 – Record found 1 – Record not found, not authorized 8 – Rule invalid 9 – Error on action |
The records added to your user index will appear in ascending order.
For example: You created a user index to keep track of your ice cream sales. Each record within your user index contains the total sales amount, item, item description, and cost center. The key for your user index consists of total sales amount and item (remember the key must be unique).
The following records are to be loaded into your user index:
Total | Sales Item | Description | Cost Center |
---|---|---|---|
$ 500.00 | CHO | Chocolate | Denver |
$ 250.00 | STR | Strawberry | Denver |
$ 750.00 | C&C | Cookies & Cream | Denver |
$1200.00 | VAN | Vanilla | Denver |
$ 400.00 | ROC | Rocky Road | Denver |
Because the key to your user index is total sales amount and item, the records will be entered into your index in ascending order by total sales amount first, then item. So your user index will look like this:
Total | Sales Item | Description | Cost Center |
---|---|---|---|
$ 250.00 | STR | Strawberry | Denver |
$ 400.00 | ROC | Rocky Road | Denver |
$ 500.00 | CHO | Chocolate | Denver |
$ 750.00 | C&C | Cookies & Cream | Denver |
$1200.00 | VAN | Vanilla | Denver |
You can retrieve data in ascending or descending order.
To retrieve data in Ascending Order
Use the User Index Server (X00IDX).
Set the Action parm to inquire (I).
Set Rule to Equal to (EQ).
Set the Key to the first record (*FIRST).
Figure 25-6 User Index Server Set to Retrieve Data in Ascending Order
To retrieve the next record, load the key with the current record's values and change your rule to "GT".
Figure 25-7 User Index Server Set to Retrieve the Next Record
To retrieve data in descending order
Use the User Index Server (X00IDX).
Set the Action parm to inquire (I).
Set Rule to Equal to (EQ).
Set the Key to the first record (*LAST).
Figure 25-8 User Index Server Set to Retrieve Data in Descending Order
To retrieve the next record, load the key with the current record's values and change your rule to "LT".
Figure 25-9 User Index Server Set to Retrieve the Next Record
Figure 25-10 User Index Server report (part 1)
Figure 25-11 User Index Server report (part 2)
Figure 25-12 User Index Server report (part 3)
Figure 25-13 User Index Server report (part 4)
Figure 25-14 User Index Server report (part 5)
Figure 25-15 User Index Server report (part 6)
Figure 25-16 User Index Server report (part 7)
Figure 25-17 User Index Server report (part 8)
Figure 25-18 User Index Server report (part 9)
Figure 25-19 User Index Server report (part 10)
Figure 25-20 User Index Server report (part 11)
Figure 25-21 User Index Server report (part 12)
Figure 25-22 User Index Server report (part 13)
Figure 25-23 User Index Server report (part 14)
Figure 25-24 User Index Server report (part 15)
Figure 25-25 User Index Server report (part 16)
Figure 25-26 User Index Server report (part 17)
Figure 25-27 User Index Server report (part 18)
Figure 25-28 User Index Server report (part 19)