11-05-2019 2:35 PM
Hello BOPF Gurus,
I've implemented a validation, and hooked it to the CREATE of the entity
I add the entity being created to the failed keys, and set some messages, due prerequisites to create the entity are not fullfilled. I want to prevent to persist the entity data just created.
MESSAGE e010 INTO msg.
MOVE-CORRESPONDING sy TO message.
c_message->add_message(
is_msg = message
iv_node = zif_i_fi_geninvi_c=>sc_node-zi_fi_geninviexp
iv_key = <expense>-key
).
add_failed_key( EXPORTING i_key = <expense>-key CHANGING c_failed_keys = e_failed_keys ).
This way no success, the entity is peristed successfully, and SADL returns the new entity to the browser together with the error messages.
I've tried to set the target(attribute) in the message and change the lifecycle, no luck. No other operations are executed in the batch request in the UI.
What is the best way to prevent creation of the entity ? (I started to debug the framework, but seems creation is still possible, when consistency checks fail. Frankly, I stopped debugging the BO framework. To get a whole picture in short time with debugging is not enough )
I have the following workarounds:
1. Add a BOPF action CREATE, which will create the entity manually instead of the Framework, and complement this with an action validation(put my checks here), which can prevent the execution of the CREATE action. Not nice to hide node instance creation into actions, but everything is kept within the BO.
2. Redefine the SAP Gateway Data provider class for the create operation, and do the checks there, before calling the generic SADL handler for create. I would rather avoid this, due validation will be out of my BO document. I'll loose the checks, when I want to reuse my BO in ABAP to do some mass automatic operations in bg. This will be even not transparent for maintenance, that code will be hard to find by anyone.
Maybe to move the checks to a determination called CHECK_CREATE may help, together changing the Evaluation time point to the very early stage in BOBX ?
We're on level 7.5 sp9.
Any suggestions are welcome on that CDS BOPF SADL GW lane 🙂
Thank you
11-06-2019 8:32 AM
Consistency Validations (in contrast to Action Validations) don't prevent modifications. But they can prevent saving. Setting the check box "Check Before Save" should make this work.
11-06-2019 8:32 AM
Consistency Validations (in contrast to Action Validations) don't prevent modifications. But they can prevent saving. Setting the check box "Check Before Save" should make this work.
11-07-2019 8:44 AM
Thank you Ivo, working as expected. You provide valueable help in BOPF area always. Best regards