on ‎2022 Apr 12 12:44 PM
Hi Experts,
I have a managed scenario with an unmanned save and with draft (list report). Additionally I have an action that modifies a field of the entity. This works so far.
Now I want this action to save the current draft as active (run the save method) and switch the app to display mode.
Is this possible at all? All my attempts so far, failed.
I have done a lot of research in the documentation etc. but have not been able to solve it. What is also not clear to me in this context is, when the save sequence is run through. If I understand the action runtime correctly the save method should be run every time after an action is triggered. But in my testing, I rarely get to save method and I don't really know when that is.
Any help is appreciated.
Request clarification before answering.
Hi Florian,
Finally, I was able to solve this issue without side effects.
Below are the extra points in addition to prevous points.




Best wishes,
Ramjee Korada
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ramjee,
thank you for analyzing the problem. Great that you found out how to get this done!!
However, the application does not yet behave quite correctly. If I use the arrow to navigate back to the list report page, the last Draft version is displayed in edit mode instead of the list report page. Is this also the case with your test app?
Do you know how to fix this?
Kind regards Florian
Hi Ramjee,
almost one year later I come back to this topic (Switch from draft to active instance). The backend system where this function was implemented is now on s/4 2022 and the UI5 Version is 1.108.7. Since the upgrade, this function doesn't work anymore.
After execution of the custom action, the following pop up is displayed, but when it's closed, everything is fine. The entity is active and the object page is in display mode with the correct/refreshed data.

Behind the black bar is the name of the consumption view for the entity.
We already have a ticket open with SAP for this. But SAP say Fiori Elements is not able to handle this draft modifications and we should not do this, because the framework expect the draft instance after the custom action.
But I'm not ready to accept that yet, because it worked in the past. And the workarounds, like set status in a separate field or button and then save afterwards, are not user friendly and can cause mistakes.
So my questions are, do you have a new system where you can check your example from the past and do you get the same error? If yes, do you see any chance to get this working again?
Thanks and kind regards Florian.
Hello @Ramjee_korada ,
I tried your coding in my application. But I get an error like this "Resource not found for entity..." . When I closed the error windows, everything is works fine.
Do you know what can be reason?
Thanks for your help and your post..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I have a question and I couldn't solve it.
orginal Question is here: Access RAP CDS behavior implementations in the backend via the SAP BAS UI5 button | SAP Community
I have a backend application with RAP that includes CDSs, CDs view, CDS Projection, Service definition, Service Binding and CDS-Behaviour and CDS-Behviour Implementation Classes. With this, a connection to a room in fiori UI is already implemented automatically.
I can also access this backend RAP from a fiori UI application with SAP BAS (Business Application Studio).
Problem: I want to be able to access this backend RAP from a SAPUI5 (not fiori UI) application with SAP BAS(Business Application Studio). But unfortunately I can't find it.
Here's what I want to do: I can't stay flexible and free with Fiori. I want to implement my own UI with SAPUI5 and I want to reach the backend (I want to use RAP - CDS Behavior Implementation Classes) with a button, for example.
In summary (just like the "-action" logic in Fiori) I want to reach the Behaviour-Class in RAP with a button in SAPUI5.
I couldn't find any source. How can I do that?
Orhan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Orhan,
you have posted this question as a comment to two posts and have posted the question separately as a questions here:
Access RAP CDS behavior implementations in the backend via the SAP BAS UI5 button | SAP Community
I would suggest to change the two comments such that you just post a link to the question that you posted originally.
This way any feedback you will get will be added to your above mentioned question.
Kind regards,
Andre
Hello Florian,
As per my Experiments, below logic can help in your scenario where you want to move draft into active version.
MODIFY ENTITIES OF BusinessObjectName
ENTITY BO_Entity
EXECUTE Activate FROM
VALUE #( ( %key-FieldName = 'Value' ) )
REPORTED DATA(activate_reported)
FAILED DATA(activate_failed)
MAPPED DATA(activate_mapped)Above statement needs to be written after your actual modify entities statement.
In other words,
Step1: update new custom filed into current draft version
Step2: Merge draft version into active version.
Also note that you have to adjust Action definition -result parameter to entity type instead of $self and keys while returning. See below blogpost that does similar activity but in reverse mode .
This helps you to switch to display mode successfully.
References :
Point 2:
Best wishes,
Ramjee Korada.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ramje,
thank you very much for your help. I already had Step1 and Step2 but I didn't change the result parameter form $self to the entity type in my attempts . Thanks for this hint. Unfortunately it still doesn't work.
I'm probably still doing something wrong.
App in Edit mode:

After click on confirm, the screen isn't updated and I'm still in edit mode.
METHOD confirm.
*- Update involved Instances
MODIFY ENTITIES OF z_i_rap_iop01 IN LOCAL MODE
ENTITY header
UPDATE FIELDS ( field1 )
WITH VALUE #( FOR key IN keys ( %tky = key-%tky
"%is_draft = if_abap_behv=>mk-off aktive Instanz ändern
field1 ='Test' ) ).
*- Activate Draft Instance
MODIFY ENTITIES OF z_i_rap_iop01 IN LOCAL MODE
ENTITY header
EXECUTE Activate FROM VALUE #( FOR key IN keys ( %key-IopId = key-%key ) )
FAILED failed
REPORTED reported
MAPPED mapped.
*- Change Keys to read active Instance
DATA(lt_keys) = keys.
LOOP AT lt_keys ASSIGNING FIELD-SYMBOL(<ls_key>).
<ls_key>-%is_draft = if_abap_behv=>mk-off.
ENDLOOP.
*- Read Header Active Instance and set as result
READ ENTITIES OF z_i_rap_iop01 IN LOCAL MODE
ENTITY header
ALL FIELDS
WITH CORRESPONDING #( lt_keys )
RESULT DATA(lt_header)
FAILED DATA(lt_failed).
result = VALUE #( FOR ls_header IN lt_header ( %tky = ls_header-%tky
%param = CORRESPONDING #( ls_header ) ) ).
*- Update Header
* result = VALUE #( FOR ls_header IN lt_header ( %tky = ls_header-%tky
* %param = ls_header ) ).
* result = corresponding #( lt_header ).
ENDMETHOD.Behavior definition:

Hi Florian,
I think it is related to side-effects and I will also explore for possibilities for moving into display mode.
However, I am able to move my draft into active version from List report page for the same action.
Is 'Merging into active version" working in list report page for you now ?
Best wishes,
Ramjee
Hi Ramjee,
you mean if I execute the confirm button on the list report page and not on the object page?

Yes this works.
The marked entry was in draft and field1 = 456, bevor click on confirm.
After execute action confirm: field1 = Test and when I navigate to the object page, the entry is active.
Thanks again for your help. If you find a way to update the object page with the active data and switch to display mode, it would be great. Currently I find it very very difficult to get information as soon as you leave the standard examples.
Regards Florian
| User | Count |
|---|---|
| 11 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.