Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

What a CDS-view can do for you | sitNL 2016

3,280 views

Published on

Ben Meijs / CTAC

Published in: Business
  • Login to see the comments

What a CDS-view can do for you | sitNL 2016

  1. 1. © Ctac - Better Business. Ctac Cloud SITNL 2016 What a CDS-view can do for You Practical use of CDS Views on ECC EHP7 on HANA - tricks & tips Ben Meijs
  2. 2. © Ctac - Better Business. Ctac Cloud 2 ABOUT ME
  3. 3. © Ctac - Better Business. Ctac Cloud 3 CDS Quick RECAP Use Case – BW Extract Unit Conversions Date defaults/ functions Use Case – Report Texts in one go Tips Outlook
  4. 4. © Ctac - Better Business. Ctac Cloud 4 What is a CDS?
  5. 5. © Ctac - Better Business. Ctac Cloud 6 Core Data Services – it’s an ABAPPER thing! • Just like defining an Database View in SE11, but with a lot more options: • INNER and OUTER JOINS • ASSOCIATIONS • UNION • Built-in functions • Parameters • Annotations => DB-viewname, client dependency, buffering. generating Odata-services and BOPF-artifacts • How do you define a CDS View? • In ECLIPSE! • Using a Data Definition Language • Generates a Database View • You use a CDS-view • With Open SQL • In other CDS-view
  6. 6. © Ctac - Better Business. Ctac Cloud 7 Creating a CDS with a JOIN - example
  7. 7. © Ctac - Better Business. Ctac Cloud 8 CDS – options and Built-in functions
  8. 8. © Ctac - Better Business. Ctac Cloud 9 CDS – options and Built-in functions
  9. 9. © Ctac - Better Business. Ctac Cloud 10 Creating a CDS with a JOIN - example
  10. 10. © Ctac - Better Business. Ctac Cloud 11 CDS Quick RECAP Use Case – BW Extract Unit Conversions Date defaults/ functions Use Case – Report Texts in one go Tips Outlook
  11. 11. © Ctac - Better Business. Ctac Cloud 12 Use Case – CDS view for BW extractor without using any ABAP Question: is it possible to define a fast BW extractor in an ECC-on-HANA environment, without any ABAP-statement? • Selection of sales orders, purchase orders, inbound and outbound deliveries within a timeframe of next 6 weeks; • Quantities in base unit of measure (MARA-MEINS); • Aggregate this data on Material Number, Plant, Week number; • Make it as fast as possible; Technical Challenges: • Material Unit conversion (every quantity in base unit of measure MARA-MEINS); • No system variables in CDS on WAS740; • No calculations possible with date fields in CDS-context on WAS740; Answer: Yes, it is possible. A weekly run including all the necessary steps on BW now only takes a few minutes
  12. 12. © Ctac - Better Business. Ctac Cloud 13 CDS Quick RECAP Use Case – BW Extract Unit Conversions Date defaults/ functions Use Case – Report Texts in one go Tips Outlook
  13. 13. © Ctac - Better Business. Ctac Cloud 14 Trick 1 - Unit Conversion using CDS Option 1 – Use the ABAP function for material unit conversions Option 2 – Let BW do the unit conversions Option 3 – Include Material Conversion Table MARM in the CDS
  14. 14. © Ctac - Better Business. Ctac Cloud 15 CDS Quick RECAP Use Case – BW Extract Unit Conversions Date defaults/ functions Use Case – Report Texts in one go Tips Outlook
  15. 15. © Ctac - Better Business. Ctac Cloud 16 Trick 2 – Default Date and Date +/+ 42 days Option 1 – Use of two view parameters for these two dates Option 2 – Use HANA: M_TIME_DIMENSION via an External view
  16. 16. © Ctac - Better Business. Ctac Cloud 17 Trick 3 – Get week number for date Option 1 – Use of ABAP calendar function to calculate week numbers Option 2 – Use HANA: M_TIME_DIMENSION via an External view
  17. 17. © Ctac - Better Business. Ctac Cloud 18 Snapshot of resulting CDS Main CDS (extraction) CDS – Open Deliveries SUM group by MATNR/WERKS/WEEKNR CDS – Open Deliveries Details from VBBE CDS – Time (Weeknumbers) Weeknumber, based on VBBE-MBDAT Stock Shipments Open Orders
  18. 18. © Ctac - Better Business. Ctac Cloud 19 CDS Quick RECAP Use Case – BW Extract Unit Conversions Date defaults/ functions Use Case – Report Texts in one go Tips Outlook
  19. 19. © Ctac - Better Business. Ctac Cloud 20 Use Case – Just a simple ABAP Report Question: Is it possible to read the first line of a ‘SAPscript’ text using a CDS-view? • Selection of Sales order data with partners and status information • The user wants the first line of a specific Sales order text in the output Technical Challenges: • How to get the first line of the text • How to read a field of type LRAW (STXL-CLUSTD) • Vague error messages Solution • Extra CDS-views needed in order to be able to read the first line of a text • All primary key fields of all JOINED tables must be specified in the field list. Otherwise a DB-view is generated with all fields as key field. LRAW-fields cannot be key fields! • The text can be converted in the ABAP ALV report using a specific IMPORT statement that converts from RAW to Text format. Answer: Yes, if the implicit View key is generated correctly.
  20. 20. © Ctac - Better Business. Ctac Cloud 21 CDS-view with first line of long text
  21. 21. © Ctac - Better Business. Ctac Cloud 22 ABAP - Converting the LRAW text to readable format
  22. 22. © Ctac - Better Business. Ctac Cloud 23 CDS Quick RECAP Use Case – BW Extract Unit Conversions Date defaults/ functions Use Case – Report Texts in one go Tips Outlook
  23. 23. © Ctac - Better Business. Ctac Cloud 24 Tips How and when to use CDS-views: • CDS offers options to limit number of needed ABAP-statements (Code Pushdown) • Limit use of WHERE-clause in CDS-views (reusability!); • CDS has more options than Open SQL • Important role of CDS in SAP Architecture Be careful and precise when using JOINS: • Are you sure that you should use an INNER JOIN? • Are you sure that you should use an OUTER JOIN? • Did you specify all relevant JOIN fields in the ON-clause? • Don’t forget the DISTINCT option of the SELECT-statement Technical tips: • CDS not limited to HANA • If not all key fields of joined tables are specified in field list, all fields are considered key field in the generated VIEW • External Views: synchronize and re-activate usage
  24. 24. © Ctac - Better Business. Ctac Cloud 25 CDS Quick RECAP Use Case – BW Extract Unit Conversions Date defaults/ functions Use Case – Report Texts in one go Tips Outlook
  25. 25. © Ctac - Better Business. Ctac Cloud 26 Outlook – CDS as common data model in S/4HANA
  26. 26. © Ctac - Better Business. Ctac Cloud 27 Outlook – CDS as central model in future developments
  27. 27. © Ctac - Better Business. Ctac Cloud 28
  28. 28. © Ctac - Better Business. Ctac Cloud 29 Outlook – CDS as central model in future developments
  29. 29. © Ctac - Better Business. Ctac Cloud 30 © Ctac - Better Business. Ctac Cloud Thank you

×