├── .gitignore
├── 03_UI5_HelloWorld
├── UI5_TemplateApp
│ ├── webapp
│ │ ├── css
│ │ │ └── style.css
│ │ ├── i18n
│ │ │ └── i18n.properties
│ │ ├── controller
│ │ │ └── View1.controller.js
│ │ ├── view
│ │ │ └── View1.view.xml
│ │ ├── model
│ │ │ └── models.js
│ │ ├── Component.js
│ │ ├── index.html
│ │ └── manifest.json
│ ├── neo-app.json
│ ├── .user.project.json
│ └── .project.json
├── sapWebIDE-PE
│ ├── logoUI5.jpg
│ └── config_master
│ │ └── service.destinations
│ │ └── destinations
│ │ ├── Northwind
│ │ └── XXX
├── ABAP_UI5-HelloWorld_v1.pdf
└── UI5_TemplateApp_Preview.jpg
├── 04_UI5_CRUD
├── ABAP_UI5-CRUDnav_MasterDetail
│ ├── webapp
│ │ ├── css
│ │ │ └── style.css
│ │ ├── view
│ │ │ ├── App.view.xml
│ │ │ ├── Detail.view.xml
│ │ │ └── Master.view.xml
│ │ ├── model
│ │ │ └── models.js
│ │ ├── i18n
│ │ │ └── i18n.properties
│ │ ├── controller
│ │ │ ├── Master.controller.js
│ │ │ ├── App.controller.js
│ │ │ └── Detail.controller.js
│ │ ├── index.html
│ │ ├── Component.js
│ │ ├── manifest.json
│ │ └── localService
│ │ │ └── metadata.xml
│ ├── .user.project.json
│ ├── neo-app.json
│ └── .project.json
├── ABAP_UI5-CRUDnav_v2.pdf
├── ABAP_UI5-CRUDnav_MasterDetail_Detail.png
└── ABAP_UI5-CRUDnav_MasterDetail_Master.png
├── 02_ODataService_Usage
└── ABAP_OData-Usage_v1.pdf
├── 01_ODataService_CreationABAP
├── ABAP_OData-Retrieval_v1.pdf
├── ABAP_OData-Retrieval_v1-Presentation.pdf
└── ABAP_OData-Retrieval_ZCL_Z_ODS_EMPLOYEE_XXX_DPC_EXT.abap
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | /.idea/
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/webapp/css/style.css:
--------------------------------------------------------------------------------
1 | /* Enter your custom styles here */
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/css/style.css:
--------------------------------------------------------------------------------
1 | /* Enter your custom styles here */
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/webapp/i18n/i18n.properties:
--------------------------------------------------------------------------------
1 | title=Title
2 | appTitle = App Title
3 | appDescription=App Description
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_v2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maenujem/UI5_OData_CRUD_Example/HEAD/04_UI5_CRUD/ABAP_UI5-CRUDnav_v2.pdf
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/sapWebIDE-PE/logoUI5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maenujem/UI5_OData_CRUD_Example/HEAD/03_UI5_HelloWorld/sapWebIDE-PE/logoUI5.jpg
--------------------------------------------------------------------------------
/02_ODataService_Usage/ABAP_OData-Usage_v1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maenujem/UI5_OData_CRUD_Example/HEAD/02_ODataService_Usage/ABAP_OData-Usage_v1.pdf
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/ABAP_UI5-HelloWorld_v1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maenujem/UI5_OData_CRUD_Example/HEAD/03_UI5_HelloWorld/ABAP_UI5-HelloWorld_v1.pdf
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp_Preview.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maenujem/UI5_OData_CRUD_Example/HEAD/03_UI5_HelloWorld/UI5_TemplateApp_Preview.jpg
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail_Detail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maenujem/UI5_OData_CRUD_Example/HEAD/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail_Detail.png
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail_Master.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maenujem/UI5_OData_CRUD_Example/HEAD/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail_Master.png
--------------------------------------------------------------------------------
/01_ODataService_CreationABAP/ABAP_OData-Retrieval_v1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maenujem/UI5_OData_CRUD_Example/HEAD/01_ODataService_CreationABAP/ABAP_OData-Retrieval_v1.pdf
--------------------------------------------------------------------------------
/01_ODataService_CreationABAP/ABAP_OData-Retrieval_v1-Presentation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maenujem/UI5_OData_CRUD_Example/HEAD/01_ODataService_CreationABAP/ABAP_OData-Retrieval_v1-Presentation.pdf
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/webapp/controller/View1.controller.js:
--------------------------------------------------------------------------------
1 | sap.ui.define([
2 | "sap/ui/core/mvc/Controller"
3 | ], function(Controller) {
4 | "use strict";
5 |
6 | return Controller.extend("UI5_Template.controller.View1", {
7 |
8 | });
9 | });
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/view/App.view.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/webapp/view/View1.view.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/sapWebIDE-PE/config_master/service.destinations/destinations/Northwind:
--------------------------------------------------------------------------------
1 | #ServiceDestination
2 | Description=Northwind OData Service
3 | Type=HTTP
4 | TrustAll=true
5 | Authentication=NoAuthentication
6 | Name=Northwind
7 | ProxyType=Internet
8 | URL=http\://services.odata.org\:80
9 | WebIDEUsage=odata_gen
10 | WebIDESystem=Northwind
11 | WebIDEEnabled=true
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/webapp/model/models.js:
--------------------------------------------------------------------------------
1 | sap.ui.define([
2 | "sap/ui/model/json/JSONModel",
3 | "sap/ui/Device"
4 | ], function(JSONModel, Device) {
5 | "use strict";
6 |
7 | return {
8 |
9 | createDeviceModel: function() {
10 | var oModel = new JSONModel(Device);
11 | oModel.setDefaultBindingMode("OneWay");
12 | return oModel;
13 | }
14 |
15 | };
16 | });
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/model/models.js:
--------------------------------------------------------------------------------
1 | sap.ui.define([
2 | "sap/ui/model/json/JSONModel",
3 | "sap/ui/Device"
4 | ], function(JSONModel, Device) {
5 | "use strict";
6 |
7 | return {
8 |
9 | createDeviceModel: function() {
10 | var oModel = new JSONModel(Device);
11 | oModel.setDefaultBindingMode("OneWay");
12 | return oModel;
13 | }
14 |
15 | };
16 | });
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/sapWebIDE-PE/config_master/service.destinations/destinations/XXX:
--------------------------------------------------------------------------------
1 | #ServiceDestination
2 | Description=XXX
3 | Type=HTTP
4 | TrustAll=true
5 | Authentication=NoAuthentication
6 | Name=XXX
7 | ProxyType=Internet
8 | URL=http\://xxx.xxx.xxx.xxx\:xxxx
9 | WebIDEUsage=odata_abap,dev_abap,ui5_execute_abap,bsp_execute_abap
10 | WebIDESystem=XXX
11 | WebIDEEnabled=true
12 | sap-client=xxx
13 |
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/i18n/i18n.properties:
--------------------------------------------------------------------------------
1 | title=Title
2 | appTitle = App Title
3 | appDescription=App Description
4 |
5 | employeeCreated=Employee with ID {0} created!
6 | employeeUpdated=Employee with ID {0} updated!
7 | employeeDeleted=Employee with ID {0} deleted!
8 |
9 | masterViewTitle=Manuel Schaffner: Master
10 | detailViewTitle=Manuel Schaffner: Detail
11 |
12 | employeeList=Employee List
13 | employeeDetail=Employee Detail
14 |
15 | createButtonText=Create
16 | updateButtonText=Update
17 | deleteButtonText=Delete
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/.user.project.json:
--------------------------------------------------------------------------------
1 | {
2 | "run": [
3 | {
4 | "filePath": "/webapp/index.html",
5 | "previewMode": 1,
6 | "dataMode": 1,
7 | "workspace": "withoutWorkspace",
8 | "ui5ActiveVersion": null,
9 | "ui5VerSource": null,
10 | "isDefaultVersion": 0,
11 | "urlParameters": [],
12 | "hashParameter": "",
13 | "backendSystem": [],
14 | "_metadata": {
15 | "runnerId": "webapprunner",
16 | "id": 6719078,
17 | "displayName": "Run index.html",
18 | "lastRunTimeStamp": 1530484024503
19 | }
20 | }
21 | ]
22 | }
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/neo-app.json:
--------------------------------------------------------------------------------
1 | {
2 | "welcomeFile": "/webapp/index.html",
3 | "routes": [
4 | {
5 | "path": "/resources",
6 | "target": {
7 | "type": "service",
8 | "name": "sapui5",
9 | "entryPath": "/resources",
10 | "version": "1.44.12"
11 | },
12 | "description": "SAPUI5 Resources"
13 | },
14 | {
15 | "path": "/test-resources",
16 | "target": {
17 | "type": "service",
18 | "name": "sapui5",
19 | "entryPath": "/test-resources",
20 | "version": "1.44.12"
21 | },
22 | "description": "SAPUI5 Test Resources"
23 | }
24 | ],
25 | "sendWelcomeFileRedirect": true
26 | }
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/webapp/Component.js:
--------------------------------------------------------------------------------
1 | sap.ui.define([
2 | "sap/ui/core/UIComponent",
3 | "sap/ui/Device",
4 | "UI5_Template/model/models"
5 | ], function(UIComponent, Device, models) {
6 | "use strict";
7 |
8 | return UIComponent.extend("UI5_Template.Component", {
9 |
10 | metadata: {
11 | manifest: "json"
12 | },
13 |
14 | /**
15 | * The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
16 | * @public
17 | * @override
18 | */
19 | init: function() {
20 | // call the base component's init function
21 | UIComponent.prototype.init.apply(this, arguments);
22 |
23 | // set the device model
24 | this.setModel(models.createDeviceModel(), "device");
25 | }
26 | });
27 | });
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/neo-app.json:
--------------------------------------------------------------------------------
1 | {
2 | "welcomeFile": "/webapp/index.html",
3 | "routes": [
4 | {
5 | "path": "/resources",
6 | "target": {
7 | "type": "service",
8 | "name": "sapui5",
9 | "entryPath": "/resources"
10 | },
11 | "description": "SAPUI5 Resources"
12 | },
13 | {
14 | "path": "/test-resources",
15 | "target": {
16 | "type": "service",
17 | "name": "sapui5",
18 | "entryPath": "/test-resources"
19 | },
20 | "description": "SAPUI5 Test Resources"
21 | },
22 | {
23 | "path": "/sap/opu/odata",
24 | "target": {
25 | "type": "destination",
26 | "name": "XXX",
27 | "entryPath": "/sap/opu/odata"
28 | },
29 | "description": "XXX"
30 | }
31 | ],
32 | "sendWelcomeFileRedirect": true
33 | }
34 |
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/webapp/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | UI5_Template
9 |
10 |
17 |
18 |
19 |
20 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/controller/Master.controller.js:
--------------------------------------------------------------------------------
1 | sap.ui.define([
2 | "sap/ui/core/mvc/Controller"
3 | ], function(Controller) {
4 | "use strict";
5 |
6 | return Controller.extend("test_MasterDetailTable.controller.Master", {
7 |
8 | onInit: function() {
9 |
10 | this.getView().setModel(this.getOwnerComponent().getModel("employees"));
11 |
12 | },
13 |
14 | // onNavToDetail : function (oEvent){
15 | // this.getOwnerComponent().getRouter().navTo("detail", {
16 | // detailId : 3 //oCtx.getProperty("detailId")
17 | // });
18 | // }
19 |
20 | onNavToDetail : function (oEvent){
21 | var oItem = oEvent.getSource().getSelectedItem();
22 | var oCtx = oItem.getBindingContext();
23 | var oId = oCtx.getProperty("Carrier") + '-' + oCtx.getProperty("IdEmployee"); //oCtx.getPath() - prepare detailId for URL /detail/{detailId}
24 |
25 | this.getOwnerComponent().getRouter().navTo("detail", {
26 | detailId : oId
27 | });
28 | }
29 |
30 | });
31 | });
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | test_MasterDetailTable
9 |
10 |
11 |
18 |
19 |
20 |
21 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/.user.project.json:
--------------------------------------------------------------------------------
1 | {
2 | "run": [
3 | {
4 | "filePath": "/webapp/Component.js",
5 | "previewMode": 1,
6 | "dataMode": 1,
7 | "workspace": "withoutWorkspace",
8 | "ui5ActiveVersion": null,
9 | "ui5VerSource": null,
10 | "isDefaultVersion": 0,
11 | "urlParameters": [],
12 | "hashParameter": "",
13 | "backendSystem": [],
14 | "_metadata": {
15 | "runnerId": "fiorirunner",
16 | "id": 3849133,
17 | "displayName": "Run Component.js",
18 | "lastRunTimeStamp": 1531592381685
19 | }
20 | },
21 | {
22 | "filePath": "/webapp/index.html",
23 | "previewMode": 1,
24 | "dataMode": 1,
25 | "workspace": "withoutWorkspace",
26 | "ui5ActiveVersion": null,
27 | "ui5VerSource": null,
28 | "isDefaultVersion": 0,
29 | "urlParameters": [],
30 | "hashParameter": "",
31 | "backendSystem": [],
32 | "_metadata": {
33 | "runnerId": "webapprunner",
34 | "id": 5263253,
35 | "displayName": "Run index.html",
36 | "lastRunTimeStamp": 1531592273397
37 | }
38 | }
39 | ]
40 | }
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/.project.json:
--------------------------------------------------------------------------------
1 | {
2 | "projectType": [
3 | "sap.watt.uitools.ide.fiori",
4 | "com.watt.common.builder.sapui5clientbuild"
5 | ],
6 | "build": {
7 | "targetFolder": "dist",
8 | "sourceFolder": "webapp",
9 | "buildRequired": true
10 | },
11 | "generation": [
12 | {
13 | "templateId": "ui5template.basicSAPUI5ApplicationProjectCommon",
14 | "templateVersion": "1.32.0",
15 | "dateTimeStamp": "Sat, 14 Jul 2018 18:15:52 GMT"
16 | },
17 | {
18 | "templateId": "ui5template.basicSAPUI5ApplicationProject",
19 | "templateVersion": "1.40.12",
20 | "dateTimeStamp": "Sat, 14 Jul 2018 18:15:52 GMT"
21 | }
22 | ],
23 | "translation": {
24 | "translationDomain": "",
25 | "supportedLanguages": "en,fr,de",
26 | "defaultLanguage": "en",
27 | "defaultI18NPropertyFile": "i18n.properties",
28 | "resourceModelName": "i18n"
29 | },
30 | "basevalidator": {
31 | "services": {
32 | "xml": "fioriXmlAnalysis",
33 | "js": "fioriJsValidator"
34 | }
35 | },
36 | "codeCheckingTriggers": {
37 | "notifyBeforePush": true,
38 | "notifyBeforePushLevel": "Error",
39 | "blockPush": false,
40 | "blockPushLevel": "Error"
41 | }
42 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | SAP: ABAP OData Service & UI5 CRUD App Example
2 | ====
3 |
4 | Welcome to a simple tutorial series about creating an SAP OData Service in ABAP and consuming its CRUD functionality with a UI5 Master-Detail app.
5 |
6 | In this tutorial series you will..
7 | * [01] ..create an OData-Service and implement associated CRUD functionality using ABAP-code to access an existing table in the SAP-System
8 | * [02] ..get to know how to use an OData-Service with different request parameters
9 | * [03] ..get to know SAP/open UI5 () and implement a Hello World Example
10 | * [04] ..access your OData-Service [01] and display the data using master-table and detail-form. In the detail form xou can also create, update, delete the current record.
11 |
12 | The tutorial is contained in the *PDF document in the corresponding directory*. There may also be additional informations and files.
13 |
14 | The series cover the following topics:
15 | - create OData-Service from DDIC and implement CRUD with ABAP
16 | - use OData-Service
17 | - UI5 Basics (View, Controller, Model, Component, I18n, Icons, Messages, Routing/Navigation, DataBinding)
18 |
19 |
20 | For further information check out the following links
21 | - https://openui5.org/ Main page
22 | - https://openui5.hana.ondemand.com/ : Reference Docu
23 | - https://open.sap.com/courses/ui51 : Online Course
24 |
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/Component.js:
--------------------------------------------------------------------------------
1 | sap.ui.define([
2 | "sap/ui/core/UIComponent",
3 | "sap/ui/Device",
4 | "sap/ui/model/odata/v2/ODataModel",
5 | "test_MasterDetailTable/model/models"
6 | ], function(UIComponent, Device, ODataModel, models) {
7 | "use strict";
8 |
9 | return UIComponent.extend("test_MasterDetailTable.Component", {
10 |
11 | metadata: {
12 | manifest: "json"
13 | },
14 |
15 | /**
16 | * The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
17 | * @public
18 | * @override
19 | */
20 | init: function() {
21 | // call the base component's init function
22 | UIComponent.prototype.init.apply(this, arguments);
23 |
24 | // create the views based on the url/hash
25 | this.getRouter().initialize();
26 |
27 | // set the device model
28 | this.setModel(models.createDeviceModel(), "device");
29 |
30 | // set the odata model for emoloyees
31 | // var sUrl = "/sap/opu/odata/sap/ZOD_EMPLOYEE_MSC_SRV/";
32 | // var oModel = new ODataModel(sUrl, {
33 | // useBatch: false,
34 | // defaultBindingMode: "TwoWay"
35 | // });
36 | //
37 | // this.setModel(oModel, "employees");
38 | // var oModel = this.getModel("employees");
39 | // oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);
40 | // oModel.setUseBatch(false);
41 |
42 | }
43 | });
44 | });
45 |
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/controller/App.controller.js:
--------------------------------------------------------------------------------
1 | sap.ui.define([
2 | "sap/ui/core/mvc/Controller"
3 | ], function(Controller) {
4 | "use strict";
5 |
6 | return Controller.extend("test_MasterDetailTable.controller.App", {
7 |
8 | /**
9 | * Called when a controller is instantiated and its View controls (if available) are already created.
10 | * Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
11 | * @memberOf test_MasterDetailTable.view.Main
12 | */
13 | // onInit: function() {
14 | //
15 | // },
16 |
17 | /**
18 | * Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered
19 | * (NOT before the first rendering! onInit() is used for that one!).
20 | * @memberOf test_MasterDetailTable.view.Main
21 | */
22 | // onBeforeRendering: function() {
23 | //
24 | // },
25 |
26 | /**
27 | * Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
28 | * This hook is the same one that SAPUI5 controls get after being rendered.
29 | * @memberOf test_MasterDetailTable.view.Main
30 | */
31 | // onAfterRendering: function() {
32 | //
33 | // },
34 |
35 | /**
36 | * Called when the Controller is destroyed. Use this one to free resources and finalize activities.
37 | * @memberOf test_MasterDetailTable.view.Main
38 | */
39 | // onExit: function() {
40 | //
41 | // }
42 |
43 | });
44 |
45 | });
--------------------------------------------------------------------------------
/03_UI5_HelloWorld/UI5_TemplateApp/webapp/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "_version": "1.5.0",
3 | "sap.app": {
4 | "id": "UI5_Template",
5 | "type": "application",
6 | "i18n": "i18n/i18n.properties",
7 | "applicationVersion": {
8 | "version": "1.0.0"
9 | },
10 | "title": "{{appTitle}}",
11 | "description": "{{appDescription}}",
12 | "sourceTemplate": {
13 | "id": "ui5template.basicSAPUI5ApplicationProject",
14 | "version": "1.40.12"
15 | }
16 | },
17 |
18 | "sap.ui": {
19 | "technology": "UI5",
20 | "icons": {
21 | "icon": "",
22 | "favIcon": "",
23 | "phone": "",
24 | "phone@2": "",
25 | "tablet": "",
26 | "tablet@2": ""
27 | },
28 | "deviceTypes": {
29 | "desktop": true,
30 | "tablet": true,
31 | "phone": true
32 | },
33 | "supportedThemes": [
34 | "sap_hcb",
35 | "sap_belize"
36 |
37 | ]
38 | },
39 |
40 | "sap.ui5": {
41 | "rootView": {
42 | "viewName": "UI5_Template.view.View1",
43 | "type": "XML"
44 | },
45 | "dependencies": {
46 | "minUI5Version": "1.30.0",
47 | "libs": {
48 | "sap.ui.core": {},
49 | "sap.m": {},
50 | "sap.ui.layout": {},
51 | "sap.ushell": {},
52 | "sap.collaboration": {},
53 | "sap.ui.comp": {},
54 | "sap.uxap": {}
55 | }
56 | },
57 | "contentDensities": {
58 | "compact": true,
59 | "cozy": true
60 | },
61 | "models": {
62 | "i18n": {
63 | "type": "sap.ui.model.resource.ResourceModel",
64 | "settings": {
65 | "bundleName": "UI5_Template.i18n.i18n"
66 | }
67 | }
68 | },
69 | "resources": {
70 | "css": [{
71 | "uri": "css/style.css"
72 | }]
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/.project.json:
--------------------------------------------------------------------------------
1 | {
2 | "projectType": [
3 | "sap.watt.uitools.ide.fiori",
4 | "com.watt.common.builder.sapui5clientbuild"
5 | ],
6 | "build": {
7 | "targetFolder": "dist",
8 | "sourceFolder": "webapp",
9 | "buildRequired": true
10 | },
11 | "generation": [
12 | {
13 | "templateId": "ui5template.basicSAPUI5ApplicationProjectCommon",
14 | "templateVersion": "1.32.0",
15 | "dateTimeStamp": "Sat, 02 Jun 2018 13:21:33 GMT"
16 | },
17 | {
18 | "templateId": "ui5template.basicSAPUI5ApplicationProject",
19 | "templateVersion": "1.40.12",
20 | "dateTimeStamp": "Sat, 02 Jun 2018 13:21:33 GMT"
21 | },
22 | {
23 | "templateId": "ui5template.basicSAPUI5ApplicationComponent",
24 | "templateVersion": "1.4.0",
25 | "dateTimeStamp": "Sat, 02 Jun 2018 13:23:23 GMT"
26 | },
27 | {
28 | "templateId": "servicecatalog.connectivityComponent",
29 | "templateVersion": "0.0.0",
30 | "dateTimeStamp": "Sun, 10 Jun 2018 09:19:52 GMT"
31 | }
32 | ],
33 | "translation": {
34 | "translationDomain": "",
35 | "supportedLanguages": "en,fr,de",
36 | "defaultLanguage": "en",
37 | "defaultI18NPropertyFile": "i18n.properties",
38 | "resourceModelName": "i18n"
39 | },
40 | "basevalidator": {
41 | "services": {
42 | "xml": "fioriXmlAnalysis",
43 | "js": "fioriJsValidator"
44 | }
45 | },
46 | "codeCheckingTriggers": {
47 | "notifyBeforePush": true,
48 | "notifyBeforePushLevel": "Error",
49 | "blockPush": false,
50 | "blockPushLevel": "Error"
51 | },
52 | "mockpreview": {
53 | "mockUri": "/sap/opu/odata/sap/ZOD_EMPLOYEE_MSC_SRV",
54 | "metadataFilePath": "",
55 | "loadJSONFiles": false,
56 | "loadCustomRequests": false,
57 | "mockRequestsFilePath": ""
58 | }
59 | }
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/view/Detail.view.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "_version": "1.5.0",
3 | "sap.app": {
4 | "id": "test_MasterDetailTable",
5 | "type": "application",
6 | "i18n": "i18n/i18n.properties",
7 | "applicationVersion": {
8 | "version": "1.0.0"
9 | },
10 | "title": "{{appTitle}}",
11 | "description": "{{appDescription}}",
12 | "sourceTemplate": {
13 | "id": "servicecatalog.connectivityComponent",
14 | "version": "0.0.0"
15 | },
16 | "dataSources": {
17 | "ZOD_EMPLOYEE_MSC_SRV": {
18 | "uri": "/sap/opu/odata/sap/ZOD_EMPLOYEE_MSC_SRV/",
19 | "type": "OData",
20 | "settings": {
21 | "odataVersion": "2.0",
22 | "localUri": "localService/metadata.xml"
23 | }
24 | }
25 | }
26 | },
27 | "sap.ui": {
28 | "technology": "UI5",
29 | "icons": {
30 | "icon": "",
31 | "favIcon": "",
32 | "phone": "",
33 | "phone@2": "",
34 | "tablet": "",
35 | "tablet@2": ""
36 | },
37 | "deviceTypes": {
38 | "desktop": true,
39 | "tablet": true,
40 | "phone": true
41 | },
42 | "supportedThemes": [
43 | "sap_hcb",
44 | "sap_belize"
45 | ]
46 | },
47 | "sap.ui5": {
48 | "rootView": {
49 | "viewName": "test_MasterDetailTable.view.App",
50 | "type": "XML"
51 | },
52 | "dependencies": {
53 | "minUI5Version": "1.30.0",
54 | "libs": {
55 | "sap.ui.core": {},
56 | "sap.m": {},
57 | "sap.ui.layout": {},
58 | "sap.ushell": {},
59 | "sap.collaboration": {},
60 | "sap.ui.comp": {},
61 | "sap.uxap": {}
62 | }
63 | },
64 | "contentDensities": {
65 | "compact": true,
66 | "cozy": true
67 | },
68 | "models": {
69 | "i18n": {
70 | "type": "sap.ui.model.resource.ResourceModel",
71 | "settings": {
72 | "bundleName": "test_MasterDetailTable.i18n.i18n"
73 | }
74 | },
75 | "employees": {
76 | "type": "sap.ui.model.odata.v2.ODataModel",
77 | "settings": {
78 | "defaultBindingMode": "TwoWay",
79 | "useBatch" : false
80 | },
81 | "dataSource": "ZOD_EMPLOYEE_MSC_SRV",
82 | "preload": true
83 | }
84 | },
85 | "resources": {
86 | "css": [
87 | {
88 | "uri": "css/style.css"
89 | }
90 | ]
91 | },
92 | "routing": {
93 | "config": {
94 | "routerClass": "sap.m.routing.Router",
95 | "viewType": "XML",
96 | "viewPath": "test_MasterDetailTable.view",
97 | "controlId": "app",
98 | "controlAggregation": "pages",
99 | "transition": "slide",
100 | "async": true
101 | },
102 | "routes": [
103 | {
104 | "pattern": "",
105 | "name": "master",
106 | "target": "master"
107 | },
108 | {
109 | "pattern": "detail/{detailId}",
110 | "name": "detail",
111 | "target": "detail"
112 | }
113 | ],
114 | "targets": {
115 | "master": {
116 | "viewId": "master",
117 | "viewName": "Master",
118 | "viewLevel": 1
119 | },
120 | "detail": {
121 | "viewId": "detail",
122 | "viewName": "Detail",
123 | "viewLevel": 2
124 | }
125 | }
126 | }
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/view/Master.view.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
33 |
34 |
35 |
38 |
39 |
40 |
43 |
44 |
45 |
48 |
49 |
50 |
53 |
54 |
55 |
58 |
59 |
60 |
63 |
64 |
65 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/localService/metadata.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/04_UI5_CRUD/ABAP_UI5-CRUDnav_MasterDetail/webapp/controller/Detail.controller.js:
--------------------------------------------------------------------------------
1 | sap.ui.define([
2 | "sap/ui/core/mvc/Controller",
3 | "sap/m/MessageBox"
4 | ], function(Controller, MessageBox) {
5 | "use strict";
6 |
7 | return Controller.extend("test_MasterDetailTable.controller.Detail", {
8 |
9 | /**
10 | * Called when a controller is instantiated and its View controls (if available) are already created.
11 | * Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
12 | * @memberOf test_MasterDetailTable.view.Detail
13 | */
14 | onInit: function() {
15 |
16 | this.getView().setModel(this.getOwnerComponent().getModel("employees"));
17 |
18 | // prepare access to router
19 | var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
20 | oRouter.getRoute("detail").attachPatternMatched(this._onObjectMatched, this);
21 | },
22 |
23 | /**
24 | * Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered
25 | * (NOT before the first rendering! onInit() is used for that one!).
26 | * @memberOf test_MasterDetailTable.view.Detail
27 | */
28 | // onBeforeRendering: function() {
29 | //
30 | // },
31 |
32 | /**
33 | * Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
34 | * This hook is the same one that SAPUI5 controls get after being rendered.
35 | * @memberOf test_MasterDetailTable.view.Detail
36 | */
37 | // onAfterRendering: function() {
38 | //
39 | // },
40 |
41 | /**
42 | * Called when the Controller is destroyed. Use this one to free resources and finalize activities.
43 | * @memberOf test_MasterDetailTable.view.Detail
44 | */
45 | // onExit: function() {
46 | //
47 | // }
48 |
49 | /**
50 | * Read from URL parameter which entry to display and bind it to form
51 | */
52 | _onObjectMatched: function (oEvent) {
53 | var aDetailId, selectedItemPath, detailForm;
54 | aDetailId = oEvent.getParameter("arguments").detailId.split('-'); // extract keys for entry from arguments - in URL
55 | selectedItemPath = "/ZTT_EMPLOYEE_MSCSet(Carrier='" + aDetailId[0] + "',IdEmployee='" + aDetailId[1] + "')";
56 | detailForm = this.getView().byId("detailForm");
57 | detailForm.bindElement({path: selectedItemPath});
58 | },
59 |
60 | onNavToMaster: function (oEvent){
61 | this.getOwnerComponent().getRouter().navTo("master");
62 | },
63 |
64 | onEmployeeCreate: function() {
65 | var path ="/ZTT_EMPLOYEE_MSCSet";
66 | var boundItem = this.getView().getModel().getProperty(this.getView().byId("detailForm").getElementBinding().getPath());
67 | var msg = this.getView().getModel("i18n").getResourceBundle().getText("employeeCreated", boundItem.IdEmployee);
68 | this.getView().getModel().create(path, boundItem, {
69 | success: function(){
70 | MessageBox.success(msg);
71 | },
72 | error: function(oError){
73 | MessageBox.error(oError.responseText);
74 | }
75 | });
76 | },
77 |
78 | onEmployeeUpdate: function() {
79 | var path = this.getView().byId("detailForm").getElementBinding().getPath();
80 | var boundItem = this.getView().getModel().getProperty(path);
81 | // var lastname = boundItem.Lastname; // nok: getProperty() getValue() data() oEvent.getSource().data("IdEmployee")
82 | var msg = this.getView().getModel("i18n").getResourceBundle().getText("employeeUpdated", boundItem.IdEmployee);
83 | this.getView().getModel().update(path, boundItem, {
84 | success: function(){
85 | MessageBox.success(msg); // update does not return anything
86 | },
87 | error: function(oError){
88 | MessageBox.error(oError.responseText);
89 | }
90 | });
91 | },
92 |
93 | onEmployeeDelete: function() {
94 | var path = this.getView().byId("detailForm").getElementBinding().getPath();
95 | var boundItem = this.getView().getModel().getProperty(path);
96 | var msg = this.getView().getModel("i18n").getResourceBundle().getText("employeeDeleted", boundItem.IdEmployee);
97 | this.getView().getModel().remove(path, {
98 | success: function(){
99 | MessageBox.success(msg);
100 | },
101 | error: function(oError){
102 | MessageBox.error(oError.responseText);
103 | }
104 | });
105 | }
106 |
107 | });
108 | });
--------------------------------------------------------------------------------
/01_ODataService_CreationABAP/ABAP_OData-Retrieval_ZCL_Z_ODS_EMPLOYEE_XXX_DPC_EXT.abap:
--------------------------------------------------------------------------------
1 | class zcl_z_ods_employee_###_dpc_ext definition
2 | public
3 | inheriting from zcl_z_ods_employee_###_dpc
4 | create public .
5 |
6 | public section.
7 |
8 | methods /iwbep/if_mgw_appl_srv_runtime~execute_action
9 | redefinition .
10 | protected section.
11 |
12 | methods ztt_employee_###_create_entity
13 | redefinition .
14 | methods ztt_employee_###_delete_entity
15 | redefinition .
16 | methods ztt_employee_###_get_entity
17 | redefinition .
18 | methods ztt_employee_###_get_entityset
19 | redefinition .
20 | methods ztt_employee_###_update_entity
21 | redefinition .
22 | private section.
23 | endclass.
24 |
25 |
26 |
27 | class zcl_z_ods_employee_###_dpc_ext implementation.
28 |
29 |
30 | * ---------------------------------------------------------------------------------------+
31 | * | Instance Public Method ZCL_z_ods_EMPLOYEE_###_DPC_EXT->/IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION
32 | * +-------------------------------------------------------------------------------------------------+
33 | * | [--->] IV_ACTION_NAME TYPE STRING(optional)
34 | * | [--->] IT_PARAMETER TYPE /IWBEP/T_MGW_NAME_VALUE_PAIR(optional)
35 | * | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_FUNC_IMPORT(optional)
36 | * | [<---] ER_DATA TYPE REF TO DATA
37 | * | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
38 | * | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
39 | * +--------------------------------------------------------------------------------------
40 | method /iwbep/if_mgw_appl_srv_runtime~execute_action.
41 | try.
42 | call method super->/iwbep/if_mgw_appl_srv_runtime~execute_action
43 | exporting
44 | iv_action_name = iv_action_name
45 | it_parameter = it_parameter
46 | io_tech_request_context = io_tech_request_context
47 | importing
48 | er_data = er_data
49 | .
50 | catch /iwbep/cx_mgw_busi_exception .
51 | catch /iwbep/cx_mgw_tech_exception .
52 | endtry.
53 |
54 | data: ls_parameter type /iwbep/s_mgw_name_value_pair,
55 | lv_dayspermonth type zde_int10_decimal2, "p DECIMALS 2,
56 | lv_salary type zde_int10_decimal2,
57 | lt_employee type table of ztt_employee_msc,
58 | ls_employee like line of lt_employee,
59 | ls_entity type zcl_z_ods_employee_###_mpc=>ts_ztt_employee_msc,
60 | lt_entityset type zcl_z_ods_employee_###_mpc=>tt_ztt_employee_msc.
61 |
62 | * check for required action
63 | if iv_action_name = 'EmployeesSalaryPerDay'.
64 | if it_parameter is not initial.
65 |
66 | * read function import parameter
67 | read table it_parameter into ls_parameter with key name = 'DaysPerMonth'.
68 | if sy-subrc = 0.
69 | lv_dayspermonth = ls_parameter-value.
70 | endif.
71 | if lv_dayspermonth is not initial.
72 |
73 | * read data
74 | select * from ztt_employee_msc into table lt_employee.
75 | loop at lt_employee into ls_employee.
76 | move-corresponding ls_employee to ls_entity.
77 |
78 | * calculate salary per day using function module
79 | lv_salary = ls_entity-salary.
80 | call function 'ZFM_2018_###_00'
81 | exporting
82 | iv_number01 = lv_salary
83 | iv_number02 = lv_dayspermonth
84 | importing
85 | ev_result = lv_salary " overwrite salary per month
86 | * EXCEPTIONS
87 | * EX_DIVISION_BY_ZERO = 1
88 | * OTHERS = 2
89 | .
90 | if sy-subrc <> 0.
91 | * Implement suitable error handling here
92 | endif.
93 | ls_entity-salary = lv_salary.
94 |
95 | append ls_entity to lt_entityset.
96 | endloop.
97 |
98 | * export data
99 | copy_data_to_ref( exporting is_data = lt_entityset changing cr_data = er_data ).
100 |
101 | endif.
102 | endif.
103 | endif.
104 | endmethod.
105 |
106 |
107 | * ---------------------------------------------------------------------------------------+
108 | * | Instance Protected Method ZCL_z_ods_EMPLOYEE_###_DPC_EXT->ZTT_EMPLOYEE_###_CREATE_ENTITY
109 | * +-------------------------------------------------------------------------------------------------+
110 | * | [--->] IV_ENTITY_NAME TYPE STRING
111 | * | [--->] IV_ENTITY_SET_NAME TYPE STRING
112 | * | [--->] IV_SOURCE_NAME TYPE STRING
113 | * | [--->] IT_KEY_TAB TYPE /IWBEP/T_MGW_NAME_VALUE_PAIR
114 | * | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITY_C(optional)
115 | * | [--->] IT_NAVIGATION_PATH TYPE /IWBEP/T_MGW_NAVIGATION_PATH
116 | * | [--->] IO_DATA_PROVIDER TYPE REF TO /IWBEP/IF_MGW_ENTRY_PROVIDER(optional)
117 | * | [<---] ER_ENTITY TYPE ZCL_z_ods_EMPLOYEE_###_MPC=>TS_ZTT_EMPLOYEE_MSC
118 | * | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
119 | * | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
120 | * +--------------------------------------------------------------------------------------
121 | method ztt_employee_###_create_entity.
122 | **TRY.
123 | *CALL METHOD SUPER->ZTT_EMPLOYEE_###_CREATE_ENTITY
124 | * EXPORTING
125 | * IV_ENTITY_NAME =
126 | * IV_ENTITY_SET_NAME =
127 | * IV_SOURCE_NAME =
128 | * IT_KEY_TAB =
129 | ** io_tech_request_context =
130 | * IT_NAVIGATION_PATH =
131 | ** io_data_provider =
132 | ** IMPORTING
133 | ** er_entity =
134 | * .
135 | ** CATCH /iwbep/cx_mgw_busi_exception .
136 | ** CATCH /iwbep/cx_mgw_tech_exception .
137 | **ENDTRY.
138 |
139 | * request-example:
140 | * 1. GET /sap/opu/odata/sap/ZOD_EMPLOYEE_###_SRV/ZTT_EMPLOYEE_MSCSet(IdEmployee='1',Carrier='AA')
141 | * 2. Use response as request, modify values
142 | * 3. POST /sap/opu/odata/sap/ZOD_EMPLOYEE_###_SRV/ZTT_EMPLOYEE_MSCSet
143 | data: ls_request_input_data type zcl_z_ods_employee_###_mpc=>ts_ztt_employee_msc, "zcl_zuserinfo_mpc=>ts_user,
144 | ls_employee type ztt_employee_msc.
145 |
146 | * read request data
147 | io_data_provider->read_entry_data( importing es_data = ls_request_input_data ).
148 | move-corresponding ls_request_input_data to ls_employee.
149 |
150 | * insert into table
151 | insert ztt_employee_msc from ls_employee.
152 | if sy-subrc = 0.
153 | er_entity = ls_request_input_data.
154 | endif.
155 | endmethod.
156 |
157 |
158 | * ---------------------------------------------------------------------------------------+
159 | * | Instance Protected Method ZCL_z_ods_EMPLOYEE_###_DPC_EXT->ZTT_EMPLOYEE_###_DELETE_ENTITY
160 | * +-------------------------------------------------------------------------------------------------+
161 | * | [--->] IV_ENTITY_NAME TYPE STRING
162 | * | [--->] IV_ENTITY_SET_NAME TYPE STRING
163 | * | [--->] IV_SOURCE_NAME TYPE STRING
164 | * | [--->] IT_KEY_TAB TYPE /IWBEP/T_MGW_NAME_VALUE_PAIR
165 | * | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITY_D(optional)
166 | * | [--->] IT_NAVIGATION_PATH TYPE /IWBEP/T_MGW_NAVIGATION_PATH
167 | * | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
168 | * | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
169 | * +--------------------------------------------------------------------------------------
170 | method ztt_employee_###_delete_entity.
171 | **TRY.
172 | *CALL METHOD SUPER->ZTT_EMPLOYEE_###_DELETE_ENTITY
173 | * EXPORTING
174 | * IV_ENTITY_NAME =
175 | * IV_ENTITY_SET_NAME =
176 | * IV_SOURCE_NAME =
177 | * IT_KEY_TAB =
178 | ** io_tech_request_context =
179 | * IT_NAVIGATION_PATH =
180 | * .
181 | ** CATCH /iwbep/cx_mgw_busi_exception .
182 | ** CATCH /iwbep/cx_mgw_tech_exception .
183 | **ENDTRY.
184 |
185 | data: ls_key_tab type /iwbep/s_mgw_name_value_pair,
186 | lv_employeeid type ztt_employee_msc-id_employee,
187 | lv_carrier type ztt_employee_msc-carrier.
188 |
189 | * read key values
190 | read table it_key_tab into ls_key_tab with key name = 'IdEmployee'.
191 | lv_employeeid = ls_key_tab-value.
192 | read table it_key_tab into ls_key_tab with key name = 'Carrier'.
193 | lv_carrier = ls_key_tab-value.
194 |
195 | if lv_employeeid is not initial.
196 | * delete record
197 | delete from ztt_employee_msc where id_employee = lv_employeeid and carrier = lv_carrier.
198 | endif.
199 | endmethod.
200 |
201 |
202 | * ---------------------------------------------------------------------------------------+
203 | * | Instance Protected Method ZCL_z_ods_EMPLOYEE_###_DPC_EXT->ZTT_EMPLOYEE_###_GET_ENTITY
204 | * +-------------------------------------------------------------------------------------------------+
205 | * | [--->] IV_ENTITY_NAME TYPE STRING
206 | * | [--->] IV_ENTITY_SET_NAME TYPE STRING
207 | * | [--->] IV_SOURCE_NAME TYPE STRING
208 | * | [--->] IT_KEY_TAB TYPE /IWBEP/T_MGW_NAME_VALUE_PAIR
209 | * | [--->] IO_REQUEST_OBJECT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITY(optional)
210 | * | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITY(optional)
211 | * | [--->] IT_NAVIGATION_PATH TYPE /IWBEP/T_MGW_NAVIGATION_PATH
212 | * | [<---] ER_ENTITY TYPE ZCL_z_ods_EMPLOYEE_###_MPC=>TS_ZTT_EMPLOYEE_MSC
213 | * | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
214 | * | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
215 | * +--------------------------------------------------------------------------------------
216 | method ztt_employee_###_get_entity.
217 | **TRY.
218 | *CALL METHOD SUPER->ZTT_EMPLOYEE_###_GET_ENTITY
219 | * EXPORTING
220 | * IV_ENTITY_NAME =
221 | * IV_ENTITY_SET_NAME =
222 | * IV_SOURCE_NAME =
223 | * IT_KEY_TAB =
224 | ** io_request_object =
225 | ** io_tech_request_context =
226 | * IT_NAVIGATION_PATH =
227 | ** IMPORTING
228 | ** er_entity =
229 | * .
230 | ** CATCH /iwbep/cx_mgw_busi_exception .
231 | ** CATCH /iwbep/cx_mgw_tech_exception .
232 | **ENDTRY.
233 |
234 | * request-example:
235 | * /sap/opu/odata/sap/ZOD_EMPLOYEE_###_SRV/ZTT_EMPLOYEE_MSCSet(IdEmployee='1',Carrier='AA')
236 | * ztt_employee_msc
237 |
238 | data: ls_key_tab type /iwbep/s_mgw_name_value_pair,
239 | lv_employeeid type ztt_employee_msc-id_employee,
240 | lv_carrier type ztt_employee_msc-carrier,
241 | ls_employee type ztt_employee_msc.
242 |
243 | * get the input parameters: key property values
244 | read table it_key_tab with key name = 'IdEmployee' into ls_key_tab.
245 | lv_employeeid = ls_key_tab-value.
246 |
247 | read table it_key_tab with key name = 'Carrier' into ls_key_tab.
248 | lv_carrier = ls_key_tab-value.
249 |
250 | * read record
251 | select single * from ztt_employee_msc into ls_employee where id_employee = lv_employeeid and carrier = lv_carrier.
252 |
253 | * fill er_entity
254 | if sy-subrc = 0.
255 | move-corresponding ls_employee to er_entity.
256 | else.
257 | * Raise Exception
258 | raise exception type /iwbep/cx_mgw_busi_exception
259 | exporting
260 | textid = /iwbep/cx_mgw_busi_exception=>resource_not_found.
261 | endif.
262 |
263 | * RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc
264 | * EXPORTING
265 | * textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented
266 | * method = 'ZTT_EMPLOYEE_###_GET_ENTITY'.
267 |
268 |
269 | endmethod.
270 |
271 |
272 | * ---------------------------------------------------------------------------------------+
273 | * | Instance Protected Method ZCL_z_ods_EMPLOYEE_###_DPC_EXT->ZTT_EMPLOYEE_###_GET_ENTITYSET
274 | * +-------------------------------------------------------------------------------------------------+
275 | * | [--->] IV_ENTITY_NAME TYPE STRING
276 | * | [--->] IV_ENTITY_SET_NAME TYPE STRING
277 | * | [--->] IV_SOURCE_NAME TYPE STRING
278 | * | [--->] IT_FILTER_SELECT_OPTIONS TYPE /IWBEP/T_MGW_SELECT_OPTION
279 | * | [--->] IS_PAGING TYPE /IWBEP/S_MGW_PAGING
280 | * | [--->] IT_KEY_TAB TYPE /IWBEP/T_MGW_NAME_VALUE_PAIR
281 | * | [--->] IT_NAVIGATION_PATH TYPE /IWBEP/T_MGW_NAVIGATION_PATH
282 | * | [--->] IT_ORDER TYPE /IWBEP/T_MGW_SORTING_ORDER
283 | * | [--->] IV_FILTER_STRING TYPE STRING
284 | * | [--->] IV_SEARCH_STRING TYPE STRING
285 | * | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITYSET(optional)
286 | * | [<---] ET_ENTITYSET TYPE ZCL_z_ods_EMPLOYEE_###_MPC=>TT_ZTT_EMPLOYEE_MSC
287 | * | [<---] ES_RESPONSE_CONTEXT TYPE /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_CONTEXT
288 | * | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
289 | * | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
290 | * +--------------------------------------------------------------------------------------
291 | method ztt_employee_###_get_entityset.
292 | **TRY.
293 | *CALL METHOD SUPER->ZTT_EMPLOYEE_###_GET_ENTITYSET
294 | * EXPORTING
295 | * IV_ENTITY_NAME =
296 | * IV_ENTITY_SET_NAME =
297 | * IV_SOURCE_NAME =
298 | * IT_FILTER_SELECT_OPTIONS =
299 | * IS_PAGING =
300 | * IT_KEY_TAB =
301 | * IT_NAVIGATION_PATH =
302 | * IT_ORDER =
303 | * IV_FILTER_STRING =
304 | * IV_SEARCH_STRING =
305 | ** io_tech_request_context =
306 | ** IMPORTING
307 | ** et_entityset =
308 | ** es_response_context =
309 | * .
310 | ** CATCH /iwbep/cx_mgw_busi_exception .
311 | ** CATCH /iwbep/cx_mgw_tech_exception .
312 | **ENDTRY.
313 |
314 | * request-example:
315 | * /sap/opu/odata/sap/ZOD_EMPLOYEE_###_SRV/ZTT_EMPLOYEE_MSCSet
316 | * /sap/opu/odata/sap/ZOD_EMPLOYEE_###_SRV/ZTT_EMPLOYEE_MSCSet(IdEmployee='1',Carrier='AA')
317 | * /sap/opu/odata/sap/ZOD_EMPLOYEE_###_SRV/ZTT_EMPLOYEE_MSCSet/?$select=Lastname,Firstname,Department
318 | * /sap/opu/odata/sap/ZOD_EMPLOYEE_###_SRV/ZTT_EMPLOYEE_MSCSet/?$filter=Carrier eq 'SR'
319 | * /sap/opu/odata/sap/ZOD_EMPLOYEE_###_SRV/ZTT_EMPLOYEE_MSCSet/?$orderby=Carrier desc
320 |
321 | data: lt_employee type table of ztt_employee_msc,
322 | ls_employee like line of lt_employee,
323 | ls_entity like line of et_entityset,
324 | ls_orderopt like line of it_order,
325 | lv_order type string.
326 |
327 | * read data
328 | if iv_filter_string is initial.
329 | select * from ztt_employee_msc into table lt_employee.
330 | else.
331 | * read data with one filter: property and select_options
332 | " simple way for any parameter
333 | select * from ztt_employee_msc into table lt_employee where (iv_filter_string).
334 | endif.
335 |
336 | * order itab
337 | if it_order is not initial.
338 | loop at it_order into ls_orderopt.
339 | "CONCATENATE: ls_orderopt-order 'ending' INTO lv_order.
340 | case ls_orderopt-order.
341 | when 'asc'.
342 | sort lt_employee by (ls_orderopt-property) ascending. "(lv_order).
343 | when 'desc'.
344 | sort lt_employee by (ls_orderopt-property) descending.
345 | endcase.
346 | endloop.
347 | endif.
348 |
349 | * fill et_entityset
350 | loop at lt_employee into ls_employee.
351 | move-corresponding ls_employee to ls_entity.
352 | append ls_entity to et_entityset.
353 | endloop.
354 |
355 | * RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc
356 | * EXPORTING
357 | * textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented
358 | * method = 'ZTT_EMPLOYEE_###_GET_ENTITYSET'.
359 |
360 | endmethod.
361 |
362 |
363 | * ---------------------------------------------------------------------------------------+
364 | * | Instance Protected Method ZCL_z_ods_EMPLOYEE_###_DPC_EXT->ZTT_EMPLOYEE_###_UPDATE_ENTITY
365 | * +-------------------------------------------------------------------------------------------------+
366 | * | [--->] IV_ENTITY_NAME TYPE STRING
367 | * | [--->] IV_ENTITY_SET_NAME TYPE STRING
368 | * | [--->] IV_SOURCE_NAME TYPE STRING
369 | * | [--->] IT_KEY_TAB TYPE /IWBEP/T_MGW_NAME_VALUE_PAIR
370 | * | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITY_U(optional)
371 | * | [--->] IT_NAVIGATION_PATH TYPE /IWBEP/T_MGW_NAVIGATION_PATH
372 | * | [--->] IO_DATA_PROVIDER TYPE REF TO /IWBEP/IF_MGW_ENTRY_PROVIDER(optional)
373 | * | [<---] ER_ENTITY TYPE ZCL_z_ods_EMPLOYEE_###_MPC=>TS_ZTT_EMPLOYEE_MSC
374 | * | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
375 | * | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
376 | * +--------------------------------------------------------------------------------------
377 | method ztt_employee_###_update_entity.
378 | **TRY.
379 | *CALL METHOD SUPER->ZTT_EMPLOYEE_###_UPDATE_ENTITY
380 | * EXPORTING
381 | * IV_ENTITY_NAME =
382 | * IV_ENTITY_SET_NAME =
383 | * IV_SOURCE_NAME =
384 | * IT_KEY_TAB =
385 | ** io_tech_request_context =
386 | * IT_NAVIGATION_PATH =
387 | ** io_data_provider =
388 | ** IMPORTING
389 | ** er_entity =
390 | * .
391 | ** CATCH /iwbep/cx_mgw_busi_exception .
392 | ** CATCH /iwbep/cx_mgw_tech_exception .
393 | **ENDTRY.
394 |
395 | data: ls_request_input_data type zcl_z_ods_employee_###_mpc=>ts_ztt_employee_msc,
396 | ls_key_tab type /iwbep/s_mgw_name_value_pair,
397 | lv_employeeid type ztt_employee_msc-id_employee,
398 | ls_employee type ztt_employee_msc.
399 |
400 | * get key values
401 | read table it_key_tab with key name = 'IdEmployee' into ls_key_tab.
402 | lv_employeeid = ls_key_tab-value.
403 |
404 | if lv_employeeid is not initial.
405 | * read request data
406 | io_data_provider->read_entry_data( importing es_data = ls_request_input_data ).
407 |
408 | * update db-table
409 | update ztt_employee_msc set
410 | area = ls_request_input_data-area
411 | department = ls_request_input_data-department
412 | firstname = ls_request_input_data-firstname
413 | lastname = ls_request_input_data-lastname
414 | salary = ls_request_input_data-salary
415 | currency = ls_request_input_data-currency
416 | where
417 | id_employee = lv_employeeid.
418 |
419 | if sy-subrc = 0.
420 | er_entity = ls_request_input_data.
421 | endif.
422 | endif.
423 |
424 | * RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc
425 | * EXPORTING
426 | * textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented
427 | * method = 'ZTT_EMPLOYEE_###_UPDATE_ENTITY'.
428 |
429 | endmethod.
430 | endclass.
431 |
--------------------------------------------------------------------------------