Variables for writing CLP AS400 programming begin with the sign ‘&’ and doeclare at the beginning of the program. Variables have 6 types including: Decimal (*DEC), Character (*CHAR), Logical (*LGL), Integer (*INT), Unsigned Integer (*UINT) and Pointer (*PTR).
For example, I will make a variable with type *CHAR. The CHGVAR command is used to change the value variable.
PGM
/* DECLARE VARIABLE VAR1 WITH TYPE CHAR, LENGTH 100 AND INIT VALUE */
DCL VAR(&VAR1) TYPE(*CHAR) LEN(100) +
VALUE('Intial Value')
/* SEND PROGRAM MSG VALUE VAR1 */
SNDPGMMSG MSG(&VAR1)
/* CHANGE VALUE VAR1 */
CHGVAR VAR(&VAR1) VALUE('Hello World!')
/* SEND PROGRAM MSG NEW VALUE VAR1 */
SNDPGMMSG MSG(&VAR1)
ENDPGM

Compile and run the program:
