New Function Definition $[internal$] $[static$] function FunctionName $[external 'ExternalName'$] $[InputParameter >$] OutputParameter> >
What does it do? You can specify new actions> and functions> for a projection BO> in the projection layer. This works similar to defining actions and functions in a base BDEF; see topic TITLE > and topic TITLE >. There is a difference however regarding the authorization concept> of an action defined in a projection BDEF: In a projection BDEF, no authorization master from the base BDEF is available. If an authorization concept is required, this must be specified for each node of a BO node as described in topic RAP BDL - authorization, projection BDEF>.
ABAP_FURTHER_INFO
Development guide for the ABAP RESTful Application Programming Model, topic Action Definition>.
Development guide for the ABAP RESTful Application Programming Model, topic Function Definition>.
ABAP_EXAMPLE_VX5 - Defining an Action in the Projection Layer The following example shows a projection BDEF that defines a new action in the projection layer. It is based on the underlying base BO DEMO_RAP_UNMANAGED_AUTH>>. It defines the new action deductDiscount> in the projection layer. For this action, global authorization control> is specified. BDEF DEMO_RAP_PROJ_NEW_ACTION The ABAP behavior pool implements the global authorization control and the new action. Global authorization control: In this simple example, the condition for global authorization control is always true. METH BP_DEMO_RAP_PROJ_NEW_ACTION(CCIMP)=>GET_GLOBAL_AUTH Action deductDiscount>: The user can specify a discount percentage. This discount percentage is subtracted from the initial value of field dec_field>. METH BP_DEMO_RAP_PROJ_NEW_ACTION(CCIMP)=>DEDUCTDISCOUNT The ABAP class CL_DEMO_RAP_PROJ_NEW_ACTION>> uses EML> to access to RAP business object>. It first creates two new entity instances and then executes the action deductDiscount> for both of them. Result: The specified discount percentage is subtracted from the initial value. IMAGE ABDOC_NEW_ACTION.jpg 243 371 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 - Defining a Function in the Projection Layer The following example shows a projection BDEF that defines a new function in the projection layer. It is based on the underlying base BO DEMO_RAP_STRICT>>. It defines the new function getDetails> in the projection layer. BDEF DEMO_RAP_PROJ_NEW_FUNCTION The ABAP behavior pool implements the new function getDetails>. This function reads the values of the fields key_field> and data_field> and returns them in its result structure. METH BP_DEMO_RAP_PROJ_NEW_FUNCTION(CCIMP)=>GETDETAILS The ABAP class CL_DEMO_RAP_PROJ_NEW_FUNCTION>> uses EML> to access to RAP business object. It first creates two new entity instances and then executes the function getDetails> for both of them. Result: The content of the fields key_field> and data_field> is returned in the result structure. IMAGE ABDOC_NEW_FUNCTION.jpg 351 110 ABAP_EXAMPLE_END