Scenario - I will be developing 2 Fiori Apps on top of my RAP BO. They have been developed using RAP managed behavior.
In Fiori App1, I will show all the entries in the List Report UI which has SupersessionType = 'C'. The BO Projection view looks like the following -
define root view entity ZC_SuperSessionChoice
provider contract transactional_query
as projection on ZI_SuperSessionChoice
{
…..
ValidFrom,
Active,
Deleted,
…..
}
where
SupersessionType = 'C'
and Deleted = ' '
Since, we are restricting only the certain fields to be visible in the UI, therefore now whenever we need to create a new instance from the Fiori UI, we need to ensure filling SupersessionType = 'C' in the new record. Otherwise, RAP runtime will throw provider error. Besides, another requirement which says few of the fields e.g. ValidFrom shall be defaulted by current date when creating a new instance.
Now I will show how the above requirements can be implemented using operation augmentation in BO Projection.
projection implementation in class zbp_c_supersessionchoice unique;
strict ( 2 );
use draft;
use side effects;
define behavior for ZC_SuperSessionChoice alias Choice
{
use create ( augment );
…
}
2. I will create the behavior implementation of the above BDEF. The augmented create operation implementation looks like below.
METHOD augment_create.
DATA augment_create TYPE TABLE FOR CREATE ZI_SuperSessionChoice.
LOOP AT entities ASSIGNING FIELD-SYMBOL(<entity>).
APPEND VALUE #( %cid = <entity>-%cid
%is_draft = <entity>-%is_draft
%key = <entity>-%key
SupersessionType = zcl_supersession_helper=>gc_ss_type-choice
channel = zcl_supersession_helper=>gc_channel-both
validfrom = cl_abap_context_info=>get_system_date( )
%control-SupersessionType = if_abap_behv=>mk-on
%control-channel = if_abap_behv=>mk-on
%control-ValidFrom = if_abap_behv=>mk-on
) TO augment_create.
ENDLOOP.
MODIFY AUGMENTING ENTITY ZI_SuperSessionChoice
CREATE
FROM augment_create.
ENDMETHOD.
Here I am augmenting the instance being created by filling up some fields beforehand e.g. SuperSessionType with C, validfrom with current date etc. .
This will also default those fields values when the instance is displayed in object page during create. Since I filled channel = 'Both' and Valid From = Current date, the same are defaulted when I click on 'Create' button and the object page is displayed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |