Skip to Content
Apr 04, 2022 at 07:44 PM

Handling of mandatory fields in ABAP RAP based web API?


Let's say I'm working on a web API to provide CRUD operations for a custom (Z...) table. I'm using a textbook unmanaged RAP scenario implementation with CDS, behavior definition and all that. There are, say, 20 fields in the table and 10 fields out of them are mandatory/required, i.e. must be filled in in order to perform create and update operations with a table. Fiori is not used in this scenario.

In the good old SEGW world I believe we had "not nullable" (?) checkbox that would trigger a message from SAP Gateway. Or we also had an option to get a list of all properties/values at the beginning of the corresponding method, run through them and provide a message (or multiple messages) respectively.

With ABAP RAP, unfortunately, I'm just not finding any examples of implementing similar functionality. There is "mandatory" designation for the field but it does not actually do anything. There doesn't seem to be any simple "not nullable" option.

The scenarios that talk about field validation are typically more complex and use FOR VALIDATION methods. Is this the way to go in this scenario? Creating 10 methods with boilerplate "IF ... IS INITIAL" code seems a bit excessive... I can do it if that's the way but is there by chance some other option?

There was a similar question about a Fiori-related scenario but the answer there doesn't really answer my question: