You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following exercise you will learn how to use the new Core Data Services (CDS) tools in ABAP in Eclipse. CDS is an extension of the ABAP Dictionary that allows you to define semantically rich data models in the database and to use these data models in your ABAP programs. CDS is a central part of enabling code push-down in ABAP applications.
18
18
You will add the following:
19
+
19
20
- SELECT statement
20
21
- CASE statement
21
22
- WHERE clause
23
+
22
24
You can find more information about CDS in the [ABAP keyword documentation](https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abencds.htm) and the [SAP Community](https://www.sap.com/community/topic/abap.html).
23
25
24
26
---
25
27
[ACCORDION-BEGIN [Step 1: ](Create a CDS view)]
26
-
1. In the context menu of your package choose **New** and then choose **Other ABAP Repository Object**.
> Note: The SQL view name is the internal/technical name of the view which will be created in the database. `Z_Invoice_Items` is the name of the CDS view which provides enhanced view-building capabilities in ABAP. You should always use the CDS view name in your ABAP applications.
65
56
66
57
67
58
[ACCORDION-END]
68
59
69
60
[ACCORDION-BEGIN [Step 3: ](Edit the SELECT statement)]
70
-
71
61
You will now insert the fields `currency_code` and `gross_amount` into the SELECT list as follows:
72
62
73
-
1. Trigger code completion in the SELECT list (by clicking on the SELECT list and using keyboard shortcut **CTRL+SPACE**), then double click on the entry **Insert all elements - template**. All the elements (fields and associations) of the underlying data source are inserted into the SELECT list.
74
-
75
-
2. Remove all the elements in the SELECT list which were inserted by the code completion apart from `currency_code` and `gross_amount`. Remember to separate the elements in the SELECT statement with a comma.
1. Trigger code completion in the SELECT list (by clicking on the SELECT list and using keyboard shortcut **CTRL+SPACE**), then double click on the entry **Insert all elements - template**. All the elements (fields and associations) of the underlying data source are inserted into the SELECT list.
64
+
2. Remove all the elements in the SELECT list which were inserted by the code completion apart from `currency_code` and `gross_amount`. Remember to separate the elements in the SELECT statement with a comma.
[ACCORDION-BEGIN [Step 4: ](Use an existing CDS association)]
71
+
You will now model the relationships between data sources by using some existing CDS associations. You can use associations in path expressions to access elements (fields and associations) in related data sources without specifying JOIN conditions. You can now display the element info by positioning the cursor on the data source name **`sepm_sddl_so_invoice_item`** and choosing **F2**.
85
72
86
-
You will now model the relationships between data sources by using some CDS associations. You can use associations in path expressions to access elements (fields and associations) in related data sources without specifying JOIN conditions. You can now display the element info by positioning the cursor on the data source name **`sepm_sddl_so_invoice_item`** and choosing **F2**.
87
-
88
-
1. To see the related data sources that can be accessed using associations, scroll down.
89
-
90
-
2. To see details about the target data source of the association header, choose the hyperlink **`sepm_sddl_so_invoice_header`**
91
-
73
+
To see the related data sources that can be accessed using associations, scroll down.
74
+
To see details about the target data source of the association header, choose the hyperlink **`sepm_sddl_so_invoice_header`**.
[ACCORDION-BEGIN [Step 5: ](Add Fields from existing associations)]
98
-
79
+
[ACCORDION-BEGIN [Step 5: ](Add fields from existing associations)]
99
80
You will now add fields of related data sources to the SELECT list of `Z_Invoice_Items`, using the associations in path expressions. Each element in the path expression must be separated by a period.
100
81
101
-
1. Add the `company_name` of the business partner to the SELECT list using the associations **header** and **buyer** in a path expression
102
-
2. You will get an error, "Field header must be included in the selection list together with field `SEPM_SDDL_SO_INVOICE_ITEM.SALES_ORDER_INVOICE_KEY`". Resolve this by adding the field **`sepm_sddl_so_invoice_item.sales_order_invoice_key`** to the Select statement.
103
-
3. Add the `payment_status` from the invoice header to the SELECT list using the association **header**
1. Add the `company_name` of the business partner to the SELECT list using the associations **header** and **buyer** in a path expression
83
+
2. You will get an error, "Field header must be included in the selection list together with field `SEPM_SDDL_SO_INVOICE_ITEM.SALES_ORDER_INVOICE_KEY`". Resolve this by adding the field **`sepm_sddl_so_invoice_item.sales_order_invoice_key`** to the Select statement.
84
+
3. Add the `payment_status` from the invoice header to the SELECT list using the association **header**
0 commit comments