Core Data Services (CDS) :
CDS is an infrastructure layer for defining semantically rich data models, which are represented as CDS views.
A CDS view is used to define the structure of an SQL view and represents a projection onto one or several ABAP Dictionary tables or ABAP Dictionary views.
This blog shows how to call a CDS view from another CDS view.
View (1) :
1. Create a Data Definition as shown below
CDS is an infrastructure layer for defining semantically rich data models, which are represented as CDS views.
A CDS view is used to define the structure of an SQL view and represents a projection onto one or several ABAP Dictionary tables or ABAP Dictionary views.
This blog shows how to call a CDS view from another CDS view.
View (1) :
1. Create a Data Definition as shown below
2. This view displays Material Master details based on Plant
3. Source code
efine view Zcds_View1
with parameters p_plant:WERKS_D
as select from mara as material_master
--joins
inner join marc as plant_data
on material_master.matnr = plant_data.matnr
inner join mard as stloc
on plant_data.matnr= stloc.matnr
---associations
association[1..*] to makt as material_description
on stloc.matnr = material_description.matnr
{
key material_master.matnr as Material_no,
material_master.mtart as Material_type,
plant_data.werks as Plant,
stloc.pstat as Maintenance_status,
material_description[1: ( spras = 'E' or spras = 'J' ) ].maktx as material_description,
material_master.ersda as Date_mat
}
where plant_data.werks = $parameters.p_plant
4. Save, Activate and Execute
5. Output
6. View (1) is now used in the following view
View (2) :
7. Create a Data Definition as below
8. For an example, in this view, my requirement is to display the Material Master details not only based on plant but also Maintenance status
9. So, Here I have taken two parameters
10. Press ctrl + space and select the Zcds_View1 (i.e. View (1) )
11. Fill the input parameter as shown below
12. Write a where condition to filter the view output based on our requirement as below
13. Source Code
define view Zcds_View2
with parameters p_plant2: WERKS_D,
p_main_status2: PSTAT_D
as select * from Zcds_View1( p_plant:$parameters.p_plant2) as View1
where View1.Maintenance_status = $parameters.p_main_status2
14. Save, Activate and Execute
15. Output
No comments:
Post a Comment