There are no secrets to success. It is the result of preparation, hard work, and learning from failure.

Thursday, 29 February 2024

Multiple create operations using batch in SAPUI5

If you want to perform multiple create operations in a batch, you can utilize the OData Model
and its batch capabilities. Please find the code snippet below to achieve this.

// OData Model initialization
var oModel = new sap.ui.model.odata.v2.ODataModel("Service_URL");
// Array to hold create requests
var aBatchRequest = [];
// Add multiple create requests to the batch
aBatchRequest.push(oModel.createBatchOperation("/EntitySet1", "POST", {P1: V1}));
aBatchRequest.push(oModel.createBatchOperation("/EntitySet2", "POST", {P2: V2}));
aBatchRequest.push(oModel.createBatchOperation("/EntitySet3", "POST", {P3: V3}));
aBatchRequest.push(oModel.createBatchOperation("/EntitySet4", "POST", {P4: V4}));
// Execute the batch request
oModel.addBatchChangeOperations(aBatchRequest);
// Submit the batch request
oModel.submitBatch(function (oData, oResponse) {
    // We will get data here for all read operations
}, function (error) {
    // We can handle errors here
});


In case of any queries/doubts please let me know by commenting on this post itself or
by sending me an email.

Friday, 23 February 2024

Multiple read operations using batch in SAPUI5

If you want to perform multiple read operations in a batch, you can utilize the OData Model
and its batch capabilities. Please find the code snippet below to achieve this.

// OData Model initialization
var oModel = new sap.ui.model.odata.v2.ODataModel("Service_URL");
// Array to hold read requests
var aBatchRequest = [];
// Add multiple read requests to the batch
aBatchRequest.push(oModel.createBatchOperation("/EntitySet1", "GET"));
aBatchRequest.push(oModel.createBatchOperation("/EntitySet2", "GET"));
aBatchRequest.push(oModel.createBatchOperation("/EntitySet3", "GET"));
aBatchRequest.push(oModel.createBatchOperation("/EntitySet4", "GET"));
// Execute the batch request
oModel.addBatchReadOperations(aBatchRequest);
// Submit the batch request
oModel.submitBatch(function (oData, oResponse) {
    // We will get data here for all read operations
}, function (error) {
    // We can handle errors here
});


In case of any queries/doubts please let me know by commenting on this post itself or
by sending me an email.

Saturday, 5 September 2020

SAP Web IDE Trial Update

Click here and follow my SAP UI5/FIORI snippets and information Page

On November 13, 2020 the SAP Cloud Platform, Neo trial environment will be discontinued and as a result SAP Web IDE Full-Stack trial will also be discontinued.

If you have an existing Neo trial account, you can continue using it including SAP Web IDE Full-Stack until November 13, 2020. This can be done by opening the SAP Cloud Platform trial home page, scrolling down to the Environments section, and choosing “Access Neo Trial” Link.  Then, under Services choose SAP Web IDE Full-Stack.

Before November 13, you must choose one of the following options:

1. Start using the SAP Business Application Studio trial as it is the next generation of SAP Web IDE Full-Stack. It offers a modern desktop-like experience in the cloud including new tools, capabilities, and much more. To learn more, please see this blog central blog with links to useful information, supported scenarios, migration guides and hands-on tutorials.


2. Purchase a license to SAP Web IDE Full-Stack, see the 
SAP Store or the Discovery Center.

3. For SAP HANA native development, the tools available in SAP Web IDE Full-Stack are not yet available in SAP Business Application Studio. To learn how to develop using SAP Business Application Studio, see this video. If you still want to use those tools, you can use SAP Web IDE for SAP HANA development which is available on the SAP Cloud Platform multi-cloud trial environment. This temporary solution will be available until SAP HANA development tools are supported in SAP Business Application Studio. To access this solution see tutorial , for usage see video.

For more information on the SAP Cloud Platform strategy, take a look at this blog , or the FAQ.

Monday, 23 March 2020

SAP Cloud Platform Business Rules- Part 3

Click here and follow my SAP UI5/FIORI snippets and information Page
SAP Cloud Platform Business Rules- Part 1
SAP Cloud Platform Business Rules- Part 2
In the Part-1 and Part-2, I have shown required configurations steps and BRM Rules project creation with all required components.In Part-3,I going to explain below point.Go through it and please let me know in case of any doubt/issue.

->How to use/call BRM project in SAPUI5/FIORI application

Advantages:
1. Without writing the code in the application, we are getting the offers below.
2. Easily we can change the offers without touching the UI5 application code.
3. Anyone can maintain BRM Rules project.
4. Technical knowledge is not required for BRM Rules project.
5. It is easy to develop.
6. It is easy to enhance.

Step 1- Create a SAPUI5 application and paste below snippet in neo-app.json         
     {
      "path": "/bpmrulesruntime/rules-service/v1/rules",
      "target": {
        "type": "destination",
        "name": "bpmrulesruntime",
        "entryPath": "/rules-service/v1/rules"
      },
      "description": "SAPUI5 Test Resources"
    }

According to the BRM Rules project, I have created UI5 view. Please have a look at below screenshots.

Application UI Screens 

There are three drop-downs in this UI screen.All are mandatory fields here.  
Select Card Type from first drop-down.

Select Brand from second drop-down.

Select Quantity from third drop-down.

Select all the fields and click on "check" button for knowing the best offer.Based on the selections you will get offer from BRM Rules.

I have selected these options.Please find below the screenshot.




I have got the offer based on my inputs.Please find below the screenshot.
Step 2- Paste below snippet in view.

<content>
<f:SimpleForm editable="true" layout="ResponsiveGridLayout" labelSpanXL="3" labelSpanL="4" labelSpanM="3" labelSpanS="12" adjustLabelSpan="false" emptySpanXL="4" emptySpanL="4" emptySpanM="4" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1" singleContainerFullSize="false">
<f:content>
<Label text="Card Type" required="true"/>
<ComboBox placeholder="Select Card Type" id="cardTypId">
<core:Item key="SBI" text="SBI"/>
<core:Item key="HDFC" text="HDFC"/>
<core:Item key="TATA" text="TATA"/>
<core:Item key="CITI" text="CITI"/>
<core:Item key="ICICI" text="ICICI"/>
<core:Item key="AMERICAN EXPRESS" text="AMERICAN EXPRESS"/>
<core:Item key="IDFC" text="IDFC"/>
<core:Item key="RBL" text="RBL"/>
<core:Item key="BAJAJ" text="BAJAJ"/>
<core:Item key="AXIS" text="AXIS"/>
</ComboBox>
<Label text="Brand" required="true"/>
<ComboBox placeholder="Select Brand" id="brandTypId">
<core:Item key="SONY" text="SONY"/>
<core:Item key="LG" text="LG"/>
<core:Item key="SAMSUNG" text="SAMSUNG"/>
<core:Item key="SPYKAR" text="SPYKAR"/>
<core:Item key="ARROW" text="ARROW"/>
<core:Item key="MUFTI" text="MUFTI"/>
<core:Item key="LEVIS" text="LEVIS"/>
<core:Item key="MOCHI" text="MOCHI"/>
<core:Item key="MATROLA" text="MATROLA"/>
<core:Item key="NIKE" text="NIKE"/>
</ComboBox>
<Label text="Quantity" required="true"/>
<ComboBox placeholder="Select Quantity" id="quanTypId">
<core:Item key="1" text="1"/>
<core:Item key="2" text="2"/>
<core:Item key="3" text="3"/>
<core:Item key="4" text="4"/>
<core:Item key="5" text="5"/>
<core:Item key="6" text="6"/>
<core:Item key="7" text="7"/>
<core:Item key="8" text="8"/>
<core:Item key="9" text="9"/>
<core:Item key="10" text="10"/>
<core:Item key="11" text="11"/>
<core:Item key="12" text="12"/>
<core:Item key="13" text="13"/>
<core:Item key="14" text="14"/>
<core:Item key="15" text="15"/>
</ComboBox>
</f:content>
</f:SimpleForm>
<FlexBox alignItems="Center" justifyContent="Center">
<items>
<Button text="Reset" type="Reject" class="sapUiSmallMarginEnd" press="handleRest"/>
<Button text="Check" type="Accept" press="handleCheck"/>
</items>
</FlexBox>
<ObjectIdentifier title="**Festival Offers on credit cards" class="marginClass"/>
</content>

Step 3- Paste below snippet in controller.

// When users click on 'CHECK' button then this method will fire....
handleCheck: function () {
jQuery.sap.require("sap.m.MessageBox");
var cardId = this.byId("cardTypId"),
brandId = this.byId("brandTypId"),
QAId = this.byId("quanTypId"),
that = this;
if (!cardId.getSelectedKey()) {
sap.m.MessageToast.show("Select Card Type");
return;
}
if (!brandId.getSelectedKey()) {
sap.m.MessageToast.show("Select Brand");
return;
}
if (!QAId.getSelectedKey()) {
sap.m.MessageToast.show("Select Quantity");
return;
}
//Input(Entity/Structure name in business rules)....
//CardType,BrandType,Quantity(Properties names in business rules)....
var payLoad = {
"__type__": "Input",
// Date type is string in business rules....
"CardType": cardId.getSelectedKey(), 
// Data type is string in business rules....
"BrandType": brandId.getSelectedKey(), 
// Date type is number in business rules....
"Quantity": Number(QAId.getSelectedKey()) 
};
// First get the CSRF token....
$.ajax({
url:"/bpmrulesruntime/rules-service/v1/rules/xsrf-token",
method: "GET",
headers: {
"X-CSRF-Token": "Fetch"
},
success: function (result, xhr, data) {
var token = data.getResponseHeader("X-CSRF-Token");
// Then invoke the business rules service via public API....
$.ajax({
// DemoRules1(Project Name in business rules)....
// OfferRulesService(Service Name in business rules)....
url: "/bpmrulesruntime/rules-service/v1/rules/invoke?rule_service_name=DemoRules1::OfferRulesService",
method: "POST",
contentType: "application/json",
data: JSON.stringify(payLoad),
async: false,
headers: {
"X-CSRF-Token": token
},
success: function (result1, xhr1, data1) {
var dis = null,
cashBack = null,
title = "",
icon = null;
if (result1.__type__) {
dis = result1.Discount + "%";
cashBack = result1.Cashback + " INR";
title = "CONGRATULATIONS";
icon = sap.m.MessageBox.Icon.SUCCESS;
} else {
dis = "0%";
cashBack = "0 INR";
title = "INFORMATION";
icon = sap.m.MessageBox.Icon.INFORMATION;
}
sap.m.MessageBox.show("Discount = " + dis + "\n" + "CashBack = " + cashBack, {
icon: icon,
title: title,
actions: [sap.m.MessageBox.Action.OK],
onClose: function (oAction) {
that.handleRest();
}
});
}
});
}
});
},

// When users click on 'RESET' button then this method will fire....
handleRest: function () {
this.byId("cardTypId").setSelectedKey("");
this.byId("brandTypId").setSelectedKey("");
this.byId("quanTypId").setSelectedKey("");

}

Saturday, 21 March 2020

SAP Cloud Platform Business Rules- Part 2

Click here and follow my SAP UI5/FIORI snippets and information Page
SAP Cloud Platform Business Rules- Part 1
SAP Cloud Platform Business Rules- Part 3
In part-1,I explained all the configurations steps for Business rules.In part-2, I am going to explain below points.Go through it and please let me know in case of any doubt/issue.

->How to create Business rules project.
->How to create Data Objects(Entity).
->How to create attribute.
->How to create service and vocabulary.
->How to create decision tree.
->How to write conditions in decision tree.
->How to deploy service on cloud.
Step 1- Click on "Manage Rules project". I have highlighted below in the screenshot.
Step 2- You will get below screen.         
Step 3- Click on add(+) button to create the rules project.I have highlighted above in the screenshot. 
You will get below screen.
I have given input in Name filed is : "DemoRules1"
I have given input in Description filed is : "Offers for credit cards example"
You can give any name as per your requirement.
  A. Click on "Save" button to create the project.
  B. Click on "Validate" button to validate the project.
  C. Click on "Edit" button.
  D. Click on "Activate" button to activate the project.

Step 4- Select "Data Objects" and from the menu list, select the "Local data Objects".I have highlighted below in the screenshot.
Step 5- Click on Add(+) button to create entity. I have highlighted above in the screenshot.
Entity- It contains properties.
Give entity name, description and select type.In the select option you will get three options.Select the one option as per your requirement.
Options are:   A- Structure
                     B- Table
                     C- Element
I have selected structure for my case. After filling the details,click on save button to create the entity.
Click on edit button and select "Attributes" option and add at least one property under the entity.
 Add property under the attributes section and then save, validate and activate the entity.
 I have created three properties for my input case.
You have to create two entities, one for input and another one for output.
I have created two properties for my output case.follow same above steps for output entity and properties.
Step 6- Select "Rule Services" option and click on add(+) button to create service. I have highlighted below in the screenshot.
  
Provide the details and save to create service.
Click on edit button and select "vocabulary".
Click on add(+) button to add vocabulary under the service.
In vocabulary, we select created entities and it's usage(whether input or result). Save, Validate and Activate.

Step 7- Select "Rules" and from the menu,select "Local Rules".
Click on add(+) button to create rules. You will get below screen.
Give Name and create the rules.You will get below screen.
Click on setting button.I have highlighted above in the screenshot. You will get below screen.
 A. Change Hit policy to "All Match".
 B. In condition write your properties of created input entity.Suggestions would be coming automatically.
 C. Select operator and click on plus(+) button to add row below.
 D. Select output entity.All properties would be added under the result.
 E. Give default value 0.
 I have added three conditions because I have three properties in input entity.
 Click on Apply.You will get below screen.
Click on "Add Row" and select "Insert First".
Write value in input and output properties.If it is string data type then write with quote.If it is number data type then write without quote.
Save,Validate and Activate. You can add any number of row.

Step 8- Select "Rulesets" and click on add(+) button to create rulesets.

Give name, description and select rule service.
Click on Add rule and select created rule.
Save,Validate and Activate.

Step 9- Select "Rule Services" and click on the deploy button. I have highlighted below in the screenshot.

You will get below screen.
Click on "SAP Cloud Platform".You would get successful deployment message.

Congratulations! Successfully we have created BRM project,Entities,Attributes,service,vocabulary,decision tree with conditions and deployment of BRM on cloud .

In the next post I will show, How to use/call BRM project in SAPUI5/FIORI application. 

Thursday, 11 April 2019

SAP Cloud Platform Business Rules- Part 1

Click here and follow my SAP UI5/FIORI snippets and information Page
SAP Cloud Platform Business Rules- Part 2
SAP Cloud Platform Business Rules- Part 3
Introduction:
SAP Cloud Platform Business Rules is a technology service that translates business decision logic into a natural language that is configurable directly by line of business key users, knowledge experts without IT or developer intervention. It provides solution architects and developers web based tools to model, author and simulate business rules independent of the backend system.
it is a platform service which enables business users & application developers to automate their decisions and enhance their decision-making experience. Go through it and please let me know in case of any doubt/issue.

How to Enable Business Rules?

Step 1- Login into SAP Cloud Platform Cockpit.

Step 2- Click on "Neo Trial".I have shown below in the screenshot.

Step 3- You will get below screen.
Click on "Service".I have shown above in the screenshot.

Step 4- You will get below screen.
Business tool is not enabled,Click on "Business Rules" tile.I have shown above in the screenshot.

Step 5- You will get below screen.
Click on "Enable" button.I have shown above in the screenshot.It takes 2 to 3 minutes for enable.

Step 6- You will get below screen.
Congratulation!Now it is enabled.

Step 7- Click on "Configure Business Rules Repository" link.I have shown below in the screenshot.

Step 8- You will get below screen.
Select "RuleAdmin" and click on "Assign" button.

Step 9- You will get below screen.
Give your User Id and Click on "Assign" button.I have shown above in the screenshot.
User Id = I have marked  above in the screenshot.

Step 10- You will get below screen.
Now Id has been assigned to "RoleAdmin".I have shown above in the screenshot.

Step 11- Go back.
Click on "Business Rules Editor".I have shown above in the screenshot.

Step 12- You will get below screen.

Congratulations! Now business tool is fully enabled.We can create BRM projects.In the next post I will show.

->How to create Business rules project.
->How to create Data Objects(Entity).
->How to create attribute.
->How to create service and vocabulary.
->How to create decision tree.
->How to write conditions in decision tree.
->How to deploy service on cloud.
->How to connect with SAPUI5/SAP FIORI application.