cancel
Showing results for 
Search instead for 
Did you mean: 

RAP Dynamic Feature Control - Custom Action enabled/disabled depending on app mode (display/edit)

florian_halder
Participant
0 Kudos

Hi all,

I am trying to enable/disable my custom action via dynamic feature control depending on the "state" of the application.

If the application is in edit mode the custom action should be enabled, if it is in display mode it should be disabled.

I use the dynamic feature control because there is some other context information which influence the custom action.

How do I get the application state (edit/display) in the get_instance_features method? I thought the requested_features-&update would indicate the state, but after a few tests it is probably not. When in display mode and I click on the EDIT button the get_instance_feature method is called twice. In the first time the %Update is 00 and the second time it is 01.

And if I click Return to Draft both times it is 00.

Any ideas on that?

Thanks Florian

Accepted Solutions (0)

Answers (2)

Answers (2)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Hi Florian,

I hope that you already found a solution but since somebody else asked me the same question and referred to this unanswered question from you I thought it would be good to put my answer to your question.

First step would be to create an action as follows in your BDEF.

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

Then you have to make it accessible by adding the following statement in the behavior projection.

use action acceptSalesOrder;

And in the metadata extension file you would have to add code like the following (either to the identifiaction section or the line item section or to both) so that the action button shows up on the UI.

@UI.lineItem: [ {
position: 20 ,
importance: #HIGH,
label: 'SalesorderID'
} ]
@UI.identification: [ {
position: 20 ,
label: 'SalesorderID'
}
, {
label: 'Accept SalesOrder',
dataAction: 'acceptSalesOrder',
type: #FOR_ACTION
}
]
@UI.selectionField: [ {
position: 20
} ]
SalesorderID;

You can use code completion (Ctrl+1) in your behavior definition to let ADT generate the definition and empty implementation of the following two methods in your behavior defintion class.

METHODS get_instance_features FOR INSTANCE FEATURES
IMPORTING keys REQUEST requested_features FOR SalesOrder RESULT result.
METHODS acceptSalesOrder FOR MODIFY
IMPORTING keys FOR ACTION SalesOrder~acceptSalesOrder RESULT result.

The get_instance_features() method can then be implemented as follows.

  METHOD get_instance_features.
    LOOP AT keys INTO DATA(key).
      APPEND VALUE #( 
           %tky = key-%tky
           %action-acceptSalesorder      = COND #( WHEN key-%is_draft = if_abap_behv=>mk-on
                                                            THEN if_abap_behv=>fc-o-enabled
                                                            ELSE if_abap_behv=>fc-o-disabled )
                     ) TO result.
    ENDLOOP.
  ENDMETHOD.

This will enable the action button when you edit the sales order and when you are thus using the draft mode.

Inactive when in draft mode:

And Active when not in draft mode.

Kind regards,

Andre

akshay154
Explorer
0 Kudos

Hi Andre,

I have a similar requirement but in my case the custom action is on the line item section of the Child entity. It is a static action with input parameter which is used to create a new child entity instance without depending on existing child entity records.

Now is it possible to enable and disable this action button depending on whether the parent entity is in create/display mode? It should be enabled only while creating parent entity and it should disabled in display mode. We are only providing create and display functionality in this app i.e EDIT scenario is not supported.

I went through a lot of blogs and sap documentation but nothing seems to work in case of static action button.


Thanks and Regards
Akshay

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Can you post this as a new questions and maybe add the link to the same?
I cannot answer this but can only add a moderation comment using the UI.

0 Kudos

Hi Andre. Thanks for the hints for the problem solving in case of draft enabled app. Any reasonable recommendations when we are in non draft case? Do we have only an option with UI js manipulations in that case?

florian_halder
Participant
0 Kudos

Hi Andre,

thanks for your answer. Yes, I solved this using an approach in BAS, but your suggestion is much simpler. I did not get the idea at that time. 🙂

Kind regards,

Florian