Changing the Value of Fields

You can change the value of fields by using the EVAL command with an assignment operator (=).

The scope of the fields used in the EVAL command is defined by using the QUAL command. However, you do not need to specifically define the scope of the fields contained in an ILE RPG module because they are all of global scope.

To change the value of the field, type:

EVAL field-name = value

on the debug command line. field-name is the name of the variable that you want to change and value is an identifier, literal, or constant value that you want to assign to variable field-name. For example,

EVAL COUNTER=3

changes the value of COUNTER to 3 and shows

COUNTER=3 = 3

on the message line of the Display Module Source display.

Use the EVAL debug command to assign numeric, alphabetic, and alphanumeric data to fields. You can also use the %SUBSTR built-in function in the assignment expression.

When you assign values to a character field, the following rules apply:

Note:
Graphic fields can be assigned any of the following:

UCS-2 fields must be changed using hexadecimal constants. For example, since %UCS2('AB') = U'00410042', then to set a UCS-2 field to the UCS-2 form of 'AB' in the debugger, you would use EVAL ucs2 = X'00410042'.

Variable-length fields can be assigned using, for example, EVAL varfldname = 'abc'. This sets the data part of the field to 'abc' and the length part to 3. To set the length part without changing the data, determine the hexadecimal value of the length (for example 11 is X'000B'), and use EVAL %SUBSTR(varfldname 1 2) = X'000B'.

When assigning literals to fields, the normal RPG rules apply:

Note:
You cannot assign a figurative constant to a field using the EVAL debug command. Figurative constants are not supported by the EVAL debug command.

To change the null indicator of a variable, use the same EVAL expression in the debugger as you would use to access the variable itself, replacing the outermost name with _QRNU_NULL_name.

EVAL FLD1 = 3
EVAL _QRNU_NULL_FLD1 = '0'
 
EVAL SUBF2 = 5
EVAL _QRNU_NULL_SUBF2 = '0' 

EVAL ARR(3) = 0
EVAL _QRNU_NULL_ARR(3) = '1' 

EVAL DS3.INFO(2).SUB4 = 'some value'
EVAL _QRNU_NULL_DS3.INFO(2).SUB4 = '0' 

For more information on debugging null-capable fields, see Displaying Null-Capable Fields.

Figure 129 shows some examples of changing field values based on the source in Figure 131. Additional examples are also provided in the source debugger online help.

Figure 129. Examples of Changing the Values of Fields based on DBGEX
** Target Length = Source Length **
 > EVAL String='123456'     (6 characters)
   STRING='123456' = '123456'
 > EVAL ExportFld           (6 characters)
   EXPORTFLD = 'export'
 > EVAL String=ExportFld
   STRING=EXPORTFLD = 'export'
** Target Length < Source Length **
 > EVAL String              (6 characters)
   STRING = 'ABCDEF'
 > EVAL LastName            (10 characters)
   LASTNAME='Williamson' = 'Williamson'
 > EVAL String=LastName
   STRING=LASTNAME = 'Willia'
** Target Length > Source Length **
 > EVAL String               (6 characters)
   STRING = '123456'
 > EVAL TableA               (3 characters)
   TABLEA = 'aaa'
 > EVAL String=TableA
   STRING=TABLEA = 'aaa   '
** Using %SUBSTR **
 > EVAL BigDate
   BIGDATE = '1994-10-23'
 > EVAL String=%SUBSTR(BigDate 1 4)
   STRING=%SUBSTR(BIGDATE 1 4) = '1994  '
** Substring Target Length > Substring Source Length **
 > EVAL string = '123456'
   STRING = '123456' = '123456'
 > EVAL LastName='Williamson'
   LASTNAME='Williamson' = 'Williamson'
 > EVAL String = %SUBSTR(Lastname 1 8)
   STRING = %SUBSTR(LASTNAME 1 8) = 'Willia'
** Substring Target Length < Substring Source Length **
 > EVAL TableA
   TABLEA = 'aaa'
 > EVAL String
   STRING = '123456'
 > EVAL String=%SUBSTR(TableA 1 4)
   Substring extends beyond end of string.      ** Error **
 > EVAL String
   STRING = '123456'


[ Top of Page | Previous Page | Next Page | Contents | Index ]