Skip to Content

Prevent entity create in BOPF with validation ? Or somehow else ?

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Nov 06, 2019 at 08: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.