|
1 | 1 | --- |
2 | 2 | outline: [2, 4] |
3 | 3 | --- |
4 | | -# CDS, EML |
| 4 | +# CDS |
5 | 5 |
|
6 | | -All examples in these docs work without CDS or EML. But on a recent ABAP release, you can also use these features in abap2UI5 apps. |
| 6 | +All examples in these docs work without CDS. But on a recent ABAP release, you can also use this feature in abap2UI5 apps. |
7 | 7 |
|
8 | 8 | ### ABAP CDS |
9 | 9 | ABAP Core Data Services (CDS) let you define structured views and read data straight from the database. The example below fetches sales orders from the `I_SalesOrder` view of the Virtual Data Model (VDM) and shows them in a UI5 table: |
@@ -45,85 +45,3 @@ CLASS z2ui5_cl_sample_cds IMPLEMENTATION. |
45 | 45 | ENDMETHOD. |
46 | 46 | ENDCLASS. |
47 | 47 | ``` |
48 | | - |
49 | | -### EML |
50 | | -The Entity Manipulation Language simplifies work with RAP business objects by giving a consistent way to read, create, update, and delete entities. |
51 | | - |
52 | | -#### Read |
53 | | -Use `READ ENTITIES` to fetch sales orders and show them in a UI5 table: |
54 | | -```abap |
55 | | -CLASS z2ui5_cl_sample_eml_read DEFINITION PUBLIC. |
56 | | -
|
57 | | - PUBLIC SECTION. |
58 | | - INTERFACES z2ui5_if_app. |
59 | | - DATA mt_salesorder TYPE TABLE FOR READ RESULT i_salesordertp\\salesorder. |
60 | | -
|
61 | | -ENDCLASS. |
62 | | -
|
63 | | -CLASS z2ui5_cl_sample_eml_read IMPLEMENTATION. |
64 | | - METHOD z2ui5_if_app~main. |
65 | | -
|
66 | | - IF client->check_on_init( ). |
67 | | -
|
68 | | - READ ENTITIES OF I_SalesOrderTP |
69 | | - ENTITY SalesOrder |
70 | | - ALL FIELDS WITH |
71 | | - VALUE #( ( SalesOrder = `0000000001` ) ) |
72 | | - RESULT mt_salesorder. |
73 | | -
|
74 | | - DATA(view) = z2ui5_cl_xml_view=>factory( )->page( ). |
75 | | - DATA(table) = view->table( client->_bind( mt_salesorder ) ). |
76 | | - table->columns( |
77 | | - )->column( )->text( `SalesOrder` )->get_parent( |
78 | | - )->column( )->text( `SalesOrderType` )->get_parent( |
79 | | - )->column( )->text( `SalesOrganization` ). |
80 | | -
|
81 | | - table->items( )->column_list_item( )->cells( |
82 | | - )->text( `{SALESORDER}` |
83 | | - )->text( `{SALESORDERTYPE}` |
84 | | - )->text( `{SALESORGANIZATION}` ). |
85 | | -
|
86 | | - client->view_display( view->stringify( ) ). |
87 | | -
|
88 | | - ENDIF. |
89 | | -
|
90 | | - ENDMETHOD. |
91 | | -ENDCLASS. |
92 | | -``` |
93 | | - |
94 | | -#### Modify |
95 | | -The example below creates a sales order with `MODIFY` inside an abap2UI5 app: |
96 | | - |
97 | | -```abap |
98 | | - METHOD z2ui5_if_app~main. |
99 | | -
|
100 | | - MODIFY ENTITIES OF i_salesordertp |
101 | | - ENTITY salesorder |
102 | | - CREATE |
103 | | - FIELDS ( salesordertype |
104 | | - salesorganization |
105 | | - distributionchannel |
106 | | - organizationdivision |
107 | | - soldtoparty ) |
108 | | - WITH VALUE #( ( %cid = `0001` |
109 | | - %data = VALUE #( |
110 | | - SalesOrderType = `TA` |
111 | | - SalesOrganization = `1010` |
112 | | - DistributionChannel = `10` |
113 | | - OrganizationDivision = `00` |
114 | | - SoldToParty = `0033500056` ) ) ) |
115 | | - MAPPED DATA(ls_mapped) |
116 | | - FAILED DATA(ls_failed) |
117 | | - REPORTED DATA(ls_reported_modify). |
118 | | -
|
119 | | - COMMIT ENTITIES BEGIN |
120 | | - RESPONSE OF i_salesordertp |
121 | | - FAILED DATA(ls_save_failed) |
122 | | - REPORTED DATA(ls_save_reported). |
123 | | - COMMIT ENTITIES END. |
124 | | -
|
125 | | -ENDMETHOD. |
126 | | -``` |
127 | | -Key Points: |
128 | | -- EML calls in abap2UI5 apps run outside the RAP framework, so explicit transaction commits (COMMIT ENTITIES) are needed. |
129 | | -- Restrictions inside the RAP framework, like disallowing direct calls to posting function modules or explicit commits, don't apply to abap2UI5 EML operations. You get more flexibility when handling commits and other actions. |
0 commit comments