ABAP On HANA
ABAP On HANA
ABAP On HANA
http://www.onlinefioritranings.com
[email protected]
SAPGUI
OData
Application Layer – NW
Application Layer - NW NW7.4 SP02, SP05
NW7.5
CDS
ADBC
AMDP
DB inf.
If i start teaching you VB, how many of you will join my course?
Outdated content <NOONE>
Fiori 2.0
XML, Comp, Rou, RMH, ALP,
[email protected]
Database – used to store all the data. ERP – Software and hardware combination to manage your business end to end.
Wallmart – Over years lots of data will be created inside of server. Sometimes there is a need to analyze this massive data to
take informed future decision.
I want to know how many laptops were sold in the month of Christmas. Mumbai
How many smart phones i sold on thanks giving day.
Which company smart phones selling the most – Samsung, iPhone, Windows,.... ETL (Extraction,
Transformation and
Loading)
Miami Santa Clara
Report in
ABAP
NYC California
Result
SQL
replication BW
Database (OLTP) (OLAP)
MARA
35 year
RDBMS
CPU RAM
Relational DB
Registers
Management System
8084 IC
8 bit Database
16 Address Bus
HDD
2~16 Max size of memory
Mechanical
MOV A,B
IO processing
ADD A
Bottlenecks –
Storing data in HDD, Mechanical device needs IO processing.
CPU has limited power to process data
Cost of RAM was high
1010 00 01 SHIP1 SOLD1 MAT1 10 500 EA MAT2 20 600 EA
MAT1 10 500 EA
1010 00 01 SHIP1 SOLD1 MAT2 20 600 EA
Secondary Secondary
Index Index
Row Data
1001 SHIP1 600 USD 1002 SHIP2 800 USD 1003 SHIP1 900 USD
Calculate total amount of sales?
100110021003 SHIP1SHIP2 600800900 USD
Column Store
SHIP1
1001 600
(1,3) USD
1002 800
SHIP2 (1,2,3)
1003 900
(2,3)
Insert only approach – SAP never deletes data, always insert data with new timestamp.
Core Core
Core Core
Row Store Column Store
When you see unique values are continuously repeating. This
When majority of values are unique. Config, Org
gives chance to compress data better.
Usually All Org data and Config data
Usually All SAP Master and Transaction tables we use column
store.
No aggregation org, config, Customizing data.
Aggregations are required on massive data.
All records all time (Select * )
ABAP on HANA
1. Buy a server access from a vendor (2500 INR per month per user)
S/4HANA OP 1610 – SAP 7.52
> SAP ABAP system access from Local computer SAPGUI + ADT on Eclipse (CDS, AMDP, ADBC)
> Access to Odata and Fiori Launchpad from local computers
> S/4HANA VDM concepts can also be covered
> Unlimited access (no per hour charges)
> Remote server access to check SAP HANA DB + HANA Studio (Local access to HANA not possible)
SAP HANA
IM – Attr, Ana, Cal (2)
SQL Scripting
JSP – Java Server pages
01012018 02012018
5AM 11AM
.java (1)
02012018
10AM
browser
HANA Colgate
IBM
SAP
TCS HANA NASA
Product Company
Infy
HANA HANA Wallmart
Notes - patch
Note to fix the bug.
BW, Analytics
Old Database Data provisioning HANA BOBJ, Crystal,
Excel
XS Advance
SAP HANA Repository
XS Classic
Java, Node.js, HTML5
Name Server – in case of distributed system architecture, it routes the requests to different server by balancing load
Persistence layer
Page management Logger
Max DB
Evolution of SAP HANA
Release 1.0 SPS0 – beta Release
SPS01 – GA (General Availability)
SPS02 – You can use SAP HANA as Secondary DB (Side car scenario) – BODS, SLT
SPS03 – To be able to connect to SAP BW directly, BW 7.31 – BW powered by HANA – Project Orange
SPS04 – Flat file data provisioning
SPS05 – DXC – Direct eXtractor connection, SAP HANA XS (Native Application develop), PAL (R Logic)
SPS06 – If you are on SAP NW 7.4 or above you can now run SAP HANA as primary database on top of ABAP
CRM, Suite on HANA, Introduced web base tooling (lm)
SPS07 – Smart Data Access, AMDP, AFL, Job scheduling
SPS08 – Only HANA DB can be installed on SUSE linux, We can now install SAP HANA on RedHat linux
SPS09 – Multitenant database containers (MDC), WebIDE tools (calculation views), new DB interface, API – zip, virus scan,
SMTP
SPS10 – Hight availability and disaster recovery options
SPS11 – XSA (Java, node.js, HTML5), ML
SPS12 – Workload analysis, Zero downtime
Release 2.0
SP0 – Backup encryption, 3rd party tool support MDC, Recover from snapshot
SPS01 – Doc Store, dynamic cache
SPS02 – Integrate google’s tensser flow ML library
download 2500 INR per month per user
9000 INR – 2-3 hours a day
SAP GUI screenshot
Step 1: go to https://tools.hana.ondemand.com/
Step 2: Download eclipse from ABAP section by choosing Eclipse Oxygen based on OS type
Step 3: After download extract to your system e.g. D:\Eclipse
Step 4: Run Eclipse.exe
Step 5: Eclipse will ask you workspace – it is a folder in your local computer where eclipse will store file. E.g. D:\anubhav
Note: Make sure your SAP GUI is already installed.
Step 6: Help -> Install new software...
Step 7: Enter url http://tools.hana.ondemand.com/oxygen and hit Enter key
Step 8: Choose ADT and HANA tools, complete the installation – Eclipse will restart
Now you can click on open perspective button, and will be able to see ABAP perspective.
Benefits:
You can work with multiple systems like Dev, Q, Prod
It seamlessly integrated with SAPGUI, whenever there is no support from ADT, a SAPGUI window will open
Multiple systems, multiple landscapes, Different system (Java, UI5, HANA, Native, ABAP)
No context switching hence increased developer efficiency
Flexible and customizable
Fast search and navigation capabilities
Supports extensibility - objects like CDS, AMDP, Proxy can only be created by ADT, Only tool for ABAP on HANA
Supports debug and Transport capability
ATC (ABAP test cockpit)
ABAP Profiler
Supports UI development in parallel to Backend development
Inbuilt quick fix capabilities
Modularize code
Code template
1. An interface – It is known to be pure abstract class. We only have method definition inside interface, never the
implantation.
2. Abstract class = We cannot create an instance of abstract class. A class which has at least one abstract method.
3. Concrete class = which implements all the methods, the actual functionality.
Abstract Abstract
Fly
ABAP Report
AC_PLANE
FLY
Load*
CL_PLANE_PASS CL_PLANE_CARGO
Load Load
NW 7.4
1. Inline data declaration, We can declare our Data object inline of code itself.
With comma separated column list it is mandatory to use host variable @ symbol.
( ) – parenthesis
{ } – Curly braces
[ ] - bracket
4. Table expression
5. String Expression
Lv_str = | Hello all ABAPers this is session from { lv_var } by { lv_by } on { sy-datum } |.
Use Case: Create a program where input is a string (can include numbers, chars, special char), traverse through each char
and print them separately.
Since we cannot tell the char. Data type we need to define dynamic reference and loop over it and print the data.
Memory
WA Anubhav
Anubhav
pointer
https://help.sap.com/viewer/f1cccec432514a3181f2852f2b91d306/7.4.15/en-US/c84cb8db0b3b43908ae4e987f3a3ade5.html
Is my custom code still valid?
Mostly.
Oracle HANA
When we migrate to SAP HANA what is valid, whats not?
OrderId Amount
Every single statement which you wrote in Open SQL and Core ABAP will be valid. 1 100
Open SQL and Native SQL
2 600
1. Native SQL statements may not work where you were directly calling DB. 3 200
EXEC SQL. 4 300
Select ROWNUM, ORDID from SAPABAP.VBAK
5 60
OPEN CURSOR C1 FOR SELECT FROM DB TABLE.....
ENDSQL.
2. DB specific hints for performance improvement – Not a show stopper
‘%_HINTS MSSQLNT ‘&prefer_join0&’’
3. Selecting data from db table without order by and then using columns for binary search
select from tab order by amount Amount
loop at itab into wa where amount < 200 binary search. 100
4. Direct access to pool and cluster tables will not work
600
5. DB specific checks for secondary indexes.
200
10000 objects which i developed over years in my company. 300
60
Code inspector – SCI – SAP NW 7.02 SP12
Native SQL
SQL, PL SQL,
SQL Script
Database Layer
before migrating .. first we need to identify the changes using SCII.. and do the changes after
that.. migrate it to HANA .. is my understanding correct..?
Fiori UX
Transparent optimization
Performance improvement guidelines – Talking to database
Discard records which are not required – WHERE
Keep the result set small Nested loops, Exit statements with loop
Use having with group by clause
PERFORMANCE_DB
You ran these Function DB checks and Performance DB Checks, You identified 5000 issues in you custom package. Can
you change everything?
Challenges:
We need some trace to find which programs are used the most, which tables are queried modified the most to be able to
prioritize where to improve. Which program is the highest entry point.
ST05 & SAT – cause overhead on system. Executions of your production become slow.
STAD & ST03 – system level tools used by basis to get aggregated performance results (high-level), it doesn’t tell which query
(Statement) caused it.
ST04 – comprehensive data but cannot tell entry point.
SWLT
1. Which of the business process (transaction/report/bapi) takes the most of the time in production system.
2. What is the SQL profile of my main business process. – At the statement level.
3. Most expensive SQL statement in your production system and which business process is triggering the same.
4. Which process works with most of my production load and process huge number of data records.
5. Most often executed SQL statement.
Advantage:
You can this both for standard and custom packages.
You can activate the tool in certain server or for all servers.
You download the results and keep them as a back up for future reference or analysis on a different system.
Look at the results of the tool from multiple angles.
FM query
User: Get the employee of team A and get all Sales orders of that team.
NW 7.3
Dev Q Prod.
SWLT 20 SQLM
HANA DB
HANA DB HANA DB
OpenSQL
DB6
Usage
EPM Data Model – Enterprises Procurement Model
This includes a model company named as ITeIO – Selling Electronic products on internet. Just like Amazon, eBay.
Stock
EPM Data model – Training data model – should not be used for productive purpose
NW 7.4> these tables are there in your company system.
May so happen that data inside these tables are not there:
New Open SQL Enhancements in NW 7.4
DDL – Data Definition Language – Create,change,delete new DB objects like tables, str, View etc.
Example: CREATE, ALTER, DROP, TRUNCATE
DML – Data Manipulation Language – INSERT, DELETE, UPDATE, UPSERT – Data Manipulation
DQL – Data Query Language - SELECT
DCL – Data Control Language – GRANT, REVOKE
TCL – Transaction Control Language – Commit, Rollback
Fresher interview Q
What is transaction?
It is a DML statement(s) given to database between stable state of database. A transaction ends with TCL.
Come to me with Certification. (85-98%)
Exercise: write a report program to print sales orders of a given range of Business partner id. (Technical GUID)
Snwd_bpa-bp_id
Cash plays very important role in a company’s running business. It is in the best interest of a company to collect outstanding
payments (receivables) from the customers as quickly as possible. By quickly turning the sales into the cash, a company has to
put its cash back again ideally in the business or re-invest to increase sales.
Mr. Jems is an A/c Receivable accountant in this company, who’s main job role is to manage the cash. Typically, search, display
Invoices that are overdue and also exceeded a pre-defined and customizable threshold in terms of Days or Amount. Also
classify the customers based on the risk of non-payment.
His department also has Barbra she also works with top notch customers but she has different criteria to classify customers.
1. Check how long on average the invoices has been outstanding from customers (customer wise report) – Takt 1
Step 1: get the all the open invoices (unpaid inv) from invoice header table. Table SNWD_SO_INV_HEAD, column
PAYMENT_STATUS = ‘’
Step 2: Loop at each open invoice, calculate the total number of days since when invoice is open ( TODAY -
CREATED_DATE ), also count the number of invoices per customer. Calculate Average.
2. Check the gross amount of open invoices in a “common currency” – Takt 2 and Takt 3
Step 1: Get the items for each ( invoice which are open ) and items which are shipped get it per customer.
inv item = SNWD_SO_INV_ITEM – all items which are shipped
inv header – SNWD_SO_INV_HEAD – unpaid, customer
BP table – SNWD_BPA – company name
Step 2: Loop at each item and does a currency conversion of gross amount to a common currency lets say EUR.
Step 3: Calculate the total of gross amount to converted amount to a common currency.
3. Classify the customers regarding their ability to pay their bills (based on threshold value which they want) – Takt 4
Design a customizing table and replace hard coding with values of threshold based on user (jems or barbra....)
4. Perform a dunning for data – Takt 5
1 368+338+308 1+1+1
Amazon
invoice
2000
US IN
Colgate
DE
4 types of people:
Sleepers: Least bother about anything, old ways, old things.
Snoozers: I have, i will i want , i should change but now,
Slamers: Took right path, leave it.
Active passionate: Walkers –
Schema in a DB?
Is a mandatory database object. Used to organize and control the authorizations of Database objects inside of a DB system.
Database object like Table, Structures, Types, Views, Procedure, Sequences, Triggers resides inside of Schema. Usually
Schema inside SAP HANA has 1:1 relationship with ABAP / non-ABAP systems.
SAP NW 7.4
Customizing
user
SAPABAP1
MARA
Old DB
Customizing Data Provisioning
MARA SAP HANA
SAPECC
MARA
Folder structure in HANA DB
Catalog : Collection of All schemas. Home of mandatory database object called “Schema”.
Provisioning : is used by DB migration experts during provisioning process.
Content: Collection of packages inside of HANA, each package includes the object, We can transport from D-Q-P objects of SAP
HANA only and only when they are part of a package.
Security: Used by Admin to control authorizations for users.
When you do productive ABAP development, where do you store your FG, FM, Rep?
Package.
Organize the application artifacts in a package.
Group of packages becomes and Application Component.
Transport layer.
In SAP HANA, When we do DB development e.g. Information models, views, procedures, functions must be part of a package.
Content stores the design time information of object (definition), When is the object is activated, it is persisted inside of
schema.
The data in an enterprise is stored in multiple database tables. We need to fire complex queries (joins, selections, conditions,
sub queries) to pull the data from db.
Challenges:
Complex for business users to write such queries.
End up writing a query which is performance disaster.
Queries also has limitations as they do aggregations and use ready to use functions but they cannot perform
transformations like currency conversion.
Information models: Main purpose of IM is to hide the technicalities of SELECT queries and make it easier for functional
consultants with little technical knowhow to produce desired data and out comes.
Table Table
Table Model SQL Statements
Table
It can be used to convert linear structure to a multi-dimensional structure w/o technical knowledge of SQL.
Data can be fetched in business understandable format.
The model execution happens with the DB layer, it can leverage the power of SAP HANA.
As a result it reduces the amount of Data transfer to application layer, Only final result is sent to DB.
Complex transformations like curr. Conversion can be also done within the DB.
Information Models
Master Data Transaction combined with More complex cases Planning scenarios
Join Master UNION, INTER
AT_ Calculate aggregates
Join Fact – dimension
AN_ Graphical Scripted
SQL Optimizer
Join Engine
Calculation Engine
OLAP Engine
Types of Data in an SAP system?
Org Data- CCA, CO, SO, SLA, PO, PLT – doesn’t even change. (Configuration for Applications)
Master Data- Doesn’t change so often, used to create transaction data. E.g. Material, Leg. A/c, BP, Product.
Transaction Data- tend to change/created frequently. E.g. Sales orders, invoices, Billing, Porders.
All the KPIs Should be measurable and they are numbers (numeric) and so called MEASURE.
Measures are stored in Fact Tables.(Transaction data)
SOID Amount Currency PID NAME CATEGORY
1 1000 EUR 100 Lenovo 550 Laptop
2 2000 EUR 200 Lenovo 450 Laptop
3 4500 USD 300 Canon D500 DSLR
4 8200 INR 400 Canon 1200 DLSLR
5 1960 INR 500 RAM FINc. 1 TB RAM
Sales
Time Customer
Attribute Views:
Semantics
Attribute output of dimension has to have
Orders Invoices
one mandatory key.
01
Data Foundation 02
03
Referential join
ABAP:
All Orders
View
Use Case: You have been asked to calculate which product in company has highest volume of sales.
HANA 2.0 – Attribute views and Analytical views are getting deprecated.
I am the CEO of ITeIO, I as a leader often listen many complaints from customers asking timely delivery and vendor’s asking
payment for products.
Use Case: Design something, which provides the details of each product in main line stream with information about volume of
sales orders v/s purchase order.
SAP<SID>
SALQTY SAPPRD
SAPDEV
CV_ANUBHAV CV_ANUBHAV
SAP NW 7.4 and above you can use View proxy concept to consume the HANA IM in ABAP system.
SAP BW 7.31 and above. SAP NW 7.4 SP05 – CDS VIEW
Transport of the object.
transport request = HTC (contain delivery unit ) + view proxy ( Consume IM in ABAP layer )
Application Layer Application Layer
Information Information
package Delivery Unit Model HANA View
Model
Delta field
Cons of View proxy approach:
1. If you transport to the Q system, corresponding HANA view is not available, Your ABAP transport will fail.
2. Delta changes in the IM would kick-out the view proxy object out of sync.
2. What if i am even below SAP NW 7.4, which means i am running SAP HANA as a side car scenario.
ADBC – ABAP DataBase Connectivity
When our ABAP system runs on any DB connected as secondary DB or Primary DB, we can fire DB specific queries directly to
Database (Native SQL query). Since we want to directly talk to DB we need an channel to do so. That is ADBC is.
Competence
SQL Script
SQL script is a collection of extensions to SQL (DML,DDL,DQL,DCL). The purpose is to give procedural capabilities to SQL. It
allows developers to write data intensive logic inside of core DB. This is one of the technique to achieve code-to-data
paradigm.
https://help.sap.com/viewer/p/SAP_HANA_PLATFORM
Types of Statement
--Q2
Lt_sales = select * from snwd_so where product_id in ( select prod_id from :lt_product); Q4
--Q3
Lt_pruchase = select * from snwd_po where product_id in ( select prod_id
from :lt_products);
Q2 Q3
--Q4
Select SUM(gross_amount) from :lt_sales;
Funda fox:
Every statement in SQL script ends with semi-column (;)
SQL script is not case-sensitive.
When we use a variable in SQL script, we have to put a colon before that (:). When we you are assigning a value to a
variable we must avoid the column.
delcare x integer;
delcare y integer;
y := :x;
:x = 4; ---wrong
x := 5; ---Correct
The assignment variable in SQL script is := not just =.
Container – Block of
SQL Script code
do begin
declare z integer;
z := 20;
select z from dummy;
end;
call totalnum(10,20,?)
Stored Procedure: It is anonymous block which is pre-compiled and stored in DB permanently. It can be reused by other
containers. It can also accept IN, OUT, INOUT parameters.
We can use ALTER statement to Change procedure, we are only allowed to change code not parameters.
It is a good practice that we drop procedure and re-create.+
IF condition THEN
Else
End if;
result := :res;
end;
call calculateOE(?,?);
While loop – it is used for conditional looping.
WHILE condition DO
....
END WHILE;
3
3*10 + 2*10 + 1*10 = 60
Funda fox:
When we create a variable in SQL script and do not assign a default value to it, it gets assigned with NULL value.
X = x + NULL; NULL
create procedure calcFact (IN x integer, OUT result BIGINT)
language sqlscript default schema "ANUBHAV"
reads sql data as begin
end;
Call one procedure in another
end;
FOR loop
FOR indexVariable startIndex..EndIndex DO
END FOR;
For loop
declare i integer = 0;
create table Emp( empId integer, empName varchar(80), salary integer, primary key(empid));
FOR i in 1..x do
insert into emp values(i, 'Employee ' || i, i * 1000);
end for;
end;
Exercise: In above procedure first time it creates and insert record. Next time i want to just insert record, do not want to
recreate or drop table.
Hint: check if table exist. If not, create table. If yes, just insert record.
In case you are unable to connect to RDP from Windows 10 laptop, please uninstall security path
https://serverfault.com/questions/911590/this-could-be-due-to-credssp-encryption-oracle-remediation-rdp-to-windows-10-
p
Exception: unanticipated/anticipated errors which may arise during execution of your programming code. When such error
occurs, end user will be exposed to dumps and technical information's, which is not really under stable for end users.
TRY.
--code
CATCH.
ENDTRY.
create table emptab(EmpID int, EmpName varchar(50), salary double, primary key (EmpID));
FOR z in z..IN_A DO
INSERT into emptab values(z, 'Employee' ||z, z*1000);
END FOR;
END;
Exception handling with exact error code and SQLEXCEPTION
--create table emptab(EmpID int, EmpName varchar(50), salary double, primary key (EmpID));
FOR z in z..IN_A DO
INSERT into emptab values(z, 'Employee' ||z, z*1000);
END FOR;
END;
How to throw exception (RAISE clause in ABAP)
SIGNAL SQL_ERROR_CODE xxxx(>=10000) set message_text = ‘any message’;
alter procedure createEmpRecord (in empid INT, in empname varchar(80), in sal integer)
LANGUAGE SQLSCRIPT
DEFAULT SCHEMA "ANUBHAV"
AS
BEGIN
END;
Table type: is a template of a table structure which can hold data (multiple records) @ runtime like internal table.
1. Implicit creation of tables
2. Explicit creation
2.1 Creating on fly
2.2 Creating using TABLE TYPE syntax
Use Case: Get all products from db table where product belongs to Veg Pizza category, get the total of all the sales gross for
those products. SNWD_PD (CATEGORY = Veg Pizza ‘Softwares’), SNWD_SO – (sum(gross_amount) where product into the
previously selected list).
create procedure getOrderGrossByCat (in imCategory VARCHAR(60), out gross bigint)
LANGUAGE SQLSCRIPT
DEFAULT SCHEMA "SAPABAP1"
AS
BEGIN
END;
Use Case: Return all the product item information where the product category items are used.
END;
Caution: NEVER create table types and procedures in SAPABAP1 schema, create them in your own schema calling DB tables of
SAPABAP1 schema from EPM model;
END;
Transfer data from an Array to a table
create procedure calculateTable (in num integer, out ret table(num integer))
LANGUAGE SQLSCRIPT
DEFAULT SCHEMA "SAPABAP1"
AS
BEGIN
declare i integer := 1;
declare calc integer ARRAY;
for i in 1..10 do
calc[:i] = :i * :num;
end for;
END;
Cursor: Cursors are used to fetch data from DB tables, they are actually a named query. Whenever a cursor is created, it is
assigned/bound to a query. It is possible to also pass parameters to the query.
It is not recommended to use cursor. When you use cursor, your are directly talking to DB interface. Typically when you use
queries, the data base optimizes your query.
Steps:
Declare Open Fetch Close
declare cursor c1 (cat varchar(30)) for select S from snwd_pd where category = :cat;
open c1(:im_cat);
--fetch statement will read row by row in the variable, here my_row variable is created automatically
fetch c1 into rprice;
close c1;
END;
Manipulate data with cursor
declare cursor c1 (cat varchar(30)) for select * from snwd_pd where category = :cat;
--you dont need to open, fetch and close - erquivalent to loop at itab
for my_row as c1(:im_cat) do
--access the row index cursorname::rowcount
arr_price[c1::rowcount] = my_row.S + 100;
prod_ids[c1::rowcount] = my_row.product_id;
end for;
--fetch statement will read row by row in the variable, here my_row variable is created automatically
--fetch c1 into rprice;
--close c1;
END;
How to check if the data is returned back from db table. Sy-dbcnt, sy-subrc.
Procedure Proxy
NW 7.4 AMDP
Class and method
Database Layer
Types of UDF
Scalar UDF – returns a scalar value, cannot use any table operations like cursor, CE, Array, input can be table
Table UDF – Returns a table value
Use case: return the list of all the customers from snwd_bpa
Where bp_role = ‘1’
Example:
create function getCustomers returns
table(bp_id varchar(20), company_name varchar(80), currency_code varchar(4)) as
begin
return select bp_id, company_name, currency_code from sapabap1.snwd_bpa where bp_role = '1';
end;
Calling:
7.4 Sp05
Procedures are called by CALL statements Functions are always called by SQL statements
You can never call procedures in SQL queries They can be called also directly with assignment operator
CircleArea = calcularArea(10); //SPS 9
We can have INOUT parameters in procedure
Cannot have INOUT parameters
It can return multiple values
Always returns one value either Scalar or table
Direct assignment of output to variable is not possible.
AMDP : AMDP stands for ABAP Managed Data Procedure
ENDMETHOD.
Advanage
Lifecycle has been simplified using AMDP
When the procedure in underlying HANA DB gets created?
not on activation, it when the AMDP is called first time.
AMDP and SQL Script Cautions with following points
You need to take care of client handling by yourself. Unlike open sql there are no implicit client handling while sending SQL
statements to DB.
You need to also handle LUW (Logical Unit Work) – not perform WRITE operation on DB SQL Script.
Locking of data.
Only work for HANA DB
CDS Views
ABAP CDS
HANA CDS
What is enhanced?
DDL (Data Definition Language)
DQL (Data Query Language)
Expression Language
CDS views are defined in ABAP layer, When activated an SQL view in HANA gets generated.
When we design CDS views in S/4, We need to follow SAP best practices.
DB - HANA
Fiori Application
@UI annotation
OData
Transactional App using BOPF
@ObjectModel
CDS Views
DML
Analytical Tools
@Analytics
OData
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abencds_f1_association.htm
1. Basic CDS View
2. Design a CDS of Composite CDS view with a fact table, where total sales of customer exceeds a certain amount.
What is VDM
https://help.sap.com/saphelp_hba/helpdata/en/e1/1389b514ca4e828a5f6e97cab8be02/frameset.htm
Association : It is a relation ship between entities (db table or another CDS view).
OData
Backend
When we want exactly one CDS view to be used for all the purpose of Fiori App, we can use
@Odata.expose: true
If we have multiple CDS views or some other tables and want to keep Odata service name based on your need, You can
design an Odata project in SEGW
From the perspective of Analytical tools
User case: Design CDS consumption to expose the sales data for products and suppliers.
Enhancement of CDS?
Z view on top of standard CDS view and include fields of your choice from exposed association of standard cds.
Limitations
1. You cannot debug CDS Views
2. Sometimes, we may have to use tables and columns of tables which are not supported by CDS. These are limitations of
CDS.
Roles
User
User
User Role_IN
User
User
User
Give access to these roles to the users Role_US
Authority-check ‘S_DEVELOP’
https://blogs.sap.com/2016/11/25/hierarchies-in-cds-views/
UI Annotations
https://wiki.scn.sap.com/wiki/display/EmTech/OData+4.0+Vocabularies+-+SAP+UI#DataPointType
Any S/4HANA system, we have a standard SAP Fiori Application delivered by SAP called Query browser.
This is Fiori application, which has details of all the consumption CDS views, Using these built-in CDS view, we can perform
analytics on of Business data at Real-time, hence it is so called SAP S/4HANA embedded analytics.
Draft state
Database Layer
Database Layer
Oracle, DB6, MaxDB,
HANA
MYSQL
Program Program
Int.Ses Int.Ses
FM sion FM
sion
memor memor
y y
FM FM
IMPOR IMPOR
T T
EXPOR Class EXPOR Class
T T
FM FM
SET
GET
Use case: design a database table for in flight meals. Where we can store preferences of meals per flight. We should allow
operator to create, edit and delete new entries in our custom db table with Fiori UX and draft functionality.
In last session, we created a Smart filter app using @UI annotations in CDS view.
DATA: LS_MEAL TYPE ZOFT_FLIGHT_MEAL.
DATA: LT_MEALS TYPE TABLE OF ZOFT_FLIGHT_MEAL.
SELECT * FROM SFLIGHT INTO TABLE @DATA(LT_SFLIGHT).
DELETE FROM ZOFT_FLIGHT_MEAL.
LOOP AT LT_SFLIGHT INTO DATA(LS_FLIGHT).
LS_MEAL-CARRID = LS_FLIGHT-CARRID.
LS_MEAL-CONNID = LS_FLIGHT-CONNID.
LS_MEAL-MEAL_ID = CL_UUID_FACTORY=>CREATE_SYSTEM_UUID( )->CREATE_UUID_C32( ).
IF SY-TABIX MOD 2 = 0.
LS_MEAL-MEAL = 7.
ELSE.
LS_MEAL-MEAL = 8.
ENDIF.
LS_MEAL-TOTAL_SEATS = LS_FLIGHT-SEATSMAX.
LS_MEAL-STATUS = 'X'.
APPEND LS_MEAL TO LT_MEALS.
ENDLOOP.
SORT LT_MEALS BY CARRID CONNID MEAL.
DELETE ADJACENT DUPLICATES FROM LT_MEALS COMPARING CARRID CONNID MEAL.
INSERT ZOFT_FLIGHT_MEAL FROM TABLE LT_MEALS.
How to expose Odata from SAP On Premise system over SCP (aka HCP) = SAP Cloud Platform using HANA Cloud Connector
https://www.youtube.com/watch?v=Cx3cXAEcnUs&list=PLcxqFaocb9WLtnq-rpXbRy5hnKECxr95G&index=8
https://blogs.sap.com/2016/09/20/fioriui5-cds-bopf-for-beginners/