enters the picture here, which simplifies ABAP programming. You can
construct a new data object (for example, using `DATA(...)`),
provide the desired type with the constructor expression and assign
- As mentioned above, the concept of [inline declarations](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abeninline_declarations.htm)
is very handy in this context. You can construct a new data object (for example, using `DATA(...)` or `FINAL(...)`), provide the desired type with the constructor expression and assign
values in one go.
- In case of [deep](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abendeep_structure_glosry.htm "Glossary Entry")
and [nested structures](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abennested_structure_glosry.htm "Glossary Entry")
or [deep tables](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abendeep_table_glosry.htm "Glossary Entry"),
the use of `VALUE` expressions is handy, too, because you can create corresponding values in place.
``` abap
"Explicit type specification needed
DATA(structure) = VALUE struc_type( a = 2 b = 'bbb' ).
```
The following examples cover:
- Populating structures and internal tables with `VALUE`
- Creating initial values (for all types possible)
- Possible additions, such as `BASE` (retaining existing content) and `LINES OF` (adding all or some lines from other internal tables; more additions are available here)
- Short form of `VALUE` constructor expressions for internal tables with structured line types
- Excursions
Note that initial values can be created by omitting the specification of
components or by providing no content within the parentheses.
```abap
"-------------- Populating structures/internal tables with VALUE --------------
``` abap
"Component b not specified, b remains initial
struc = VALUE #( a = 2 ).
"Declaring structured data type and structured data object
TYPES: BEGIN OF struc_type,
a TYPE i,
b TYPE c LENGTH 3,
END OF struc_type.
"Explicit setting of initial value for a component
struc = VALUE #( a = 1 b = value #( ) ).
DATA struc TYPE struc_type.
"The whole structure is initial
"Using VALUE constructor expression
"Note: The data type can be retrieved from the context. Then, # can
"be specified.
struc = VALUE #( a = 1 b = 'aaa' ).
"Using an inline declaration
"In the following example, the type cannot be retrieved from the
"context. Therefore, an explicit specification of the type is
"required.
DATA(struc2) = VALUE struc_type( a = 2 b = 'bbb' ).
"The following syntax is also possible (explicit data type
"specification although the type can be determined).
struc = VALUE struc_type( a = 3 b = 'ccc' ).
"Using such a VALUE constructor expression instead of, for example,
"assigning the component values individually using the component
"selector (-).
struc-a = 4.
struc-b = 'ddd'.
"Internal table
"Note the extra pair of parentheses for an individual table line.
DATA itab TYPE TABLE OF struc_type WITH EMPTY KEY.
itab = VALUE #( ( a = 5 b = 'eee' )
( a = 6 b = 'fff' ) ).
"Using such a VALUE constructor expression instead of, for example,
"APPEND statements (note the BASE addition for retaining existing
"table lines further down)
APPEND struc TO itab.
APPEND INITIAL LINE TO itab.
"Inline declaration, explicit table type specification after VALUE
TYPES itab_type TYPE TABLE OF struc_type WITH EMPTY KEY.
DATA(itab2) = VALUE itab_type( ( a = 7 b = 'ggg' )
( a = 8 b = 'hhh' ) ).
"Internal table with an elementary line type
"Unstructured line types work without component names.
@@ -986,6 +986,43 @@ MODIFY ENTITIES OF root_ent "full name of root entity
for other EML statements.
>- The [`SET FIELDS WITH`](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapmodify_entity_entities_fields.htm#!ABAP_VARIANT_4@4@) addition is available as another field specification option. However, it has limitations that you should be aware of. It can cause syntax warnings. Check the documentation. It is recommended that you use `FIELDS ... WITH` and `FROM`.
Excursion: Specifying `%control` component values in the short form of `VALUE` constructor expressions
```abap
"The following EML statement creates RAP BO instances. The BDEF derived
"type is created inline. With the FROM addition, the %control values
"must be specified explicitly. You can provide the corresponding values
"for all table lines using the short form, i.e. outiside of the inner
"parentheses, instead of individually specifying the values for each
"instance within the parentheses. In this case, the corresponding %control
"component value is assigned for all of the following table lines.
MODIFY ENTITIES OF zdemo_abap_rap_ro_m
ENTITY root
CREATE FROM VALUE #(
%control-key_field = if_abap_behv=>mk-on
%control-field1 = if_abap_behv=>mk-on
%control-field2 = if_abap_behv=>mk-on
%control-field3 = if_abap_behv=>mk-on
%control-field4 = if_abap_behv=>mk-off
( %cid = 'cid1'
key_field = 1
field1 = 'aaa'
field2 = 'bbb'
field3 = 10
field4 = 100 )
( %cid = 'cid2'
key_field = 2
field1 = 'ccc'
field2 = 'ddd'
field3 = 20
field4 = 200 ) )
MAPPED DATA(m)
FAILED DATA(f)
REPORTED DATA(r).
```
The following EML statement combines multiple operations in one EML
request. It demonstrates the use of `%cid` and
`%cid_ref`. First, two instances are created by specifying
@@ -44,7 +44,7 @@ This cheat sheet provides a high-level overview of classic dynpro topics with a
> - is not intended to encourage you to start creating classic dynpros for programming new applications.
> - does not cover all facets, techniques, and keywords in great detail.
> - is intended to cover a selection of dynpro-related topics and syntax that you may encounter in older ABAP code. If you need more information, always consult the ABAP Keyword Documentation.
> - Some of the statements described here - the ones used in the dynpro flow logic - are programmed in a special programming language. Although it looks like ABAP, it is not ABAP.
> - Some of the statements described here - the ones used in the dynpro flow logic - are programmed in a special programming language.
> - Links to the ABAP Keyword Documentation in this cheat sheet refer to the documentation for [Standard ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenstandard_abap_glosry.htm) (latest version).
## About Dynpros
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.