Use this field-level keyword to activate the Dup key on the display station keyboard. Press the Dup key when the cursor is in this input-capable field. This indicates that data for this field is to be duplicated from the record sent in the previous input operation. The actual duplication is the responsibility of your program (see Programming for the Dup key later in this section).
Refer to Appendix B, System/36 environment considerations for display files, for special considerations when specifying the DUP keyword in files that are used in the System/36 environment.
The format of the keyword is:
DUP[(response-indicator ['text'])]
You cannot specify the DUP keyword on a floating-point field (F in position 35).
You should specify a response indicator for a numeric field defined with this keyword. Hex 1Cs for numeric fields will not be returned to your buffer, but hex F0s will be returned for the remaining field positions.
Option indicators are valid for this keyword.
When you press the Dup key, the OS/400 program handles the field as follows:
In your program, you can duplicate entire fields (either character or numeric) with the following procedure:
You can also duplicate character fields one character at a time by saving them in arrays, then moving the array one character at a time and checking for the DUP key indication of hex 1C.
You can achieve duplication of numeric fields one digit at a time by defining the field as character and eventually moving it to your numeric field after the hex 1Cs have been removed. You can test whether the Dup key has been pressed:
The field will contain hex 1C at the cursor position and in the remaining positions if the Dup key has been pressed.
Restrictions on validity checking:
Validity checking keywords (CHECK, COMP, RANGE, and VALUES) can be specified with the DUP keyword. However, they have no effect if the Dup key has been pressed.
If another field in the record format fails validity checking, the OS/400 program tries to read the display again. Whether or not the workstation user keys over the DUP characters or presses the Dup key again, the DUP response indicator is still returned to your program in the on condition.
Example:
The following example shows how to specify the DUP keyword.
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 00010A R RECORD1 00020A FLDA 5 I 3 2 00030A 15 DUP(16 'FLDA was duped') 00040A FLDAH 5 2H A
FLDA is an input-capable character and hexadecimal field for which the workstation user can press the Dup key. In your program, you must test the data in FLDA to ensure that it includes only the digits 0 through 9. In RPG III, you can use the TESTN operation code. In COBOL, you can use a numeric class test. In BASIC, you can specify an ON CONV statement earlier in the program than the statement with which you assign FLDA to FLDAH. In PL/I, you can specify an ON statement with the ERROR condition earlier in the program than the statement with which you assign FLDA to FLDAH.
Field FLDAH is a hidden numeric field with the same length as FLDA. When the application program reads RECORD1 and finds response indicator 16 set off, the program moves FLDA to FLDAH and uses FLDAH (which is a numeric field). When the application program reads RECORD1 and finds response indicator 16 set on, the Dup key was pressed and FLDA contains hex 1Cs. The program uses FLDAH without changing its contents (which are the contents from the previous input received from the display device).
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.