CDS TUTORIAL 2 : SAP HANA ABAP MADE EASY

Share

CDS Tutorial 2

Please refer below Blog for CDS tutorial 1

In this tutorial we will create CDS with parameter

  1. Right Click on the package or local object select New🡪Core Data Service🡪Data Definition give the CDS View name, and its description click on Next🡪Select the TR and click on Next
  2. Please select the template Define View with Parameter if you want to use the template else you can directly write the syntax.
  1. After Clicking Finish below code snippets will be generated let’s understand it
  1. To know more about the default annotations please refer the tutorial 1
  2. parameter_name : parameter_type🡪  parameter_name This will be the name of the input field and  parameter_type  will be the data type for that field data_source_name will be the table name.
  3. By default, parameterized CDS Views parameters will be mandatory, for system field like client, user, date, time, language by using annotation we can remove the mandatory check
  4. @Environment.systemField : #CLIENT🡪 Annotation for client
  5. @Environment.systemField : #SYSTEM_DATE🡪Annotation for date
  6. @Environment.systemField : #SYSTEM_TIME🡪Annotation for system time
  7. @Environment.systemField : #SYSTEM_LANGUAGE🡪 Annotation for system language
  8. @Environment.systemField : #USER🡪Annotation for user 
  9. If above annotation is used and field client, user, time, language, date used in parameter they can remove a mandatory.
  1. Example without annotation

Execute F8

  1. Example with annotation

Execute F8🡪Field become non mandatory and OK button is enable without any input

  1. Key word $parameters. is used in where condition for the CDS it is not mandatory to give $parameters. as an alternate : is also used