What is Field String
A field string is a type of variable, and is the equivalent of a structure in the DDIC but is defined within an ABAP/4 program. Like a structure, a field string is a series of fields grouped together under a common name. The difference lies mainly in where the definition resides. The term structure in R/3 applies only to a Data Dictionary object containing a collection of fields. The term field string applies to a collection of fields defined in an ABAP/4 program.
Two statements are usually used to define field strings in an ABAP/4 program:
- data
- tables
Using the DATA Statement to Define a Field String
A field string defined using the data statement is a modifiable data object. It can have global or local visibility. Syntax for Defining a Field String Using the DATA Statement
The following is the syntax for defining a field string using the data statement.
data: begin of fs1,
f1[(l)] [type t] [decimals d] [value 'xxx'],
f2[(l)] [type t] [decimals d] [value 'xxx'],
…
end of fs1.
or
data begin of fs1.
data f1[(l)] [type t] [decimals d] [value 'xxx'].
data f2[(l)] [type t] [decimals d] [value 'xxx'].
…
[include structure st1.]
data end of fs1.
or
data fs1 like fs2.
where:
- fs1 is the field string name.
- f1 and f2 are the fields (also called components) of the field string.
- fs2 is the name of a previously defined field string, or is the name of a table or structure in the Data Dictionary.
- (l) is the internal length specification.
- t is the data type.
- d is the number of decimal places (used only with type p).
- ‘xxx’ is a literal that supplies a default value.
- st1 is the name of a structure or table in the Data Dictionary.
Field strings follow the same rules as variables defined using the data statement. To refer to an individual component, its name must be prefixed by the name of the field string and a dash (-). For example, to write the number component of the cust_info field string, you would use the statement write cust_info-number.
The include statement is not part of the data statement; it is a separate statement. Therefore, it cannot be chained to a data statement. The statement before it must be concluded with a period.
Examples of programs that define and use field strings are shown in below
A Simple Example of a Field String Defined Using the DATA Statement
1 report ztx0802.
2 data: begin of totals_1,
3 region(7) value ‘unknown’,
4 debits(15) type p,
5 count type i,
6 end of totals_1,
7 totals_2 like totals_1.
8
9 totals_1-debits = 100.
10 totals_1-count = 10.
11 totals_2-debits = 200.
12
13 write: / totals_1-region, totals_1-debits, totals_1-count,
14 / totals_2-region, totals_2-debits, totals_2-count.
Popularity: 7% [?]






