|
1 | 1 | --- |
2 | 2 | outline: [2, 4] |
3 | 3 | --- |
4 | | -# RTTI |
| 4 | +# S-RTTI |
5 | 5 |
|
6 | | -<i class="fa-brands fa-github"></i> [S-RTTI Project on GitHub](https://github.com/sandraros/S-RTTI) |
| 6 | +In abap2UI5, you don’t necessarily need to define your data model at design time. Instead, you can work with generic data references and apply typing dynamically at runtime based on your program logic. This is particularly useful for scenarios like tables, where different columns and table types may be displayed depending on user input. |
7 | 7 |
|
8 | | -In abap2UI5, you don’t necessarily need to type your data model at design time, just work with generic data references and apply typing at runtime based on your program logic. This is for example useful for tables where, depending on user input, you may want to display different columns.<br> |
| 8 | +abap2UI5 serializes app instances to ensure stateless behavior in client communication. However, SAP’s standard transformation features are limited and do not support data references with local types created at runtime. To overcome this limitation, the project [S-RTTI](https://github.com/sandraros/S-RTTI) is integrated into abap2UI5 under the `z2ui5` namespace. |
9 | 9 |
|
10 | | -abap2UI5 serializes your app instances to ensure stateless behavior in client communication. The SAP standard serialization features are limited; they do not support data references with local types created at runtime. If you encounter problems, just install the fantastic project [S-RTTI](https://github.com/sandraros/S-RTTI) filling this gap. |
11 | 10 |
|
12 | | -#### Basic |
13 | | -Fully typed data at design time, it works out of the box: |
| 11 | +#### Standard Transformation |
| 12 | +With fully typed data at design time, the standard SAP transformation works out of the box: |
14 | 13 |
|
15 | 14 | ```abap |
16 | 15 | CLASS z2ui5_cl_app DEFINITION PUBLIC. |
@@ -47,8 +46,8 @@ CLASS z2ui5_cl_app IMPLEMENTATION. |
47 | 46 | ENDCLASS. |
48 | 47 | ``` |
49 | 48 |
|
50 | | -#### Generic Data Reference (local type) |
51 | | -Data typed at runtime with local types; this only works with S-RTTI: |
| 49 | +#### Transformation with S-RTTI |
| 50 | +When working with data typed dynamically at runtime using local types, S-RTTI is required: |
52 | 51 | ```abap |
53 | 52 | CLASS z2ui5_cl_app DEFINITION PUBLIC. |
54 | 53 |
|
@@ -82,3 +81,11 @@ CLASS z2ui5_cl_app IMPLEMENTATION. |
82 | 81 | ENDCLASS. |
83 | 82 |
|
84 | 83 | ``` |
| 84 | +#### Functionality |
| 85 | +With generic types, the standard transformation throws an error. abap2UI5 resolves this issue by looping over all attributes and applying a workaround: |
| 86 | +- For each generic attribute, a separate serialization is performed using S-RTTI beforehand. |
| 87 | +- The data is stored in a separate table. |
| 88 | +- The variable is initialized, and the standard SAP transformation is called again. |
| 89 | +- On the way back, the object is recreated, and the table content is deserialized back into the attributes. |
| 90 | +- |
| 91 | +This approach ensures compatibility with dynamic types while maintaining a robust transformation process. This process works in the background and independently of the two app implementations above. |
0 commit comments