cancel
Showing results for 
Search instead for 
Did you mean: 

Validation not triggering - ABAP RAP Unmanaged

12-09-2023 12:54 AM
AbhishekSharma Active Contributor
7438 views 10 comments Go to solution
0 Likes
Subscribe

Hi I am trying to put simple validation in Unmanaged RAP. Below is my validation method looks like

I am seeing message in yellow color... what this message means?

After some reading got to know we need to add determine action and added that method (commented in above screen shot).

Still Validation is not triggered...

In unmanaged scenario validation needs to be done in check_before_save method. So is that means Validations can not be used in Unmanaged scenario ?

I have already used Validation in Managed scenario and it works fine...

Any direction to documentation regarding this issue will help...

Thanks-

Abhishek

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

Ramjee_korada
Active Contributor

Hi Abhishek,

check if the draft determine action is already exposed in Projection Behaviour ?

// if you use validation in custom determine action - The way you commented in your code
use action trigger_all ;
Or
// if you use the validation in standard prepare action. 
// --Base behaviour
draft determine action prepare
{
validation validate_age ;
}

// -- Projection behaviour
use action prepare ;

Best wishes,

Ramjee Korada

Answers (2)

Answers (2)

DiegoValdivia
Active Participant

Hi Abhishek,

When using validations in Unmanged Scenario + Draft. The validations must be attached to any of the Draft Actions (SAP names them "Actions", but I see them as events).

In my case, I created the following validation to validate Mandatory Fields when Draft is going to be persisted:

Regards.

AbhishekSharma
Active Contributor
0 Likes

Hi diegovaldivia

Thanks much for your response...

I understood this and I tried this as well but I don't know how to call this "Prepare" method (in your example)

Do I need to implement determination as well ? How this validation will get Triggered ?

This validation will not Trigger until there is a Draft entry in system or Validation will only be Triggered when opening Draft entry to make any changes ?

Thanks-

Abhishek

DiegoValdivia
Active Participant

Hi Abhishek,

The Prepare method will be called automatically by the RAP framework as soon as you press the Save button.

The RAP Framework usually calls those Draft actions implicitly, that is, we developers don't need to implement any code to handle such Actions, but in cases where we need to do "something" when certain action occurs, then we need to add some code to given actions. In the code in my screenshot, I'm telling the framework to execute given validation when the user presses the Save button.

You don't need to implement the Determination in my screenshot, I'm using it for other stuff not related to your question.

Please refer to following documentation for further information:

RAP - Draft Actions

I would suggest to implement the Validation method, then set a breakpoint inside it and save a Draft document. You will be able to see the moment it's called.

Regards.