/
index.html
186 lines (155 loc) · 5.12 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<title>ABAP Active Record Demo - v.1.0</title>
<script
src="./openui5-runtime-1.32.7/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons, sap.ui.table"
data-sap-ui-theme="sap_goldreflection"
data-sap-ui-language="en">
</script>
<script>
/*global sap*/
/*global abapActiveRecord*/
/**
* It's just to show all functionalties of ABAP Active Record.
* You will find bellow how to use it to execute CRUD operations in SFLIGHT table
*/
// Load resources
sap.ui.localResources('abapActiveRecord');
jQuery.sap.require("abapActiveRecord.ARModel");
// create ABAP Active Record model
// Note that URI is not informed. It's defined in the abapar.json file.
var oARModel = new abapActiveRecord.ARModel();
//--->{ READ OPERATION (entity set)
/** Execute the equivalent Open SQL command:
* SELECT CARRID CONNID FLDATE PRICE FROM SFLIGHT WHERE CARRID = 'LH' AND CONNID = '2402'.
*
*/
var oFlightsTable = oARModel.aarGetEntitySet('SFLIGHT', ["CARRID", "CONNID", "FLDATE", "PRICE"], {carrid: "LH", connid: "2402"});
var oTable = new sap.ui.table.Table({
title: "Display Table: SFLIGHT",
width: "1000px",
visibleRowCount: 10
});
var fieldName = "";
for (fieldName in oFlightsTable.getProperty("/SFLIGHT/0")) {
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: fieldName}),
template: new sap.ui.commons.TextField().bindProperty("value", fieldName),
}));
}
oTable.setModel(oFlightsTable);
oTable.bindRows("/SFLIGHT");
oTable.placeAt("content");
// }<---
//--->{ CREATE OPERATION
/** Execute the equivalent Open SQL command:
* INSERT INTO SFLIGHT VALUES wa.
*
* wa: working area with follow values:
* CARRID = 'LH'
* CONNID = 2402
* FLDATE = 20160119
* PRICE = 500
*
*/
var oCreate = new sap.ui.commons.Button({
text: "New Flight",
press: function() {
oARModel.aarCreate('SFLIGHT', {carrid: "LH", connid: "2402", fldate: "20160119", price: "500.00"});
},
});
oCreate.placeAt("content");
// }<---
//--->{ READ OPERATION
/** Execute the equivalent Open SQL command:
* SELECT SINGLE PRICE FROM SFLIGHT INTO wa
* WHERE
* CARRID = 'LH' AND
* CONNID = 2402 AND
* FLDATE = 20160119.
*
*/
var oFormRead = new sap.ui.layout.form.SimpleForm({
title: "Read Price",
content: [
new sap.ui.commons.Label({text: "Airline ID:"}),
new sap.ui.commons.TextField("carrid", {value: "LH"}),
new sap.ui.commons.Label({text: "Connection ID:"}),
new sap.ui.commons.TextField("connid", {value: "2402"}),
new sap.ui.commons.Label({text: "Flight Date:"}),
new sap.ui.commons.TextField("fldate", {value: "20160119"}),
new sap.ui.commons.Label({text: "Price:"}),
new sap.ui.commons.TextField("price", {editable: false}),
new sap.ui.commons.Label({text: ""}),
new sap.ui.commons.Button({
text: "Read",
press: function() {
var value = oARModel.aarGetSingleValue("SFLIGHT", "PRICE", {
carrid: sap.ui.getCore().byId("carrid").getValue(),
connid: sap.ui.getCore().byId("connid").getValue(),
fldate: sap.ui.getCore().byId("fldate").getValue()
});
sap.ui.getCore().byId("price").setValue(value) ;
},
}),
]
})
oFormRead.placeAt("content");
// }<---
//--->{ UPDATE OPERATION
/** Execute the equivalent Open SQL command:
* UPDATE SFLIGHT FROM wa.
*
* wa: working area with follow values:
* CARRID = 'LH'
* CONNID = 2402
* FLDATE = 20160119
* PRICE = <user value>
*
*/
var oForm = new sap.ui.layout.form.SimpleForm({
title: "Change Price",
content: [
new sap.ui.commons.Label("newPriceLabel", {text: "New Price:"}),
new sap.ui.commons.TextField("newPrice"),
new sap.ui.commons.Label({text: ""}),
new sap.ui.commons.Button({
text: "Change",
press: function() {
oARModel.aarUpdate("SFLIGHT", {carrid: "LH", connid: "2402", fldate: "20160119", price: sap.ui.getCore().byId("newPrice").getValue()});
},
}),
]
});
oForm.placeAt("content");
// }<---
//--->{ UPDATE OPERATION
/** Execute the equivalent Open SQL command:
* DELETE SFLIGHT FROM wa.
*
* wa: working area with follow values:
* CARRID = 'LH'
* CONNID = 2402
* FLDATE = 20160119
*
*/
var oDelete = new sap.ui.commons.Button({
text: "Delete Flight",
press: function() {
oARModel.aarDelete('SFLIGHT', {carrid: "LH", connid: "2402", fldate: "20160119"});
},
});
oDelete.placeAt("content");
// }<---
</script>
</head>
<body class="sapUiBody" role="application">
<h1>ABAP Active Record (abapar.js) Demo - v.1.0</h1>
<div id="content"></div>
</body>
</html>