Skip to Content
0
Feb 04, 2022 at 04:17 PM

ABAP RESTful Application Programming Model - How do I validate mandatory fields?

1915 Views Last edit Feb 04, 2022 at 04:25 PM 3 rev

(Using RAP in an unmanaged scenario with SAP API's via consumption models)

I have the following Behaviour Definition setup, with a root SalesOrder entity and it's associated SalesOrderItem entity.

I've setup the mandatory control field on Material and RequestedQty, which adds the red asterisk to those fields in the UI (Elements).


unmanaged;
define behavior for /N4C02/CE_ORDER_SEARCH alias SalesOrder
implementation in class /n4c02/bp_ce_order_search unique
lock master
authorization master ( instance )
{
association _Items { create ; }
}
define behavior for /N4C02/CE_ORDER_SEARCH_ITEMS alias SalesOrderItem
implementation in class /n4c02/bp_ce_order_srch_items unique
lock dependent by _SalesOrder
authorization dependent by _SalesOrder
{
create; field ( readonly ) SalesOrder, SalesOrderItem, SalesOrderItemText;
field ( mandatory ) Material, RequestedQuantity;
association _SalesOrder;
}

Unfortunately, that's all it does...

I've looked a little further into feature controls, but that seems to be focussed on the 'Actions' (e.g. Create, Delete, or user defined).

My question is how exactly are the mandatory fields validated in the Behaviour Implementation?

Is this done manually by checking them individually and throwing an exception? ...

...Or is there a way to perhaps disable the Save button until all mandatory fields have a value?