Technical Articles
Custom Reusable Elements, Custom Business Objects and Data Source Extension to add fields in standard VDM
Purpose of this blog
This blog explains how to add the custom field to standard VDM using
- Custom Reusable Elements,
- Custom Business Objects
- Data Source Extensions of Custom Fields
- Custom CDS View
- Extend View
using the example scenarios.
The reason why I write this blog is it should be common request to add fields to analytical Fiori apps and Key User Tools in this blog should help effectively. But I am afraid not so many people woudl have been aware of the effectiveness of the tools. So, In the blog, I want to show it by explaining based on the typical cases.
Values:
- With Data Source Extension of Custom Fields, the attribute of the master view which has been associated to the CUBE view can be added.
- With Custom Reusable Elements, Custom Code List can be created in which the code and description can be created manually or by uploading csv file. (No effort to create custom UI to update code and key).
- With Custom Business Objects, Custom Business Object can be created in which data can be stored. It works as a kind of custom table. Fiori Elements List Report can be created using it as the source in which data can be maintained.
- With Custom CDS Views, a Custom CDS View can be created. Custom Code List and Custom Business Object can be used as the source.
- CDS View is generated or extended internally when creating objects with those tools. It is reused in the custom CDS View created with ABAP Development Tools(ADT).
- With Extend View, the fields can be added with ADT, and object created with the tools above can be reused.
Sample Scenarios
Sample scenario1
Create the custom CDS View in which Country and Region are added to CUBE View I_GLAccountLineItemCube.
- Data Source Extension: To add Company, an attribute of I_CompanyCode to I_GLAccountLineItemCube.
- Custom Reusable Elements: To create Custom Code List of Regions.
- Custom Business Objects: To create the mapping View between Country and Region in which the Custom Code List of Region can be used.
- Custom CDS View: To create custom CDS View in which the Custom Business Object is associated to Country in I_GLAccountLineItemCube.
Sample scenario2
Sample scenario 2 is the other way to add the same fields.
Firstly, create the Custom Code List and Custom Business Object created as the same way as in scenario (2, 3), and then
- Custom CDS View: To create custom CDS View in which the Custom Business Object is associated to Country in I_CompanyCode
- Extend View: To add Country and Region to I_GLAccountLineItemCube.
it is not possible to add fields in CompanyCode with Custom Fields as it is based on Customizing table (T*) so it is not possible to add fields in it, so that Business Context for those objects are not there in Custom Fields, e.g. Plant. In the case, mapping table has to be used to add fiedls. This is the reason why Custom Businss Object is created in this scenario.
Scenario1:
1. Data Source Extension: To add Company, an attribute of I_CompanyCode to I_GLAccountLineItemCube.
After launching Custom Fields and go to Data Source Extension tab, select Country/Region Key in Custom Code is added and renamed to Country.
Internally, Extend View is generated for I_GLAccountLineItemCube.
See the blog more about Data Source Extensions.
2. Custom Reusable Elements: To create Custom Code List of Region.
Launch Custom Reusable Elements.
The Code and Description can be created manually.
Or they can be uploaded from csv file.
Browse the file.
(Use the file layout downloaded from it.)
Codes and Descriptions are added. Push “Save and Publish”.
The custom Code List is created.
Generated CDS View.: ZZ1_REGION
Table: ZZ1_542DFB639D0D
Records in the table
Generated CDS View.: ZZ1_TV_REGION
Table: ZZ1_A0FD909624BA
3. Custom Business Objects: To create the mapping View between Country and Region in which the Custom Code List of Region can be used.
Custom Business Objects is launched.
Tab General Information
Name: Name of the object
Check
Determination and Validation: Uncheck (when checked, the logic of Determination and Validation can be created, but in this scenario, it is not necessary). See more about Determination and Validation in the blog.
Back End Service: Check (To create OData Service).
Can Be Associated: Unchecked. (When checked, this Custom Business Object can be used in Custom Fields).
System Administrative Data: Checked (to add Created On/Created By/Last Updated On/Last Updated By in the business object).
Change Document: Checked (to generate change documents).
Tab Nodes:
Nothing is added.
Tab Fields:
Add fields as below.
Country: Type Text, set as key.
Region: Type Code List, set ZZ1_REGION as the Code List in the right side.
Tab: Logic
Nothing is changed. And push Publish.
CDS View is created.
OData is published.
@OData.publish: true
Transactional Processing is enabled with the following annotations.
@ObjectModel.transactionalProcessingEnabled: true
@ObjectModel.createEnabled: true
@ObjectModel.deleteEnabled: true
@ObjectModel.updateEnabled: true
Business Object is created.
Constants Interface: Z1_IF_ZZ1_COUNTRYREGION_C
Go to the ROOT node.
Node Overview
Alternative Keys
Properties
Associations
Actions
Determinations
Validations
Authorizations
The generated OData is added with Transaction /n/IWFND/MAINT_SERVICE. (ZZ1_COUNTRYREGION_CDS)
With Business Application Studio in BTP, Fiori Elements List Report app can be created using the generated OData Service. See more in the guide.
Create button is added for transactional OData Service in the List Report as below.
The code and description can be added.
4. Custom CDS View: To create custom CDS View in which the Custom Business Object is associated to Country in I_GLAccountLineItemCube.
Primary Data Source: I_GLAccountLineItemCube
Associated Data Source: ZZ1_COUNTRYREGION
Set Join Condition.
SAP_UUID is custom Business Object has to be added in the Join Condition as is the key. Both the Data Source Field and Value uses the same field: _ZZ1_COUNTRYREGION.SAP_UUID.
ZZ1_Country (added with Data Source Extension) and Region (from ZZ1_COUNTRYREGION), and other necessary fields are added.
Publish it.
Custom CDS View is generated.
ZZ1_COUNTRYREGION is associated.
ZZ1_Country1, _ZZ1_Country1 and _ZZ1_COUNTRYREGION.Region and _ZZ1_COUNTRYREGION._Region are added in the CDS View.
Run the Custom CDS View in which Country and Region are added.
SQL View name of the custom CDS View: ZZ1_6F75BC4E564A
Query: 2CZZ1_6F75BC4E564A/!2CZZ1_6F75BC4E564A
(2C<SQL View name of CUBE View>/!2C<SQL View name of CUBE View>
Result: Country and Region are available.
It is now possible to create a custom query on top of the view.
5. Custom CDS View: To create custom CDS View in which the Custom Business Object is associated to Country in I_CompanyCode
Custom CDS View: ZZ1_CompanyExt
DataSource
Primary Source: I_CompanyCode
Associated Data Source: ZZ1_COUNTRYREGION
Keys
I_CompanyCode.Country = ZZ1_COUNTRYREGION.Country
ZZ1_COUNTRYREGION.SAP_UUID = ZZ1_COUNTRYREGION.SAP_UUID
Elements:
Element properties:
And publish it.
6. Extend View: To add Country and Region to I_GLAccountLineItemCube.
Extend View: ZX_GLAccountLineItemCube1
@AbapCatalog.sqlViewAppendName: 'ZXGLACCT1'
@EndUserText.label: 'Extend GLAccountLineItemCube1'
extend view I_GLAccountLineItemCube with ZX_GLAccountLineItemCube1
association[0..1] to ZZ1_CompanyExt as _ZZ1_CompanyExt on _ZZ1_CompanyExt.CompanyCode = $projection.companycode
{
@EndUserText.label: 'Country'
@ObjectModel.foreignKey.association: '_Country'
_ZZ1_CompanyExt.Country,
@EndUserText.label: 'Region'
@ObjectModel.foreignKey.association: '_REGION'
_ZZ1_CompanyExt.Region,
_ZZ1_CompanyExt._Country,
_ZZ1_CompanyExt._Region
}
Like this case, Custom CDS Views generated with the tools can be used in the custom CDS View with ADT.
it would take longer time for activation. See more about Extend View in the blog.
Now County and Region are added in I_GLAccountLineItemCube.
Run the Custom CDS View in which Country and Region is added.
SQL View name of the custom CDS View: IFIGLLITMCUBE
Query: 2CIFIGLLITMCUBE/!2C IFIGLLITMCUBE
Country and Region are available.
Custom Library (Class) with Custom Reusable Elements
- With Custom Reusable Elements, The Custom Library (Class) can be created which is available In, e.g. Custom Logic or Custom Business Object.
Class ZZ1_USER_DETAILS, Structure TS_USER_DETAIL and Method GET_DETAILS_BY_ID are created.
Structure: TS_USER_DETAIL
Method: GET_DETAILS_BY_ID
Parameters
Parameter ID USERDETAIL uses the structure TS_USER_DETAIL
Implementation
The Class is generated internally.
Transaction SE24.
Thanks!
Very nice blog.
Perhaps, you may help me. My customer has created a Custom field. I have created a custom field. I want to check this field (with the values of its table) in the custom logic Validate Customer Badi. But it's not allowed. I've tried to add a class in Custom Reusable Elements bu I can't access directly to the table ZZ1_F19F.... neither if I create a CDS for this table
Any suggestion for me ?
I've found the solution. You can do a select on the table ZZ1_SPECFIELD_V and not the code internal code