Вы находитесь на странице: 1из 71

End to End Development Example in

SAP® NetWeaver 7.4 & SAP® HANA


SAP NetWeaver 7.4 Support Package 5
Author: Jasmin Gruschke- jasmin.gruschke@sap.com

Target Audience
• Developers
• Consultants

For Public usage


Document version 1.00- April, 2014
Contents
1 Remarks before you start .............................................................3
2 What's inside this guide? ..............................................................4
3 Technical Prerequisites ................................................................6
Check some preconditions .................................................................... 6
4 Scenario Description .....................................................................8
Data ModeI............................................................................................... 8
Full Reference Application .................................................................... 8
5 CDS View Building in ASAP .........................................................9
Let's create the CDS View(s) ............................................................... 10
6 ASAP managed Database Procedures (AMDP) ......................... 15
Let's create the AM DP .......................................................................... 15
Let's create the AMDP ... now we really start!. ................................... 21
7 Gateway OData Service .............................................................28
Would you like to test the GW service? ............................................. 42
8 Fieri-like Application ....................................................................45
Local SAPUI5 Application Development ............................................ 45
Import of the SAPUI5 Application to the ABAP backend ................. 54
You would like to test the Fiori-like App, right? ................................ 58
Thanks for joining ................................................................................ 58
Appendix ..........................................................................................59
Installation Guides ................................................................................ 59
Install Eclipse ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 59
Install needed Eclipse Plug-Ins •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 59
Add an ABAP Backend Connection (SAP Logon and ADT) ............................................. 61
System Configuration & Example Data Generation .......................... 63
Generate Example Data ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 63
ICF Configuration ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 65
Customizing for UIS & Gateway Services ..................................................................... 67
Appendix: ADT Shortcuts .................................................................... 69
Edit............................................................................................................................ 69
Help .......................................................................................................................... 69
Navigate•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 69
Run, Debug •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 69
Appendix: SAP HANA Development Guide ....................................... 70
Appendix: SAP HANA SQL Script Reference .................................... 70

2
Remarks before you start

1 Remarks before you start


<D This demo can be executed on an SAP NetWeaver AS ABAP 7.4 SP05 or higher
running on a SAP HANA database SPS6 or higher.

<D All screenshots have been made in an AS ABAP system with System ID (SID)
"HANAABAP" installed in the HANA Database Schema "SAPHANAABAP". Please
consider to adapt this based on the SID and schema of your system .

<D All ABAP Entities have been created in the "$TMP" package of the user
"DEVELOPER".

<D You will need a user on SAP NetWeaver AS ABAP with the following roles assigned:
o SAP_BC_DWB_ABAPDEVELOPER
o SAP_BC_DWB_WBDISPLAY
o /IWFND/RT_DEVELOPER (For Gateway Service Development)

<D A dedicated HANA User is not necessary, however, in case you would like to check
on created artifacts, you need a HANA user with role ABAP_ DEV assigned.

<D The screenshots in this end-to-end guide have been created based on HANA Studio
version 1.00.70 (Build id: 386119) and may differ with respect to other HANA
releases.

<D For more details, information and guides based on SAP NetWeaver AS ABAP and
SAP HANA please visit our SCN Page: http://scn .sap.com/docs/DOC-35518.

3
What's inside this guide?

2 What's inside this guide?


5. FIORI·Iflce App

25 min. TE>st{Oebug Cycles

This document shows you an end-to-end development example from SAP HANA via ABAP
to a Fiori-like application, which will look like:

• Cl X
_Jmo:/lobolld.~n...,-.n ~Jic•~i~.h!.m1 l.:t.J
~ ~ d!I~;~J,COJ«ri•t·f~'l:~~.:!_Jc;_~,;5J-.4.'.~:h._f~r,~,,~~··W•I ~ D- + ft
I Customer Llsl Del'9 led Customer lnformalton
r--------------, r---------------------------------------------~ -
Customers
Talpa 15842570.29
vso
SAP
100000CJ3

1 00000~0 Hanncve..
30625
An der Bretten Wiese
DeiBont Industries
DE

1000 00002

Order I) Crea:.onOate Gross Amount


,-- ~~;~~-----··--·--··----··--·--·------~--!
500000521 20 14-01 -0STOO·OO 00 0000000 5016.47 vso
CateQOI"f :.i'

100000003
50000HI26 201.'1-01-06100:00 OO.OOOCJOO 11t49.24 uso
Panorama studios
D
C3tegor; 500001627 20 14-01-0 7100.00 00 0000000 6018.47 tJSO
100000CJ)d.

2014-01- 16100:00 00 0000000 202.42 VSD


TECUM s
C~!e!IOI'f
600002637 2014-0 1-06100.00 00.0000000 6018.47 USO
I OOOOOOJ:..

50000254$ 2014-01 - 15TOO'OO 00 0000000 202.42 vso


More

15 138 ! 500003286 2014-0 1-26TOO.OO OO.OOOCJOO 24797.97 VSD

On the left-hand side of the application, a list of customers is retrieved, showing the name
and the ID of the customers as well as a category which depends on the number of open
invoices.

Selecting one of the customers from the list populates the right-hand side of the application .
In the header part some more detailed information on the selected customer is shown, in
particular the address information as well as the aggregated gross amount of all open
invoices for this customer. In the lower part, the list of sales order invoices with their creation
date and the gross amount per sales order invoice are listed. All gross amounts in the
application are converted to USD.

From a technical point of view, the application is based on a SAP NetWeaver OData Service
comprising the entity sets for the customer list (left-hand side) and the sales order invoice list
(lower right-hand side) and an entity set for the detailed customer information (upper right-

4
What's inside this guide?

hand side). While the customer list entity set is based on a CDS view, the information on the
right-hand side is retrieved from ASAP-managed database procedures (AMDP).

If you now say "never heard from neither CDS nor AMDP" don't worry, you'll get to know
these objects and their features while working yourself through this end-to-end guide ©.

5
Technical Prerequisites

3 Technical Prerequisites

, 1. Install and

30min.
Configure
2. CDS View building

n
i'Omin. Test/Debug Cycles
3. ABAP managed DB
procedures

G
70min. Test/Debug Cycles
4. Gateway Servfc.e
ModelinJ

7Smin. Test/Debug Cycles


S. FIORI-I ike App

m
25min. Test/Debug Cyd es

To follow this end-to-end guide you need an Application Server ABAP 7.4 SP5 (or higher) on
SAP HANA SPS7 and an Eclipse-based development environment including ABAP
Development Tools for SAP NetWeaver as well as the Ul Development Toolkit for HTML5
(SAPUI5 Tools).

Concerning the backend system, the easiest method is to set up and run the developer
edition of the AS ABAP 7.4, which is provided as virtual appliance by the SAP Cloud
Appliance Library (see http://scn.sap.com/docs/DOC-52323). Choosing this variant, there are
no additional system configuration steps. If you are working on other backend systems,
please consult the system configuration steps described in the Appendix (System
Configuration & Example Data Generation).

Using the virtual appliance as described in the document above, you can connect to your
frontend image via a remote desktop connection . On the frontend image, you can find a SAP
HANA studio installation including all necessary tools (ABAP development tools, Ul tools). If
you prefer a local Eclipse installation, please see the Appendix (Installation Guides) or the
Additional Information chapter in the mentioned SCN document.

Check some preconditions


As mentioned above, if you are using the AS ABAP 7.4 SP5 as virtual appliance, you don't
have to do any system configurations. However, it's worthwhile to check some preconditions.
1. Open the SAP Logon application and check that the ABAP system (in our case the
connection to application server abapci.dummy.nodomain instance number 00) is
maintained.

Choo;e lhe oonneclion ~e <Jnd c:hon~ the .iv;lem P<Jtomder; os •eQJited. Oelr:le lhe old d~1ipCion
l yovmnt the SY$lemto I:'OPO*C ode;cr.p!icrt. Button 'Q!C' i; mly ocbve when dl •eCI!Ated .,.,.. doto
~'»<$been ertered.

1
Ccrmeclion Type: ]custom Appac.!Jtion Se1vl!l' •

~ Sysl@mComedion Patamet!llr

I Oeserip!k!n. E .Develq=~et Edtion


AppieationSI!IIve• cb:::_
;=I .;o<:::_
l.a._::::m'"':.::..nod:::_om:::_
•n--===:J=~-"
lnctanc:e Numbet: ~
SV$temiD: ~
SAPro-.ter S uirr.~:

2. In the ABAP Perspective of the SAP HANA Studio, check that the ABAP Project for the
backend system mentioned in the previous step exists. The ABAP Project belongs to user

6
Technical Prerequisites

DEVELOPER (client 001) and the passwort is (initially) identical to the master password
of the virtual appliance instance (see http:/lscn.sap.com/docs/DOC-52323).

Fil$ Edit ~go!ll:e Search Project Run Window He\:1


O · 1:11 o • 'I;'J- · 0 · 9 · C9' · c:'!> r Q.
_ _ _ _ _ _ _ _ _ _ _ __'_IQu~,~~IV.~ce~ss===!J:J ~ I E/St>PHANA~ffoN"'

3. Please also verify that the Ul Development Toolkit for HTML5 (SAPUI5 Tools) are
installed, e.g . via the context menu Help> About SAP HANA Studio, where you should
be able to find the SAP Ul5 development toolkit with version 1.16.6.

fJ A4H_001 _bwdeveloper_en
~,. About SAP HANA studio 1!1~ Ef
t:J A4H_001 _~_en
SAP HANA Studio
(!)J.f V~r<inn: 1.n. mnn
r" About SAP HANA StudiO features 1!1~ Ef
. All Rights Reserved.
About SAP tWo&A studio Features )
licensed under the folowing license terms:
Provider Feature Name Feature ld p://www.apache.orgjlicenses/LICENSE-2.0
1-':'-'='------.l...':.::=="""-...,--.,--...,----'--"='-'-----'-','-"om"'.""sa""'
SAP SAPUIS AIJI>kation Devel. .. p.""
;de-.u-,iS,-.a-pp-:.f-eatu'-e p://www.eclipse.orgforgfdocuments/epl-v10.php
SAP SAPU!S AIJI>kation Devel. .. 1.16.6 com.sep.lde .uiS.epp.featu'e
SAP SAPUIS Featu'e 1.16.6 com.sep.uiS.uihb.feeture
SAP SAPUIS Featu'e 1.16.6 com.s~p .uiS .runtime.fe4b.l'e

7
Scenario Description

4 Scenario Description
The scenario you are going to implement is part of the reference scenario delivered with AS
ASAP 7.4. Based on the open item analysis, the scenario will give you several business
figures like a simple customer classification and open invoice amounts per customer
(including currency conversion).

Data Model pk = guid data type


The data model you will be using consists of four tables. Each table has a primary key
(datatype GUI D) called NODE_KEY and the key component CLIENT.

'II:; SAPHANMBAP.SNWO. AO • ill' SAPHANMBAP.SNWD_SO.INV_HEAD • liJ' SAPHANAABAP.SNWO_SO_INV_ITEM •


,. ., CliENT " "'CliENT
.;:.,.NQOE_KEY t~ ..- NOOE_KEY
.. . CUENT
~~ w NOOE_KEY \l1"'NOOE_KEY
' "'BP_ROLE 111"'SO_GUIO
..em < • EMAJL_AOORESS "'OLY_NOTE_NUMBER \!10.PARENT_KEY
"' POSTAl_CODE • PHONE_NUMBER "1.. SO_ITEM_GUID
\!1w CREATEO_BV
•STREET FAX_NUMBER v QUANTITY
w CREATEO_AT
BUILDING ' VIEB_AOORESS QUANTITY_UNIT
111 .. CHANGEO_BY
• COUNTRY ' AOORESS_GUIO GROSS_AMOUNT
CHANGED_AT
ADDRESS_TYPE NET_AMOUNT
• BP_IO GROSS_AMOUNT
VAl_START_OATE COMPANY_NAME TAX_AMOUNT
NET_AMOUNT
VAl_ENO_OATE CURRENCY_COOE
LEGALFORM TAX_AMOUNT
CREATEO_BY CURRENCY_COOE PRODUCT_GUID
CREATED_AT BUYER_GUIO INV_ITEM_POS
CHANGED_BY DUNNING_LEVEL
CHANGED_AT PAYMENT_STATUS
CURRENCY_CODE

Table SNWD_ BPA contains the relevant information on the business partner complemented by
a 1:1 relation to the business partner address data given in table SNWD_ AD. The information
on sales order invoices is given in tables SNWD_ so_ INV _ HEAD (header data) and
SNWD_ so_ INV _ I TEM (position/item data). The business partner table can be connected via
a 1:n relation to the invoice header table field BUYER GUID. The invoice header table can
further be connected to the sales order item table in a 1:n relation using fields
SNWD_ SO_ INV _ HEAD . NODE_ KEY to SNWD_ SO_ I NV _I TEM . PARENT _ KEY. One special
feature of the data model is that the invoice items table contains all items of a given invoice
in different currencies.

Full Reference Application


The scenario described here is just a small part of the full ASAP for SAP HANA reference
scenario. More details can be found in transaction SE PM_ OIA in your AS ASAP or on SCN
http://scn.sap.com/docs/DOC-35518.

8
CDS View Building in ABAP

5 CDS View Building in ABAP


1. Install and 3. ABAP managed DB 4. Gateway Service 5. FIORI·IIke App
Confiaure procedures Modeling

,If"'
3D min.
(A TestjOeb..lg Cycles
fh
20min. Test/Debug Cycles
w
25min. Test/Debug Cycles
~
25min. Test/Debug Cycles

As mentioned in chapter What's inside this guide?, the final application displays a list of
customers including the customer name, the customer ID, and the customer classification
category. While this could be performed by fetching the data into an internal table on the
application server layer and perform all necessary calculation there, we'll follow the code-to-
data paradigm, i.e. we push data-intensive calculation logic to the database layer and only
fetch the (display) relevant data to the application server. More information on the code-to-
data paradigm can be found in
http://scn.sap.com/community/abap/hana/bloq/2014/02/03/abap-for-hana-code-push-down .

The task at hand could be done using advanced functionality of Open SQL (see
http://help.sap.com/abapdocu 740/en/index.htm?file=ASENNEWS-740 SP05-
0PEN SQL.htm). We've chosen an alternative approach; we'll make use of a new feature in
the AS ASAP 7.4, namely a Core Data Services (CDS) view.

In general, Core Data Services (CDS) is an enhancement of SQL which allows a simple and
harmonized way for the definition and consumption of semantically rich data models natively
in HANA applications- independent of the consumption technology. The enhancements
compare to SQL include:
• Annotations to enrich the data models with metadata
• Associations on a conceptual level, replacing joins with simple path expressions
• Expressions used for calcu lations and queries in the data model

You may say: We don't want to create a data model in this end-to-end guide, which is
entirely true. However, we can make use of the advanced ASAP view building capabilities to
define a CDS view, facilitating the query on the data model described in chapter Data Model.

CDS views, like the well-known dictionary views created and maintained in transaction S E ll,
are managed by the ASAP data dictionary. During activation, a database view is created on
the HANA layer, yet only the ASAP CDS view (defined in a so-called DOL source) has to be
transported via the ASAP Change and Transport System (CTS). Moreover, the functionality
provided by CDS views can be used on all SAP supported databases, you don't have to
worry when transporting these objects in a heterogeneous system landscape.

More detailed information on CDS View building can be found in


http:/lscn.sap.com/community/abap/eclipse/bloq/2014/02/04/new-data-modelinq-features-in-
abap-for-hana and references therein.

9
CDS View Building in ABAP

Let's create the CDS View(s)


In our development example, we'll create two CDS view:
• zcosv_ OPEN_ I NVOICE, used to calculate the number of unpaid sales order
invoices per customer
• ZCDSV_ CUST_CLAS SIFICATION, used to consume ZCDSV_OPEN_ INVO ICE and to
additionally provide the customer name and 10 information

For the definition of CDS views in the ABAP data dictionary, an ABAP DOL source object
(R3TR DDLS) has to be created . These new objects can only be created and maintained with
the ABAP Development Tools for SAP NetWeaver, the artist also known as ABAP in Eclipse,
so we'll start the task in the ABAP perspective of our SAP HANA studio:

Description Screen Shot


1. In the ABAP perspective of ~ EA ~~ '54014'1 PfOII(I R\1'1 ~.. ~

1\ 1!' . 1> · 0 · 0, ·
the SAP HANA studio, right- ~~~~~~~2~~d·l d;t 9St#IWM~e
click on the $ TMP folder of
your ABAP project and select
New> Other ABAP
Repository Object from the
context menu.

2. In the creation dialog window, r,.. f"'!ew ABAP Repository Ob)ed R~ Ef


ABAP Repository Object
filter on "ddl", select
Create an ASAP Reposi.:c:ry Object
Dictionary> DOL Source and
continue with Next. Project: IA4H. 001. devel:>per_en Browse

Ba:k I li7¥?
Next ~ fin1sh Cancel

10
CDS View Building in ABAP

3. In the New DDL Source


OOLSOuJCO
dialog, enter the information: Cre<te oOOl Sovte

a. Name :
f!r'otect:• JA4H..orn ...~vebper.en
ZCDSV OPEN INVOICE PAdia~: • 'JWP

b. Description : r Md •• to9VO't" Nd·a:_,s

A4H : Information on open


sales order invoices

4. You develop in the $TMP


Selection of Transport Request
package, therefore you're CJ) Hoc:h!t'lge r!COJdhgeMI:I!d for ~kb;e $11'-'P

informed, that no transport r (11jZIS' ftO'Ylt~·"?.'"tnt,.,•:tl ·Y"'f'IYO'..,.d

request is necessary. Just TIM!fcrtReaaest I User I ro~~roet I Te.'llt


confirm this information.

Note: If you chose a


transport-relevant package,
you have to create/select a
transport request.

--GD-----------------------r-::-~-~-~:-::-l-,-,,---11~~cM-~-,-~-I
5. You can find the DDL source lC:, ProjectExplorer ~ = 0 (ill (A4H( ZCDSV_OPENJNVOICE ~

q;: ~ laz v
in the project explorer view r-· £J A4H_001_bwdeveloper_en
and an empty CDS editor S·~ A4H_OOI_developet_en [A4H, 001, ~VEI.OPa
9.. ~ Favorite Pad<aoes
window is opened. S·~a:J fiQ!MijiMJI
8 Q;j. Oictiona'Y CDS editor
El··IQ ABAP DOL Sources
;. l!i) ZCOSV_OFEN.)N\IOICE
, 1!1 £B S. EPM. OIA
63 a\ System Libr~rv

Code snippet: ZCDSV...E:1?EN~INVOICE

@AbapCatalog.sqlViewName: 'ZV_CDS_INVC'
define view zcdsv_open_invoice as select from snwd so inv head
{
key snwd_so_inv_head . buyer_guid,
'C' as category

where snwd so inv head .payment status <> 'P'


group by snwd-so inv head .buyer guid
having count(- dii tinc t snwd_so_inv_head . node_key ) <= 2000

union all

11
CDS View Building in ABAP

select from snwd so inv head


{
-
key snwd_so_inv_head . buyer_guid,
'0' as category

where snwd so inv head .payment status <> 'P'


group by snwd::::so_inv_head .buyer_quid
having count( distinct snwd so inv head . node key ) > 2000
and count( distinct snwd::::so::::inv::::head . node::::key ) <= 4000

union all

select from snwd so inv head


{
- - -
key snwd_so_inv_head . buyer_guid,
'S' as category

where snwd_so_inv_head .payment_status <> 'P'


group by snwd_so_inv_head .buyer_quid
having count( distinct snwd so inv head . node key ) > 4000

The CDS view is built as union of three distinct select statements. According to the number of open
(not-yet paid) sales orders invoices No_of_Inv, the customers are categorized according to:

• Category C: No o f I nv <= 2.000


• Category D: 2.000 < No of Inv <= 4.000
• Category S: 4.000 < No o f Inv

Remark: You may ask whether the usage of the HAVING clause and therefore the usage of
the UNION ALL functionality in the CDS view is necessary. The answer is yes, since CDS
currently does not feature a searched CASE functionality like
CASE ... when exp ress i o n ; the n ...",
which would simplify the given task. Let me just say: Stay tuned ©!
6. Activate the view (short cut
,. II

F;lo Edt SOtJrce NoW;! Click Proje<t Run W<ldow H.-,


~
Ctrl +F3). - • ~J>J{:;;j Ci' 1!0 t o ~ ~ - 0 · 9~ · lB - ~ .. ~ ~ · } · 1'"

CD Project Explorer ~ = El li5 •JA4H) ZCDS\1_OPEN_INVOICE !:3 )


@Aba p Catalog.,q lVievNM>e : ' ZV_ CDS)
de"t:ine view z.cdsv open invoice as ,.
-····Q AAH. OOI. bwdeveloper_en
El g A1H_OO I_developer_en (A4H1 00 1, DEVELOPEr
{ - - I
$ ~ f""or~ePocl<ages key snwd_so_inv_head.buyer_qu~
! 8··£tl $TIVP - DEVElOI'ER } ' c • as eeu:.e9or y ~
i 8 ca, Dictionary
I 13 (!; ABPS' DOL sour<es w-here snwd_so_inv_head. paymene_ sta
1 ~. mzcosv_DPEN_INVDra group by snwd _ so_ i nv _ head.buyer_ g
having count( distinct s nvd so i nv
i iti !B S_EPM. OIA - - -i
IE Ill Syst.., Ubrory
W>ion all. flj

-- -·-- ......
~el.ect fr' : :nvd_so_ i nv _llead .-.._}
-

12
CDS View Building in ABAP

7. You can have a look at the [0 Project Explorer ~ = El II:) (A4H) ZCDSV.OPENJNVOIC
output of the view. Right-click @ AbapCaea lo g . ~qlV

r tJ A<IH_OO l_bwdeveloper _en define view zcd~v


on the DDL source in the
~ Tc'J A<IH_OO l_developer _en [MH, 001, OE't'ELOPEf
project explorer view to open ~ ~ Favorl e Packages key ~nwcl_~o_ i

i 8 G) $TMP • DEVElOPER •c • as cat.eqo


the context menu and select
8 eJ. Dictionary 1 1. right-click I
Open Data Preview. i , 8 t;3- ABAP OOlSoul _ ___.:j where snwcl_so_ i nv
i ' ' maiiiiiiP!~·=- uroup by snwd_so
, rB tB S_EPM_OIA CJ New DOL Source
ffi a\ System Library Open

l.J copy Ctri+C

~ Delete d 2.dCk L
Copy ABAP Resource;:.
LJ\
:.:::L' - - - - ,

tAMIMii=-
Get o'here·used LIS< . . Ctr +Shift TG

8. The data preview displays a li1J (A4H) ZCDSV. OPENjNVOICE 4' )A4H ) Data Previtw • ZCDSV.OPENjNVOICE !:!

list of customer unique IDs IDI Raw Data l


(BUYER_GUI D)andthe I f' ~ .:j/ 38 rows r"trlev"d - ~ ms I
BUYER QJID ]_ CATEGORY 1 1
classification category. (OE95F38CS2081EE3A28CCCFA9A87S604 c I
OE9SF38CS2081EE3A28CCCFA9A881604 C
OE9SF38CS2081EE3A28CCCFA9A887604 C
Note: If the data preview OE9SF38CS2081EE3A28CCCFA9A893604 C
OE9SF38CS2081EE3A28CCCFA9A89D604 C
shows an empty result set, OE9SF38CS2081EE3A28CCCFA9A8CS604 C
a. you either need to double- OE9SF38CS2081EE3A28CCCFA9A86F604 D
OE95F38CS2081EE3A28CCCFA9A8n604 D
check the modelling of OE9SF38CS2081EE3A28CCCFA9A87F604 D
your CDS views or OE9SF38CS2081EE3A28CCCFA9A885604 0
OE9SF38CS2081EE3A28CCCFA9A888604 0
b. you're lacking data in the OE9SF38CS2081EE3A28CCCFA9A88F604 D
OE9SF38CS2081EE3A28CCCFA9A891604 0
system, e.g. if you're not OE9SF38CS2081EE3A28CCCFA9A895604 D
using a virtual appliance OE9SF38CS2081EE3A28CCCFA9A898604 D
OE9SF38CS2081EE3A28CCCFA9A8AI604 D
and didn't generate data OE9SF38CS2081EE3A28CCCFA9A8A3604 D
OE9SF38CS2081EE3A28CCCFA9A8AS604 D
(see Generate Example OE9SF38CS2081EE3A28CCCFA9A8A7604 D
Data). You may check the OE9SF38CS2081EE3A28CCCFA9A8A8604 D
OE9SF38CS2081EE3A28CCCFA9A885604 D
number of entries in OE9SF38CS2081EE3A28CCCFA9A887604 D
transaction SEl l (on table OE9SF38CS2081EE3A28CCCFA9A888604 D
OE9SF38CS2081EE3A28CCCFA9A8C I604 0
SNWD_ BPA) OE9SF38CS2081EE3A28CCCFA9A8C3604 D
OE9SF38CS2081EE3A28CCCFA9A873604 S
OE9SF38CS2081EE3A28CCCFA9A879604 S

9. Ready for the second view! fD Proj ect Expl orer 1;3 (A4H)i
Right-click on the ABAP DDL E" Raw D
Sources folder in the project ,·LJ A4H_OOI_bwdeveloper _en r;---
EI ~ A4H_OOI_developer_en [A4H, 001, OEVELOPEf ---
explorer and select New DOL e 'Ci'
Favorite Pack.aoes BUYI
Source from the context l; Sr fa $TMP,• j, · ht-d 'IC k
1 • ng J OE95F38C

menu '
! ! El '?'
e~
Diet l
.. . -
l2. d ick
BC
f l
J3ac
! ; ~. ~ @ New DOL Soorce Y
, ~ ffi S_EPM_OIA
00 a\ System library _ _o_pen
_ _ _ _ _ __
Copy Ctri+C

~ Refresh F5

13
CDS View Building in ABAP

~Ufl-!e -~ EJ
10. Maintain the necessary ' • New DOl

DOl Source
information: Q~~ODL SO._,c.e

a. Name:
ZCDSV CUST CLASSIFI
CATION
b. Description:
A4H: Information about
customer classification

Code snippet: ZCDSV_CUST_CLASSIFICATION


@AbapCatalog.sqlViewName: 'ZV_CDS_CUST'
define view zcdsv_cust_classification as select from snwd_bpa as bpa
join zcdsv_open_invoice as opn_inv on bpa . node_key opn_inv . buyer_guid
{
key bpa . bp_id as customer_id,
key bpa . company_name as customer_name,
opn_inv . category
}

In the CDS view, the business partner table SNWD_ BPA is joined to the previously created CDS view
zcosv_ OPEN_ INVOICE on the customer unique ID, and semantic aliases are given to the business
partner information.

11.Activate the DDL source Fi, Ett. •,~.:.,.,..,tot S-nt" PI-~~~~ fl.o..n <'40...... "it-'-"
['1 • I~ o ' <;) • Q • 9, · '1S'
(ct r l+F3) and check the
output of the view via the
Open Data Preview feature in
the context menu of the DDL
td:«m.l'k'..," d:n::c;9;r
source in the project explorer l~e.w l rttle~
C~mm"~b
G~':f ~o.'h:.rdl~ :<e••
(see step 7) . o,'llsh ~sh Tr~dr11 Um ,,

""
Al.'.AUTl'l,
Al;rt:S~fl'lli
10-I»'XtOJi An,v!~

CIOCOXOIC. l·b~:r'l d tr~drc ccm •.


CHt:OXOII 1·~ ~.~
0 11)X((019 p.,~
01()X(C022 (tU'tl<o! 1<01N~~
GI I)X((O<;S t~t(<iQ [HtctlloJ
'o~tc £1Rll),iltb"'dl: ...
Ot'~iCfltP.:t:tOG.. . 0
a~l ft(tn)!o:ns
Q1').0.'(0)J
(lti))X(0)5
OIOXttO:tS
"'"'
fr~~N~"~~'
AI!~G*JA..-JO ~o•r.J• •
(lh) .."'XO~S E:i:n;A$5$~·d'IV:b
(, JOC(((Otl
Ci i!)X((OU

Okay, you completed the first (or second if you count the configuration) step in this end-to-
end development guide; you used the advanced view building capabilities of the ASAP 7.4
SP5 to create a CDS view.

14
ABAP managed Database Procedures {AMDP)

6 ABAP managed Database Procedures


(AMDP}
1. Install and 2. CDS View buildina: 4. Gateway Service S. FIORI·Iike App
Configure Modeling

30 mln.
Wl
20 min. Test/Debug Cycles
~
20 min. Test/Debug Cvcles
fi
25 min. Test/Debug Cycles 25 min. Test/Oeb~.~g Cycles

In the previous chapter you saw the usage of CDS views as one technique - of course Open
SOL would have been another- for push-down of application logic to the database layer.
Now, you'll get to know another techniques for code pushdown in the ABAP 7.4 SP5 namely
ABAP managed Database procedures (AMDPs).

From a technical point of view, an ABAP managed database procedure is "just" a simple
ABAP class methods containing database-specific procedure coding. Thus, an ABAP
developer can write database procedure coding directly in the ABAP and the call of the
database procedure is just a call of the class method.

But- you might guess- AMDPs can do even more; if you are developing an SQLScript-
based AMDP on HANA, the AMDP runtime provides you with a complete syntax check on
the SQLScript coding. And concerning lifecycle, AMDPs as well as the underlying database
procedure are entirely managed by the ABAP server. In particular, only the ABAP class
method has to be transported (using the well-known CTS) while the creation of the database
procedure on the database layer happens at first execution of the class method. This
technique allows- as was the case for CDS views -to transport AMDPs in heterogeneous
system landscapes.

More information on AMDPs can be found in http://scn.sap.com/docs/DOC-51612 and


references therein.

Let's create the AMDP get() method-->AMDP


As mentioned in chapter What's inside this guide?, we'll create three ABAP managed
database procedures:
• g et_ c u stomer_ i n f o, to retrieve customer information for a given customer
including the summed gross amount currency-converted to USD for all open sales
order invoices
• g et_i nvoice_i nfo, to retrieve the list of open sales order invoices for a given
customer including the gross amount currency-converted to USD
• g et_c u rr _ c onv_ r elev a nt_ i t e rns , to retrieve the list of relevant sales order
invoice items- consumed in the two previous AMDPs

ABAP managed database procedures can only be created and maintained via the ABAP
Development Tools in Eclipse, so we go back (well technically we never left©) to the ABAP
perspective of our SAP HANA studio.

Before we start with the implementation of the AMDP, we'll create structured data types in
the ABAP dictionary (transaction SEll). This will allow a simplified definition of the Gateway
services and the consumption in the Fiori-like application .

15
Creating table structure in SE11
ABAP managed Database Procedures (AMDP)

Description Screen Shot


1. In the ABAP perspective of lCJ Project Explor<r ~ El
the SAP HANA studio, right-
click on the Dictionary folder
of the $TMP package and
select New> Other ABAP
Repository Object from the New • IJ!j DOL Source
context menu. Open LS Datdbase Procedure Pr'jloJ<o- - - - 1
- - - - - - - Q ¥ - Oictionary View 2. dick
Copy ctri+C
1::::1 Other ASAP Reposrtory Object
.. Refresh FS

r ,.. r"ocw ABAP Rcpos1tory Objcd ~ EJ


2. In the New ABAP Repository
ABAP Repository Object
Object dialog window, select Create an ABAP Repository Object

Dictonary > Structure


PrOject: JA1H_001 _develope, _en &owse

Itype flter '""'


e-e. Docta..v
· -(j oatabase Ptoced.l'e PrOXY
!

;
{II' Mbb~se T"ble
~ ~4E1ement
'·· ID OOl Source
'--~ (ll(tOO>-y l>lew
J
i : [P' O<'AMin
i , L l ock ctject

I~

<Back c~ncel

• "' New AllAP Reposttory Ob~d 1!!1(!1 EJ


3. Provide the object name
ZI NVO I CE I NFO
ABAP R ep o sitory Object
New SI;:Iucture
structure
ZINVOICE_INFO

-fdkkl_
[toxt ::..J ~ _Cancel

16
ABAP managed Database Procedures {AMDP)

4. An embedded SAPGui opens


(transaction SE ll). Provide
Diction• t y: Ch•nge structuttJ
as short description "A4H : *' -+ '?I f6 <8 61> t ~ ."• ~ l!l II Ho<••chr Cl!O>t I>WYldS""''"""'
Sales Order Invoice
Stru:t\¥9 ~~~
ZDlV
~OI~CE~I<~F0!7~~:;;:~~·
Sh:rt oesa~orcn A4H: sam Q(d;.)f ~mote lnftrma~on
Information" and the field list:
Att1b..ltes Ccmponents &lb hel:p ched<
• CUSTOMER_I D Types
SNWD- PARTNER- ID - -1
• ORDER_ID Types •%N"~ 50 ID Cl".AR 10

SNWD SO ID • TI~ $T.u!?L !l! C 21 7UTC TilTS St<tf(l in Len:.! Form (YYYYMI·lr:ct'f
• :S!ilil> C1IAA CODE CUXV s Oa:N: (UitenC.Y Co:l3

• INVOI CE DATE Types • !PM OJ.\ TOTAL AMOW'I' ~V'AA 1S ZEPf\i OJA: Tota1 Amoorrt

TIMESTAMPL
• CURRENCY CODE Types
SNWD CURR CODE
• SUM_GROSS_AMOUNT Types
SEPM- OIA- TOTAL- AMOUNT
r (Ae~oi] ZUNOIC~f.O $t
5. Navigate to the
~ el f
Currency/quantity fields tab OktlonMy: C/J.tn/14 SITudllle
~ ... -rJ U q;l 60 · a;. :~ ,aD 0 Her.-dTtO:J~&.y ~Sin..cb..le•••
and maintain the currency
code for field
S UM GROSS AMOUNT as
liS
reference table T)tirQ """lhxt COmiXJf'lerc l)1;le oac•T • R.e~erce tilbie Ref. ~ ~
• !m?_!_.umctR~ Cl'..ut I
Z I NVO I CE I NFO and
Typu

,,.,....
Type• ·~ OL\R ""
If
reference field · ~Ol>!CUX'f
GJ,.
Zlr-.~-IC-,_-,.-
,.-CUF=o
--CT-_-
,oc-,-.>
• UJ!!_ OU_TI!t'At_ . CWR

CURRENCY CODE

6. Maintain the enhancement St:ru:t ure

category via Menu > Extras > @:Ito


Her•n:llll Dosp~y ADt:>end Str\lct<re...

'j
Enhancement Category. l,!tll.tlos

E><tr~
StLUCtlre LonQth•.•
~k'cnmoot • !;lob~ Seorch ...
Atiiii) SJ~stem • ttleraochy DISPlay Ctri+Siift+Fl2
t'Ot> • QB Attrib.Jtes
~ij\'@i] I~JLSe••chHEtp I, A~tNa tbn Type ...
Component Typno Method Cha'lg9j01spiay lab~
T\'PO ~(

CUSTOER II> Type:J • ~ Enhancement CateJcry..

7. Confirm the information that @ Info<matlon x

you haven't select an f) ~N.Y.Q.If5.J~QJUJQ!..~~~.:2~g_~


enhancement category yet... enhancement category (see documentation)
you actually just wanted to do
so © ...

17
ABAP managed Database Procedures (AMDP)

8. Purely for simplicity reasons,


Erha"lOOIOOnt (.atEQOIY fcf StruCtul8
choose "Cannot Be Q CanBe Enharced (Deep)
Enhanced" as Enhancement Q an be enhan:ed (ch:.acte!'-type cr nlinlific)

category. ......................................................,
......................................................
;

9. And with these eight easy ~ [A4H) ZINVOICEjNFO 1:3


steps, you're ready to activate IMerl..l .I e
the structure type via the well-
Dictionary: Chan~cture
known matchstick icon.
+t '* 'P t~ ca 60~ G'o ~ D H Hierarchy Display

Structure @WorcE_ INFO ~ New(Revised)


Short Description IA4H: Sales Order Invoice Information

- ----
10. Check that the create object @'Create ObJect Directory Entry x

directory entry popup shows Object R3TR iiiBi:' ZINVO ICE_INFO


the correct packages ( $TMP
in our case) and click on the Attributes

save icon. Package


Person Responsible

OriQI'lal System 'A4H1


r--
Origi"lal language EN English
Created On

11 . Now, we'll repeat steps 1-1 0 [D Project Explorer 1:3


to create the structure type
ZCUSTOMER I NFO.
Don't scroll back up .. . I'll
repeat them for you ©
@ DOL Source
In the ABAP perspective of Open LS Database Procedure Pro,=- --1
the SAP HANA studio, right- - - - - - - l f DictionaryView 2. dick
Copy Clri+C
click on the Dictionary folder c:l Other ABAP PeP"SJtor; Ot l)e<t
"' Refresh FS
of the $TMP package and
select New> Other ABAP
Repository Object from the
context menu.

18
ABAP managed Database Procedures {AMDP)

r..., i"'PW ABAP RpPO~itory Objf"cl III!Jf3


12. In the New ABAP Repository
ABAP Repository Object
Object dialog window, select Create an A6AP Re!:Joslory Object

Dictonary > Structure


Project: IA<iH_00 l _developer _en Browse

Itype filtedext
e l<;!. ott~CNtv
l · C§ Dd:obose Proced.re Proxy
' ~ Database Table
t·if:.. Oata Element
' ID 001.sour<e
' ~ Did:i:n:ry View
J
.
i"·if::.
~ Domain
Lockct.ject
i ~·· I I~
! ~-/

___ <_~-~--~-~
-d-1~~ ---·-~--~ Cancel I

~.. 1-:ew ABAP Rcpo51toty ObJ~d 1!1~ Ef


13. Provide the object name
A BAP Repository Object
ZCUSTOMER I NFO New Shucture

14. An embedded SAPGui opens P' IA4H) ZCUSTOMERJNFO !;!

(transaction SE ll) . Provide a IMeru ·' e [


DlctiontiTy: Ch;mge structure
short description "A4H:
Customer Information" and • '* ~~~ Co r ~ ~"ol !i. c:J 10 Hier<rchv Oisplay AJll)end Stoucture ...

St ruc tu1e ~niR I JJP'O ~ tnactlve (R.evlsed)


the field list:
s hcrt Desatlt1on € 4H: cus.tom91' rnfamatien)
• CUSTOMER ID Type s Attrib.rtes Cwer>:y/~t<!Y fiel:ls

SNWD PARTNER ID
- - ~~~~~~ ~!]~~~~~ Preclemed TYlJ<! I 1 I 8
• CUSTOMER_NAME Types Let><;Jth oeci... Short Oesoi:>tiOn
CUSTOMER I D Type• • Sll\JD PARnliR ID 10 OEPM: Busness Partner 10
SNWD COMPANY NAME
- - CUS1'0Mn. JJAKI: Types ..,. S'Ji\1'0 C0)1P.l.JIV JIAM!: 80 OEPM: COOIP"W Nama
• CITY T ype s SNWD_CITY 'l'Y'Pe:s ·~ 40 OEPM: City
Type• • Sll\JD S'mEET 60 OEPM: Street
• STREET Type s SNWD_STREET Types • SU\JD POSTlL COD£ 10 OEPM: Post al Code
• POSTAL_CO DE Type s T'I'P•• • SJl\lD COUNTRY OEPM: CCUltry co:le
Curutt»CY CODE Type• • Sll\JD Curu< CODE OEPM: CL11encv Cede
SNWD POST AL CO DE 1sUM c
- - c.ROSS AMOUNT Types • S'£PM OIA TOTAl AMOUlJT lS 2EPM OIA: Total Amount

• COUNTRY T ypes
SNWD COUNTRY
• CURRENCY CODE Ty p es
SNWD CURR CODE
• SUM_GROSS_ AMOUNT Type s
SEPM- OIA- TOTAL- AMOUNT

19
ABAP managed Database Procedures (AMDP)

.. tMHI ZCUSfOMf~NFO 2':&


15. Navigate to the
§!!U .' e
Currency/quantity fields tab 0 /ctlonMy: Ch - structurtl
and maintain the currency .. ,. '!1> t~ <8 r;1. • '* f • .t1 o 0 ...,.,llodor ""'""'stn.c......
code for field Slrucnse

SUM GROSS AMOUNT as


reference table
®ffl11!) Cf[ Sean:h Hoi> ] I I 8
ZCUSTOME R I NFO and COIT<lonent
,., ..
Tyl)h;J M:'thod

,.,..
<;onwnent Type Data T .. Referenc:e table Ref, field ShorttleSaiOtJon

reference field
CURRENC Y CODE
~~
CUSTOIIIR """"

POSTAL CODe;
,.,
,., ....
,.,..
,., ..
• SJM> PART11ER ID CJU.R
• 'liD COilPllif .n_ CBAR
·~
·~
CIWt
CJU.R
• SIND f'OST.I.L COllE CIU.R
-'--
EPM: 9Jsness P.artne1 1D

EPM' Oty
EPM: Street
EPM' Poot<f Ccxlo
COW11tY
C\DISi!UCT COOl ,..,.. • SPD ~ COD! C'IIKY
EPM: Ccurtty Code

• SE1'ft OU TOT'U CUJI.R <icvSTGI"'CR UiTO Ctli!:FD'ICT CO[)[ ) PM'OlA:


....---------------....:- w....:v ~
TOYIcoao

16. Maintain the enhancement !Menu ,j StriXture

category via Menu > Extras > Didio !;dit

Enhancement Category. ..... ~oto

!.!tilities
~ CJ 0 Hierarchy Display Append Structure ...

Structt.s:e Extrs15 Structure Length.. .


Enl[~onmen t Y,lobal Search ...
Short DeSCI
Attrib S~stem !::!ierarchy ffiplay
!:!elp QB Attributes

~~~ ~tivation Type .. .

Ic Component
CUSTOMER ID Typ~! ... ~
C Change/Display Iable Type
!;,mancement Category .. .

17. Confirm the information that @Information x

you haven't select an 0 ~g~_F_g~9_t._~~~-~g~


enhancement category yet.. . enhancement category (see documentation)
you actually just wanted to do
so© ...

@" llldintc.n ErhanCQ'TIBit Category for ZCUSTOMER_INFO x


18. Purely for simplicity reasons,
choose "Cannot Be
Enhanced' as Enhancement
category.

19. Activate the structure type via L [A4H) ZCUSTO MER_INFO 1;3
the well-known matchstick lMenu ,j (?i
icon.
Dictionary: Chan~ctura
<:- '* ~ ~~ c8 6"1>~ ic. ~ ID D Hiera1

Structure [ zcUST OMER_INFO lNe\


Short Description j A4H: Cust omer Information

20
ABAP managed Database Procedures {AMDP)

20. Check that the create object @ Create Ob)ect [)rect ory Entry X

directory entry popup shows ObJect [R3TR!iTABLJ[zcuSTOIIER_INro J


the correct packages ($TMP
in our case) and click on l Attributes
Package
save.
Person Responsible

OriQnal System
Orignal lan~age

Created On

As mentioned before, we created these structure types since this simplifies the definition of
the Gateway OData service as you will see in chapter GW Service. In general, ASAP
managed database procedures do not require these steps. In principle, the structure types
could have as well been defined in an ASAP interface or in an ASAP class.

Let's create the AMDP ... now we really start!


You'll now implement the three ASAP managed database procedures
get_customer_i n fo, get_ invo ice info, and the supporting
get_ curr _ conv_ relevant_ i terns. All three methods will be implemented as class
methods of the ASAP class ZCL CUSTOMER OPEN INVO ICES.

Description Screen Shot


1. In the ABAP perspective of
the SAP HANA studio,
right-click on the $TMP
package and select New> 12.dick 1
ABAP Class from the 6' A8AP trterface
f) A8AP Pr·OQI'am
context menu. Copy a ri+C
Ccpy ABAP ResOU'ce URl t"i Other /ISliP Reposl:ory Object
Delete £Mete

• C X
2. In the New ABAP Class AEIAPCiau
dialog window provide: Q'oXe;~"' ~8'-P ci ~Scl

a. Name : &·co...JC.. - I
ZCL CUSTOMER OPEN &Q.'IS$... I
INVOICES
I'IC,• ~L\J..CO;TC<<ER.t<>fN..I'®lCfJ
b. Description : A4H : Qes~l)on: • A.fli : Custcmtr tnform~~

OtUnallar~;Je EN
Customer Information

Continue via Next and


confirm the following "no
transport request is
necessary" dialog.

21
ABAP managed Database Procedures (AMDP)

3. The ABAP Class editor ~ [A4H[ ZCL. CUSfOMER_OPEN)NVOICES !3

window opens. The class 2!~~ ZCL_ C USTOI!ER_ OPEN_ I NVOICES de f inic ion
public
definition and final
create publ ic .
implementation skeletons
public sect.ion .
are shown which you'll prot.ect.e d section.
implement in the following privat.e sec t.io n .
~~~~~=~~§ .
steps.

- CLASS ZCL_ CUSTOIIER_ OPEN_ I NVOICES I MPLEM.ENTATION.


ENDCLASS .

4. Prepare the public section Codesn~et


of the class definition:
a. Prepare the ABAP class PUBLIC SECTION.
INTERFACES: if_amdp_marker_hdb .
for AMDP usage via the TYPES:
marker interface tt cust info TYPE STANDARD TABLE OF
-zcustomer info WITH KEY customer_id,
b. Define the table types
tt inv info TYPE STANDARD TABLE OF
TT CUST INFO and -zin;oice info WITH KEY customer id .
TT INV INFO based on
the structure types METHODS:
qet_customer_info
ZCUSTOMER INFO and IMPORTING
ZINVOICE INFO VALUE( iv client) TYPE symandt
c. Define the methods VALUE( iv=bupaid)
TYPE zcustomer- info- customer id
g et_cu stomer_in fo EXPORTING
and VALUE(et bpinfo ) TYPE tt_cust_info ,
g et_in voice_ i n fo qet_invoice_info
IMPORTING
with AMDP-conform VALUE( iv client) TYPE symandt
parameter interfaces, VALUE( iv=bupaid)
e.g. parameters are TYPE zcustomer info- customer id
EXPORTING
passed by value. VALUE(et_invinfo) TYPE tt inv info .

5. Prepare the private section Code snippet


of the class definition:
PRIVATE SECTION.
a. Define the structure type
TYPES:
t y_ re l _ items as well BEGIN OF ty rel items ,
as the table type client - TYPE snwd_so_inv_item- client ,
tt re l items inv i quid TYPE snwd so inv item- node key ,
inv=guid TYPE snwd=so=inv=head- node=key ,
b. Define the method buyer_quid TYPE snwd bpa- node key ,
g et_cu rr_ con v_ re l e customer id TYPE snwd-bpa- bp id,
van t i terns with an invoice date TYPE snwd=so_inv=head- created_at ,
qross_amount
AMDP-conform TYPE snwd_so_inv_item- qross_amount ,
parameter interface currency_code_conv
TYPE snwd_so_inv_item- currency_code ,
END OF ty_rel_items ,
Note: The methods you just
defined use the client as tt- rel items TYPE
input parameter. If you are STANDARD TABLE OF ty_rel_items .
familiar with the ABAP

22
ABAP managed Database Procedures {AMDP)

client handling, you know METHODS:


qet_curr_conv_relevant_items
that OpenSQL statements IMPORTING
per default add client filter VALUE( iv client) TYPE symandt
(via a WHERE clause VALUE( iv=bupaid)
TYPE zcustomer info- customer id
enhancement); except if a EXPORTING
CLIENT SPECIFIED clause VALUE(et conv items ) TYPE tt rel items .
is added. In native SQL or
in database procedures,
you have to take care about
client handling yourself.

6. You defined three get cr...r:- corN :-c _cvn:J.t ltclU=

unimplemented methods.
The light-bulb icon indicates
there is a quick fix for this
issue. Click on the icon and
select the quick-fix to - CL ASS
f:NDCLA
implement the methods. .!.l
§lobai Ciass~~·~==:::=:=:::=:=~==Jl~~========~~~u·~r.~b'~~~·w~<~~~·~·~~<'~~~~
~'

7. The three method - CLASS zcl_cuscomer_ ope n_ i nvoic es IMPLEMENTATION.


implementations are added.
Let's start with the
implementation of the I -.. '.-EITIHO.-~.~~g~elclclulrlrlclolnlvlrlelllevlalnlclliclelmsll.lllllllllllllllllllllllll
.!!~!'!~~!!2!! -

g e t _ c u rrent_ c onv_re l e
METHOD gec_invoice_ into .
vent ite ms.
ENDMETHOD .

METHOD g et_cus tomer_i nf o .

ENDMETHOD .

ENDCLASS .

23
ABAP managed Database Procedures (AMDP)

( .. Preferent:es 1!1(!] El
8. Before we start the
Itype f ilet ted Colors and Fonts
implementation, configure B· Genera
Cdcws ondFonl:s (? • ,:,ny<N1,:,ctt#. ,. • ony strf'lo):
l 9 Appearance
the background coloring for · · ; ColorsondFQnts l typeUterte>'t

embedded languages. Open l- Comp<J'e/P.:~tc.h


Windows> Preferences (not
shown on the screenshot)
select General>
Appearance > Colors and
Fonts, Select ABAP >
Syntax Coloring >
Embedded Language. Via
the Edit button you get
some basic colors you can
choos from or - my SMwleteld:

personal favourite - you can


choose Custom Colors.

9. Back to the ASAP Class Code snippet: get curr conv relevant items
editor, implement the
g e t _ c u rr_conv_re l evan METHOD get_curr_conv_relevant_items BY DATABASE PROCEDURE
FOR HOB
t _ i t e rns as read-only LANGUAGE SQLSCRIPT
AMDP. This is achieved OPTIONS READ-ONLY
using the language USING snwd_bpa snwd_so_inv_head snwd_so_inv_item .
statement "BY DATABASE
declare a local variable
PROCEDURE" and we'll do declare lv_today date;
an AMDP for the HANA -- get current date for conversion
database (HDB) using select current_date into lv_today from dummy;
SQLScript as language. The -- select relevant invoice items
using clause includes the lt_relevant_items =
ASAP dictionary types that select
will be used to query from. i .client as client,
i . node_key as inv_i_guid ,
h. node_key as inv_guid ,
The method body only bpa . node_key as buyer_guid ,
contains SQLScript coding. bpa . bp_id as customer_id,
h.created_at as invoice_date,
First the actual date is i .gross_amount ,
retrieved, which will be used i. currency_code
as date for the currency from snwd- so_inv_item as i
conversion later.
join snwd- so_inv_head as h
on i .client = h. client
Then, the sales order and i . parent_key = h. node_key
invoice items for a given join snwd _bpa as bpa
business partner (provided on h.client = bpa .client
and h. buyer_guid = bpa . node_key
via the importing parameter where h.client = : iv_client
i v _ b upaid) are selected if and bpa . bp_id = : iv_bupaid
the payment_ s tatus of and h. payment_status = I I ,

'
the sales order is empty
--convert gross amount of items to currency USD 1 1

(not-yet paid). And et conv items =

24
ABAP managed Database Procedures (AMDP)

additional information on the ce_conve~ston( : l t _relevant_items,


business partner and the
( fatally = · eur r-eMy' 1
method • ' ERP' i
sales order header is .steps =
selected into the t empotary 's~J ft, convert , shift_bick' ,

table .source_unit_column =
output_unit_column =
All these relevant sales
order items in tarset_unit = ·uso· ,
N!ference_date = :lv_today,
client = : iv_client
subject to a currency
conversion routine (using ( gross_anount) ) ;
the CE-function
f~THOO.
<:<~_<:mw<~ r~~ i <m) with
target currency USO and
prcwidtng the rcsuttset for
the exporting parameter
ct_conv_ i terns.
t O.Implement the method Code snippet: qet invoice info
gct_ invoi cc_ info as ME111l0 get_invoice_inf o BY OATA8ASE PROCEOlllE
AMDP and provide the FOR: HOB
LAHGUAGf SQLSCRIPT
ABAP dictionary tables OPtiONS R:EA.O·ONLY
SNWD_ S PA and SNWD_ AD, USING sm.cl_so .snwd_so_inv_head
as well as tho AMOP zcl_custoner_open_invoiccs• >set_curr_conv_relevant_itens.
ZCL CUSTOM!R OP~N !NV
ICBS=>9et_curr_conv_r call
eleva~t items ln thG "ZC l _ CUSTOJIIER_ OPEN_ I HVOI CfS=>GfT_ CURR_ CONV_RELEVANT_ ITEllS"
using clause. (
1v_c11~t => :1v_cl1ent,
iv_boupdd •> : i v_bupaid,
In the me thOd bOdy, the et_conv_itefi'IS => : lt_converted_itellS );
AMOP is called ancl the
resun is retrieved into the --accrecated cross a~nts per sales order invoice
c t _invi nfo •
temporary table select
lt_convert ed_i t ems. customer_id,
so_id as order_id,
1nvo1ce_date,
Then the gross amounts are
currency_code_conv as currency_code,
aggregated per sales order SUI!( «~nv_itefi'IS . cross_anount )
invoice and the information as sum_e:ross_anount
on the sales order I0, the f"on : lt_cet~verted_1tet~s as conv_itens
join snwd_so_inv~ead as h
invoice date are added. on h. cl ient = conv_item.s. client
and h. node_key • conv_items . inv_evid
The result set of the query is join snwd_.so as .so
return via the exporting on so. client = h .client
and so. node_key • h. so_guid
table et i nvi nfo. aroup by cu.stomer_id, so_id, invoi ce_date,
cur-N!ncy_code_conv
o"de,. by so_id asc;
EJIDJUTHOO.

25
ABAP managed Database Procedures (AMDP)

11.1mplement the method


get_cuetomer_ i:l!O as METHDD ttt_cvs to~r_in ,o IV DAT~E PROCEDURE
JOftH08
AMOP and provide the I.AHCJ.MGf SQLSC.IW'T
ABAP dictionary tables OPTIOHS IUAIHllll.V
USING si!Md_bpa snwcL_illd
SNWD_ B PA and SNiiD_ AD, :c l_customer_open_invo l cc s•>sct_curr_conv_rclev~nt_it~ .
as well as the AMOP
Z.C T. COSTOMZ :t OPi:N TNV ..u
~ZCL_CUSTCJtER_OPEN_IMYOICES·>G£T_ CURR_CerN_ RELEVAHT_rtEI'IS ~
TCZS- > gt'lL_ <:\Jrr_ <:unv_ r: iY_clienl => : i v_cli ent»
t'l l t'\vtenL .i. Lt'\m~• in the iv_bupilid :) : iv_bupdd ~
ct_conv_ite.T£ •> :u_conY'Clrtco_itcm );
USING clause.
• ·~pted sron ;;onol.ftts por cust-r
ct_bpinfo ..
In the m ethod body, the sd~cl
AMDP Is called and the custoncr_id,
bpCI . corrpany_nant CIS ('USto.Mtr_nan.:,
resub is retrieved into the
~ . city .
temporary table ~ . street,
~ . P<ISUl_code ,
l t converted items. .-d. country,
conv_itcns . cur~cy_codc_conv ~s currcncy_codc ,

Then all gross amounts for su11( conv_itens . ~;ross_ltlnount ) •s S\~Uross_ltlnount


ft>oft : lt_convortcc!_it-~ ;;os coiW_iuns
the given customer arc join stwd_bp;;o ~s bp;;o
aggregated and adcfrtional on conv_itcns. cl icnt = bolll .clicnt
buycr _au1d
~nd .. bp;;o . nod~_koy
lnforrnadon on the customer join sn.'CI. •d •s •d
address and nam e is added. on bp1 .clicnt = llld. clicnt
bp;;o .;;oodr•ss_avtd • ;;.o.nod• _k 'Y
~nd
VOUP by cu-.stom:r . id. corrpany. 114'11e, city. street,
The result set of the query is posul_co6t, country, currH~cy_cocl•_conv;
return via the oxpottlng EIOifTHOD.

table et_bp!nfo.

12.Betore we activate the


class, I thilk it's a good time
to run the pretty ptinter
(ShortCUt Sh UtH'l). AS in
0
the gOOd·Oid SAPGui you
have to define the project
specific pretty printer
settings - or in the AOT
language the formatter
settings. Navigate to
configure the settings and
e--..1-a•••m••B
<..~ ...... lol

configure the settings of


your choice.

b·l I
I ~

26
ABAP managed Database Procedures (AMDP)

13.Activate the class (shoncut .. -. .


Shift+F:l) or via the
_,_
8
... .-·. ..
matchstick icon.
--.-......-
•n

__
.. -"·-'>1.-- .. .... ..........
~ ~

.--
."(;iit,..-.... _,_ ..__....
. ..-- .....- ........ -- ..-·-
"""
........ ....•.................. .......... .... .
·- ·-~-·
_ ~

.,
- . __ ,_
~
,
• ...... ... __ _-
... ,..............
_,,

.
.
.
,
Congrats. you just finished the second major step of this end·IO·end development guide; you
defined and implemented ABAP managed database procedures! Now get yourself ready for
the consumption of the CDS views and AMDPs in a SAP NetWeaver Gateway OData
service .. . our next step towards the Fiori-like application.

consume CDS Views and AMDPs in NW Gateway

27
Gateway OData Service

7 Gateway OData Service


............,.
J.A'U#..,o.....-oG S. MOIII.Ji........

li
lll...... '~41" ......,....,_.

SAP NetWeaver Gateway will play the role of OData service provider in this end·to-end
guide. OData is a standardized protocol, which is used tor the oommuntcation between the
AS ABAP bacftend system and the Fiori-like application running in the browser of your PC or
MobiLe device.

As of SAP NetWeaver release 7.4 SP2, you don't need an additional plugin to use the
Gateway functionality but we have a fully functional Gataway •on board• ©.

In the following, you'll develop the OData service ZE2E_ CUST_I NFO featuring three entity
sets:
• CustomerC&assifications, consuming the CDS view
%COSV_CUST_CLASSI FlCATION
• Customerlnfos, consuming the AMDP get_ cus t omer_ in fo of class
ZCL CUSTOt1ER OPEN l NVOICES
- -
• Openlnvoices. oonsuming the AMDP g e t _ i nvo i c e _ inf o of class
ZCL CUSTOt1ER OPEN I NVOICES
- -

Screen Shot
1. The OData service is
developed In the Gateway
seJVice builder transaction
(transaction code SSGW).
Qrktl l

In the ASAP perspective of '"


the SAP H ANA studio. fl)-lCJ 11~11_(101~ ·~ _... :-..
navigate to Run >Run ABAP A- ~ ~H_I:.;It_......,.. _on(AA-1,

Oevelopmenr Obiect (short


CUI

28
Gateway OData Service

2. In the Run ASAP Application


dialog, filter for "SEGW" and
_____._ _____ ...

continue.
......,..._

_
............. . ..

3. An embedded SAPGul opens. r (.U-11 f i " IS ~===?


Cr eate a new project. ~ e r • 4Q
l et;CifN•tW•wM G.,..,...., SMtlk•l
~zHBIIH~.a

4. In the Create Project dialog,


ptcMdC
• Name: ZZ:zt:_CUST_ INFO
• Oosetlption:
Atl.ttva
A4H: Encf-2-End GW PIOJI)I:t T)ce
SeMoo fof Customer Info G<~nor;r.;cn Slr¥.Q I.....,.
• Package: STMP

~r::: ===="'"
,.;;:;J~)'""
llrn;lo't:a

s. Right-click on the Data Model ~ 1'-'ti ::K.W"

and select Import> ODIC 1- -1 e ~------,.,~ . 9 e 0 e !;}Ill


Structure from the oootext
menu.

29
Gateway ODota Service

----•----·
6. In the ODIC lmpon dialog,
choose ZV_CDS_ CUST as
ASAP SlfUCNrO and ho
<etum.
_#___. --~
·-...
..

_,...._~.,.._,....,..
---·- ··"'---
-
J ...
...
0 I •
_, ••,..,. ,_....,_
' ...... ~

Change the Ol>ject Name 10


CUstomerClasslflcatlon.

You sec a list oC lick:ls and a


proposed Uaage ty~ which
should be ildjuSied tike
• !--!.!;_,'"D'!' as Ignore
• CCS't'OM1Jt_ JO as Key
• CUSTQ!I!~R tiAME and
Cll.'f'F.CO~Y Ill Property

Note: Tho ODIC view


ZV_CDS_COST is the SQL
~cwcorrosponcli)g 10 the
cos,.._
RDpeat stop 5 (Oata M<xk!l >
Import> ODIC Structure). In ·--
-··• - ··-
-·-. -----
-· -··-
tho ODIC Import dialog, ~

.·,•
-- -
Choose ZCU$TOMER_INFO as • •
••• •
ABAP Struc!Uro and hk
retum. --
Cl1ange the Ol>ject Name 10
CtJstomerlnfo and verity the
usage of au fields is set to
Property, excopt lor
CUSTOMER_ I D, Wh~ is used

Repeat S!Gp 5 (0.10 Model>


'"-l> OCHC - e j . In --
• --
---- --. .. ---
the ODIC tmpon <Wog,
choose 2.1NV0lCE lNf'O as
ABAP Structure and hit ·~ -·- -·
·-·- '

return.

Change lho Objoc:l Name to


lnvoicelnfo and veriy the
usage of an llotds
CUSTOM!:!t !. U and
o:w=::t 1 u l'IIO set Key and
the Proper1y it set for all
tlelds.

30
Gateway OData Service

9. Via the conteX1 menu of Data •9 w.o_o.T_Io"' A<-\ &ontrQ/Jiof'll.~ owf:. W l.o tO ; 11;.
• OIIolo -
Medel > Enr;ry Sets. create •A...," r,.p....
the entity sets corresponding
to the entity types defined in
....,.........
. ...(1., _ , . ,

· <>-
/)

the previous steps. • CJS:t" •-.;..I


• <.:.~:;......... .., """'*17.;;1
· 0~..... ~~

......
. o~..........,., >I•J:o

10.Cr eate the Entity Sets:


-
• CustomerCtasslflcatlons
based on
CustomcrCtasslflcatlon
• Customerfnfos base on
Customcrtnfo
• lnvoicelnfos based on -------------------------------------------
@Crea·E' EntitY Set x
Invoice Info
II..,,., se• ._.,
II En<nvr..,. Name

!nYOicelnfos

dick

11. The relations between entity


are defined in assOCiations .
Select Create from the
context ot Data Mod9/ >
Assockltions.

31
Gateway OData Service

12. The CustomerCiassification is

---
related with the C ustomerlnfo
with cardinaJity 1:1.

Create the association


-·-·--
...- ce:-)
.........
.
ToCustomerfnfo via the
Create Association wizard.
The principal Entity is
CustomerCiassification with
cardinality 1, which should
additionally obtain the
navigation property
ToCustomertnfo. The
dependen1 entity is
Customcrlnfo with cardinality
1 as weft

13.1n the second step, specify


the dependent property
Cu.:otomccifJ ol entity ....... ,....
f.»'.....-~
,........
... ....
~
....
Customerlnfo

14.FinaJiy, set the Association


Set name to ToCustomorlnfos
ancl cfick FNlish.

32
Gateway OData Service

15.Repeat step 11 to create a


second association (Select
Create from the context of SAP NriW-~ a•,_., Servke Build
Data Model> Asscx:latrons) ~~. @!Ji!!!:IZC fQJ!i
~,$:~

!'a-

,"""""""'
.......
.;"""' -:m~tl
Cu:I.OTCfQx::.. c..:u:r

16.Wc'U need a 1:N relation


between
CustomcrCiassification and
the Invoice Info.

Create the association


Tolnvok:clnfo via the Create
Association wizard. The
principal Entity Is
CustomerCiassification with
cardinality 1. which should
additionally obtain the
navigation property
Tolnvoioelnfo. The dependent
&ntlty Is lnvoioetnfo with
1 .. .n.
17.1n the second step, specily
the dependent property
Customer I Do4 entity
lnvoicelnfo.

33
Gateway OData Service

18.Finally, set the Association


Set name to Tolnvoicetnfos
and click FNJish. ...........
O'<;oo~l-.
..............
o-a. ~.-.

19.Save the project and


l1.'dckl
. ~
generate the runtime objects
via the gcnctatc bunon.

~(Q]~
"""""..... c ~
... -,.,.
• ~ ttz:r_ruST-.tlliro
~ ...............
A4H: .&.
- N¥Te .
·-· ...
20. You receive a list ol m oclel
and servtce dcfinlttons. Just
conti nue with the check-mari( ...___......_ ....·••""-1
_
bunon.
--~
·--
---
~GorooroOOO.U.
tn.zr;u-.nn_,_
m._tt:~.nn_l _
_,~e_rxr

_,~<:

--
~olo»l~,yq~

l~lt:<)li~

lf)dVJQI '.lco'o ~
,.~-

21.tn the Create Object Directory I" •~-'" ~""' T .,. • •· t I" •

Entry specify package S'l'MP


and save.

34
Gateway OData Service

22.tf the generation has been .. •c


. <1 8 o 0 e QlllM "'''O)c l:!ll!! Ill&
suooassfuJ, you see the
messages as shown in the
~ ~ ,_.,.."'"
.5' . ,. ~ ~ (&)OI~~@)I?JF,-;;J
.......
screen shot. I '7a ............
1"'"'" ..... _,_,...........
" ,.~ ....... ,..~ ..., 11'11: ~ .......
• d i.<O>- ' _... ...... .... 3-''""'-.
.. ....
o.r.o..- ..-..... ' .!1....•· · - - ..,.,., -.,

·CJ•u-.-·
. ....-, ._-·....
• c.o~ .,, ..... r~

..
1 too:.....,. n

. ....
.:.:
,-,~ ~-··
· Ca ..... ~....,
·u - - - ~J -
~ .~
•••

23.Now you're finally ready for


the Implementation of the
OData services.

Good news here is, that we


only need to do this manually Procedure correspondin g to the "bad news· part © :
for two ol the three entity
sets, while we'Dusc SADL to Switch to display mode:
create the necessary services
fot the CustomcrCiasstficatlon
I._ ·I0 [ • <l
based on the CDS 'view. sAl{_
click J •ver G•tew•y Servit.
[g)~~ ~~i[EE!)
Bad news is, that WinOOws
OOM not like too many
YMdows lnsiOO windows IOpe~a second intomal mode in a "detached" SAP GUI M"'dow:
(Yitlat a contradiction @) ... 1-.. ·I e<I{.seGWI ;) <l g
therefore we'll doing a trick!
Please switch the gateway
pro;ect to diSplay mode
ll SAP N11tw11•vu G•t11w•y Servke
[g)~~ ~11+- 11 ..
(pencil icon), open another
internal mOde (via / oSEGW in

protect in this other internal


mode and switch to change "'- .. ...,
-· ....... ...
the OKCode field), select your Switch to change mode:

.. · HI e 0 e UJtM ac.:~u m
mode (pencil icon). b~ a.t.-ykwk~ (luilfh,
~ li!:W ,~[;'

r: . ._
· ~n-.l!,.um_u:
: fi'.ciCk
•0
· CJ~~
t l...W.. lfttVt<
t"'"tiO.'.U oJ IIIN::O...:oi!Lo W.-ltfu

35
Gateway OData Service

24.Setect Map to Data Source


from the context m enu of the • @ ll21_CVST_IIii'O j3\ N.Tn9
A<ltt End """""""'
Servfce lrnplementa.tion > • t:i D.stt.t.Model j - - - TcCust~¥
CvstomerCia.ssification. • -OEnbty TYPOS TOOWOice-Wo
' Q AsSOCIMO"'S
. a Entity sets
• a ASSOCIOtbn
. 6sero:.~~
· ~~ra
• a:D (ustor~ t,t;olay
• .., lnwaccfl t~ ct
0,.,.,. "' ---';;.;:;;:;.,..__,.---,\1r
a SEM:e Mar 14;p lo e»t.~ Saun: ~..'
~lals II
--
25.Select Business Entity as
Type and
DDlC ....zV CDS CUST as
Name.

26.Provide the Elements


, _____ j

mapping to the ptopetUes.


.... .-... ··-...:::::---·-·-
"D"oo•- • - - -a...-... )
I ... --~-----

-...... ···,..·-...__...-_,..___.. --.


.-.._ Jl G
.._.....
Note: This lnfonnation Is case
sensitive, so please use
capitaiiBMrs or just use the
·~;~

_____
• •<

.c.:.."
·-- ..,••
··- --
·o--
~:::--
=-~··-
-
-_~1

... ·--
· ·---~ -- ~

·-r::: ·--··-
F'l help to select thB
·a-· .._ ,..,_,...
·=----
ekunents from the given Jist.
·-
·-
··-·
·--·
27. Save the project and
(re-)generate the runtime
objects.

This generates the neoessary


getter method. If you're
interested on the
implementation details, have
a look at the methods
COSTOMZ:I:CT..ASSIFI GZT Z
N'!' 1 '!'Y and
COSTOMZ:I:CT.ASSIFI GZT Z
N'!'l '!'YS!:'! ' o4 class
J.C T. J.i:2i: COST INFO DPC
(usc shoncut c:: r l+ ~h!.f:: +.;.

36
Gateway OData Service

to open the class or have a


look at the classes i n the
STMP package)

Note: You could now savely


switch back to the gate·way
project tab in your HANA
Stud"10 (no mote need for the
additional internal mode
created in step 23), but you
can as well continue with the
·de1achfed" SAPGui w indow.

28.We need two more L/ IJWt)A"i_OOl_Df\I"HOI'EI\.fN ~!I


implem entations, i.e. the
Gctt:nt i ty m ethod for
1...... .J e r
Customerlnfos and the
GctZnt i tySct method for
lnvoicel nfos.
• ~ r.t::~t_tu!fT'_r•to
· 0~~~
Navigate to the - e~~utb\
Implementations, vta select • lal> ~(m:die«a""5
- IWCI.t,101100titfoc
Go to ASAP WQtkbench from
. $1 CrNte
the oontext menu of Service • .$ Delete
Implementation>
CIJ$tom9rlfllos > GetEfltltySet .*
. *&iifimty_~;"i;}L
Get£ntltvSet ~
· $i ~te
.,_
r::;;;r
(Query) • liED ltMX&Irilx
'Jo4Qtt -
~toD.Ita~

-
' 0 RtTUI'le MW'<Y..U
• Os.w:o~ ~ 10 ASAP W(ll<t"f'(h

29.Confirm the information that


you didn't implement the 0 ~..L~....QM!¥9s ·<5! tNTITYfiiC.!!Iit..:e]
method yet. been~tecl

37
Gateway OData Service

30.The ABAP class editor opens


including the class definition
L ...... ~,,. •IJ'Il'.'< (li~OO • I-""J :D,),.lJ;1'
~ h•• ICI_J:UI_~t_ IIIIO_I~_UT .....,.,...
..
W$1.J'"'M'W'« 1t
--·
and implementation skeletons • '"''
,......"'" .... ' .... ,.,,_- ..
........ ,....." . ~.-co ...-'""'-'""
for c lass
zcr.. ZZ2Z COST INFO DPC
' .-
.... u ......,, ....
- - -
_ ZXT, whid"l you'll enhance
- ,u....... ...,. .......
lt'O<V.<..S ..... . ....

liiY.U:.O.
with the two missing
implementations in the
(~ to tfl~ (l.ln Ull'.) ll'(' UT Urt.lll'!l''UTI(III,
following steps. tl!Hio.U$.

31.fn the protected section of the Code snil!pet


class, de-fine the rwo methods
PROTECTED SECTION.
e..<> redefinitions.
NETHOOS invoiceinfos_get. entityset aEOEFINITION.
METHODS custonerinfos_get_entity R£DEFINI110N.

32.Usc the quick·flx to add the


~~ ........ .............. -............
ff IMIIMlUUC'oti~U~
~
$'jMI)I(vr;f,w:l')'IC.,:':.;>1 U

unimplem ented methods, i.e.


click on the llght·butb Icon
-"
............ -=· ..._-_....... ..._.....
(flUff I!M.tc •
_. ~

and choose Add 2 l .(lct_ l!!~,;:,n~·~: ~


unimplemented methods. -·
.-u.:c~ ,_~_.;;..~ ~ --..;><·~·-·:.:::..--.,..... \<~-"'--"
. . __ _
........,....,._.,......,. . ...
-
~IVI'"t NC 411 _ ___~ ..... "''"' .. , -~.P""-'""--·"""·-

.. ... ·-----"'----
_ _
~ ~ r~ .-.~

·---~---...... - ......-
....-.
('""'" \._
~.

33.1mplement the c u stomerinfos_9et_entity method:


,, _, . - .

Code snll!eet: cuatomeri.nfoa_qet_ enti.tl


METHOD '~stomerinfos_ge t_entity .

·Entity can only be accessed via the nevl&&tlon p~y TOCustonerinfO


• of entity type custooerelassific~tion and if the key custooeriD is p~ided
I F iv_source_namt <> zcl_ze2e_cust_1nfo_epc=>gc_customer class1f 1cation.
RAISE EXCEPTION TYPE /iwbtp/Cx.Jf«W_tech_e.XGeption.
ENOU.
READ TABLE i tj.ey_tab INTO MTA(lsj.ey) WITH KEY name • 'Cust011eriD' Nti';)_T£XT •
I F Sy· Subrc <> 9.
RAISE EXCEPllON TYPf /iwbtp/CXJCW_busi_exc.eption
EXPClftTIMG
textid • /iwbep/~_busi..exception•>f ilter_not..supported.
ENOU.

DATA lv_customer..id_f ilter TYPE snMd_p~rtner..id.


•Apply the converSion of Snwd_pal"tner_id (dobain O_EPM_IO)
CALL 1'\MCTION 'CONVERSION..EXIT..,ALPHA,..INPUT'
EXPORTDeG
iRI?:IIt • ls..ke~ -value

38
Gateway OData Service

output = lv_custoner_id_fil t er .
•create an instance of class zcl_custo.er_open_tnvotces
DATA(lo_cust_info) • HEN zcl_c ustomer_ope~invoices ( ).
•call the ASAP manaced DB procedure respectively the
•ASAP cla:ss method cet_customtr_info
l o_cust_info->get_cust oner_info(
EXPORTDIG
iv_client = sy-nandt
iv_bupaid = lv_custcmer_id_f ilter
DIPORTIJI6
et_bpi nf o = OATA(lt_enti ty)
) .
•only one line ts e•pected to be retrieved
IF lines( l t_entit y ) <> 1 .
RAts£ £XC£PliOH TYP£ /iwbep/c•_"Ww_bu si_uception
EX""'"'IMG
messaae_unlinited = I Preble~ i n Custoner I nfo; { lines ( lt_entity ) } <> 1
textid = / iwbeop/ <)(,JJgw_busi _excepdon=>buslness_e,.rol"'_u-nlimited .
l:NDIF.
•11ap t:M fir-st row of lt_ent:ity to tf'le output
.~~,,~·!~'" a l t_entity[ 1 ).

~~================~
the
34.1mplement invoiceinfos_geLentityset method:

COde •

NETHOO invoiceinfos_aet_entityset .

'"£ntttyset can 0t1ly be accessed vt.a the nav1cat1on pr<lf)erty Toinvoicetnfo


•of entity type CustCMMrClanification and i f tht key CustOMriO is pi"'Vided
IF iv_source_n a~~~t <> zcl_uze_cust_il'lfo_•pc=>cc_custOI'I'Ierclassiflc.ation.
RAts£ EXCEPTION TVP£ /iwbep/CJUf'CIIf_tech_exctption.
£NDIF.
READ TABU i t_key_tab INTO DATA(b_key) WITH KeY name • ' Cu stoner iO' NNO_TtXT .
IF sy-subrc <> e.
RAts£ EXCEPTION T't'P£ /iwbep/c)(,JI'.CW_bud_ txctpti on
EXP<ItTIMG
t txtid • /iwbep/~_busi_exce pt ion •>filter_not_supporttd .
£NDIF.

DATA lv_customer _i d_f ilttr TYPE snwd_partntr_id.


•.t.pply thot converdon of sRNd_p,artner_id (donain o_£,._ID)
CALL FUNtTION ' CONVERSION_EXIT_ALPHA_JNPUT'
EXPORT.DeG
inptrt • ls_key-valut
DIPORT.DeG
otrtput • lv_cust oner_i d_fil ter .
•create an instance of class zcl.customer_open_invoices
DATA(lo_cust_info) =NEW ~cl_c ustoflltr_open_invoic es ( ).
•call tht A8AP maneaed DB p~edure respectiv~ly tht
•ABAP class method c:et_invoice_info
l o_cust _iniO·>set_invoice_info(
EXPORTDIG

39
Gateway OData Service

iv_client = sy-nandt
iv_bupaid = lv_cus tcrner_id_fUter
DtPORTINii
et_invinfo = OATA(lt_entityset)
) .
• provide the resultset of the N/ifJIP to the tabular
• tabular output para.eter
et_entitvset = lt_entityset .
ENOM.£TI400.

35.Save and activate the class


(shMCUtS Ctrl+S,
C':l·. rl +F3).
l .. l.,.- <'l.ltUI Ml _.~..-~..,,._u•"-"f"-"n t«•nllnl)ol

If you•d like to format 1 apply ---"''·""• ~


l 'l'HtO:
r- ..,, .a.,'"'"'


,._,..,..!1<1'\0.I,IX'o~ UI11UU1' 1ll\l <Ul<> <1><:
oun ""'u.: .
the pretty printeJ remember '"'""'"" ........, ....,.......
shortcut Sh i ft+F1 @, ~':'1-:TD ~C.:ftCII.
l i l t - ..,_ _,,.,,...,."'"'"-"'' ~" lllQll'Ufi'JI(II ,
llii'Wll:4 '"""''~·•nt"•-o-e_,.,,,,~?,...t IIUUIWttl(ff,

"'JYl'll$ III'JCTIIlfl·
OO<~.

36.Last step is to register the " I"AI'lt....,.I.,:I\~VII IC

OData servioe. Go back to )oo.•• , & • <l A 0 0 11: QIU6 b'..U1fl 1:11!1 $ &

transaction SEGW (you migh1


sti11 have the tab open or use
Alt+FS to open it again).
, SM_,._~•ys-tc~•·~ l 2ia:~~
Ull.t!.~ r.t!. ~l!.!:J • lllll;lt't Al 'i11~
. "· lnl.«".-
·o·--·---
,..._~,..- w-~-~ .
,. ~... •'"'~

~~-
·--
..._
Do...- -
:.-...
.o 00<1
0» O,Qf;
=
Ooubl<rclick: on SIJIVIc6
Maintainance and then on
RogjsttJt.
·---
··- .... ·M,.._
onr""..-1
O)(I b'- 40ih
.\i'":".:;J
. .....-
37.Confirm the Warning.
(.(r lll!f,J5tel, M<lr(iin~&tOI VJOQ:Iel~t.IO!'IS, \0,1 wl be
'1''--~'~"'iected to tl'l: d:«ed system. Do rou W¥tt to con!T!Jeo?

"'"' '(~ 110

40
Gateway OData Service

38.Provide the package STMP to


which the OOata servioa will --·--
··-- ......... ,...._
be added.
----
"-c--. '
.......... -
-~
--··. .
-·--
--
---·
·-·-
- -
...___
_..,. .....
-~-·-.-..-

39.tf everything went fine you


can see the registration status ....,,
indicated by the g reen status
indicator. ""

41
GW Testing:
Testing OData Gateway Service:
/IWFND/GW/CLIENT
Gateway OData Service

Would you like to test the GW service?


If yes. this can be done in several ways. I'll tell you how to use the Gateway client
(transaction / I WFND/G\i_ CLI2:NT) .

Description Screen Shot


1. One option how you can
navigate to the gateway
d ient transaction is to click
on the Maintain icon
• ~. :x (WI UIU
•!.l')ol.o-
• CJ ,Y•« ITC~IliOl
. .._.,.,...htW't\
n~

2. In the service maintainance


display, select the service
A<IIWI'Ir--~
from the sel'\lice catalog and
click on the Gateway Client
button in the lower right part
of the view.

--
-............
--
.
,.. __ - ... ,.,.....
••

3. Confirm the SAP GUI sccurtty


infonnatiOn dialOg (m aybe
even with the remember my
,.,.,._ . ~ -
.... . . ..
h.~hiii«<J.U.UC.,_f~.l~o»BXIIU~ml:l

decisiOn functionality @).


.........
C.\OicoAA.t.._'lfiN«/)~T~"\

00)o'Oo' """'' O)fPIII t.t _...,'-"'O:»i""' _. ~¥'4 ~ 01 ~•A-~?

42
Gateway OData Service

4. Check lhe Reqves1 URI


(/sap/opu/odata/Z£2E_C
·-·- .. --- ll••--- -....-. .._

~7;:::.,_
• tw • • • C!~"'~' a :r. • •

OST_ INVO_ SRV/?S! Ot!!litL-


,.,
_ .,. "...,,..,'"....;;;--," ' ) ,.
X!Ill) and execute {Fa) -..c ~

-f .zi);.,_._, ... F ,
·- ....
Ifill'~.......

.. GO! ••
...._
1!1'~

'
5. Several more SAP GUI
Security information wtndows .... -........- .......
appear. Read them carefuly
e or just click allow (and now, .......
(_...,,.,_ _ _ _ U<Ill'~

please remember my o.--·" ,...., ••-.;;.........*....-, .......... -.~ ....,_,.~


clecision!}

---
,. ___ ...
6. If everything went fine, you
should see a successful
HTTP Response (status cocfe

----
---------
~- ...
• . . . .. . . . . . rltloiiO Ill: • •

~--
200) and the xml tesult of the ----- -~

_
~·- lir- ·.._,.·-·-U•

____-__
--
OData request
--
--
___
-----··-
--
___ _
__
.. _
.. _...
_,__, ,,
---~=-=:::=::--
~~

--..--
--- ..·---------·
...~-------
_,...

--
--·
--·
---
--·
--· --_ .,-· -
--
---· ·--•..... .-v,._ _ ___ _ .

7. Repeat the test tor the Request URls:


• /sap/opu/od.ata./aal)/tE2E_cosr_lNro_SRV/$me tad.ata.
Metac:lata ol the OOata service
• Is aptopu/ od.ata./a a!)/ tE2E_cos r _ INTO_SRV/cue tome tCla.sai r 1ca t ions
List ol Cus!ome~ Ctassificalions. Le. query on the COS view (get an;ity set method ol
Custameretassiflca11on)
• /sap/opu/oda.ta./sai)/ ZE2E_COS!_ INTO_SRV/ CusLometCla.2Si C1c aLiO!!S (' 100000000' t / :'OCu
SLOm-t.I'Ill£'0
Query the customer in'orma:ion for customer ID IO<XXXXXX> (SAP AG). 1ectrically executing the customer
tnfoonatlon AMOP
• /S :.(>/ Opu /¢\Ula./s ~v /tli 2 £ COS! INTO SRV/ CuSLUtln:.ClaesHlc<:LiC:iS ( '100000000' t / :'OI~l
vvi c o=::1!C
Query the list of sales order invoice information for customer 10 100000000 (SAP AG). technically executing
me InVOice trUormstlon AMDP

43
Gateway OData Service

Well done, you finished the implementation and testing of the SAP NetWeaver Gateway
OOata Service and hence the second to last step on our joumey to the F10ri-like application.

If you would like to leam more about SAP NetWeaver Gateway and/or contact the experts,
please visit http://scn.sao.com/oommunitylnetweaver-gateway.

44
Fiori-like Application

8 Fieri-like Application

.,
~. .......
c.ot~~,
_
.....
).txk';\1-a...J ...~

n
-n - -
A.IIIIIIP"'*"'l:ool0l
.,... .... ~.,

b,j
...
•.c:...._$oot\i«<

-.........
to. nn~t:WIIIo/IFf>

~
..,... lo;ft:OO., .......'"""'.......... ,.; ..... ....... ..... y...,• .......
-
Ready for the final step? You'll now create a Fiori-like appltcation to display the list o f
Customer Classification Information and to do a drill-down on the detailed customer and
open sales order information.

Technically, the Fiori-like application is a so-called split application (sap.m.SplitApp- see


https://sacuiS.netweaver.ondemand.comlsdkf#content!Qverview.htmt for detafls on available
Controls, API references, etc.) targeted for mobile d evices.

In the following, you'll create and d evelop SAPUIS application locally, where locally means
you develop a SAPUIS application in you Edipse installation. The local SAPUIS application
will then be impcxted to the ABAP backend using the SAPUIS repository team provider.
Having provided the application to the ASAP backend, you're ready to run and test your
Faori·like application in the browser.

Local SAPUIS Application Development

Deecriflllon ScrwnShot
t. Right-click In the Project
Explorer view and select
New > Otherlrom the
context menu.

·- - ·-- - ·~

-- ...
-
6-·--
·--..
..,.___
~·-
...................
-~ •
... ........

.._ -
-~ 0:0~·-··
"- ··~~--
r '·-· t '·-
-·-·
• ••

~-
--
fli: ¢o.tlo'- l.
.... - -~L•O""•"
...........

--· ··-

45
Fiori-llke Application

2. In the new project wizard,


selea SAPUIS Application
a....... ..;....... _,• •
Development> Application
Project (to fitter for e.g. sapui
o.......- -

-· ................. --
r

eases the search for the ~


- ~~
corresponding entry).

~ --·-~ ~~
3. Provide the necessary c:....... .._,_,.... ,...._ .... :;AI'IM
'

lnformatkm for the new - ...,.~··d-·'"-•


application project:
~- Q...aJ-o... )
• PtoJcct name: Z£2£_FICRI
,;..,._40,_ .. ,.,.
• Target Device: Mobile
• Options: Create an Initial
Vrew (checkbox)
I

.... t_..
'
r s ...:__j

c."'-
.- - >
cr;.. .. tw,
<!! ... ~ I f)oH I L__J~

•• Provide the information for


the initial view:
• Name: Master
- .............
(loo_,_VI_
~.-·p..-

-

....... Jil(ll:;,o>
• Development Paradigm:
XML (ra<lio·bunon)
I_..._._.,. "'
-·· e:::> ,
~-,_..,..
__
~..-·---
c~.-~.~)
,
·..-·-..........
,_
~-·--""'

"11 ~
r .)l.. ~l ~~
'""

46
Fiori-like Application

5. The SAPUI5 develoment


..-;.._.._ _ _ :. . ~
--------··
--.
f""
"c&.O
"~.':'
preted is created.
...- . . . - - ~- ·-~ - .. II'- " . :-=:-
You're redirected to the Java ~- .-=....
"'"'""'".. ,... - ....,. .. ____ . _:;
EE perspective and the three . :::...
·-
development artefacts are · ·~
opened. namely the
i lldt'\X . h l.m1, the
Ml'! ~• Lt'\ r . <:un Lrul lt'\ r . j ~•,
and the M~~~ uu: . v i <·~w . xm l

--
6 . Implement the i m !1:x. h t.ml file (best thing is to oopylpes.te everything ·~) :

Code snippet: index. btml.

<!DOCTYPE HTML>
<f'lt• l>
<head>
<!leta http-equiv="'X·U.·Ca..potible" content o: "IEc~dg~">

<script src• "~sources/sap • ut•r:ore.js ..


id= "sop-ui-bootstrQP~
d.-ta•Up•ui-libs• "s.op.•1 SflfJ.fH1 sap.ut. Layout"
dau • sap· ut-xx -btndil\gSyntax="COMPLex"
dat.a• up•ui•thue• "sop_btwc-rystaL " >
</script>
<script>
II Define pat:h of the ooata backend service
var sOOat a$t rvict Url •
"1 sa.p/oc>u/odata/saplte2e_ cus t _info_si"Y" ;
var oOOat aModd •
sap. u.i.II'IOde 1 . odata.ooataMOde 1( sooataservtc·eor 1) ;
oOOata~l . a t~a chR tqut stFa iltd ( func tion () {
a1er t ("OData Request Failed!");
));
sap. ut .get Core(). setNOdel (OODataMOdel );

II Tell the Application where to find the


II local ruourcts
sap. ut . l oc.a1Resourc es(•u2t_f1ori ");

I I "'ster & Detail ~its


vat' mtasterPage = s ap.ut .vi bl({
id : • tdMasterl",
viewNat~e : "~.ele_fiori,,.aster" 1
type : sap. ui . core.mvc .vi ewrype.XML
));
var ooetailPa.ge .. sap . ui. vi ew( {
id : ..idDeUiU" J
viewNane : "tele_ftori.Oetail" ,
type : sap . ui.core.~c.ViewType .XML
));
II Spli~ .Application
~==~"'= IUADD , ••

47
Fio ri-llke Application

oSplltApp. &ddMaste rPa&e (oMasterPage) ;


oSpl1tApp. &ddDetailPa&e (oDeta1lPage) ;
oSplitApp.plac eAt( ~content• );
</Script>

</I'IUd>
<body class.,•sQPVIBod)'" £2U.,"oppt tcG"tion">
<div id= "cont~,.t"'></div>
</body>
</l'lbll>

7. Implement the !>laster . control l er. j s:

Code snippet: Master. controller. j a

sap. ui . controller( "ze2e_fiol'i .Master", (


handlePress fu nction(oEvt) {
'
v~ r oContext = oEvt .setSource().get8i ndinaContext();
if (oContext) {
sap.u1.getCOre() ,getEvent8us () , publtsh("e2e_app• ,
"ReadyToFetcNDetaiJs•, (
octx : ocontext
});
)
)

_));
....,., ., ..~... '"

-
•o

-·-
B. Open the I'-"•,.:•'""""' u ~""'"' "'- a

..·-_ -·-
E ,.
~ l\
Master . v i ew. xml with a

··-
15 .....>V~o•. . - -......1- ...........
taXI adltor. Right-click on - 1!1-uiii .........)Mo..,.. l - "'· ..........
.: v .._,_ I'IW ~-

Master . view. xml and


selea Open With> Text
~ -tt:t.Jt:lll
e :1 --
~ "~---llJCJ'if.I'S.
..,.. -· -·~
_,__
Editor from the contaxt
menu ··--·
·----""llXJ""'··
15 11 --.....

··-
.......,..
..
·-~.... ...
"''~'~--.-4~·~.,.

··-
~ --~
It .. I'C'l....

- --__
15'4-·,..-
.., _~
...

.,.
...... " .......,,..
0
:i
. ' "'""""
-·-·~
Q~

-
~- -·
.......-..
~

9. lmp1em ent the Har: t.t! t' . v i t!~o• . x.tlll :


-··
~~-

Code snippet: Maater. view. xm1


(<!Of'I'!:Vil!'"' l!llllm: :COI'tl:•sap. ui. t;OI'C!"
1011lns : r~vc - •sae .ui. core .mvc"

48
Fiori-like Application

xm l n s : ~Msap.n ·
col'ltr"'llerName= "ze 2e _f 1or1. Master-"
xnl ns: html-''http ://tNW. w).org/1999/xhtnl•>
<n:Page ld="page_Kaster•
cbs s-" sapu i Fi oriObj ect Pa.ge"
Utle="Custoner list• >
<.n:content>

<.n:Lis t
id=" l i st_CuslCl &ssif icauw,"
heat!-erText- "Custoners"
gro..,ill&="lrue•
gro.oJinglflreshol d- • S"
items-" {/Custoner c lassifications ) • >
<m : ObjL~ tl i Stlten
titl~" {Custoner Nane}"
number-=" {Categor·y}•
m.rnbel"\kk it=• Category"
press=" h::mdl ePr·e ss"
type-="Active •>

<m:attributes>
<m:Objc!ctAttribute tcxt•"{Cu:litonerlO}" I>
<1m: attributes>
</m:Objcetlis t l tcn>

</m: l i 11t >


<In: content>
</n: Page>
</corc::Vi ll'lrl>
8 ;. <UEJ~~
10. In addition 10 the Master 11;1 jt ~~t ltitJ'lOIII i f 10':4ntelltl t
~ -.~Fot:mJIOio:l ... "l) . •.u .~t-Cote ll. ~t
page, which has been "lln.doyTorno
•·~ s..·--
created during creation of - J,t.f6o<ol ~CH
0~0: : 0

the SAPUIS application, a 1!1--a.t...,


s ~ ~v«<'(
Detail page is needed for !il • wr~·llf'

..........
the SptitApp. Create a new 111--Qt • t llo:l'l"

file via the context menu of


~ ~ £:£·· ..~. !~·····••"•'••11~ .J[~
'"'' ----'
.lil ~tf¥1 """"'~ .~
the 2e2e_ t1or! fOlder by
...liN\.....
selecting Now> File
«<N

·-
(bw~--

49
Fio ri-llke Application

11.1n the New File wtzard,


._,._ ... ,_
·~
provide the file name 1
Det.ail . vie~~t .x:nl
.....'"".....-..
,..,..,..._..._ _
jlj u••.
.c\ - - -.. !H·~~· tiC

_
~ ~ ..~..... ...-
.,. ,....._ ..t.., ...................... w
..............
-~-
~"
• *~
. .;;,.,..,_
,_. ,. ._.
~--

-.......,
... ........c......::::;, ~

~
, ,...~ I ~

..-_
··-...··-
-- -·-··· ...
12.0pon the ..
" .... ,
. .; ...._,
~
ouail. v i e to. x::nl file
with the Text Editor via the
oorrtext menu Open With >
Text Editor
. .~-··-"
-~--
. . . -. -- ...-... :l...e. ._

"

- --
_.._.....,......_
·~ '"'

13.1mplem ent the Detail. v ie~o.· . xrnl:


·~
(- ---· ~- -~ .....

Code snippet: Detai.l. view. xml


<core:Vte-.v lOI'Il lls :co re= •sap. u1. core"
xmlns :Bvt• •up. u i . C()~ .mvc;"
lOI'IliiS="sap.ta"
controlle~me .. "ze2e_fiori .o euil"
xnlns: html ... "http ://ww. w).()rg,/1999/xhtnl•>
<Page 1d="pa,ge_oeuu·
c hs s · " sapVi FioriObj ectPage"
Utle="Deta11ed Cust011er Illfol"nnat10r'l" )
<content>

<ObjectHeader
1d=" head_ It~vo1c::es •
title-· (Ctls tomel'Harte) •
nunber="{SumGrossAnOur'lt}"'
nt.rnbef"\kd t-"{CurrencyC()c!e}" >
<attri butes>
<Obje<:tAttdbute text=" {CustOIU'!f' ID}" I>
<ODjectAtt ribute t ext-''{Ci t)'}" / >
<Obje<:t Allribule te.x l:" {Poslal Code}" I>
<ODject Attribute t ext-''{St ru t )" I>
<Obje<:t Allribule te.xl="{COufllry}· />
</ attl"ibtltes>
</Obj e~UMC~dCr >

50
Fiori-like Application

r==~<<T!~ab~l~
e ~~~~
>•• P~
ath~
1S ~~~.~
- ~~~
••~~==-
-- >============~
id-"tbl. Invoice s·
items ="{ p3th : · ro t nvoi cd nto·r
noonar ext-"No data available - Please select a <ustoner·
gN>wiJI&="true•
g~~i n3Thresho ld - "28~ >
<colulllllS>
<(0}1.11111>
<lu:ader><label tex t="OI*dt:1· to• /></header>
</Col utm>
< CU l urW~ hAli gn:•center" >
dt~ad e r > <labe l text -"C~at ion Date" 1>< /h.~aden
</Col utm>
<C0l unw1 hAli gn:•Rt ghl" >
< h.~ade r > <lab~ l text- "Gross Nlount• /></Mader >
</CU lum >
</ col uiTI'I S>
<i tl."ttiS )
<Col umnlist l t en>
<ccl h>
<Obj e<t i dent l fier t i t le ="{Order iO} ~ />
< T~:x t tr.xta • { Invoi ct.~t~:} "/>
<Obj e<tN.,' "ber nl.lflber=-" {SuttGrossAftount}" nufl'tle runit= ~ { Curre~c ytod e } • />
</cclh>
</Columnli~tltr.n>
</itums>
</Tal>lo>
</ content>
</Page>
</cor e :View>
14.Adcfitionally, a file tor the
Detail controller is required..
B i 'tJ ~o.tcr~ !UfJ~
1)> ~~\'((II !(W lEa_FIOIU '
.. (oCon~~,.) (
""l'·"' . v-~Con () . (iiOOt
Ill :t s.r...~<:es •I:!Hdvhr-eu:
Create a new file via the
oontext menu of the
2e2e_t1o ri iOider by
..... ..
!tl ·k~ll-­
e .- . . ~- )
• '"
O(tll I 0

111 ~ t•('!!\ •llF


selecting Now> File
-
·-
1!:1 ~ M:IHP#-

~~-·
....
'""
G ~t(IT
"'
·~IIID'•::::IIIIII~~~~~~·
.~..,.
~}'I
~~~~
~ ~+:;NI..W

·-- .
""'
~ ~-~-..
"""'
..... ~ foil"~
"""
......
"
.. .....

51
Fiori-llke Application

>
15.1n the New File wtzard,
••. ,_,_.,.,_
provide the file name '
llet~i l . (:tll'l.t'.t\.,llet. xml

~ ·~
>
---
.... .. ............ ...
~-~···

,.. ... .,., - ~,..,,..,,_...,.....,.,nc

o :~
--
f> \!: . ... . -

,...... .'"'
..l>.,(l;o.((!(WI)t.t)(

·....,.,
~

.;...,,...,_
~,. .;. ....,__

-
...._.._......~- /§
_.,_.,r
---
I
1 ~-=.J
16.1mpklmcnt the ouail. controller. j s:
"'
Code snippet: Detail . controller. j e
sap.u!.controller(• te2e_f1or!.Detail" , {
,..•Called wMn a controller is instantiated and its Vi ew controls (if
• availabl e) are already cr eated. C.n be used t o nodi fy the View bef ore it
• is displayed. to bind event 1\andlel's and do ot her OM- UIW 1n1t1al1ut1on.
.,
• @"r~b~rOf zele_fiori .Detail
on I nit : f unction() {
II handle data loaded events
v-ar o8us • ll4!W sap.ui.aetCore().aet.Event8us();
oeus. substr1boe{"e2e_app'", "Re&dyl'oFetctiDetaUs" ,
this.handleFetchOetails, this );
),
tlandleFetchDetail s : funct ion(sca.n.nellO, sEvtid, ooata) {
var ocontext : OOilta.oCtx;

i f (oContext) (
II 81nd obje<t header to the OOata model
var oHeader • th is .byid( ' he~Invoices' );
var sODataHlterP-ath = oCont-e xt. sPath + 'IToCustOrllerinfo' ;
oHeader.bindElement(sODataFilterPath);
II sind the ~vieation properties of the ooata service to the
II UI table control
this.getview() . setSindingContext(OCOntext);

II scroll to top of pace


this. getview() . byid(•pace_Drtail") . scrollTo(e);
)

),
));

52
Fiori-llke Application

17.Save all files

53
Fiori-llke Application

Import of the SAPUI5 Application to the ABAP backend


After local devek>pment of the SAPUI5 application, you'll now import the application into the
SAPUIS ASAP Repository (technically a BSP reposnory) using the SAPUIS Repository Team
Provider.

···--- ----
Description Screen Shot
1. Select Team> Share
· ~- - ··- -~
• -...... ~ -·
Project from the context
menu of the Zl::?.l:! e'!OHl
application project
-
• l" -~

·~-
c ~-
~-
-
..
.,••.,:.

#..:•-
.......
-· --·
·~
~··
.-. . .....
•.c........ '

..........
... .....-
" '
. ::..... u ...
-..~

......... _,
-
~~ '
-~ ~- ~·--*'
"'"""'....,
<Uo ,9"'-V. . .ft ,o

••• ................
-•.or.v••••··•

-
-·~
-·-;-:._:----t~~~~~
-
2. In lhc Share Project dlaJog,
seleo< SAPU/5 ABAP !lh ..... """''""
,..,., ...- . . ................ -.."""".......t>oo ......,..;,.....,
ReposlrOty

,Gf}

54
Fiori-like Application

3. Select the backend ~ ..eo- •• =


·~:...w::.--
~~-:;=~:e::.-~·:·:·:·-:··;-;~-~-~··~-~·-~·=·~-=·~r;.: (
connection, e.g. on the virtual
appliance you can choose ~ -'-"u!J o.,__J
A4H- Developer Edirion. i.e.
-
"•-"e..- ...
c;o:--
the NJAP backend
connection provided in the

--..•-----r..
._........
___.,., _._....,. --
I

~~-~l
SAP Logon application

Note: In case you•re not


....., _.....
-,_,__
...., I
I

working with a virtual I


appliance. the connection ••
name m ay differ.

.... ,G~ L_ _J...!:W

4. Provide the system logon ..._ ..It_


credentials

-·-
~-= ~::::::::::::::::::::::::::::::~1
... , m
,.. ~--
r

55
Fiori-llke Application

5. In the Share Project dialog, .


.,.... ............._ ..,.
..
choose to create a new BSP .......... _._
application and provide: ,._....-. ..
• Name: ZE2E FIORI
• Description:
- .
n

.. . .
'
A4H: End-to_encl F10ri
Application
• Package: $TMP
- -.
.
··-.·· .. '¥
---
........ .- ..........
., • +

-- : ... . ;,". .. •
•¥•~
-:~":~
-
" .... .. - ~

............ .....
-.- --
--~

-
-, .,_
...
· 1oM(_____
.........
~.,.._ ,

_............ ..
...,_.
_._.,.__.....,,..............·-·
..,..,., ,............,... .,..

.!.:- &fl ·-
6. The ·No transport req uest~
Information Is shown.
Continue with Finish, which
- '
~ ,.,~_

,
...................__
......... ... _..,..
I I

results ln a Server Runtime .


Version Check information
_
..........._.. ... _,..
__ ____ ._ .._•
which you can just confirm
and continue. I

-- _ ___
.........,........ _..... ""-_
...,_
_
!0!....- l t N - ! O tU
!.'::'~i.Z.";:C:.~.;.:.~:.!.

_
._..._
.....
.._... _.,..,_,........_-.........
- ... ~-
.. __
...
""'

<! .....·------~-~-
_ ..._ )
~-
,
I·,
__J

I ~' I ,\··~ s .

56
Fiori-like Application

7. You have now prepared the


ASAP backend respectively .............. _.....- .-. 101

............._.J&i""""''·-- ...
..
• 0
!0 .\ ..
.,,._


.... - -- . . . ....
......................... .,...-... ...
.............

- -- .... -
the SAP\JI5 ABAP "~~~·-·"'-
.. ...,........ I
Repository and you can now .....
.. :r . . . ___ "' ...
... -~ · .....
- ~ .... =· ................
submit the application to the ...............
....... ..........
...
-......... -
~

... ...... .. "


.. ~ -··
repository. ~ ~~~~ ·-- ~ ; ~

.....
Fa this purpose, choose
Team> Submit from the
context menu of the
··----- ......- .....
c ~,.!';':..'! ~.-. ~~~ -

"!..... -·- .- ...


a.........
,..,..
"

7.E?.E_ FiORi application


.......
project.
--··
-·-
..... .....,_
8 . The Submit C hanges dialog s.··,.··~+-· ......... :~••,..;,
shows the list of Information

---
that will be submitted to the
repository, check the list and
oontinue with Finish.
••
!:i- -··.
Iii I ! ! _ > "-___
8 . .. _ .., ......... ' ..
I'Jf
• ··

-~
es- -...' " "'
s.--
Ii - --
e • ..- ....~- ..- - . ..."- ·-
e •~
&! Iii _ _ _.... .............
IO! Iil _ __ _...
-
.-.
._,
~

·-
ll a -
11 8- . - -
--
- ----

Jlppee!
You have successfully created the FtOri·like application! But. ..

57
Fiori-llke Application

You would like to test the Fiori-like App, right?


If yes, open the browser of your choice (or the one you like best from the installed ones©)
and open http://abapci.dummv.nodomain~SOOOOJsaplbc/uiS ui51saplze2e fiorilindex.html.
After providing the system logon credentials you should finalty see the picture I promised you
at the very beginning of the guide ( ...at least after you selected a customer from the list on
the right·hand side of the application!):

--....-.....
.....
+ · -..·--··..· · - · - - -
-

••1.10...~............. "'"'

'·"""'"' 150412570 f2 -
~· 1

...••• ...... --.


. . . . {> ........... .............
1... c
! .,. ,. . ,. ...... ..,,.,....,....,_
L.·-----·····-----·······' -·- .........,... ., ....,
.................,........ ........,
-·~ ..,,., _____ l!Of . .....

-··
s

-
.....
- • "' -~ O) _......-.)

Thanks for joining...


.. .this end-to-end development guide from HANA via ABAP to a SAP Foori·like application.
We hope you liked developing Core Data Services (CDS) Views and ABAP managed
database procedures and encourage you to also have a look at the latest features in
OpenSQL. With the SAP NetWeaver Gateway as OData provider you stepped towards the
user intertace and finally developed (okay with a lOt of copy-and-paste) a very simple SAP
Feori.,tikc application ... fool free to enhance the application to indudc all the eye·candy and
rnobile-device-leveragiflQ features!

58
Appendix

Appendix
Installation Guides
Install Eclipse
In the following I assume that you are 'WOrking on Windows. In this case, download the 32·bit
Version of Eclipse Kepler from (www.ecliose.om) . extract the zip file to a folder of your
choice. and run the eclipse.exe application.

.n,
Install needed
Screen Shot
1. Open the Help menu and
choose Install new
Software . .. If:::_ ~~~~: ~:.·:..
F~. ... ltJ' ~"""
li
'4 ~-..........
~ij wt.<c..W.~...WTU .,_~
(ly-.
(M.-...
r.,-n.;..~o..

' ~~ ..t -

<-.-·-
~ <-~w.--.

"'"""'
_. ,-
-·---~-
..,~ ....
2. Click on Add... to add the
needed updato Sites lor the
Plug· Ins
·-· _._
- ..... ~
--
: --~

3 . AIJd the update site


htt~:/JtooiS:.hana.ondeman

d.com/keoler
1-· f/#~1-

. .,...,_,.....••, _.....ot{loof....

('[! 1
~kHef~ I ,_.
SAP

59
Appendix

. . ___.. _
4. Install the plugins:
• ASAP Development Tools
for SAP NetWeaver
._.

--·----·
__ __- - _
... __ __.... __... - .,.
• SAP HANA Tools
• Ul Development Tooll<it
for HTMLS
-*----·-..
··--
-
.....,.

- ·--
·--
-·-- --
.....
~""'"]
l
=
5 . Check the installation
details ---
-··-·
---- - _...._
•_.,... ____
..---
·---
- ~~~~~--···
---- - "•••'
-.........-
·---
·--..
·--
·-----
·-------
·---- ..
..·-------
..,
----
__.._,_ ---........
....
....
,....
"""
---
------
--
------
---
-......_._..

-
6. Accept the terms of the
license agreements flnaize
the installation.
~:§:;;:;"""""'"""";------,-;
. ..••::-:.;
...- -.- -
.....,uru
Note: D uring the i nstallation -~(-
process you'll be asked to
confirm security warnings
and to restart the Eclipse.
Please do the needy here
@.

60
Appendix

Add an ASAP Backend Connection (SAP Logon and ADT)

1. Toaddan ABAP System to


the ASAP Development
Tools you need to create . Q r • ..,.....
· (,;)~.... ~ Here
the entry for your system in "' Q """"'",.....,
the SAP Logon first. -~

So. please open the SAP


Logon application and cic'k
on the New System Icon.

2. Add the system details, I.e.


Application Servet (IP
- ___
••

--·---..,--
...... ....... ...
~
_
,_ ...
•-r,.._,. __ ,_.._..,. ""'-"--
_
Addtcss or System alias It
maintained in the
---
----- .-
C :\Wi ndows\SystemJ2\
drive rs\ etc\ hosu file .....-.-.
(as ls the case for Wtual
appliances).

-- •
,·-

------------
3. Go to the ASAP pe"!>ectiVO
ot your Eclipse installation.

( _,..,,...,.....
s... ,~. , ...
P.c.c~. P..,~•M.
(boo """-"'•
c:.... AJ ,.,........ .
"....,_..

61
Appendix

'
.. ~

1 m~, ,­
&M~""""""

··.,-__
9'cot~1

~-·__,
,,! ..•.:t
hf.-,t i)U l -.,O><IIY

,_
...
·· ~A . . . . ..,.-
flo....•;
...., ,_,.....,.,
Ot~~

c.: I c.-... I

4. Righ t click in the Project


4

explorer view and select


N9w > ABAP Proj9ct
from the context menu
- .-
'
-..;.,

'""'-~
....
......
.-·-·
,, ;; r..'*"""'"¥<1
J ~-hojo«
....·I"' f •• "'!....
.... ,.,.,••• I ;"8 ,!>...........
__,...,..,.4:..~"--"''

c-c Oick ~ ,....... """"'


""
t., .o,..............

.-·
a ..,, ( .,_..
........ .
III~PI\IjHJ-

It: _
-)<;..........,..._
...,.••..,.~
Cl<· -'IN'I· J

~-·

5. In the dialog window, enter~::;:;===:===~~~=~


~~!!!!! :-- - - - --1
the necessary system data: ,_.. ,..._ e
a. Client
b. User
c. Password
- ··-·
~·· ··--·ol
~-'-"'

' .... I . .... ~I ~~ I

62
Appendix

System Configuration & Example Data Generation


Generate Data
Screen Shot I
1. Press RunABAP
Development Object (short ~,. ·-·
r:i * "> · O · Q. · -.~
... . . . . . "'.,. . ·< . .
c ut ld L.f-i"f!)

2, Select transaction c; ........."~


-or;-on.
:>E ?H HWII'<q"""' MIUOIII .-IIono. M IMi t OO'I,IW\'4U (IIii , . N!

·- u....- ."' ~·.. "'d-·"'. . ~t.al'*-<1-1 """""'~ .


S€~ OO.OIIf
........,11.....,
P' SET'M_OG.O~
-
~;~r·.

P' stFM,.OG.OI.I

.. _.._..
i _ _ )_._,.._

®
C¥5...)
"' I[
,_. I
3 . Configure the data II' IAAHI SfYt.t_OO_W. !:!
generator aooording to the
screenshot and please read
H~ • 0 v
• 1!1 e~e IP
the axp&anation beklw. £PH: RI!PQrl to sblrl O.t• GIJn~r•tor CIMnnel fiir I
~IS>

Rtat;atto Mast:ff ~ttl X


l b . of S*'s Ordt.:s 1.1()0.000
l b . d'tMI'«< t. OOO. OOO
SUr't:l'l\1 ~t tns:u.~
End"9 0Jt11 o&.oc. znc

"Explanation beloW'
The transaction will generate the all data necessary to run the described scenario and show you the
benefit of the SAP HANA. We recommend you to run the data generation as a background job
because it takes a wtlile to generate the data.
The values as shown on the screenshot will generate 1.000.000 Sales Orders with approximately
6.000.000 Sales Order ttems, the according Invoices and the corresponding m aster data.

Press :;9 to execute the program as a background job or :~s ot the execute button to run the program
1(not '

63
Appendix

4. If you have chosen \Wsety


to run it as a bad'(ground
job. just continue with the
next dialog window.

To ~

5 . Press the Immediate button


and press the save bunon
tm.:«te ~ NW'lil»
afterwards.
(ci(JIHWfl )
- .....
cw,..rn-

This is now the time to take


a btcak and fetch a coffee
or continue with the
oonflguratlon.

To check whether the data


generator finished, please
have a klok at transac1lon
Sl-!31 and check on job
RS_E?M_DGC_I!ANA.

64
Appendix

ICF Configuration
For SAP Gateway services, SAP UIS and ASAP Oocu you will need to activate special nodes
on the ABAP ICF Server.

Daacilptlon ScraenShot
-

1. Run transaction ~;rce· f:: -NU;> ~.-....

(short cut i\ l L-+F U and 1.$foPPo~ ""11..001.~to ~WI, I.:t\11(10ta,l.t<j ·I, '
select ~ace')
, ,.,...,. -,.,,....w-tt-.MJP~tpn... lltjo<t· •
....
MnW")~

""''
Q ,._! HIM. M ll~llllt
, Wllft~ll

r 11C.ntc.~
~
0 9(flf(JHOW .
' ~,. .... U~(Oo'ltf\lotled,

"-""
~~;l
® I c...~

2. In the opened search ~ [AAHJ SJCF Si


screen just press
execute I""'" ·I $ • « Q t~ C! e
N~lntaln Services

~ Ill

~(Hf~r,.,.
;J' ••mchy Q!J
!OUVIcl
,,._,.... u....
'

65
Appendix

3. Activate the Service for VTtude Hosts/ SerYces Oocu!TI!IOtl:ln

ASAP Docu (sap > be "' Od~host


"' ~ AP IS OIIUGED HOT T.
> docu) ) @ opnon AVAUIIU: <>t.UilJIU
) ® 11'-bk: SER\IIC£S

&'! '':'"'-''"""-'1···"'''''" )~
)• S}ap
' «8 A_lle'N_ItiTAJ
"' ~ IK 11(1£ (IIASts IUfCTIOtiS)
• S:!J t:llt
"' ~ lfl'/fOI.rtlllil!iOn ASAP

~ SUb-Oeornent
Qeo!jy St:1'11Ct:
Odeto: So:IVC:o:
!en:~me St'M:II

!"' ""\..;;;;;.=:=.J
!est Lo;d i!<I~CJ'IIl
sererttM:es to Sef\'ICe
QbJ. llw«tocy £ntr(

tut
{00'1'
e~.

4. Repea111 for the UIS ~- •• •'• ' 'f - •• •

Node (sap > be >


ui5_ui 5 and press YES ~ 0o YOU 'fl1nt to ~tt -~
(with sub nodes) /dllhutjtost/QPibC/IJ6.u6? ~k He;re }

Yts .:• Yts lD lr!fo X


"""'
5. Finally activate the
Gateway node
(detaulr_host >sap>
opu) also with sub nodes

66
Appendix

Customizing for UIS & Gateway Services


Remark: You will be requested for a Customizing tranSIX)rt during the configuration steps.

Daacrlll!lon Scraen Shot I


1. Run transaction :;L•RO -·--. ... •e~ •• ~-

-·- ....____ __
(short cut 1\ LL-+FU and
select :;t•Ro).

-.---....____
•':.
.

~
_
.
,
2. Click on the Button SAP ,
·lA<»~·...· - - - -
Reference IMG and open ." .......,_
. "'
the folders as shows on the .._
--,.
screen shot
" . . .__.........____.
·~- ,.........,......
~==~=
...
,.....,.........

--
..................
·lll9h-..----.. ......_,._,. _ _

... --- . -
~w-

·~~--·-(looot..........
·\11~--·
> - ......

. __ ->ff'H-.-... ...,.

__ ___
......... ,...._
. "--~
- ~~--r;:
.·~~---
"~·----.,.
.,.

.. ----
-- --~

3. Click on Activate or SAP


Deactivate SAP
NetWeaver Gateway. In
the dialog window press
Activate, and click back
in the menu Of press F3.
<N<.'rt~~-,.6}~""'-"'~ ~..,_
4. CliCk on Manage SAP
System Aliases. In the new
screen, press New Entries
and insert 1he values as
----
., - - o -.n J. !LCJ

...- -
,__ t:::
.·~-..-

shown on the screenshot.

67
Appendix

-·- __,.._ .. • & e • ~ - .,. "~ & 0


5. Click back in the menu or 0

press F3. Next step is to __ _ ,


ut:---..._~-
_, .........
Create RFC Destination
for Outbound Queues. In
the configuration screen ·-~
_ ,-· ·--
~. .()roo......

~-

-·····~
..._,_.,....._,.((ooo.- -
click the create icon [lJ]
and insert the values as
shown on the screen ~
-- ...-~r=:!!:t;

...................
!:::::: • "·~ , .._

..... q _
1111:

shot.
--
.,.., "'"
...... ·~ ·
--
•..
·---
..........
Oo ... ~ ......

,_.,_.
'
·-·('.0. . . .
--·-- ... --·- ~.

...................... ,......
~·-

·-- ·I

6. Go back two times (press C~ W.W "G.tto!W.tY Nttklt#": OioW\IMw


"" ·-·~-·- ..
FJ twice). Now you're ~ No•loeno• !C ~ .., 1'. ~ /,
ready to configure the
SAP NetWeaver
611:...~ w:".J'OI;
Otll:rl:rJ:ln ~·~~~ ... '"..
}n ~- I¥( O.ltl!~tbl r:l

~··
Gateway Settings. Click M f teJGI11(Jl'"..$T •

New Entries and enler
the values.

Note: H74 is the SID of


the ABAP system resp. a
system alias and might
differ in your case. Same
holds for the client. i.e.
001 in the screen shot.

68
Appendix

Appendix: ADT Shortcuts


Edit
Ctri+Shlft+A Open development objecl
ctr i+F2 Checl< development object
Ctr i+F3 Activate develop ment object
Ctri+Shtft+F3 Activate all inacrive ot>;ects
Ctri+Space Code completion
ctrl+ t Quick fix proposal
Ctrl+< Add commen1
Ctri+Shift+< Remove comment
Shlft+F1 Format source aka pretty printer

Help
F1 ASAP keyword documentation
F2 Show code element information
Ctrl+3 Search for commands & views
Clri+Shllt+L List all keyboard shortcuts

Navigate
F3 Open definition
Alt+Lelt Backward h lstOI)'
AJt+Right Forward h lstOI)'
Ctrl+T Quick hierarchy
F4 Open Type Hierarchy
Ctri+O Quick outline
Ctri+Shift+G Where-used list

Run, Debug
F8 Run current ABAP object
Alt+F8 Select & run ABAP application
ctri+Shilt+B Toggle breakpoint
F5, F6, F7, F8 Step into, ove~ , return, resume

69
Appendix

Appendix: SAP HANA Development Guide


hHp1/help.sap.comlhana/hana..dev en.pdl

Appendix: SAP HANA SQL Script Reference


http:/Jhelp.sap.com/hanalhana..dev sglscrict en.pdt

70
www.......com

01!1'1'1.-<110 ...,_,.._....

Soli'-
-----·----
- e -.... ··--·-··""!>" - -

--
s.-' .-:L 1"!~.....,__,-.,_...,.."""'
..,..__ _ __ _.._a.;:~~

_Gitdt_..."""-"'-. . . . . .--
---·-CIIIoo!ll-··----
..--.....- .....---
~1 - ~
-~---~

d-0.......-'" 11-nr.,...-... ~

............. -
~..... ~ ..... ~ ..... ~!0:!1..&

..
~"'"'"~to4!ot~'i,WWIO~t...u('""'~'"'""""'h,t\••
~~ ~- ............."'
.........t...,..,.,...,!l'·

_______
•-, .. .__.,~,.h\ ,,~w"

Con...,., ot'iiO'f ..,.,.,, llf )W, " oJ 1:11 !>tV &,..w....,


~,...,..,,_, .... ., c-...,.NJ ., c...""" .. .. d~,

__
..... ,.....oil'
d-o ...~,.._...
,__ .. ____ ... __ #
,...,...,..,""',.
__
~ ...-
.-.,_,_ ,..,- .

__ ..._______ __
-~eo.-.--._

""~- --
....tl-4 ...
............
.. ____ ...-.--
.... ~-~-·-~
., -~d
~-...,..
-·-~-

_ _ ... _ _ _.,....,...,._
1""~..,..,.,

-~ .....·-----~
. _. -...-·-·-..,.-.rg......_.
··.....-v~-
·~
··""'----.·.,. . . --01

Вам также может понравиться