Professional Documents
Culture Documents
ByD SDK Exercises
ByD SDK Exercises
ByD SDK Exercises
Exercises
www.sap.com/contactsap
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP or its affiliated companies shall not be liable
for errors or omissions with respect to the materials. The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty statements
accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop or release any functionality
mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platform directions and functionality are
all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment, promise, or legal obligation
to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are
cautioned not to place undue reliance on these forward-looking statements, and they should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other
countries. All other product and service names mentioned are the trademarks of their respective companies. See http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark
information and notices.
TABLE OF CONTENTS
3
The objective of this hands-on is to put in practice how to develop SAP Business ByDesign
extensions with SAP Cloud Application Studio.
The hands-on exercises will require several steps, you must follow them in the proposed
order as each one might be counting on the precedents.
Pre-requisites:
4
GETTING STARTED
Download, install, configuration and login into SAP Cloud Applications Studio.
5
Go to the SAP Software
Downloads page:
SAP Software Downloads
Select the latest version
that matches your tenant
version and download the
installation package.
Double-click the
downloaded file.
The installation wizard will
open.
Hit Next as many times as
required and finish the
installation with the default
options.
If not installed before some
Visual Studio components
will be requested to be
installed as a prerequisite.
6
c. Configure your development user
Important Note: In all the steps we will be talking about your specific <YourID> to be
replaced. If you are working in your own private tenant and no one else is doing the same
exercise you can ignore the <YourID>, but if not please use one to avoid conflicts with
other users. This recommendation applies to all the instructions on this document.
In my case <YourID> is 300.
Fill in a
Service Agent ID
(ex: EXT<YourID> in my
case EXT300),
First and
Last Name.
Hit Save.
7
Now that the Service
Agent details are in place,
you are good to request a
user.
Hit the button “Request
User”
8
Search for your Service
Agent ID;
Go to the tab
Work Center and View
Assignment
9
Log off the Administrator
user.
10
d. Configure your business user
Fill in the
Service Agent ID
EXT3001
e.g. EXT<YourID>1,
First and
Last Name.
Hit Save.
11
Go back to the main menu,
and open
Application and User
Management >
Business Users
Change the User ID
BU_EXT3001
e.g. BU_EXT<YourID>1
Important: please, take note of the User
ID you are creating. You will use this
user to connect to SAP Business
ByDesign tenant.
12
Click Save and
“Edit Access Rights”
Go to the tab
“Work Center and View
Assignment”
ask you to
change the initial
password.
13
e. Log on using the SAP Cloud Application Studio
14
If you still can’t connect, try
reinstalling .Net Framework
Shell (isolated)
Great job! You are good to start the creation, development and test of solutions with the
SAP Cloud Applications Studio.
15
BODL
Create a solution, a custom business object and its screens.
Solution Type:
Customer-Specific Solution
Description:
EX_BYD_CarPark<YourID>
Detailled Description:
Workshop ByD SDK Car
Parking Solution
Deployment Unit:
Foundation
Click OK
Go to the Project
Explorer on the top right
side and click Add New
Item.
16
Select Business Object
Press Add.
by this snippet.
businessobject CarPark_<YourID> {
// Root node must not be specified, it is created implicitly
// Add elements here.
[Label("Car Park ID")] element CarParkID : ID;
[Label("Car Park Name")] element CarParkName : LANGUAGEINDEPENDENT_LONG_Text;
[Label("Car Park Description")] element CarParkDescription : LANGUAGEINDEPENDENT_LONG_Description;
[Label("Number of Parking Spaces")] element NumberOfParkingSpaces : IntegerValue;
// for a multi-level car park, we have the possibility to specify a level number
[Label("Parking Space Level")] element ParkingSpace_Level : NumberValue;
17
c. Create the screens for the new business object
Screen Name:
CarPark_<YourID>
Supported Devices:
Desktop Only
Screen Scenario with
Navigation:
true
Short ID:
CarPark_<YourID>
18
d. Customize the screens
Select the
Misc -> FloorplanTitle
property and press the
small arrow.
19
Change the text to
“Car Park: ”.
20
Press Save and Activate.
Press OK if a pop up
shows the Activate
Worklist of components to
be activated.
21
Find the following
component:
/SAP_BYD_APPLICATION_UI/Reu
se/Attachments/documentlist
Drag&Drop it to the
PaneContainer.
22
On the Source Side Data
Model and select the Root
node.
On the Target Side
Bindings select Node
Reference Binding.
Press Bind.
And then OK.
Open the
CarPark_<YourID>_OWL
(double click on the
OWL.uicomponent file).
23
Go to the Properties tab
on the bottom right
Find
Events ->
OnClick and select
EditHandler.
Go to
Properties ->
DataInformation ->
Text and select the
CarParkID in the
Dependent Property Editor
window.
Press OK.
24
f. Assign the work center to your business user and test the solution
Go to Application and
User Management ->
Business Users
25
Assign the Work Center.
Save and Close.
Log off.
Open the
CarPark_<YourID> View.
26
ABSL AND UI
For each car park, you want a table listing the car spaces and the assigned employee for each space.
We will customize the custom business object screens and implement some business logic with ABSL.
Open the
CarPark_<YourID>_QA
Click the
AddFlexLayoutRow
button.
Select
View >
BO Browser/Data Model.
The view should appear on
the right-hand side of the
UI Designer.
27
Drag the ParkingSpaceID
and drop it to the header
of the first column of the
advanced list pane.
28
Select the
DataList >
ParkingSpaceID on the
left tree.
Check it is binded to the
ParkingSpaceID Business
Object Model on the right
side of the screen.
29
Select
ObjectValueSelector
at
Appearance ->
DisplayType.
Search
ValueHelp ->
OVSComponent
and click the “…” button.
Click OK.
30
Click OK again
31
Select the
BO Browser/Data Model
tab.
32
Select the Properties tab.
Go to
Appearance ->
DisplayType
and select StaticText
Press Save.
33
Under Toolbar
Information, set the
UseToolbar value to True.
Click OK.
34
Enter a name for the event
handler: AddRowHandler
Select
Operation: AddRow
Target List: /Root/DataList
Click OK.
Type: List,
Name: RemoveRowHandler
Operation: RemoveRow
Target List: /Root/DataList
Save
35
b. Create an ABSL file
We have set up the QAF screen and created an OVS to find the Employee ID.
We need now a script file to assign the value selected in the OVS to the
Parkingspace_AssignedEmployeeID element and to update the name field after the
selection of the employee.
snippet.
Event: AfterModify
Note:
- To access the elements of the business object node,
use path expressions, for example, this.<element name>.
- To use code completion, press CTRL+J.
- This script file is mass-enabled, i.e. the keyword "this"
https://raw.githubuserconte
refers to a collection of node instances.
- The solution uses this script if:
- the value of any field in the node in which this script is contained is modified.
- the node itself is modified by another business object within the same solution.
nt.com/mendesthi/ByDSD
*/
import ABSL;
import AP.FO.BusinessPartner.Global;
KWorkshop/master/AfterM // Auxiliary flag that will help us decide whether we have to update the ToEmployee association.
var bUpdateEmployee = false;
odify
if (!this.ToEmployee.IsSet()) {
// We have an employee indicated for parking space,
// the association ToEmployee hasn't been initialized yet.
// Set flag to true.
bUpdateEmployee = true;
}
else if ( this.ToEmployee.IdentificationEmployeeID.EmployeeID.content != this.ParkingSpace_AssignedEmployeeID) {
// We have an employee indicated for parking space,
// association ToEmployee still holds employee that had been associated to space before.
//Reset association to the employee first, since the new employee ID might be invalid.
this.ToEmployee.Reset();
// Now look for the details of the given employee. connect to the BO Employee's query...
var qryEmployees = Employee.Identification.QueryByEmployeeAttributes;
36
Test the solution.
Open the browser, log into
the tenant with your
business user and add
some data to test the
solution.
37
BAC
In this exercise we will create a Business Adaptation Catalog element to allow customers to set up and adapt
their tenant to their business needs by setting different configurations in scope.
Click Add.
38
Fill in the form accordingly:
Type: Business Option
Name: CARPARK_YourID
Description: Business
Option for Car Park
Solution <YourID>
Scoping Question:
Do you want to activate
the Car Park Solution
<YourID>?
Documentation Overview
and Relevance (two tabs):
Activate Car Park
Solution <YourID>
Choose:
General Business Data ->
Employees and Service
Agents ->
Employees
39
Hit Select to fill the
Required Scope
Click OK
40
Hit Next and Finish.
Save and Activate.
41
b. Test your configuration
Go to
General Business Data ->
Employees and Service
Agents -> Employees
Look for the question you
have added.
Note: If you cannot see your
question, go back to the
solution explorer, save all and
activate all again.
42
BUSINESS OBJECT EXTENSION
In this exercise we will extend the employee business object to show the assigned Parking Space ID in the
employee fact sheet screen.
Namespace:
http://sap.com/xi/AP/FO/
BusinessPartner/Global
Business object:
Employee.
43
The node Common {
[Tooltip ("If the employee has been assigned a car parking
EmployeeBOExtension_ space, the ID is displayed here.")]
<yourID>.xbo opens. [Label ("Car Parking Space <YourID>")]
element Assigned_Car_Parking_Space_ID_<YourID> : ID;
}
Replace ONLY the
Common node by the
given snippet (don’t forget
to change the label and
field name by your ID
number)
Click OK.
TIP:
If you want to find out the
floorplan corresponding to
the screen you want to
modify press
Ctrl + Alt + Shift + D
for 3 seconds.
You will get a Debug
Console showing the
details of your current
floorplan.
44
The floorplan is opened in
the UI Designer.
Go to the main menu,
select View, Display <->
Edit.
45
The Add Extension File
dialog box opens.
Check the Add and Is
Display Only chekboxes
for the Card Parking
Space <yourID>
corresponding to your
user.
Click Apply.
Add this snippet at the end //When a car space is modified, this script will update the
//extension field with the ID of the Parking Space.
of the script file, just before var common = this.ToEmployee.CurrentCommon;
the closing bracket. if (this.ParkingSpaceID != "") {
common.Assigned_Car_Parking_Space_ID_<YourID> = this.ParkingSpaceID;
}
(Don’t forget to replace the
element’s ID reference by your
own ID number)
46
c. Test the Employee screen
47
WEB SERVICES
In this exercise we will learn how to create and consume OData web services.
Our goal is to create an OData web service for the Car Parking solution.
Click New.
MMA_PERSONNELADMIN
Select it.
48
Click Select Business
Object.
49
Click OK.
50
It should return the service
metadata.
https://<yourTenant>.sapbydesign.com/sap
/byd/odata/cust/v1/carpark_<yourID>_servi
ce1/EmployeeCommonCollection?$format=
json&$filter=(Assigned_Car_Parking_Spac
e_ID_<yourID>_SDK ne '')
51
c. Create an OData web service for the Car Parking master data
Click New.
MMA_PERSONNELADMIN
Select it.
52
Click Select Business
Object.
Select
BO Name:
CarPark_<YourID>
Click OK.
Root
CarParkName
53
Mark the following
elements to expose them
on the ParkingSpace node:
ParkingSpaceID
ParkingSpace_Assigned
54
d. Test the CarPark OData Web Service
55
Check the data returned
for example by asking for
the list of your carparks:
https://<yourTenant>.sapbydesign.com/sap
/byd/odata/cust/v1/carpark_<yourID>_main
tain/CarPark_300RootCollection
URL: GET
https://<tenant>.sapbydesign.com/s
ap/byd/odata/cust/v1/carpark_<Your
ID>_maintain/CarPark_300RootColl
ection?$expand=CarPark_300Parki
ngSpace&$format=json
56
Here you have an example of
response.
URL: POST
https://<tenant>.sapbydesign.com/s
ap/byd/odata/cust/v1/
carpark_<YourID>_maintain
/CarPark_<YourID>ParkingSpaceC
ollection('<objectID>')
57
ANALYTICS
Let’s now create a new Data Source for our CarPark business object and build a report based on it.
CarPark_<YourID>_Datasource
Hit Next.
58
Click Finish on the final
Review step.
59
Confirm the action.
60
Select the characteristics.
Hit Next.
Review the
characteristics
properties.
Hit Next.
Define variables if
required.
Hit Next.
61
Choose Create View for
this Report in a Web
Browser.
Open the
CarPark_<YourID>_WCVi
ew.uiwocview in the UI
Designer.
62
Select Edit -> Display <->
Edit.
Go to
Properties ->
Extensibility ->
Anchors
Click OK.
63
Open the
CarPark_<YourID>_WCF.
WCF.uiwoc in the UI
Designer.
Go to
Properties ->
Misc ->
ViewSwitches.
64
Click the Add button.
Go to Misc -> Name.
Name it Report.
Click OK.
65
Go to Misc ->
SubViewSwitches and
click the … list button.
66
Click OK again to close the
ViewSwitch Collection
Editor window.
Select ReportView.
Open the
Configuration Explorer.
67
Select the item
SAP_BYD_TF ->
Analytics ->
AnalysisPattern ->
ana_reports_view_wc
68
Select the second report
sub view:
WorkCenterSubView1.
69
Select the item
SAP_BYD_TF ->
Analytics ->
AnalysisPattern ->
ana_reports_carousel_view
70
Save and Activate.
Select you
CarPark_<YourID> Work
Center.
Check the Assign
checkbox to assign the
report to the solution’s
work center.
Log off.
71
Our report is shown, select
it.
72
MASHUPS
We can embed an external system UI into ByD screens via Mashups.
In this exercise we will show a Google page inside our business object screen.
Select
Screens ->
Port Type Package (PTP)
Give a name e.g.
CarPark_<YourID>_PortTyp
ePackage.uicomponent.
Press Add.
73
Open the new
Port Type Package with
the UI Designer
Select the
CarPark_<YourID>_PortT
ypePackage
Select Rename.
Rename it to Inport
74
Right-click the PortType
and select
Add Parameter.
Select Rename.
Rename it to
InportParameter
75
Select Mashups and Web
Services and Mashup
Port Binding.
Give it a name
CarPark_<YourID>_Mash
upPortBinding.
Click Add.
Open the
CarPark_<YourID>_Mashu
pPortBinding file.
Make it editable.
76
InPort Type Package:
Select the port type
package you have just
created.
Inport Type Reference:
Inport
In the studio, you can create HTML mashups to show html pages from an external cloud
solution. The results are displayed within the iframe.
Pre-requisites:
• You must know the end-point URL of the web site providing the service. This could be,
for example, the search results page of an online search provider.
• You must enable the admin mode for the solution in which you create the mashup to
ensure that the system saves your content and any changes you make in the solution.
Right-click on
MashupConfiguration ->
MashupAuthoring.
77
If prompted Enable the
admin mode.
78
Complete the information:
Name:
HTMLMashup_CarPark_<
YourID>
Description:
HTMLMashup_CarPark_<
YourID>
Type: URL
Height: 800
URL:
https://www.google.com/
search
Parameters:
q – InportParameter
source – hp
igu – 1
79
Open the OIF floorplan in
the UI Designer.
Make it editable.
Go to the
BO Browser/Data Model.
Drag the
CarParkLocation to the
FieldGroup pane.
80
Right-click the Outports
folder and select
Add Outport
Rename it to
URL_Mashup_OutPort
In the Outport
Configuration:
UR_Mashup_Outport
pane, select the following:
PortType Package: choose
the port type package
created in previous step
CarPark_<YourID>_PortT
ypePackage.
Press OK.
81
Click the ellipsis button of
the InportParameter.
Choose the
CarParkLocation
element.
Press OK.
Right-click the
NavigationItem and select
Add -> OIF View
82
Go to Properties ->
Design -> Title and click
on the arrow button.
Press OK.
83
Drag and drop the mashup
to the pane container.
Click the
Navigation Configuration
tab.
Right-click the
Navigation folder and
Add Navigation.
84
Select on the right side of
the Navigation
Configuration the Target
InPort:
Inport_In
Click OK
85
Click View All
86