abap char variable
In ABAP, a character variable is declared using the CHAR
keyword. The CHAR
type is used to store a fixed-length string with a specific number of characters. The syntax for declaring a character variable is as follows:
DATA variable_name TYPE CHAR(length).
Here, variable_name
is the name of the variable, and length
specifies the number of characters that the variable can hold. For example, if you want to declare a character variable named name
that can hold up to 20 characters, you would use the following statement:
DATA name TYPE CHAR(20).
You can assign a value to a character variable using the MOVE
statement. For example, to assign the value "John" to the name
variable, you would use the following statement:
MOVE 'John' TO name.
To access the value stored in a character variable, you can simply use the variable name in your ABAP code. For example, to display the value of the name
variable, you can use the WRITE
statement as follows:
WRITE name.
This will output the value of the name
variable, in this case, "John". Character variables can be used in various ABAP operations, such as string manipulation, concatenation, and comparisons.