cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function import is not unique for actions

ivansofronic
Associate
Associate
0 Kudos
847

I am playing around with RAP so I created some demo app. I defined root entity ZIS_I_Training and projection of it in ZIS_C_Training.

Here is the definition of these entities

define root view entity ZIS_I_Training
as select from zis_a_training as Training
composition [0..*] of ZIS_I_Participant as _Participant
composition [0..*] of ZIS_I_TrainingTask as _Task
association [1..1] to ZIS_I_Status as _Status on $projection.Status = _Status.Status
{
@ObjectModel.text.element: ['Name']
@Search.defaultSearchElement: true
key training_uuid as TrainingUuid,
@Search.defaultSearchElement: true
name as Name,
@Search.defaultSearchElement: true
@ObjectModel.foreignKey.association: '_Status'
@Consumption.valueHelpDefinition: [{entity:{name: 'ZIS_I_Status', element: 'Status' }}]
status as Status,
valid_to as ValidTo,
created_by as CreatedBy,
created_at as CreatedAt,
last_changed_by as LastChangedBy,
last_changed_at as LastChangedAt,
local_last_changed_at as LocalLastChangedAt,
/* Associations */
_Participant,
_Status,
_Task
}

Here is the projection:

@EndUserText.label: 'Training projection view'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.allowExtensions: true
@Search.searchable: true
define root view entity ZIS_C_Training
provider contract transactional_query
as projection on ZIS_I_Training
{
@Search.defaultSearchElement: true
key TrainingUuid,
@Search.defaultSearchElement: true
Name,
@Search.defaultSearchElement: true
@ObjectModel.text.element: ['StatusText']
Status,
ValidTo,
@Search.defaultSearchElement: true
CreatedBy,
CreatedAt,
LastChangedBy,
LastChangedAt,
LocalLastChangedAt,
_Status._Text.StatusText as StatusText : localized,
_Participant : redirected to composition child ZIS_C_Participant,
_Task : redirected to composition child ZIS_C_TrainingTask,
_Status
}

I think that definition of associated entites is not relevant for the problem, so I will not write it here.

I wanted to check how would it be possible to grab the input from the user described in the Blog post, so I introduced new action extendValidity and defined behavior for the interface entity as follows:

managed implementation in class zbp_is_i_training unique;
strict ( 2 );
define behavior for ZIS_I_Training alias Training
persistent table zis_a_training
lock master
authorization master ( instance )
etag master LocalLastChangedAt
{
create;
update;
delete;
association _Participant { create; }
association _Task { create; }
action extendValidity parameter ZIS_I_TrainExtend result [1] $self;
field ( numbering : managed, readonly ) TrainingUuid;
field ( readonly ) CreatedBy, CreatedAt, LastChangedBy, LastChangedAt, LocalLastChangedAt;
field ( mandatory ) Name;
determination setInitialValues on modify { create; }
determination setReadFieldOnChange on save { field Name; field Status; }
mapping for zis_a_training
{
TrainingUuid = training_uuid;
Name = name;
Status = status;
ValidTo = valid_to;
CreatedBy = created_by;
CreatedAt = created_at;
LastChangedBy = last_changed_by;
LastChangedAt = last_changed_at;
LocalLastChangedAt = local_last_changed_at;
}
}

and the projection

projection;
strict ( 2 );
define behavior for ZIS_C_Training alias Training
use etag
{
use create;
use update;
use delete;
use action extendValidity;
use association _Participant { create; }
use association _Task { create; }
}

The problem is that I am getting following error after I enter date in the popup window and confirm input.

Error is: Function import 'extendValidity' is not unique for actions ZIS_I_TRAINING-EXTENDVALIDITY and ZIS_C_TRAINING-EXTENDVALIDITY

What should be the reason for this?

Accepted Solutions (1)

Accepted Solutions (1)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Ivan,

have you published ZIS_I_TRAINING as well as the projection ZIS_C_TRAINING in your service definition?

If yes, try to remove ZIS_I_TRAINING.

Another possible reason could be that ZIS_I_TRAINING is used as a value help of one of the published views?

Kind regards,

Andre

ivansofronic
Associate
Associate

Hi Andre,

ZIS_I_Training hasn't been published in the service defintion but has been used as a value help in one of the published views. After I corrected this, duplicate action error is not there any more and everything works fine. Thanks a lot for help.

Kind regards,
Ivan

Answers (3)

Answers (3)

ivansofronic
Associate
Associate
0 Kudos

I've just tried to create OData V4 service and found out that this works perfectly fine. Maybe this will help someone who has the same problem. Still, would be interested to know how to solve this for OData V2.

ivansofronic
Associate
Associate
0 Kudos

One addition. I've just added feature control for this action and implemented it

action ( features : instance ) extendValidity parameter ZIS_I_TrainExtend result [1] $self;

and now there is another error:

Action name: 'extendValidity' already exists

By debugging I see that loads both entites, ZIS_I_Training and projection of it, ZIS_C_Training and therefore it thinks that action already exists. Shouldn't it load only action from ZIS_C_Training?

ivansofronic
Associate
Associate
0 Kudos

andre.fischer do you maybe have a hint?

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Which release are you working on ?
SAP BTP ABAP Environment or SAP S/4HANA on premise (e.g. 2022) ?

ivansofronic
Associate
Associate
0 Kudos

SAP S/4HANA on premise 2022