cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove edit button from Object Page ( Developed using Fiori Elements and RAP )

former_member207873
Participant
0 Kudos

Hello Experts,

I have developed a Fiori App( List Report - Object Page ) using Fiori Elements and ABAP RAP Programming. I do not want the user to edit or delete any of the created instances.

managed implementation in class zbp_c_etn_entered_info unique;
strict;

define behavior for ZC_ETN_ENTERED_INFO alias etn_info
persistent table ztsdb
lock master
early numbering
authorization master ( instance )
//etag master <field_name>
{

   field ( readonly ) Counter, Status , StatusDescription, ProjectJira , Ticket, TicketText,
                      WorkLogID  , UnitOb , UnitConsulting , UnitAdditionalCosts ;
   field ( mandatory : create  )  WorkDate , ConsultingDocument , MessageText ;


  create;
  update;
  // delete;

<br>

I was able to remove the 'Delete' button just by commenting

But I cannot remove the update button since I have determinations with Modify Entity with Update fields .

Ex.

 MODIFY ENTITIES OF zc_etn_entered_info IN LOCAL MODE
        ENTITY etn_info
        UPDATE SET FIELDS WITH VALUE #( FOR xxx IN lt_xxxx
                                      ( %key = xxx-%key
                                        Status = '10' "
                                        %control  = VALUE #( XXX = if_abap_behv=>mk-on )<br>

If I remove the Update command then it will throw runtime errors.

So long story short, How can i remove edit button from the object page ?

Accepted Solutions (1)

Accepted Solutions (1)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Hi PD,

if you want to have a dynamic behavior based on the content you have to use the key word ( features : instance ) for the operation update.

If you just want to disable the option that users can edit content that has been created the approach described above is the best.

Here you are able to create several projections. One that is offering the option to edit the date

projection; 
define behavior for ZC_TESTFEATURESTP alias TestFeatures 
{ use create; 
  use update; 
  use delete; }

and a second one that blocks the use of update

projection; 
define behavior for ZC_TESTFEATURESTP alias TestFeatures 
{ use create; 
 // use update; 
  use delete; }

When you are looking for a dynamic solution look at this:

managed;

define behavior for ZR_TESTFEATURESTP alias TestFeatures
implementation in class ZBP_R_TestFeatures unique
persistent table ZAIRPORT1
etag master LocalLastChangedAt
lock master
authorization master( global )

{
  create;
  update ( features : instance );
  delete;

  mapping for ZAIRPORT1
  {
    AirportID = AIRPORT_ID;
    Name = NAME;
    City = CITY;
    Country = COUNTRY;
    LocalLastChangedAt = LOCAL_LAST_CHANGED_AT;
  }
}<br>

The you have to implement in your behavior implementation class the method get_instance_features( ).

CLASS lhc_TestFeatures DEFINITION INHERITING FROM cl_abap_behavior_handler.
  PRIVATE SECTION.

    METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION
      IMPORTING REQUEST requested_authorizations FOR TestFeatures RESULT result.
    METHODS get_instance_features FOR INSTANCE FEATURES
      IMPORTING keys REQUEST requested_features FOR TestFeatures RESULT result.
ENDCLASS.

CLASS lhc_TestFeatures IMPLEMENTATION.

  METHOD get_global_authorizations.
  ENDMETHOD.

  METHOD get_instance_features.
    READ ENTITIES OF zr_testfeaturestp IN LOCAL MODE
       ENTITY TestFeatures
         ALL FIELDS
         WITH CORRESPONDING #( keys )
         RESULT DATA(entities).

    result = VALUE #( FOR entity IN entities
                    ( %tky                   = entity-%tky
                      %update                = COND #( WHEN entity-City IS INITIAL
                                                      THEN if_abap_behv=>fc-o-enabled
                                                      ELSE if_abap_behv=>fc-o-disabled )

                                                         ) ).
  ENDMETHOD.

ENDCLASS.<br>

As a result you will see the following:

Nadeem_Mohammed
Explorer
0 Kudos

andre.fischer

In case we created a CDS view, generated a Business Object (BOPF) for it, exposed via OData using annotations and created Fiori Element List Report application based on this service.

How can we remove EDIT button from object page for such applications OR handle dynamic behavior based on the content.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

This question is answered and relates to RAP, not BOPF.
Can you please open a new question (where you can add a link to this question for sure)?

harrouchi
Newcomer
0 Kudos

Thanks for your explanation andre.fischer

However, the provided solution is just applicable on the update button, not on the create one? do you confirm that ?

Yassin

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

You can comment out the "use create" in the projection layer and no create button will be visible.

For more detailed questions, please raise a separate question instead of using the comments area.

Answers (1)

Answers (1)

dominik_ee
Advisor
Advisor

By using projections you can create access to your entity without exposing certain capabilities. Your underlying BDEF could still be create, update and delete enabled, but the App you have built will be based on an projection on top of it which exposes on the projection layer only the create capability: https://help.sap.com/docs/BTP/923180ddb98240829d935862025004d6/6e7a10d30b74412a9482a80b0b88e005.html

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Your approach is correct if you want to disable the option to update data at all.

If I understood PD correctly he is looking for a dynamic behavior.