SAP BDL ACTION INPUT PARAM



Get Example source ABAP code based on a different SAP table
  


• PARAMETER ABAP_BDL_BODY, input parameter
• DEEP ABAP_BDL_BODY
• TABLE ABAP_BDL_BODY
• PARAMETER $SELF ABAP_BDL_BODY

ABAP_RAP - InputParameter

ABAP_SYNTAX_FORMS

Flat Parameter
... parameter ${ ParameterEntity $| $self $};

Deep Parameter
... $[deep $[table$]$] parameter AbstractBDEF;

ABAP_ALTERNATIVES:
1 ... parameter ${ ParameterEntity $| $self $};
2 ... $[deep $[table$]$] parameter AbstractBDEF;

What does it do?
Defines an input parameter for an action or function . The input parameter can be flat or deep.

ABAP_FURTHER_INFO
Development guide for the ABAP RESTful Application Programming Model, topic Action Definition.

ABAP_EXAMPLE_VX5
The following example shows a managed BDEF based on the CDS root view entity DEMO_CDS_ACTION_INPUT_PARAM. The business object describes a purchase order item. The BDEF defines one action, deductDiscount. This action has an input parameter for the discount percentage and it calculates the price of an item minus the discount. It is implemented in the behavior pool BP_DEMO_CDS_ACTION_INPUT_PARAM.
BDEF DEMO_CDS_ACTION_INPUT_PARAM
The class CL_DEMO_CDS_ACTION_REDUCE accesses the business object using EML and carries out the following operations:
It asks the user to specify the discount in percent.
It creates two instances of a purchase order item, identified by the key PurchaseDocumentItem, and assigns a price Price to each.
It executes the action deductDiscount.
Using the AB_SQL SELECT statement, the content of the underlying database table is displayed.
Result: the price is reduced by the specified discount - here, the discount was specified as 10 percent.
IMAGE ABDOC_ACTION_DISCOUNT.png 389 253
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
The example above is explained in detail in the executable example RAP BDL - action with input parameter.
ABAP_EXAMPLE_END

ABAP Alternative 1 parameter ${ ParameterEntity $| $self $}

What does it do?
The input parameter entity ParameterEntity can be a CDS abstract entity or a classic DDIC type
$self can be specified if the input parameter entity is the same abstract entity the action or function is assigned to.
Input parameters with $self are only allowed on static actions or functions. When specified for instance actions or functions, there is no syntax check warning, and a runtime error occurs instead when a RAP BO consumer accesses the action or function in question.



Latest notes:

If BDEF strict mode is enabled, $self is not allowed as input parameter.
If a CDS abstract entity is specified as input parameter, the annotation EndUserText.label can be used to define a label that is displayed on the user interface in an OData scenario.
NON_V5_HINTS
ABAP_HINT_END

ABAP Alternative 2 $[deep $[table$]$] parameter AbstractBDEF

What does it do?
The input parameter AbstractBDEF must be a RAP abstract BDEF with hierarchy. The BDEF derived type for an abstract BDEF is a hierarchy that contains all entity fields plus a component for every composition.
The following syntax options are available:
deep parameter AbstractBDEF: The input parameter is interpreted as a structure.
deep table parameter AbstractBDEF: The input parameter is interpreted a table.



Latest notes:

An abstract BDEF can also be used as input parameter only with the keyword parameter. In this case, it is interpreted as flat parameter. It represents the same derived type as a single CDS abstract entity and does not offer any additional value.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following example shows an abstract BDEF with three nodes that is constructed as hierarchy.
BDEF DEMO_CDS_ABSTRACT_ROOT
The managed BDEF DEMO_CDS_DEEP_PARAMETER uses the abstract BDEF as action parameter in three actions.
BDEF DEMO_CDS_DEEP_PARAMETER
The abstract BDEF is used as flat parameter, as structure, or as table, depending on the keywords used.
Usage as flat parameter in action a2_from_flat
IMAGE ABDOC_ABSTRACT_FLAT.jpg 417 74
Usage as structure in action a2_from_deep
IMAGE ABDOC_ABSTRACT_STRUCTURE.jpg 434 203
Usage as table in action a2_from_deep_table
IMAGE ABDOC_ABSTRACT_TABLE.jpg 479 199
ABAP_EXAMPLE_END