https://sapui5.hana.ondemand.com/sdk/#/topic/642dab291a7b47ec9d46c39b3c482aba
data-sap-ui-flexibilityServices='[{"connector": "LocalStorageConnector"}]'
https://sapui5.hana.ondemand.com/sdk/#/topic/642dab291a7b47ec9d46c39b3c482aba
data-sap-ui-flexibilityServices='[{"connector": "LocalStorageConnector"}]'
So far I have not found a better/shorter way to check if a table entry exists than the following:
let exists = await SELECT(1).from(Books,201)
return (exists .length > 0) ? true : false
Found here: https://cap.cloud.sap/docs/node.js/cds-tx#cds-tx-ctx-fn
Simply go to your Component.js file and add this line to the init
function:
this.getModel().setHeaders({"myCustomParameter": "test"})
In a CAP Backend, you get this parameter from the express req object, which can be accessed via the req.http property:
req.http.req.headers['myCustomParameter']
And here is a nice code snippet, on how to read this header parameter in an ABAP system: https://answers.sap.com/answers/425621/view.html
Somehow I always forget that there is a boolean function in ABAP. That’s why I’m writing this post to hopefully remember it better. 🙂
If you just want to check something for truthiness, you can do it in the following three ways:
IF sy-subrc = 0.
result = abap_true.
ELSE.
result = abap_false.
ENDIF.
result = SWITCH #( sy-subrc WHEN 0 THEN abap_true
ELSE abap_false ).
result = xsdbool( sy-subrc = 0 )
If you are using the Launchpad Sandbox in your CAP project (like it is done here or here) and you want to change the logo in the header bar, simply add this little CSS snippet in the launchpad.html file:
<style>
#shell-header-icon {
content: url("./logo.png");
}
</style>
Of course you could also provide a base64 encoded image:
<style>
#shell-header-icon {
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAGGoAAAVNCAYAAAAIhfswAA...);
}
</style>
To increase the session lifetime, simply increase the sessionTimeout property in the xs-app.json of your approuter.
https://www.npmjs.com/package/@sap/approuter#xs-appjson-configuration-file
xs-app.json
{
"welcomeFile": "index.html",
"authenticationMethod": "route",
"logout": {
"logoutEndpoint": "/do/logout"
},
"sessionTimeout": 60,
"routes": []
}
https://www.w3resource.com/sql/aggregate-functions/Max-with-group-by.php
entity myEntity {
key ID: Integer;
key seqNr: Integer;
key createdAt: DateTime;
...
}
@readonly
entity myEntityMaxSeqNr
as select from myEntity {
ID,
count(seqNr) as maxSeqNr: Integer
createdAt,
...
}
group by
ID,
createdAt;
This can also be done using CQL like here.
https://sapui5.hana.ondemand.com/#/api/sap.ui.core.format.DateFormat%23methods/format
const today = new Date()
const oDateTimeFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({
pattern: "yyyy-MM-ddTHH:mm:ss",
UTC: true
})
const todayISO = oDateTimeFormat.format(today)
The UTC flag can also be set, when calling the format function.
const today = new Date()
const oDateTimeFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({
pattern: "yyyy-MM-ddTHH:mm:ss",
//UTC: true
})
const todayISO = oDateTimeFormat.format(today, true)
Manually adding Lanes to a Process Flow Control:
https://sapui5.hana.ondemand.com/#/api/sap.suite.ui.commons.ProcessFlow
https://sapui5.hana.ondemand.com/#/api/sap.suite.ui.commons.ProcessFlowLaneHeader
https://sapui5.hana.ondemand.com/#/entity/sap.suite.ui.commons.ProcessFlow/sample/sap.suite.ui.commons.sample.ProcessFlowUpdateLanes/code
In my case, there was no way to bind the model to the view, so I did the mapping for each ProcessFlowLaneHeader in the callback function after reading the oData entity.
view.xml
<flow:ProcessFlow id="process-flow"/>
controller.js
var oProcessFlow = this.getView().byId("process-flow")
var oRequestFilter = new sap.ui.model.Filter({
path: "myId",
operator: sap.ui.model.FilterOperator.EQ,
value1: myId
})
this.getView().getModel().read("/WorkflowSet", {
filters: [oFormularIdFilter],
success: (oData, response) => {
for (var i = 0; i < oData.results.length; i++) {
var oLaneHeader = new ProcessFlowLaneHeader({
laneId: oData.results[i].LaneId,
iconSrc: oData.results[i].IconSrc,
text: oData.results[i].Text,
position: oData.results[i].Position,
state: [{state: oData.results[i].State, value: "100"}]
});
oProcessFlow.addLane(oLaneHeader)
}
},
error: oError => {
sap.m.MessageToast.show("An error occured while reading entity /WorkflowSet.")
}
});