Abap Hana
Abap Hana
Abap Hana
Ans: Inline declarations is a new way of declaring variables and field symbols at operand positions.
EXAMPLES:
Before 7.40
With 7.40
DATA(text) = `…`.
Before 7.40
With 7.40
Before 7.40
With 7.40
Declaration of a result
Before 7.40
With 7.40
Before 7.40
DATA a1 TYPE …
DATA a2 TYPE …
oref->meth( IMPORTING p1 = a1
IMPORTING p2 = a2
… )
With 7.40
… ).
Before 7.40
ixml = cl_ixml=>create( ).
stream_factory = ixml->create_stream_factory( ).
document = ixml->create_document( ).
With 7.40
DATA(ixml) = cl_ixml=>create( ).
DATA(stream_factory) = ixml->create_stream_factory( ).
DATA(document) = ixml->create_document( ).
Field Symbols
For field symbols there is the new declaration operator FIELD-SYMBOL(…) that you can use at exactly
three declaration positions.
ASSIGN … TO FIELD-SYMBOL(<fs>).
Ans: while using aggregate functions in a SELECT QUERY, all the columns that do not belong to
aggregate-functions should be put in GROUP BY Clause.
When an aggregation is used with CASE statement, it has to be mentioned in the GROUPBY clause
Ex:
itab = VALUE #( ( 1 ) ( 2 ) ( 3 ) ).
Ans. DBACOCKPIT
Ans. A Catalog is collection of Database Schemas in HANA. Schema: grouping of all database objects,
Schema is a mandatory database object allows companies to use same database keeping data from
multiple system where DCL and DB constraints can be managed at schema level
Ans. Schema user , i.e the database user is used to access the data with certain authorization levels.
Ans. Information Model: main purpose is to hide the technicalities to select data and make it easier
for business users to model their data which can be pulled w/o technical knowledge just db
functional knowledge is sufficient.
An information model: ( purpose was to hide the complexity and to overcome some setbacks with
the queries )
Used to convert linear structure to a multi dimension structure w/o knowing technical language.
Are Process of converting source data (in tables) into business understandable format.
If we define information models inside HANA DB, We can also reduce the data transfer b/w DB and
App layer.
For the purpose of taking business informed decisions and they run on top of HANA DB doing code-
pushdown or functional pushdown to the DB layer
Ans. SQL optimizer function is to process and optimize the SQL queries submitted to HANA and
finally executed by the SQL engine in SAP HANA
Q30. What are the other three engines which are part of SAP HANA?
Ans.
Q33. What is a Star Schema in ABAP on HANA?
Ans. When we combine data of dimension (master) with measure (transaction), it becomes Star
Schema. And to join two or more Star Schemas, it is done by Calculation View.
Ans. This view can have only one measure. It cannot have multiple measure. Basically one fact table
in an Analytical view. Ideally only one Fact Table should only be used with Analytical view since Fact
Table requires an aggregate.
Ans. Steps to create an attribute view in HANA Studio since graphical representation is not available
in ABAP on Eclipse:
Data Preview
Ans. Content is collection of development packages where we add different development objects
including Information Models: which are HANA specific data type.
Ans. It provides a name space for your development object. Once an information model is activated,
it creates a view in the HANA DB and it is stored inside the schema.
Eg. <packagename>::<viewName> schema
It allows you to transport all logically related development objects. Grouping development artefacts
together known as Delivery Unit.
Statement: To expose a View/Model to the user, you create a select query on top of your view and
create an OData on your query and create a fiori app to expose it to the user…sap.viz OR use ALV
grid
Ans. View Proxy is used to pull the data from a view in ABAP. To expose a Data Model to the
application layer ( ABAP Layer ), SAP NW7.4 SP02 onwards, provides a feature called View Proxy
which allows SAP HANA data models to communicate with the ABAP Layer using ADT in eclipse and
lock the objects in a Delivery unit to transport the objects.
Q41. What is Hierarchy?
Level based hierarchy – Relation between master data w.r.t. groups, these groups can come from
multiple tables.
Parent-child hierarch – the relation works as self-relation. In this the table has a relation with itself
and mark one of the column as parent and another a child. E.g. manager employee relation.
Ans.
Inner This join type returns all rows when there is at least one match in both the database
tables. In short. join between 2 tables must fulfill the join criteria
Left Outer This join type returns all rows from the left table, and the matched rows from the right
table.
This join type returns all rows from the right table, and the matched rows from the left
Right Outer
Joins the tables as like inner join, additionaly it will include the record of the table in-
direction for which no corresponding records available in transaction table.
Referential This join type is similar to inner join type, but assumes referential integrity is maintained
for the join tables.
Its smart inner join.
If we have 2 tables connected via ref. join and a query is written on Attr. View and do
not include the join column or the column on master check table. Essentially you are
just selecting data from main table, The join will be “pruned” (exclude – don’t care).
When you also apply an filter on data model, the ref. join also acts like inner join
Text Join This join type is used to obtain language-specific data from the text tables using a
language column.
Full Outer This join type displays results from both left and right outer joins and returns all
Joins (matched or unmatched) rows from the tables on both sides of the join clause.
Text Join A join between master table and its text table with language key
Temporal join for timeframe – also known as Equi-join. BETWEEN condition in select query. **
Join applicable only on Analytical Views
Star join Its only used in calculation views, it is used to combine multiple fact table directly.
Ans. When a Fact table to be connected to multiple dimensions, we use analytical view. The
Analytical views are built to perform complex Aggregations( SUM, MIN, MAX, AVG, COUNT ) on
measure. These views are processed by OLAP engine in SAP HANA. They are used to build so called
STAR schema. Also has capabilities to define calculated columns, restricted columns, filters, import
parameters, complex conversions.
It is important that In an analytical view, we must mark attributes and measures at the end in
semantic. Because an aggregation will be applied only on measure.
Ans. To include multiple facts as part of data model, we can go for calculation view, these views are
processed by Calculation Engine in SAP HANA. They are suitable for more complex calculation. CVs
can be created in two ways: Graphical and SQL Script ( to achieve parallelization). SQL scripting in
Calculation view can be implemented in two ways: CE functions ( to get better performance ) or pure
SQL
Unions
Aggregations
CE_*
St. In case of CE functions the call/execution remains in the CE engine, where as in case of SQL
Scripts, it has to go outside of the Caln Engine to SQL Script Optimizer to execute the function
leading to a drop in performance.
Q49. What are the cases when can you use different views for different requirements?
Q51. What is ADBC?
Ans. ADBC stands for ABAP Database Connectivity. It is used to run HANA related queries directly
using ABAP code. ADBC APIs are available since NW 7.4 to call the queries using simplified interface.
Your system does not have ABAP ADT available, you cannot create proxy object.
Q52. What is a Decision Table?
Ans. A Decision Table is used for planning scenarios, that allows business users to model business
rules with less/no technical knowhow and apply the rules to see the results with read data.
2 types of DT
Decision table with update value: We can update the data of a specific column in SAP HANA by
defining business rule.
Decision table with Return Value: In this we have the result as an additional updated column.
(preferred for use business cases: not changing the actual data in the DB)
Ans. A Business Rule Management system manages set of rules which are frequently changing in the
business.
Ans. CALL “<procedure_name>”(?)
Ans. Programming language are independent products, they generate their own executables.
Code is compiled by programming language and converted to machine code / OS code.
Scripting languages are embedded on programming language. They rely on the APIs of programming
language.
Ans.
Decomposing complex business logic, Intermediate results from the views cannot be store.
SQL queries can only return one value and has no chaining.
Imperative logic.
Q57. What is SQL Script in HANA?
Allows developer to write performance-intensive logic inside database. One of the technique used in
code-to-data paradigm.
SQL statements which are not assigned to variable. ( Eg: Lt_Anubhav = select * from snwd_pd
where price > 1000; --Query 1 )
Ans.
SQL Script is executed and processed in the calculation engine within the HANA database.
In SQL Script, a local variable can be declared to hold the interim result.
SQL Script Procedure can return more result by using "OUTPUT Parameter" while Normal SQL
Procedure can return only one.
In SQL Script, you can define global or local tables types which can be used as parameters.
Q63. What are different Data Types in SAP HANA?
Ans. Different Data Types that are called Primitive Data Types in HANA are:
Ans.
Q66. What is the difference between PROCEDURES and USER DEFINED FUNCTIONS in HANA?
Ans.
Ans. When we declare variable in SAP HANA SQL Script ( Scalar Parameters ), These variables are
initialized with NULL value. We can explicitly assign value during creation also.
When we want to use a variable in SQL script, we use symbol colon (:) to refer the variable. E.g.
Declare x integer;
BEGIN
….
END;
Ans. CREATE PROCEDURE <proc_name> (in pname ptype, out pname ptype, inout pname ptype)
LANGUAGE SQLSCRIPT/R
WITH ENCRYPTION AS
BEGIN
----code
END;
CALL <procname>(params);
Ans. Whenever a New Procedure is created, in order to re-create or replace the existing procedure,
it needs to be dropped first. Syntax to Drop Procedure:
Q73. What are different syntaxes in SQL script for different functionalities?
Ans. If condition
IF <cond> THEN
…..
….
END IF;
Loops – iteration
While Loop
While <condition> DO
END WHILE;
BREAK;
FOR i IN startIndex..EndIndex DO
….
END FOR;
Ans. TRY.
…..code…
…...code…
CATCH ex_class INTO lx_obj.
…
ENDTRY.
Syntax:
---code
END;
Syntax:
Cursors are used to fetch data records from table row-by-row from result of a query assigned to
cursor. We always bind a Query to cursor. It is also possible to parameterize cursor.
NOTE!!: If possible Avoid using Cursors in HANA DB , since HANA cannot optimize or run SQL in
Parallel mode.
Open the Cursor (Submit the query to Database) – query submitted to DB and data is loaded
5. Close cursor
Q80. What is the syntax to create an Array?
Ans. An Array is a Single column table a one dimension structure to hold multiple values of same
type. An Array CANNOT be used in SIGNATURE of a PROCEDURE.
Ans. User Defined Functions in SAP HANA are the read only function that means we cannot perform
any DDL and DML(insert update and delete) operation inside the body of the function.
Q84. Things to consider while working with SQL Script Procedures for CODE Pushdown?
Ans.
Since there is no explicit functionality of LUW concept in HANA, it has to be taken care while using
SQL scripting
There is no implicit locking mechanism, it has to be taken care while working with SQL scripting on
DB
Ans. Whenever an Information Model or a Procedure is created in HANA DB, a View Proxy or
Procedure Proxy is created in ABAP Stack respectively. Which means that an object already exists in
a DB and in order to communicate with the DB object from ABAP stack, you need to create a proxy.
Ans.
Lifecycle management of HANA vs ABAP object.
No extensibility
SQL script code which was earlier done in HANA DB is added to this method
When we call the AMDP first time, it will create the corresponding DB procedure. Name of that
procedure will be classname=>method
Ans. Pre-requisites:
We must add an interface to a class in ABAP to make it powerful so that it can become a AMDP,
IF_AMDP_MARKER_HDB
All the parameters of AMDP has to be table type or scalar parameters, No object or nested tables
allowed.
Advantages:
Syntax check
Disadvantage:
Client handling
…..
….
ENDMETHOD.
Ans. CDS view is basically an abstraction of ABAP to Database layer which allows you to model
semantic rich data models ( like Information views on HANA DB ) on ABAP Stack and on activation it
leads to creation of corresponding Database View in DB. It is an enhancement of SQL which provides
us DDL for defining semantically rich data models (table/view) and user define types in Database. It
is an extension of SQL : i.e DDL DQL and DCL
St. The objective behind creating CDS Data Model is that , it will be understood by all SAP
products viz SAP Fiori, KPI modeler, BO/BI, BOPF, FPM, IDA Native HANA Apps.
Annotation to enrich the data models with additional details (all annotations starts with symbol @)
DB Entities are connected using Association at conceptual level (replacement of join conditions)
1. ABAP CDS
Ans. CDS view is defined using CDS data definitions.:-> Also known as CDS document or CDS source
code. To create CDS views we need to use ADT.
Ans. Annotations are used to add metadata information to CDS entity. Annotation specifies the
properties and semantics of entity and its behavior when it is consumed. There are UI
Annotations, Object Model annotations, VDM annotations, Environment Annotation etc.
Extensions Yes No
Q100. From semantic point of view of S/4 HANA what are the categories of CDS views?
Ans.
Also Read: Associations in S/4HANA
Ans. It represents join where the two columns are used in join where one of the column is a
Projection. To make it available in the Data Preview, it has to be exposed to the DB. In S/4 HANA the
association is indicated with a name starting underscore. Eg. _Supplier, _BusinessPartner etc.
Ans. Columns are indicated using a Projection of a table, We can use $projection in CDS for the same
in association join condition.
Q104. How to create an ALV report in SAP HANA using CDS view?
Ans. SAP NW 7.4 onwards ABAP list viewer comes with an IDA ( Integrated Data Access )
it is possible for tables that contain very large quantities of data to be displayed on the UI which is
called Pagination and
Automatic Query (No need to write a SELECT Statement, since the IDA framework prepares the
Query, sends it to the DB, pulls the data and displays it in the ALV. Only Data Source Name needs to
be provided to the IDA f/w, this data source can be a CDS View, which leverages the strength of CDS
like code pushdown and performance). The results of operations such as sorting, grouping, or
filtering are also delivered with a very fast response time.
Ans. In order to consume the OData service based on CDS, to create a Fiori app, we used concept of
Cloud Connector. To communicate securely, over the internet , by S/4 HANA On-premise with the
SAP Cloud Platform, we need Cloud Connector.
Q106. What are the steps to configure Cloud Connector?
2. download msi
https://tools.hana.ondemand.com/#cloud
https://www.microsoft.com/en-us/download/details.aspx?id=40784
3. login to sap cc -
user: Administrator/manage
expose resources
6. create destination
Ans.
Ans. A CDS entity is enriched by annotations which are used to build end-to-end fiori app utilizing
these annotations. To consume a CDS view, instead of consuming it in ABAP program it is advisable
to consume it using “CDS entity” since it allows access to metadata.
Ans. In order to Develop CDS view for Analytical tools for BW, VDM – Virtual Data Model – Analytical
query can be build using CDS views.
An Analytical App can be build using a CDS view ( Consumption View ) on top of a simple CDS view
( interface view) using UI annotations.
Using UI annotations, we can define selection fields, the lines items of table, data points of chart,
measures and dimensions for chart and expose this CDS as an odata service and build a Fiori App
Ans. CDS Table Function can only be implemented with NetWeaver 7.5 which calls an AMDP ( ABAP
Managed Data Procedure) using CDS view. Using CDS interface concept, underlying calls an AMDP.
This is required in case there is some functionality which CDS cannot achieve -> Eg. Data Type
Mismatch, Looping, Conditional Looping and Logic
Q111. How can you secure your Data Access using CDS view?
Ans. Right click -> Core Data Services Folder -> Create Access Control -> mention the PFCG Role
Name
Ans.
@UI. presentationVariant – to initialize the UI ( available only on S/4 HANA systems ), define SORT
order, group based on fields, define default visualization at the view level
Ans.
Normalization : converting each letter into its equivalent upper and lower care.
It also does linguistic analysis of words: finding equivalent word with the nearest meaning
Ans. FUZZY SEARCH in SAP HANA is a Fault Tolerant search which allows a level of accuracy ( which
can be specified in the WHERE clause as percentage ) , and returns the value with an approximate
match.
Ex: Query