on 07-15-2022 7:00 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.