What does it do? Factory actions> are used to create RAP BO entity instances>. Factory actions can be instance-bound or static. Instance-bound factory actions can copy specific values of an instance. Static factory actions can be used to create instances with prefilled default values. For factory actions, the same rules apply as for non-factory actions> with the following differences:
Output parameters OutputParameter> are not allowed. A factory action always produces one new BO entity instance for which it is declared. It is therefore not necessary to specify the result in the BDL. Factory actions may also create child entity instances.
It is mandatory to specify a cardinality. The cardinality must always be [1]> for factory actions. The result of a factory action is returned in the response parameter > MAPPED> by a mapping between the BDEF derived type> %cid> and the key of the newly created entity instance. Exactly one static factory action can be defined as default factory action using the syntax addition default>. This definition of default factory actions has an effect on consuming frameworks, such as OData. For further details, see topic TITLE >.
ABAP_AVAILABILITY
Managed RAP BO>
Unmanaged RAP BO>
In a projection BO>, factory actions from the base BDEF can be reused. For details on reuse, see topic TITLE >. It is also possible to specify new factory actions as described in topic RAP BDL - actions and functions, projection BDEF>. ABAP_AVAILABILITY_END
ABAP_EXAMPLE_VX5 The following example shows a managed BDEF> which defines two factory actions:
copy_instance>: All values of the requested entity instance are copied and a new key value is assigned.
new_instance>: A new entity instance is created with default values. BDEF DEMO_RAP_FACTORY_ACTION The actions are implemented in behavior pool BP_DEMO_RAP_FACTORY_ACTION> >. The class CL_DEMO_RAP_FACTORY_ACTION> > accesses the business object using EML> and executes both actions. Result: the entity instance with key field 1> is copied and a new entity instance with default values is created. ABAP_EXAMPLE_END
ABAP_EXAMPLE_ABEXA The example above is explained in detail in the executable example RAP BDL - factory action>. ABAP_EXAMPLE_END