Hi everyone,
I defined a API using RAP. Here below all the details.
ROOT ENTITY
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Sales Report (SLSRPT from Lobster)'
@Metadata.ignorePropagatedAnnotations: true
define root view entity ZLBSR_R_SALES_DATA
as select from zsd_lbstr_slsrpt
{
key uuid as UUID,
erdat as CreationDate,
erzet as CreationTime,
ernam as CreationUser,
status as Status,
bstkd as CustomerReference,
bstdk as CustomerReferenceDate,
ean11 as ArticleEAN11,
// @Semantics.quantity.unitOfMeasure: 'QuantityUnitOfMeasure'
kwmeng as Quantity,
vrkme as QuantityUnitOfMeasure,
vdatu as RequestedDeliveryDate,
sold_to_party_gln as SoldToPartyGLN,
ship_to_party_gln as ShipToPartyGLN,
@Semantics.systemDateTime.localInstanceLastChangedAt: true
local_last_changed as LocalLastChanged,
@Semantics.systemDateTime.lastChangedAt: true
last_changed as LastChanged
}BEHAVIOUR DEFINITION
managed implementation in class zbp_lbsr_r_sales_data unique;
strict ( 2 );
define behavior for ZLBSR_R_SALES_DATA alias SalesData
persistent table zsd_lbstr_slsrpt
lock master
authorization master ( instance )
etag master LastChanged
{
field ( readonly )
UUID,
CreationDate,
CreationTime,
CreationUser,
Status,
LastChanged,
LocalLastChanged;
field ( numbering : managed )
UUID;
create;
update;
delete;
determination fill_administrative_data on save { create; }
static action deleteWithFilters parameter ZLBSR_D_DELETION_FILTERS;
mapping for zsd_lbstr_slsrpt
{
UUID = uuid;
CreationDate = erdat;
CreationTime = erzet;
CreationUser = ernam;
Status = status;
CustomerReference = bstkd;
CustomerReferenceDate = bstdk;
ArticleEAN11 = ean11;
Quantity = kwmeng;
QuantityUnitOfMeasure = vrkme;
RequestedDeliveryDate = vdatu;
SoldToPartyGLN = sold_to_party_gln;
ShipToPartyGLN = ship_to_party_gln;
LocalLastChanged = local_last_changed;
LastChanged = last_changed;
}
}ABSTRACT ENTITY ZLBSR_D_DELETION_FILTERS
@EndUserText.label: 'Sales Report - Filters for deleteWithFilters action'
define abstract entity ZLBSR_D_DELETION_FILTERS
{
CustomerReference : bstkd;
SoldToPartyGLN : zlbstr_slsrpt_sold_to_prty_gln;
ShipToPartyGLN : zlbstr_slsrpt_ship_to_prty_gln;
}The 3 fields CustomerReference, SoldToPartyGLN and ShipToPartyGLN are all character fields with different lenghts.
When I send a POST request for the action deleteWithFilters I have always to declare the value for all the 3 parameters. I could always declare the ShipToPartyGLN as empty (like "ShipToPartyGLN": "") and that works but I'd like to set the ShipToPartyGLN as optional in order to avoid the caller to set this parameter everytime. How can I do that?
Thanks!
Request clarification before answering.
Hi @emalelez15 ,
Try using Abstract Behavior Definition as shown in the screenshots below,
mandatory:execute: Marks CustomerReference and SoldToPartyGLN as required in the request body,
ShipToPartyGLN is not marked, so it should be optional
I hope this helps you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Oleg_Vokh,
Thanks for your response. In order to create a behaviour, I had to change the definition of the abstract entity adding "root".
@EndUserText.label: 'Sales Report - Filters for deleteWithFilters action'
define root abstract entity ZLBSR_D_DELETION_FILTERS
{
CustomerReference : bstkd;
SoldToPartyGLN : zlbstr_slsrpt_sold_to_prty_gln;
ShipToPartyGLN : char100;
}Then I create the behaviour:
abstract;
strict ( 2 );
with hierarchy;
define behavior for ZLBSR_D_DELETION_FILTERS alias DeletionFilters
with control
{
field ( mandatory : execute )
CustomerReference,
SoldToPartyGLN;
}I unpublished the service, the published it, cleaned the cache, but I still get this error:
Any other suggestions?
@emalelez15
I just published the service and was able to test it. Everything works for me.
I think this might be because in Behavior Definition you just specified a parameter, but you need a deep parameter.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.