cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP RAP - Behavior Projection and Implementation Class

asm_sapdev
Explorer
0 Kudos

Hi All,

I am building a sample app to learn RAP. I created a BO with two fields. This BO has @AccessControl.authorizationCheck: #CHECK annotation. This BO does not need any additional functionality hence after creating Behavior Definition, I thought I will skip creating behavior implemntation class and created service,

While testing the service, when I create a record, I get following error in the browser.

Runtime Error: 'RAISE_SHORTDUMP'. The OData request processing has been abnormally terminated. If you use SAP S/4HANA Cloud, please create an incident. Otherwise, if "Runtime Error" is not initial, launch ADT feed "Runtime Errors" or transaction ST22 / SM21 (system log analysis) for details and analysis.

In ADT, I can see following error(s)

Gateway error log - Backend Error: Metadata cache on hub system for current model is outdated

I also got another error, which I thought was not related to above.

The current program has intentionally triggered a termination with a short dump.

The dump analysis revealed "The exception is related to the previous exception "CX_RAP_HANDLER_NOT_IMPLEMENTED" that occurred in
program "CL_RAP_BHV_PROCESSOR==========CP", in line 30 of include "CL_RAP_BHV_PROCESSOR==========CM01G". The reason for this exception
was: Handler not implemented; Method: GLOBAL_AUTHORIZATION, Involved Entities: ZC_LV_CAT_9000"

While trying to figure out how to resolve cache issue, I decided to create the implementation class which would fix the error, The current program has intentionally triggered a termination with a short dump. however after creating the class, I did not write a single line of code and all the errors disappeared.

I am struggling to understand the relationship between the implemntation class and the other two errors. I'll appreciate any guidance in this context.

Regards

ASM

asm_sapdev
Explorer
0 Kudos

Now I udnerstand whats going on. Thanks everyone for taking time to resolve my query.

Regards

ASM

Accepted Solutions (1)

Accepted Solutions (1)

naveen_k1
Product and Topic Expert
Product and Topic Expert
0 Kudos

Relationship Between Implementation Class and Errors

When you created the behavior definition with @AccessControl.authorizationCheck: #CHECK, you instructed the RAP framework to enforce authorization checks. The framework then expects to find a corresponding implementation that defines this logic. However, as you initially skipped creating the behavior implementation class, the framework couldn't find the necessary code to execute this check, leading to the CX_RAP_HANDLER_NOT_IMPLEMENTED error.

When you eventually created the behavior implementation class, even without adding any specific code, you effectively provided the framework with a placeholder where it expects to find the authorization logic. By doing so, you satisfied the framework's requirement to have an implementation class associated with the behavior definition that includes authorization checks.

The absence of the implementation class was indirectly causing the "Metadata cache" issue as well. The RAP framework relies on a consistent and up-to-date view of the metadata to operate correctly. When part of the expected implementation (like the authorization handler) is missing, it can disrupt the normal operation and caching of metadata, leading to such errors. Once you added the implementation class, the framework's expectations were met, allowing it to correctly process and cache metadata, which resolved the "Backend Error: Metadata cache on hub system for current model is outdated" error as well.

asm_sapdev
Explorer
0 Kudos

Thanks @naveen_k1 for your detailed and clear explaination. Somehow it did not appear earlier. I can now understand why I was getting the error.

Thanks 

ASM

Answers (2)

Answers (2)

SachinArtani
Participant
0 Kudos

The relationship is not between the annotation @AccessControl.authorizationCheck: #CHECK and the implementation class, but when you create a Behavior Definition (BDEF), and you specify strict mode, you must specify - "authorization master". And when you do that, you must define a method in the implementation class for this.
Now, if you skip creating the implementation class, the framework will be unable to find a method corresponds to authorization you have defined in the BDEF, hence the dump.
Also, the method will be part of local class inheriting from CL_ABAP_BEHAVIOR_HANDLER, hence the exception raised is CX_RAP_HANDLER_NOT_IMPLEMENTED.

asm_sapdev
Explorer
0 Kudos
Hi Sachin, Thanks for your inut. Yes previously I did not use strict mode and removed authorization master (global/instance) from the BDEF. Then I did not need to create the implementation class. However if I choose to keep strict mode and just create the implementation class, things worked, So I am just curious about how the things worked.
SachinArtani
Participant
0 Kudos

Hi @asm_sapdev, As I mentioned earlier, the framework expects a method declaration for authorization. It does not matter if you don't implement it. But it must be present and for a method to exist, a class must persist. Hence, it's needed.

If your query has been resolved by anyone's answer, please mark that answer as accepted. 🙂

DiegoValdivia
Participant
0 Kudos

Hi,

I think there's a confusion with the authorization terms. See next:

  • @AccessControl.authorizationCheck: #CHECK is declared in the CDS. It indicates that authorization checks will be performed during runtime for data to be read from the database. You must create an Access Control, which will basically filter data read from the database based on user authorization
  • The Authorization you declare in the Behavior definition limits the permission to perform certain operations for a RAP BO. For example, you can check authorization to delete certain instances, depending on specific values.

I hope this helps.

asm_sapdev
Explorer
0 Kudos

Hi,

Thanks for providing the explaination. I think I may not have explained my problem clearly.

My understanding is -

  1. I have to use AccessControl annotation in CDS view and it means authorization checks will be performed during runtime for data to be read from the database.
  2. I will have to handle thiose checks in my behavior implementation class, I will have to use some code to perform those checks. I did not created the class and got error.
  3. However, I created an empty behavior implementation class, did not perform any checks and yet the error was fixed. What I don't understand is, what caused the error to go away.

Hope it is more clear now. Once again thanks for your help.

Regards

ASM

SachinArtani
Participant
0 Kudos
Hi @asm_sapdev, The AccessControl annotation in CDS view allow us to use that BO in access control data definition that we create. It is used for data level restriction. While, the authorization you see in Behavior Definition is to implement the authorization on UI level. So, if you don't want to create implementation class, don't use strict mode and remove authorization master (global/instance) from the BDEF.