ABAP On HANA

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 115

S/4HANA Developer

Training with
ABAP on HANA
CDS Views, HANA Views, AMDP, HANA,
SQL Script, Fiori Apps, OData and more

Anubhav Oberoy
www.anubhavtrainings.com

End-to-end real
scenarios for more http://www.anubhavtrainings.com
for more http://www.anubhavtrainings.com
What You will Learn in this course?

Explore Plan your move


Unleash the potential of In- Custom Code adaptions to
memory computing Engine move to new ERP

Innovate Performance
Innovate new Analyze and Boost
dimension applications performance of existing
with UX applications

Adapt Build New Apps


Adapt new techniques like C-t- Create amazing Fiori Apps on
D, new syntax, new S4
frameworks

for more http://www.anubhavtrainings.com


Who is this course for?

This is a sample text.


Insert your desired
text here.

13:55

Make a smart move

• Developers
• Architects
• Solution Experts
• BW Consultants
• Technical Consultants

13:55

for more http://www.anubhavtrainings.com


What we see in this demo?

03
Build an App

Consume the service and

02
Create OData
create an end to end app
Expose data over http

01
Create first View
protocol
Create your first CDS view
on demo data

01 02 03

for more http://www.anubhavtrainings.com


Presentation layer Presentation layer
SAPGUI Fiori UX

Application Layer
Application Layer
7.5x

Database Layer In-memory - HANA

for more http://www.anubhavtrainings.com


What is CDS
CDS stands for Core Data Services, it is an extension of SQL.
DDL – Data Definition Language – CREATE, ALTER, DROP
DQL – CDS Views – Data Query Language – (semantically rich-data model, expressions)
DCL – Data Control Language – CDS Security

OData – Open Data Protocol, it is used to expose data over http using REST principles.

Business CDS Views


Fiori UX
Partners @annotation

Eclipse
WebIDE
ADT
1. Just add an annotation called @Odata.publish
2. Create the registration of the service
(/n/IWFND/MAINT_SERVICE)
for more http://www.anubhavtrainings.com
Schedule
Weekend 7 -9 PM India time
2 Hrs+2 Hrs = 4 Hours
40 Hours / 4 Hours = 10 Weekend = 2.5 Months

Minakshi
[email protected]

for more http://www.anubhavtrainings.com


I can’t do it
He/She Not willing They Don’t know
to do it how to do it

for more http://www.anubhavtrainings.com


Introduction on SAP HANA
SAP HANA is an in-memory database. It is different from traditional database because those systems relies on DBMS, which
keeps all the data to HDD.
HANA –High Performance ANalytical Appliance (HW + SW)
HANA Express – 16 GB

Primary Memory Secondary Memory


CPU
RAM HDD

OS / Kernels
8084 – 8bit 16bit
1 ins per sec
MOV A,B, ADD A
64 bit

for more http://www.anubhavtrainings.com


What made HANA possible?
Hardware:
• Reduction in memory cost
• Able to fabricate more memory in small space
• Able to composite multiple cpu cores on a single blade
• Faster throughput times
• Powerful backup system

Software Innovation
OS are now capable of submitting high no of instructions to CPU, CPU can process them in parallel
Higher Compression of data
The way we store = Row Store, with HANA the default store is Column Store
Calculate Aggregations on fly

for more http://www.anubhavtrainings.com


Row v/s Column

OR 0001 X MAT1 10 560 USD OR 0001 X MAT2 10 800 USD OR 0001 Y MAT1 10 950 USD

OR 0001 Z MATD 20 1750 USD OR 0001 Z MAT2 10 780 USD OR 0001 D MATX 10 1800 USD

TOTAL SALES
Row Store – traversing all the records and cells
Give me all records and all columns
Good
Was there any program you have ever written which needed all records and all columns = MARA

Accessing Few Columns


Calculating totals, max, min..

We used to create indexes – They again duplicate the data PK RowNo


You need more storage to access this data

for more http://www.anubhavtrainings.com


Column Store

10 560 USD
X 10 800 USD
OR – Y – 2,3 10 950 USD
0001 – 1,2,3,4,5,6
1,2,3,4,5,6 Z – 4,5 20 1750 USD
D 10 780 USD
10 1800 USD

1. It is possible to aggregate the data much faster because we don’t have to traverse through all columns.
2. Column store every tiny column is itself an index – Significantly reduce memory footprint I am gonna
3. No need to store these aggregates in another table, it is possible to calculate the aggregate (SUM, MIN, MAX, delete 5
COUNT) on-fly. Which means you can give real-time picture.
4. Compression – Less memory requirement,
Much faster rather comparing chars
5. Parallel processing – Each column can be processed by one core of CPU
6. Insert only approach
Buy Hardware from SAP Certified vendors – IBM, HP, AWS, GCP, Azure
In-memory Computing Engine - HANA
for more http://www.anubhavtrainings.com
What are guidelines to choose Row v/s Column
Row Store Column Store

• If there is a table which needs to be Updated frequently • Read very frequently


but not read frequently • If you need few column in Select
• You always reading all columns SELECT * • Many Non-unique values, Data is repeating
• Large no of unique values • You want to do aggregates
• Less restricted • Analytics

for more http://www.anubhavtrainings.com


ERP / BW BW
7.31
HANA Driver

Oracle, MaxDB HANA HANA – SP03

Side-car scenario BW on HANA – Project Orange

ABAP System

ABAP on HANA - technology ABAP – tech


Business Suite – Suite On ECC - Solution
HANA - product
HANA

for more http://www.anubhavtrainings.com


Miami Santa Clara
OLTP Suite
Suite
Suite OLTP
Write
OLTP

NYC LA

Data provisioning
ETL – Extraction Transformation and Loading
SLT, BODS, DXC…
BW System
SAP BOBJ
Read - OLAP

Crystal Report data Modeling


Information modeling
 IM - Models
Excel Sheet
for more http://www.anubhavtrainings.com
Real-time analytics
Overhead gone
ABAP Cost comes down
S/4HANA – True Hybrid – Analytic Tool embedded in
S/4HANA
S/4HANA Embedded Analytic
S – Simplified
4 – 4th Generation ERP
The default database – HANA DB
HANA Default experience for user – Fiori
OLTP + OLAP

2025
HYBRID DATABASE

https://www.cbronline.com/opinion/saps-2025-deadline

for more http://www.anubhavtrainings.com


ABAP on HANA Consultant
HANA Admin HANA Consultant
• Installation of HANA
• Tools to bring data from Native HANA • When my co move from oracle
• Upgrades to HANA DB
another sources and
load in DB
Developer HANA, they ask me whether my
• User Creation in HANA NO ABAP – PURE HANA ABAP code will work or not?
• Authorizations to users • Data Modeling – XS Engine • When my co move from oracle
• DB Monitoring and Join and make IMs XSJS – Server Side JS S/4HANA, they ask me whether
Backup • Tools to report the data XSODATA ABAP code will work or not?
• Check system health XSDS, HCDS, HDBDD • We got HANA, can you really
models BW
improve it?
• Where to improve?
• We already have HANA, can u
consume data model in ABAP.
• New type of Fiori Apps on HANA
Old System • CDS View, AMDP….
• Fiori UX

HANA Box XS Engine

BW

for more http://www.anubhavtrainings.com


SAP HANA Platform – No more just a db
HANA Studio HANA WebIDE ABAP System BW System

XS Engine (eXtended Server) – Light weight application server which is embedded inside of HANA

HTML5 –Fiori Apps JRE – Java Apps V8 Engine – Node JS Bring your own

Index Server – Actual In-memory computing engine – in-memory DB

Name Server – in case of distributed system for scaling, this component is the coordinator

Script Server – Manage the other capabilities


PAL AFL EML

Doc Store

Integrations Data LM tooling Tooling support for provisioning


for more http://www.anubhavtrainings.com
Index Server – In-memory DB

Client Side tools, BW Tools, BO/BI Tools. HANA Studio, ABAP

Auth.
Session
Manager Connection and Session Manager Component
Manager
XSUAA

Request processing and execution control

Store Procedure
SQL Processor Planning Calculation Analytic Engine
MDX Engine Engine
(DML) (SQLScript) Engine Engine (OLAP)

Column Store In-memory Store Row Store

Page Management Disk Store (HDD) - MaxDB Log Management


for more http://www.anubhavtrainings.com
Release and Support Pack

Walmart
Accenture

Colgate
TCS
SAP Product Company
Entire market

Delloite ONGC

ll SP + New Functionality  1 year


1Q – 3 months 1Q – 3 months 1Q – 3 months 1Q – 3 months
Support Pack Support Pack Support Pack Support Pack

for more http://www.anubhavtrainings.com


SAP HANA Evolved over sp and release
SAP HANA Release 1
SP0 – Beta release
SP1 – GA Release (General Availability)
SP02 – SAP HANA Can now run as secondary DB using Driver (Side Car Scenario)
BODS – Business Object Data Services for data provisioning SLT – SAP Landscape transformation
SP03 – Now enabled to run on SAP BW system (>7.31) – Project orange – BW on HANA
SP04 – DXC – Direct extraction Connection , PAL – Predictive Analytics Library
SP05 – XS Engine + Web Server (XSODATA, XSJS)
SP06 – NOW SAP HANA CAN RUN ON AN ABAP SYSTEM – ABAP on HANA (NW 7.4) – Primary DB
Suite (SD, HR, MM, PP, FICO) on HANA, CRM powered by HANA, SRM powered by HANA
SP07 – SDA – Smart Data Acess
SP08 – HANA Appliance now can be installed on RedHAT linux – Earlier SuSE linux
SP09 – MDC (Multi-tenant data containers to support cloud), Now to model IM on WebIDE
SP10 – high availability and disaster recovery
SP11 – XSA engine which now supports Node JS, XSA, Python, bring your own runtime
SP12 – Workload analysis for production system and ZDO
SAP HANA 2.0
Sp0 – Backup encryption, 3rd party tools to support MD, Recovery from Snapshot
SP1- Doc Store, Dynamic Cache
SP2 – EML with google’s tensor flow integration http://help.sap.com/hana_platform
for more http://www.anubhavtrainings.com
Server access for practice – 24X7
• FREE – Ask your co. 
• Google if someone providing ABAP on HANA server access below our rates
• Anubhav Trainings provides you an fully activated (developer key is applied to your user) S/4HANA 1808
 ABAP on HANA
 CDS Views
 SQL Script
 HANA Access
 SAPGUI download – From your own/co system to our server w/o any pre-requisite – local sapgui – Windows
 Connect this ABAP server from Eclipse – ADT
 SAP Fiori Launchpad designer + LPD access ALL Anubhav’s courses in
 Connect server from WebIDE personal edition, WebIDE Full stack this single box
 Build OData Services
 All our demo data is also available in this server to practice
 FULL SUPPORT in terms of Documents, Videos, Materials, PDF, Call Support
 User lock issues also SLA 30 Min (9.30 AM – 6.30PM)
 Licensed SAP solutions

You can email on [email protected] and get the server access


2500 INR per month per user
40 USD per month per user
for more http://www.anubhavtrainings.com
Question
Is HANA Studio same as Eclipse
Can I run abap code on hana studio also
What is the cost of hana studio

HANA Studio is a modified version of eclipse. Eclipse IDE is a development tool like any other tools like SAPGUI. We can do
HANA development + ABAP development both on Eclipse also and HANA Studio also.
1. You can install the Eclipse in your local computer – Connect to ABAP system
2. You can connect to RDP – This system has HANA Studio and SAPGUI pre-installed for you.

*You can connect to HANA Box using RDP only but ABAP system you can connect from your local computer eclipse

What is ADT
How can I run abap on eclipse
How to setup eclipse and tools for abap development

for more http://www.anubhavtrainings.com


presentation

SAPGUI

ABAP Layer

Eclipse – FREE – Open 2


Source
Java, Web, Android
1
HANA Studio
HANA

for more http://www.anubhavtrainings.com


How do I get eclipse – then connect to ABAP system
Pre-requisite
• Your computer must have installed JDK – cmd  java –version  download from here
• Installed Windows .NET 3.1 environment
• Must also have SAPGUI installed

Main Course
Eclipse – https://tools.hana.ondemand.com/#abap
ADT – ABAP development tools on eclipse

Now enable you to develop abap applications on eclipse.

ABAP project is a handler to an SAP server who talks to ABAP server.

https://www.youtube.com/watch?v=cnHZeQ_5uJ0

for more http://www.anubhavtrainings.com


Motivation for using ABAP on Eclipse
ABAP project is just a container which holds all the artifacts which you are working with ABAP server. It is a channel by which
you are talking to ABAP layer like SAPGUI.

ADT - ABAP Dev Tools on Eclipse


• It is FREE, open source, easy to configure in any laptop and no licensing cost
• You can work with Dev, Q and P simultaneously
• Connect to multiple systems and landscapes and develop using multiple programming languages and types of projects
• Flexible and customizable dev environment
• Fast Search and navigation
• Support Extensibility – CDS Views, AMDP, SQL Script can only be developed using ADT
• Supports the debugging and transport management
• ATC – ABAP test Cockpit
• ABAP Profiler
• This is the only development tool which Fully supports ABAP on HANA and ABAP on Cloud
• Supports UI dev for Webdynpro, UI5 and Fiori
• Inbuilt Quick fix feature
• Modularize code
• Code Templates

for more http://www.anubhavtrainings.com


Quick Shortcut
Ctrl+Shift+A – to search any type of object in whole system
Ctrl+F2 – Syntax check
Ctrl+F3 – Activate the object
Ctrl+6 – Open an SAP GUI window inside eclipse
ABAP Server
Ctrl+O – quick outline view
Ctrl+T – open abap type hierarchy
Ctrl + Shift + G – open where use list

ADT
Onion,
Capsicum,

Dough – Base
Eclipse

for more http://www.anubhavtrainings.com


With 7.4 SAP Introduced new ABAP syntax
FundaFox
1. Is old stuff still valid, what will happen to my old code, will it still work
when we move to NW7.4.
Yes
2. Can is still write code as we learnt in old
Application layer Yes
Netweaver – Technical platform on which 3. Why should I switch to new code?
all SAP Applications and Solutions are More advance version of coding
based upon It has a little performance improvement
NW 7.5x Follows industry best practices
>= 7.4 onwards 4. Classification of syntax
4.1 Classical ABAP coding
4.2 SQL Logic
5. Are SF, Scripts, BADI, BAPI, SPRO, WF – S/4HANA On-premise > 90%
Yes

HANA Sp06

for more http://www.anubhavtrainings.com


Classical ABAP coding
1. Now we can specify comma separated column list inside SQL query.
2. If you are using comma separated column list, we must use the escaping of host variable. Only applicable for SELECT query.
3. Data declaration, field symbol declaration is now possible inline – inline data declaration in abap
You can declare variables while on the go.
4. Object creation we also have new syntax – create objects of class.
Data(lo_object) = new className( ).

Funda Fox
( ) - parenthesis itab 1,2,3,4,5…
{ } – braces, curly braces
[ ] – bracket
Object
5. New way to process data of an internal table using object traversal
6. Value Expression – now you can create structures and tables at runtime, w/o separate declarations. – value #
7. Reading an internal table made easy using table expression
8. String Expression – allows us to avoid using concatenate, printing a single quote ‘’’’

for more http://www.anubhavtrainings.com


SQL Side what has been improved

2. Now you can add RIGHT 1. Improved the abstraction layer


OUTER JOIN also in ABAP which converts query to native
ABAP
Language SQL, especially when its HANA,
Open SQL
3. No. of Joins also increased SAP knows how to prepare
to > 20 optimized query to HANA

Click here for doc Application Layer DB Abstraction


Which is the DB I am
connected

Native SQL

Database
Oracle  DB2  MaxDB

for more http://www.anubhavtrainings.com


Writing SQL in Better way
1. Case statement in SQL
1.1 Simple Case
1.2 Expression Case
2. We can now use the aggregation functions (SUM, COUNT, MIN, MAX, AVG) inside having clause.
4. New functions like CEIL, FLOOR, COEALEASE..
5. Arithmetic expressions inside SQL queries

Funda fox:
Whenever we use aggregation functions, the columns which are not participating in agg. Functions must be added at the end
of query as GROUP BY clause.

for more http://www.anubhavtrainings.com


A B C

P P P
2025

Application Layer Application Layer Application Layer

DB HANA HANA
ABAP on Any DB – ABAP Changed data models – They
ABAP on HANA – An ABAP
system running on DBMS have introduced new table,
system running on HANA DB as
system removed tables.
a primary DB
ECC – MM, PP, FICO, SD,.. Simplification – S
Suite on HANA (product –AoH )
ABAP 4th generation Suite
– ECC+CRM+PLM+SRM+HCM
S/4HANA - Solution
for more http://www.anubhavtrainings.com https://www.cbronline.com/opinion/saps-2025-deadline
A  B – Just Changing the Database from RDBMS  HANA DB
What will happen to my custom code when we migrate to HANA DB, How do you prove that nothing will be affected.
It is just like any other DB migration.

1. Any Native SQL queries written in ABAP will not work EXEC SQL…END EXEC, OPEN CURSOR, DB Interfaces to fire Native
SQL, these things will not work. Oracle
Select ROWNO from DBTAB Every table has a predefined HANA
column ROWNO
2. If you query data from db, in unsorted form, and later we are doing operations like binary search or delete adjacent
duplicates, these operations will produce bad results.
Price
10 10 10
12 12 12
30 30 15
15 15 15
18 18 18
45 45 30
15 15 40
40 40 45
50 50 50
for more http://www.anubhavtrainings.com
What else is affected – [email protected]
3. DB specific hints wont work HINTS ‘%_HINT_USE_INDEX’ idx_0
4. Direct access to pool and cluster table will not work

In your company in last 20 years, about 40 developers build 7.62 Mn lines of custom code,
can you guarantee that everything will work and none of above is applicable for you.
SAP Has provided 2 tools since many years, SAP have enhanced these tools to support you
and help you to plan and decide that your move to HANA DB is smooth by ensuring that
none of above case arise in your custom code.
 SCI – SAP Code Inspector
 ATC – ABAP Test Cockpit
We will not perform an analysis to check our DB migration stability in terms of our code.
Can be performed
@Individual object level (just for one program)
@Package Level (Home of all objects)
By Using 1. SAPGUI 2. ADT
for more http://www.anubhavtrainings.com
www.anubhavtrainings.com
www.anubhavtrainings.com
S4HANA_READINESS
https://blogs.sap.com/2016/02/02/sap-s4hana-custom-code-migration-worklist/
www.anubhavtrainings.com
SAP Providing a FREE Service if you know in the system
S/4HANA Readiness Check 2.0 Note 2758146

for more http://www.anubhavtrainings.com


www.anubhavtrainings.com
www.anubhavtrainings.com
www.anubhavtrainings.com
Implementations of S/4HANA
• Green field implementation – 10%
• Brown field implementation – 90%

for more http://www.anubhavtrainings.com


https://launchpad.support.sap.com/#/notes/2706257

What About My Custom Code?

www.anubhavtrainings.com
Guidelines for an robust programming in ABAP w/r/t performance
Discard the lines using WHERE and HAVING conditions
Keep Result Set Small Avoid using Selects which gets you large no. of records
Try to use aggregations with GROUP BY clause

Usage of Select…EndSelect, Loop At …Select….EndLoop


Minimize the number of hits to We can use Joins, Subqueries, FOR ALL ENTRIES
DB Perform array operations INSERT dbtab FROM TABLE itab

Minimize the amount of data We care about number of columns, Avoid SELECT *
transfer Use aggregate functions

Minimize the search overhead on Full Text Search


DB

Don’t overhead DB with


unnecessary calls and executions

for more http://www.anubhavtrainings.com


Core Topic

There are never bad students, always bad teachers


OrderId Product Price ProductId Category
1 A 100 A Laptop
2 A 200 B SmartPhone
3 B 300 C SmartPhone
4 C 520 D Laptop
5 D 900
5 D 1500

Calculate the total sales of products in category Laptop. Calculate the total sales of products in category Laptop.
Read Product – inside an itab where category = laptop Read Product – inside an itab where category = laptop
Loop at itab into wa Select From orders FOR ALL ENTRIES IN itab
Select from orders where product = wa-product WHERE product = itab-product.
sum *CAUTION: IT WILL READ ALL THE RECORDS OF ORDER TABL
endloop IF itab IS EMPTY, Make sure you check if itab is NOT INITIAL
for more http://www.anubhavtrainings.com
S/4HANA
We sat on one weekend with whole of my team and did performance_db check on entire package. We have got 14,399
findings which can cause potential performance issues.
We have go live next week, my manager asked me, which of them you would like to fix first, give me a feasible plan with
details.
What you should focus? – critical ones? – How do you present a feasible ideal plan(worklist) to your manager?
WHAT USED THE MOST IS WHAT WE SHOULD FIX THE FIRST

Which system will you do that check?

Production system is where users are using your sol. You will get
Real statistics when you do in production.
6000 concurrent users at a time
50k requests per min
130k ABAP statems executed every min
140B records are modified every week

How to find what is used the most?


SQLM – Do performance check and find expensive queries – SQL monitor tool
SWLT – SQL Performance Worklist Tool to find prioritize list of action items
for more http://www.anubhavtrainings.com
How to find what is used the most?
ST05 & SAT – Runtime analysis – Cause overhead on system because it collects huge data, slows down over all system
STAD & ST03 – System level tools used by basis teams to get aggregated performance, only high level performance not drill
down report.
ST04 – SQL Trace – Traces gives you comprehensive data but it cannot tell the entry points.

Problem Statement
We want to use a tool which cause no/min system overhead and I can run the same in production system.
Goal
1. Finding the most expensive Request Entry point (Transaction Code, Report, FM,) in terms of DB cost
2. In these entry points which SQL query dominates the SQL profile
 Most expensive or used SQL query in whole of my system
App Layer
SQLM- SQL Monitor Tool

DB Inf. async SQLM

DB
for more http://www.anubhavtrainings.com
SWLT – SQL Performance Worklist Monitor

Most Expensive/Used Causing a performance


Programs/Reports/FM/Jobs inguideline violation
your system 14,699 results

Top priority to be fixed for next week because there is a


performance guideline violation and these objects are also
used the most in your company
for more http://www.anubhavtrainings.com
EPM model – Enterprise Procurement Model
For the purpose of demo and training purpose. It is all above a company called ITeIO which is dealing in selling of electronic
goods on the internet (amazon)

Business Partners Product

A >= B
Sales order Purchase Order
Order Items POrder Items
A 20 Laptops 50 Laptops
10 iPhones 10 pendrive
3 HDD 20 HDD

Customers Suppliers
ITeIO
Invoice
Invoice Items
B 10 lap
10 iphone
1 HDD

10 lap
10 iphone
1 HDD
for more http://www.anubhavtrainings.com
Database Tables – NW 7.4 - Training
Master Data
Suppliers and Customers – snwd_bpa
Addresses of business partners – snwd_ad
Products – snwd_pd
Product description (language specific – text table) – snwd_texts

Transaction tables
Sales orders – snwd_so
Sales order items = snwd_so_i
Invoices – snwd_so_inv_head
Invoice items – snwd_so_inv_items
Po – snwd_po
Po items – snwd_po_i

Why GUID to be a PK (Antibiotics)


https://youtu.be/1tk4DUOXXQw

for more http://www.anubhavtrainings.com


Exercise
Design an ER (Entity Relationship) diagram for the tables mentioned in last slide.

1 * SNWD_TEXTS
SNWD_PD
PK NODE_KEY
PK NODE_KEY
FK PARENT_KEY

for more http://www.anubhavtrainings.com


Demo Scenario - SEPM_DG
Job Profile : Account Receivable Accountant
Mr. Jems is an account receivable accountant in your company, he is an owner of BMW X3, he like skiing and sailing an full of
life person. A happy father of 2 girls, living in a quite place in down town.
Cash plays a very crucial role in success of a company and running the business, it is in the
best interest of the company to collect the pending cash of unpaid invoices on timely
manner from the customer. By putting this cash back into the pipeline of the business
company can make more profits and achieve the goals.
Mr. Jems who is account receivable accountant in the co. whose job is to manage the
collection of the cash from the customers of unpaid invoice. He typically comes to office
and spend his time in doing following activities
• Search for the unpaid invoices
• Arrange them
• Find the most critical ones which are not yet paid
• Organize them based on their risks (by threshold – amount OR time)
• In relation to that Mr. Jems will finally classify customer and perform dunning
Mr. jems has a direct say to CIO and has contacts upto CEO level. Your manager also afraid of him.
OIA – Open Item Analysis
Find out the total due amount and avg. no of days since the amount is due per customer. This has to be in common currency.

for more http://www.anubhavtrainings.com


Planning and Break down
1. Create a DB table which contains the customizing – Threshold and Curr – ZDP_CUST
2. How long on avg. an invoice(s) per customer are pending
• Invoices which are not yet paid – snwd_so_inv_head – where PAYMENT_STATUS = ‘’ Takt 1
• Calculate the average days since when invoices are pending (Today – Last Change date)
• Formula for avg – Total / Count 2,3,4,5  2+3+4+5 / 4
• Also get The customer information SNWD_BPA
3. Change the total GROSS_AMOUNT of unpaid invoices in common currency
• Invoice header data again for unpaid invoices
• Go to line item level and get amounts of each line item (which can be in different currencies) Takt 2
• Apply the currency conversion
• Total Gross amount which will be in a common currency
• Join data with Business Partners (SNWD_BPA)
4. Classifying the customers based on their threshold levels
5. Dunning
6. Check sales history of the customer….

COLLECT STATEMENT in ABAP – in abap is used to add records to the internal table, unlike append it will not create new line
in internal table but it will add the numbers while creating lines by comparing non-numeric columns.

the total time taken was 122 ms


for more http://www.anubhavtrainings.com
Customizing table for OIA

for more http://www.anubhavtrainings.com


Customer Invoice Date
A 01.01.2019
A 01.01.2019 3

A 01.01.2019
B 01.02.2019
B 01.02.2019 2

for more http://www.anubhavtrainings.com


SAP HANA based approaches
How ABAP is meeting HANA technically,
What happens when you create an table, structure, ddic in SE11 how and where the object is persisted in HANA.

When we create a program in abap/ create a table in ABAP where do we store it?
Package – collection of your artifacts, folder where all our development objects are stored. – DESIGN TIME OBJECT
Grouping, Transport

When we activate a runtime object gets created in DB.


This will be then created in underlaying db (3rd layer) – RUNTIME OBJECT

SE11
App Def. App Def. App

CREATE TABLE tab PK…. CREATE TABLE tab PK…. CREATE TABLE tab PK….

DB A DB
DB
dA
for more http://www.anubhavtrainings.com
A
Content and Catalog
Content in HANA is a collection of all the packages. Each package will contain the design time object (definition), when we
activate a runtime object will be created.
Schema is a container of All the DB objects (runtime object), it is the ultimate home of all the DB objects like tables,
structures, procedures , function. Schema it self is a db object which is MANDATORY. On this planet if there is a DB, it is
impossible that will not have atleast one schema. In HANA, we can see all the schemas in Catalog section.
Database is collection of schema.

https://help.sap.com/viewer/product/SAP_HANA_PLATFORM/2.0.04/en-US

Funda Fox
• When we create a new User in HANA, a schema with same name as user name will be created for that user in HANA,
and all the authorizations will be automatically granted to the user itself.
• A package in HANA is a collection of design time object, it serves 3 purpose
1. Grouping of development content
2. Control who can develop in a particular package – security
3. Package provides a namespace for the artifacts, suppose we create a view with name called V_MARA, your friend in
SAP HANA can also create a view with same name as V_MARA provided he/she developing in other package. When
the runtime object is created, the name of runtime object contains PACKAGE_NAME/OBJECTNAME
• Now we can create a table MARA though sap also ship mara provided its part of our package, sap deliver their objects
in their package.
for more http://www.anubhavtrainings.com
Data Model / Information Model / HANA Views
Data of an ERP system is distributed across multiple tables, In order to takeout some meaningful results from HANA, we need
to combine these tables together. As a technical consultants, you can write ABAP reports with complex SQL but it has
following dis-advantages
• Since we are writing ABAP queries, these queries are submitted to the DB and then results are obtained, this leads to
traffic between ABAP and HANA layer.
• It becomes so complex to write such queries and needs High technical knowledge
• A person with Domain knowledge with out SQL knowledge should be able to also model data

Concepts of Modeling
Allows us to develop data models using tables and other models and produce desired data out of HANA system, The best part
is we can develop these models w/o any technical SQL knowledge. These models are created, stored and transported in
HANA system so we get naturally code-to-data paradigm.
Deprecated – There is NO NEW DEVELOPMENT
Attribute Views
FROM SAP SIDE. IF YOU GET PROBLEMS WHICH
YOU THINK STANDARD SAP ISSUE, SAP WILL NOT
Types of IMs Analytic Views FIX THE BUG. MAINTENANCE IS NOT GARUNTEED.
HANA 2.0 onwards

Calculation Views
for more http://www.anubhavtrainings.com
Types of Data in ERP systems
Org Data – Never changes… e.g. co codes, cost Center, profit center, sales org, porg
Master Data – changes rarely – data used to create transactions – e.g. products, materials, vendors, suppliers, customers
Transaction data – Changes very frequently – SO, PO, Billing, INV, Ledger entries, ….

Asset of a company like Products, Employees, Partners


All of them are called dimensions.
Employee – No. of Hours, Salary, Defect, Amount of code, Bonus
Sales – Revenue, profit, loss, cost
Payroll – Taxes, Hours Spend, Expenses, Paystubs
CRM – Complaints, Resolutions, Productivity

Measures, They are all Numbers (Numeric) – KPI – Key Performance Indicator
Which category of data is KPI and which tables are they store?
Stored in Transaction Tables, These are known as Fact Table

for more http://www.anubhavtrainings.com


Transaction (Facts) + Dimensions (Master) – Star Schema
Customer (Dimension)
Cust1 SAP Employees (Dimension)
Cust2 Accenture EMP1 Jenifer
Cust3 IBM EMP2 Jack
EMP3 Rohan
Sales Data (Fact Table – Transaction)
Cust1 2000 EUR X EMP1
Cust1 2500 EUR Y EMP2
Cust2 1000 EUR Y EMP1
Cust2 1500 EUR Y EMP3
Cust3 1800 EUR Z EMP2
Cust4 2200 EUR X EMP1

Product (Dimension)
X Laptop
Time
Y iPhone
Z Printers
What is my total sales in the co
2000+2500+1000+1500+1800+2200
Which co. gave me max sales, which is my top customer.
for more http://www.anubhavtrainings.com
View?
1. Hiding the complexity of query
2. Security

Attribute View
The purpose of att. View is to expose master data. Because its processed by the
Join Engine in HANA. Typically to obtain master data we would do a join between
tables.
• It is mandatory to have at least one key column defined to attr. View

for more http://www.anubhavtrainings.com


Types of joins in SAP HANA
8 types of Joins in HANA
• Referential Join
• Text Join – Is used when we want to join a table with its corresponding text table. This join allows to make a relation
inclusive of logon language.
• Inner Join – Join when both the tables have records with a common key this is called a foreign key. When we apply this join
the view always return the dependent records between both tables. If there are no matching records, system will produce
null.

• Left Outer Join – It is the output of inner join and records from the left side table even the corresponding records not
existing in right side table.

• Right Outer Join - It is the output of inner join and records from the right side table even the corresponding records not
existing in left side table.
for more http://www.anubhavtrainings.com
• Temporal Join – join which is applied when we are joining tables with time dimension (M* tables).
• Spatial Join – Used to join coordinates.
• Star Join – Used to join 2 star schemas, this join can only be used in calculation views.

Referential Join V/S Inner Join


In context of HANA Views, Inner Join is a guaranteed join it is going to compare 2 tables based on the join conditions and then
returns the values. A Referential join is a SMART Inner Join, Whether the join will be applied or Not at Runtime, it depends on
SELECT Query you pass. The Join will be pruned (ignore) if the data is not selected from both tables.

for more http://www.anubhavtrainings.com


ShipmentNo Date FlightDate Airline

100 01.01.2020 01.01.2020 FedEx

200 01.03.2020 01.02.2020 DHL

300 03.03.2020 03.03.2020 FirstFlight

400 04.04.2020 01.04.2020 DHL

HANA View AT_MY_VIEW

Case 1: If the join is INNER JOIN Case 2: If the join is REFERNTIAL JOIN
1.1 Q1 : SELECT SHIPMENTNO, AIRLINE from AT_MY_VIEW 1.1 Q1 : SELECT SHIPMENTNO, AIRLINE from AT_MY_VIEW
100 Fedex ; 300 First Flight 100 Fedex ; 300 First Flight -- Same as INNER JOIN
1.2 Q2 : SELECT SHIPMENTNO from AT_MY_VIEW 1.2 Q2 : SELECT SHIPMENTNO from AT_MY_VIEW
100 ; 300 100,200,300,400

for more http://www.anubhavtrainings.com


Analytic Views
Are used in cases when we want to develop star schema, we would like to join master data with transaction data to evaluate
the analytic outcomes e.g. total sales per product, per customer, avg days of open invoice. These views are processed by OLAP
engine in HANA. Also it gives an option to perform currency conversion.
My co. has so many sales orders, I want to find what are all the sales order line items and sales per customer, per product.
• Which product Sold the most in the co.
• Which is my top prio customer
• Which country gives me highest sales
• Which is the top sales making currency

It is mandatory to mark at least one measure (numeric).

select company_name, sum( gross_amount ) as gross from


"_SYS_BIC"."MOB5_DEC/AN_SALES_DATA" ( 'PLACEHOLDER' = ( '$$IM_CURR$$' , 'USD' ))
group by company_name

for more http://www.anubhavtrainings.com


Use Case – CEO Secret Task
I am very disturbed today because there are so many complaints from the customers about their product not being delivered
because of out of stock. Also complaints from vendors that you are defaulting on the payments.

Customers S ITeIO P Suppliers

50 pc 5 mn
1mn USB 100 Pc.

Case 1: Blocked with inventories, Block your money and space.


Case 2: You will not be able to ful-fill the customer needs, UNHAPPY customers

for more http://www.anubhavtrainings.com


D Q P

package

Delivery Unit
Delivery Unit
Delivery Unit
for more http://www.anubhavtrainings.com
Exercise
Create the OIA scenario using Calculation view.

How to consume the IM data in ABAP layer?


SAP NW 7.4
< SP2 + Side Car HDB as SAP NW 7.4 SAP NW 7.4
secondary >= SP2 >= SP6

ADBC View Proxies Mr. X  CDS Views (S/4HANA)


ABAP Database A option which works on top down approach
Connectivity rather bottom-up approach.

for more http://www.anubhavtrainings.com


ADBC – ABAP Database Connectivity
ABAP provides us an ABAP Object based interface to talk to DB directly. This is used in cases we are below NW 7.4
SP2 specially and you want to consume HANA views (also in side car scenario).

Cl_sql_connection

Disadvantages of ADBC approach?


• Cannot debug the SQL statement feeded to HANA
• So error analysis becomes difficult
• Complex for Non-programmers
• No intermediate result

for more http://www.anubhavtrainings.com


Disadvantages (HANA view must exists)
1. Both the ABAP layer and HANA layer Transports must be in sync.
2. Lifecycle challenges w.r.t. synchronization of these objects
3. So much confusion, so many things, error prone Quality

Application layer Application layer


Transport
Request
HTC – HANA
View View Transport
oc ABAP ABAP
Proxy HTC – HANA Proxy
Container
xy
Transport CDS View
AMDP CDS View Container AMDP

Bottom-up
Bottom-up
HANA DB Top-down approach HANA DB
approach Approach

Proc Proc
HANA
HANA View
View IM View
Proc IM View (must)
(must)
Delivery Unit

for more http://www.anubhavtrainings.com


Disadvantages of IM in HANA
1. We cannot debug the IM, we can check the logs (activations).
2. In complex requirements, the decomposition of solution is not possible.
3. There is no possibility to write any control flow logic, orchestration logic inside the view IF…ELSE, LOOPS
4. SQL queries written on these views always return one result, if want to chain the results, you have to use sub queries and
becomes cumbersome at times.
5. Not possible to handle the imperative logic
6. Also the desired performance of the views cannot be achieved

SQL Script
One of the best technique to achieve code-to-data paradigm, allows developers to write more complicated logic which is not
possible with simple views in HANA. This helps us to squeeze the best performance out of HANA DB, This is DB programming
language.
SQL script is a collection of extensions to SQL (DDL, DML, DQL, DCL). The purpose of SQL Script is to provide the procedural
capabilities to SQL. It allows developers to write data intensive logic inside the heart of DB.
https://help.sap.com/viewer/de2486ee947e43e684d39702027f8a94/2.0.04/en-US

for more http://www.anubhavtrainings.com


Types of Statements

Declarative Logic Imperative Logic


Data Flow logic Orchestration logic
(Pure SQL – Sequence of DQLs) (IF,ELSE,LOOP,WHILE,FOR)

Code gets converted to a Data flow graph HANA will never process this logic in parallel
There is a strong chance that HANA will process this type of
logic in parallel

for more http://www.anubhavtrainings.com


Preview of Data Flow Logic/Declarative Logic
--Q1 result
Lt_products = SELECT * from SNWD_PD where price > 10000;
--Q2
Lt_sales = SELECT * from snwd_so where product_id in (
Q4
SELECT pid from lt_products );
--Q3
Lt_purchase = SELECT * from snwd_po where product_id in (
Select Pid from lt_product );
--Q4
Lt_total = select sum( gross ) from lt_sales; Q2 Q3
Lt_po_sum = Select avg(gross) from lt_purchase;
What kicks you out of parallel mode?
• Local variables or scalar parameters usage
• Inside a processing block, if we use the DML/DDL
• System encounters any imperative logic like IF, LOOP Q1
• SQL Statements which are not assigned to any implicit variables.
Best practices:
• Split the code in different containers which can be parallelized.
• Put all the imperative logic at the end. So most of the time hana runs Imperative declarative
The above logic in parallel.
for more http://www.anubhavtrainings.com
Containers in SQL Script
Container is a block of SQL Script code. There are 3 types of containers

Procedure
Stores your code in DB and never
Anonymous Block need compilation after stored in Function
DB, Reusability – STORED
PROCEDURE
SAP HANA 2.0> have parameters CREATE PROCEDURE proc_name ( CREATE FUNCTION proc_name (
DO BEGIN IN pin type, OUT opname type, pin type)
--SQL Script Code INOUT pname type RETURNS stype/TABLE tt_type
) LANGUAGE SQLSCRIPT/R DEFAULT LANGUAGE SQLSCRIPT/R DEFAULT
END; SCHEMA saphanadb READS SQL DATA SCHEMA schemaname
BEGIN AS BEGIN AS
This is used to write logic which you never --SQL Script Code
need again. Because DB never stores it. --SQL Script Code ALWAYS RETURNS ONE VALUE
Testing. Means they are always compiled. ----You want to access ABAP tables END;
SELECT …. TABLE; Scalar Table
END; Function Function
SUDF TUDF
for more http://www.anubhavtrainings.com
Funda Fox
1. SQL Script is not case-sensitive like ABAP
2. Every statement in SQL Script ends with semi-column (;)
3. When we declare a variable and want to use that variable in our code we use column symbol before the same (:) but when
we want to assign a value to our variable we don’t need to use the column. E.g.
Declare x integer; declare y integer; declare z integer;
X = 10;
Y=20;
Z = :x + :y ;
4. If we want to output data from sql script code, everything evolves around sql. We can use a table called dummy to show
output on console from variables.
5. When we are working with SQL console, system will set the default schema (session schema) to your user’s schema.
Whenever we create any object system will perform the activation on session schema. We can check session schema using
below statement
Select CURRENT_SCHEMA from dummy;
We can change the session schema for that session using SET SCHEMA command
So that we can access the objects of other schema during SQL console is open. Remember when we close the session and
open an another one the session schema will be reset to the user’s schema again.
5. If you not assign value to a variable, the value will be assigned as NULL

for more http://www.anubhavtrainings.com


Exception handling
In hana we can also do exception handling using
DECALRE EXIT HANDLER FOR SQL_ERROR_CODE codeNo
Logic;

for more http://www.anubhavtrainings.com


How to declare variables in HANA
Syntax:
DECLARE variableName variabletype;

Types of variables:
Numeric: TINYINT, SMALLINT, INT, BIGINT, INTEGER, DOUBLE, DECIMAL()
Char: VARCHAR, NVARCHAR, ALPHANUM
Date : TIMESTAMP, DATETIME, DATE
Binary: VARBINARY
Large object: CLOB, BLOB, NLOB Types OF variables

Tables Variable (itab)

Scalar variable Arrays

Implicit Explic

Using Tables
for more http://www.anubhavtrainings.com
Exercise:
If the table exist, insert 10 more records using procedure, if the table not exist, create the table and insert 10 records.
Enhance the same procedure to do same.

Syntax for if condition in hana


IF condition THEN
….code
END IF;

WHILE condition DO
----condition
END WHILE;

FOR I IN start..end DO
----fixed count
END FOR;

for more http://www.anubhavtrainings.com


Array
SYNTAX : Multiple values of same data type, cannot have
DECLARE arr_name arrayDatatype ARRAY := ARRAY( val1, val2, ….); multiple column
Funda Fox:
WE CANNOT RETURN AN ARRAY OUT OF A PROCEDURE.

Arrayname[index]
Cursors:
Cursors are handler for DB memory. They are actually named queries. Whenever a
1
cursor is created, it is always bound to a query. It is also possible to pass parameter
to cursors.
Declare  Open  Fetch  Close

Example:
Read data from abap table snwd_pd based on product category.

Using a single cursor does not make sense until used with PK, It is a good idea to use
cursor with Array for multiple record processing. Benefit of using cursor with array is
we don’t need to open cursor and fetch again and again. It will be managed by a FOR
loop.

for more http://www.anubhavtrainings.com


Create table types in the system
If you need to return some data out in a specified structure every time from different procedures, better to create a reusable
type. And then define output/input using the same type.
Syntax:
CREATE TYPE type_name AS TABLE (col1 type, col2 type, col3 type…);

for more http://www.anubhavtrainings.com


AMDP
ADBC – ABAP Database Connectivity
ADT – ABAP Dev. Tools
View Proxy - >7.4SP2 you can consume HANA Views
HANA Views ?  IM – Information Models – 3 (Attr, An, Calc)
Calc – Graphical and Scripted
SQL Script container – 3 – Anonymous, Procedures, Functions ( Scalar UDF and Table UDF)
HTC – HANA Transport container – transport HANA Delivery unit
UDF – User Defined Function
ATC – ABAP Test Cockpit
SQLM – SQL Monitor Tool
AMDP – ABAP Managed Data Procedure

for more http://www.anubhavtrainings.com


ABAP Managed Data Procedure
AMDP is just another container of SQL Script code which is kept on ABAP side. It is ABAP global class created in SE24 or in ADT.
Peter parker  Spiderman SPIDER
ABAP Class  AMDP MARKER INTERFACE – IF_AMDP_MARKER_HDB
The main benefits of an AMDP
• It is a top down approach
• No life cycle challenges
• Easy to code SQL script even w/o having access to HANA
Funda Fox
• Typically AMDP is a static method of an AMDP class
• This method have inp and exp parameters only pass by value
• No nested tables/structures allowed for parameters
• AMDP only works if your DB is HANA
• An AMDP class can also contain the normal abap methods as well
• Methods with returning parameters cannot be implemented using AMDP
• The HANA procedure will be create not when you activate the AMDP rather when you CALL IT FOR FIRST TIME.
• When you call AMDP it calls HANA DB procedure – Code- to-data
• When we want to use a DB table in an AMDP it must be specified in USING clause

https://www.youtube.com/watch?v=KLgTI1J5d3E
for more http://www.anubhavtrainings.com
For dumps

[email protected]

for more http://www.anubhavtrainings.com


CDS Views?
Motivation for having CDS Views?
When we want to achieve code push down to HANA using IM, in order to consume these results in ABAP layer, we need to
create proxy object. These proxies has problem in terms of lifecycle management. When we create a CDS view in ABAP, on
activation the HANA view gets created automatically.

IM(design time) activate

HANA View

CDS View in ABAP activation


CDS Document
CDS Entity
Data Definition DDIC View in SE11

for more http://www.anubhavtrainings.com


CDS – Core Data Services – New Language
It is an extension to SQL in ABAP. It is extending followings
• DDL – Data Definition Language – You can create new DB objects using CDS Concept –SE11
• DQL – Data Query Language – CDS View
• DEL – Data Expression Language – Case, Functions…
• DCL – Data Control Language – Grant and Revoke of data access

for more http://www.anubhavtrainings.com


Question
1. Which layer do we create the CDS Views?
Create them in ABAP layer and when activation happens the HANA view gets created automatically
2. In HANA what type of view it creates attr. Ana or calc?
It has nothing to do with DT object it ultimately produce the similar Runtime Object (DB View)
3. Is it mandatory to be on HANA DB to create CDS views?
No, NW 7.4 SP6 and above
4. Do I need to learn ABAP to create CDS Views?
You and ABAPer from here are at same point of race
5. We have already view concept in SE11, why sap introduced new concept of CDS views?
pass
6. How CDS view will help in S/4HANA
CDS views are backbone of S/4HANA product, you can do many things starting from UI building to analytics
7. Are there pre-delivered CDS views by SAP which I can use
Yes SAP delivers lists of CDS views for almost every area, How to find
8. Where all I can use the CDS Concept
This concept can be used to build reports, Fiori UX, Analytics, Built in Analytics in S/4HANA, Exposing date
9. How it is different from AMDP?
AMDP is a SQL Script code, CDS is new language. CDS views are easier to implement than AMDP
10. Can I have multiple CDS views on one Table and vice-versa.
Yes, You can also create View on View
for more http://www.anubhavtrainings.com
1. Do I need to transport HANA view also which is created by CDS view to Q system
Not at all, when we transport CDS view to Q system a similar activation takes place there and HANA view gets
created
2. I heard about HANA CDS also how it is different from ABAP CDS
ABAP CDS is what we are learning in this course, HANA CDS is actually the same concept in different flavor. It is
needed by Native HANA Developers, Who have NO ABAP SYSTEM IN THEIR COMPANY.
Click here for sneak peak of HANA CDS
3. Can we create CDS view in SE11
NO, we can only use ADT For development of CDS views
4. Can I debug CDS views
No

Change is the only thing which is constant


https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.9/en-US/630ce9b386b84e80bfade96779fbaeec.html

for more http://www.anubhavtrainings.com


Funda fox
CDS Views: CDS can be used to query the data from DB table(s) even other data sources (cds views). It is used to define
semantically rich data model (use of annotations).

Types Of Views

Parameterized CDS view Non Parameterized CDS views

for more http://www.anubhavtrainings.com


DDIC Views v/s CDS Views
Parameters CDS Views DDIC Views
Right outer join Yes No
Semantically Rich Data Model Yes, They have annotation concept No
OData Services Direct No
Complexity Simple Complex
Code To Data Yes No
S/4HANA Embedded Analytics Yes No
ADT Support Yes No
Lose Coupling between tables Loosely – association Costly
New Features BOPF, RAP Support No
Backbone for S/4HANA SAP Delivers No
Fiori UX Very Good @UI No

for more http://www.anubhavtrainings.com


Engineering Graphics

for more http://www.anubhavtrainings.com


Fiori UX
@Odata, @UI

BOPF Framework –
Transactional Apps
CDS Views @Semantics

Analytics
@DefaultAggregation
@Analytics

S/4HANA Consumption for


Embedded Analytics and
WebAPI
@VDM
for more http://www.anubhavtrainings.com
Hdr
Super

Join

Item

for more http://www.anubhavtrainings.com


Funda Fox for association
1. Fields which is used in association condition must be part of selection list
2. Good practice to put _ before association name
3. There has to be at least one key maintained in the view to make association work. ADT with Eclipse

Can a Fiori App talk to CDS view or FM or BAPI or Program?


No FIORI ONLY AND ONLY TALK TO ODATA
S/4HANA

CDS views
Fiori App OData

FM, DB, Rep, In


Pre-requisite
1. Setup WebIDE
WebIDE 2. Connect to your ERP system using WebID
1. Personal Edition E
2. Using WebIDE Full (our documentation of server)
stack in SCP 3. Basicsforofmore
Odata
http://www.anubhavtrainings.com
Funda Fox of OData
1. We can generate an Odata service Out of the box using the CDS view annotation @Odata.publish: true
2. The name of the service will be CDS_VIEW_NAME_CDS
3. You are not allowed to write change odata manually, system will control the odata automatically
4. Each view with its exposed association will become an entityset for odata
5. After activation, it is also mandatory to activate the odata service as well using tcode /N/IWFND/MAINT_SERVICE
6. One time activation only
7. Activation of service needs to be also transported by locking it in same package under which the cds is locked

Remember this is one of the way to create odata service. There are other ways
• Using SEGW manually
• SADL
• API way using RESTful ABAP programming paradigm

for more http://www.anubhavtrainings.com


DCL – Data Control Language
1. Create a DCL for the CDS view
2. Make sure that your CDS view also understand that it has to check for DCL
3. Create an Auth Class in SU21
4. Create an Auth Object under the class
5. Maintain the Standard field called ACTVT
6. Maintain permitted Activity as 03
7. Create Authority fields of your choice depending on which field basis you want to control auth . E.g. based on country so
we create a field with data type LAND1
8. Save and Activate Auth Object
9. Use same auth object comparing against the field of CDS view with Auth field and we can hard code activity type check

o e
What is the difference between auth rization and auth ntication?
E comes before O
IS user allowed to enter inside system - authentication
Once he/she enters, what is that all he/she can do – authorization – PFCG

https://www.youtube.com/watch?v=gM5fl22iRZo&list=PLcxqFaocb9WIeYOzOx0cH3fvblA5LvDrx

for more http://www.anubhavtrainings.com


VDM – Virtual Data Modeling
Gold standard introduced by SAP in S/4HANA product. It is an annotation to standardize the development of CDS View.

@VDM.viewType

Private View Interface Views Consumption Views


P_ I_ or _I_ C_

Private views : you can use these views Will have odata enabled so that
as part of your views but SAP Does not they can directly be used for
Basic Composite
guarantee that these views will not external consumption via fiori,
change in future in a destructive way. SAC,….
Master data and Master data +
dimensions Transaction Data
#CUBE #COMPOSITE
for more http://www.anubhavtrainings.com
Analytic Scenario using CDS - + gold Standard  VDM
Use Case: Design an analytics on top of sales data to see which products are selling the most, which customers are giving us
max data.
Use the data in analytic tool called RSRTS
Use the CDS View as Odata In Fiori App
Used by S4 Embedded Analytic
S/4HANA Embedded
Analytics Consumption Views RSRTS , S/4HANA
#CONSUMPTION query Embedded
Analytics

Composite Views Composite Views


Interface Views RSRT_ODP_DIS
#COMPOSITE #CUBE #COMPOSITE #CUBE

Interface Views #BASIC #BASIC


#BASIC
#DIMENSION #FACTS

for more http://www.anubhavtrainings.com


Funda Fox

• If we want to consume a Composite view in an analytic tool, we must mark it as Analytic category as #CUBE
• Do not expose all the properties from dimension, only expose the properties we need
• All the properties except KPI has to be marked as key
• To make sure that we inform SAP CDS engine about the measure we need to properly mark the same as well using
@Semantics annotation

Wang, Yang

Language field which had used to pass to the CDS view, we have hard code it. Is it possible that I can pass this language field
as a input parameter to the CDS. Moreover I would like to know is it also possible to pass current login language
automatically to the CDS

We can also pass some range of values for example, we want to see the analytics only for certain customers.

User when open the report must have a default report presented with CompanyName, CurrencyCode and Gross Amount

for more http://www.anubhavtrainings.com


5 pillers S/4HANA Embedded Analytics – Within the system, No Extra license cost WITH S/4HANA FREE
You need to know How to build Analytic Query from CDS Views
• Query Browser
• KPI Modeler
• APF – Analysis Path Framework
• OVP – Overview pages
• ALP – Analytic List Pages

Change is the only thing which is constant


1. Assign a role delivered by SAP to your user SAP_BR_EMPLOYEE – PFCG tcode, Don’t forget to click
user comparison button and then SAVE
2. Just open Launchpad – Is the central access point for All the Fiori Apps - /n/UI2/FLP
250 Fiori Apps = 250 URLS

for more http://www.anubhavtrainings.com


Limitations for CDS Views
• Implement the complex logic, data exchange happens between queries
• Sometimes CDS gives errors related to data types.
• Cannot imperative logic like Looping, if and extra things

CDS Table Function


Was introduced in SAP NW7.5 onwards. Helps us to call an SQL Script code from
the CDS View using an AMDP method.

Additional Learning:
https://youtu.be/xcwXtn_5LBA

Table UDF
Can CDS Views CREATE, UPDATE and DELETE Data?
BOPF – Business Object processing Framework - CRUD
for more http://www.anubhavtrainings.com
Challenges of Classical ERP (ECC system)
UX Experience
UX Experience
SAPGUI Server Stickiness Fiori UX
Collaboration
Device Switch (draft
functionality)

Server Stickiness

Workflows, Application Layer


Application Layer SPRO,BADI,RICEFs,B GATEWAY = ODATA Services
APIs,Extensions,Use REST – Stateless Protocol
r Exist, Script, …….

Collaboration
Device Switch (draft functionality)
CDS + BOPF Temp …
DB Transient M

for more http://www.anubhavtrainings.com


when move CDS view to another packaged what about other view it reference . how can you move complete
package

You need to make sure that the logically related objects are also moved to same package (hopefully), essentially
to SAME TRANSPORT.

Which TR, Which Package, What Nami-convension, TR frquency

in RSRTS, i saw execute+debug, does it mean you can degug CDS Q

T B
B

A
P

for more http://www.anubhavtrainings.com


CDS View
Fiori ? OData DDIC
View
BAPI…

for more http://www.anubhavtrainings.com


1. Can we update the data using CDS Views. – No until unless we combine CDS with BOPF
2. What is CDS BOPF Integration
3. What is the new Programming paradigm for ABAP developers with S/4HANA?
4. How to develop Draft capabilities with Fiori Apps with better collaboration
5. If we can build complete application on HANA Layer why we still need ABAP layer – We cannot compromise on YEARS of
investment done by co. building BADIs, User Exits, Script, SF, BAPIs, Custom Report, …….

BOPF – Business Object Processing Framework

Screens
Screens
Screenflow
Jack – Finance (ABAP) Stephanie – HR ABAP Screenflow

FM, Class – CRUD Diag Prog1 BOPF Diag Prog2


Hey BOPF I want to FM, Class – CRUD
Lock-Unlock
Lock-Unlock
Validation write data in these 2
Validation
Determination tables and this is the Determination
Action relationship Action

for more http://www.anubhavtrainings.com


Scenario
We are working in Etihad Airways in the SAP Development Unit. They have a challenge today, they want to assign meals to the
ongoing flights from different airports. The supervisor staff on the airport has this big challenge to assign the meals to each of
the flight and keep track of the assignment as well as take approval from manager.
The qualities are expected in the solution
1. The solution must be consumable on Mobile/Tablet
2. They want to know the REAL TIME STATUS update on passengers travelling in the flight and seats available
3. Validate airline code and connection while saving
3. Good Collaboration
4. Device Switch – Draft Functionality
This integration CDS and BOPF applies only to Custom DB Tables and will also be outdated soon with emergence of RESTful
ABAP programming Model with S/41909 OP + ABAP on Cloud.
In custom table the PK of the table HAS TO HAVE DATATYPE AS /BOBF/UUID

for more http://www.anubhavtrainings.com


Business Object

Header

Items

for more http://www.anubhavtrainings.com


Documentation
https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.9/en-US/a77d28ccaa114c009a17d7313075f86e.ht
ml

Hierarchy - Tree data structure


When we have a data which is interdependent, it always helpful to visualize the same in form of parent child relationship with
hierarchy.
Operating CEO
Concern
SVP
Country
Manager
Co Code
Emp
SLA

Co Code
Co Code

for more http://www.anubhavtrainings.com


New Hierarchy – parent-child hier
ABAP Report
CDS Views
Classical Hierarchies – Annotations
Fiori App

Funda Fox
1. If the data resides in same table, we need to create a join/self reference of table by itself.
2. Association for hierarchy, association cardinality comes as [1..*]

for more http://www.anubhavtrainings.com


C1 AND C2

c1 C2

for more http://www.anubhavtrainings.com


Approaches to build Fiori App using annotations

@UI annotations in the CDS


View

CDS View
Fiori App
OData
Annotation file will be
created in WebIDE
View Ourself

Processing
Controller

IO Data
View Data binding
Model

for more http://www.anubhavtrainings.com


Easy steps to build the tree table app
1. Get started with a sample UI5 project
2. Create a connection to our SAP Server (S/4HANA)
3. Create a Odata Model which can use the connection and talk to SAP Server
4. Create an annotation file which will tell the view in SAP UI5 to display what columns and what fields.
5. Create the view and add the controls which we need – Smart Filter Bar and Smart table + Tree Table
6. Binding to fetch the data and load in UI

Steps to create tile for this fiori app once deployment is complete (available as a TILE in Fiori launchpad)
Fiori Launchpad is the single access point of all the fiori app. - /n/ui2/flp
7. Create a tile in launchpad designer /n/ui2/flpd_conf
8. Create a catalog (home of all tiles)
9. Create a tile assigned to a sem object – action and create a target mapping for the same
10. Create a group
11. Create a role (include the catalog and group)
12. Assign the role to end user so that they can access your

for more http://www.anubhavtrainings.com


Links

https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.9/en-US/f8af07bb0770414bb38a25cae29a12e9.html

https://sapui5.hana.ondemand.com/#/topic/68e62adedfd44cd48cb6ebc418c8d95a
All CDS Annotations
https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.9/en-US/630ce9b386b84e80bfade96779fbaeec.html

lv_msg = & created under the number &

v1 = Standard PO
v2 = 4500000007

step 1: take lv_msg split in 2 parts based on first occurrence of &


left - ''
right - created under the number &
concatenate - left + v1 + right = Standard PO created under the number &
step 2: repeat again for v2
left - Standard PO created under the number
right - ''
concatenate - left + v2 + right = Standard PO created under the number 4500000007
for more http://www.anubhavtrainings.com
SAP is already offering FREE READY MADE APIs of Type ODATA and SOAP services in S/4HANA systems to expose your PO, SO,
Material, AD, HR, Per., PR, PO – API.SAP.com

S/4HANA

ODATA Services ME21N


Consumer New Fiori App for PO

for more http://www.anubhavtrainings.com