cancel
Showing results for 
Search instead for 
Did you mean: 

How to Keep a Button Always Active in SAP Fiori Elements (RAP)?

bettulaksu
Explorer
0 Kudos
307

Hi everyone,

I am developing a Fiori Elements application using RESTful Application Programming (RAP). I have added a custom button (e.g., "KURBUTON"), but it appears inactive (disabled).  However, I want this button to be always active, regardless of whether any selections are made.

Here is the code I used for the button:

projection;

//strict ( 2 );

 

define behavior for ZC_ZBA_P_01 //alias <alias_name>

{

// use create;

// use update;

// use delete;

use action KURBUTON ;

 

// use function kurbuton;

 

}

-----------------------------------------------------------------------------------------


managed implementation in class zbp_i_zba_m_001 unique;

//strict ( 2 );

 

define behavior for ZI_ZBA_M_001 //alias <alias_name>

persistent table I_ExchangeRateRawData

lock master

authorization master ( instance )

//etag master <field_name>

{

// create;

// update;

// delete;

// field ( readonly ) ExchangeRateType, SourceCurrency, TargetCurrency, ValidityStartDate;

 

action ( features: instance) KURBUTON result[1]$self;

 

//function kurbuton result [0..*] $self;

}


görsel3.pnggorsel2.png

View Entire Topic
ClearQueries
Explorer

Hi @bettulaksu,

As per what I can see from the details you shared, you've created an instance action.

Ideally an instance action means that you want to perform some action on an instance of record, e.g., if there are 10 employees in the report - you've to select one record and then the button will be enabled.

If your requirement is to process the selected record, ask the end user to select the record and then the button will be enabled automatically.

There is one more type of action available in RAP known as Static Action.

If the action does not depend on the record selection, define the action in your behaviour definition as Static action.

Syntactically you're just supposed add a keyword static in your current behaviour definition.

Refer this documentation to know more - https://help.sap.com/docs/abap-cloud/abap-rap/action-definition#action-types

Please accept the answer if it resolves your query.

Regards,

ClearQueries.com 

LinkedIn - ClearQueries

 

bettulaksu
Explorer
0 Kudos
Thank you, the solution worked! In this program, I want to display a popup with a message containing only text when a button is clicked. How can I achieve this?
bettulaksu
Explorer
0 Kudos
My codes: CLASS lhc_ZI_ZBA_M_001 DEFINITION INHERITING FROM cl_abap_behavior_handler. PRIVATE SECTION. METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION IMPORTING REQUEST requested_authorizations FOR zi_zba_m_001 RESULT result. METHODS kurbuton FOR MODIFY IMPORTING keys FOR ACTION zi_zba_m_001~kurbuton. ENDCLASS. CLASS lhc_ZI_ZBA_M_001 IMPLEMENTATION. METHOD get_global_authorizations. ENDMETHOD. METHOD KURBUTON. APPEND VALUE #( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-success text = 'Successfully changed Result_status' ) ) TO reported-zi_zba_m_001. ENDMETHOD. ENDCLASS.
ClearQueries
Explorer
0 Kudos
The behaviour you're expecting is possible to some extent using fiori elements. Using the code you shared in earlier comment, you can show the message in message toast. If you want to show it in the form of popup, you've to do invoke this action using some custom UI coding from Fiori/UI5.