on 2024 Jan 26 3:03 PM
Hello,
Using the ABAP RESTful approach (https://help.sap.com/docs/abap-cloud/abap-rap/abap-restful-application-programming-model) I have implemented an app using root entity CDS view, metadata extension, behavior definition, service definition, and service binding.
Everything works fine, but I am unable to figure out how to implement DEFAULT values for fields when I click the CREATE button. I have a local helper class that is handling auto numbering just fine (using class for getting a GUID) and it also populates values for fields ON CREATE execution using a determination. But I also need DEFAULT values populated when I INITIALLY click CREATE.
The approach of using "action" does not work ... it does not populate any values initially.
Please provide the behavior definition entry as well as the class ABAP code for defaulting values.
Thanks,
Kevin
Request clarification before answering.
Hi Kevin,
if you are working on BTP ABAP Environment release 2311, you can use default values function to set default values for create, CBA, action and functions. Please refer to https://help.sap.com/docs/abap-cloud/abap-rap/operation-defaulting , there is also an example linked at the bottom of the page.
SAP S/4HANA Cloud, public edition will get this feature soon but OnPrem will take longer.
Regards,
Jessie
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For anyone else landing in here, in hopes of finding the answer to how you can add initial/default values to your entity (f.ex. for hiding fields, or defaulting types, etc) - currently there's no way to achieve this on-prem, in an unmanaged scenario, in your behavior pool class - or in metadata on your cds views...
The only way I could find, to achieve this requirement - was to add a controller extension to your Fiori Elements app / object page, and adding something along the lines of the following snipplet of code to it:
onInit: function() {
this.extensionAPI.attachPageDataLoaded($.proxy(this.onPageLoaded, this));
},
onPageLoaded: function(oEvent){
if(this.getView().getModel("ui").getProperty("/createMode")) {
var ctx = this.getView().getBindingContext();
ctx.getModel().setProperty(ctx.getPath() + "/<Property>", <value>);
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Claudia_D , first you need to declare a controller extension; like so - in manifest.json:
"sap.ui5": {
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
"sap.suite.ui.generic.template.ObjectPage.view.Details": {
"controllerName": "mycomponent.ext.controller.MyEntityExt"
Then you create a new file, MyEntityExt.controller.js in the ext/controller folder of your project, and give it the following contents:
sap.ui.define([
"sap/suite/ui/generic/template/extensionAPI/extensionAPI"
], function( extensionAPI ) {
"use strict";
return sap.ui.controller("mycomponent.ext.controller.MyEntityExt", {
onInit: function() {
this.extensionAPI.attachPageDataLoaded($.proxy(this.onPageLoaded, this));
},
onPageLoaded: function(oEvent){
.... as I wrote earlier.
User | Count |
---|---|
52 | |
6 | |
6 | |
6 | |
5 | |
5 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.