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

RAP - Operation Augmentation

Rory_A
Explorer
0 Likes
745

I am having a problem trying to get operation augmentation working for my RAP managed scenario project. This is in an on-premise system.

Root View

define root view entity ZI_OMSOPPS_PRICING
  as select from zoms_oppspricing
{
  key matnr                 as Material,
  key charg                 as Batch,
  key werks                 as Plant,
      @Semantics.amount.currencyCode: 'Currency'
      kbetr                 as Price,
      konwa                 as Currency,
      validfrom             as ValidFrom,
      validto               as ValidTo,
      @Semantics.user.createdBy: true
      local_created_by      as LocalCreatedBy,
      @Semantics.systemDateTime.createdAt: true
      local_created_at      as LocalCreatedAt,
      @Semantics.user.localInstanceLastChangedBy: true
      local_last_changed_by as LocalLastChangedBy,
      @Semantics.systemDateTime.localInstanceLastChangedAt: true
      local_last_changed_at as LocalLastChangedAt,
      @Semantics.systemDateTime.lastChangedAt: true
      last_changed_at       as LastChangedAt

}

Projection View

define root view entity ZC_OMSOPPS_PRICING 
  as projection on ZI_OMSOPPS_PRICING
{
  key Material,
  key Batch,
  key Plant,
  Price,
  Currency,
  ValidFrom,
  ValidTo,
  LocalLastChangedAt
  
}

Behavior Definition for Root

managed; 
define behavior for ZI_OMSOPPS_PRICING alias Pricing
persistent table zoms_oppspricing
lock master
etag master LocalLastChangedAt
{
  field ( mandatory : create )
  Material,
  Batch,
  Plant;

  field ( readonly )
  LocalCreatedAt,
  LocalCreatedBy,
  LastChangedAt,
  LocalLastChangedAt,
  LocalLastChangedBy;

  field ( readonly : update )
  Material,
  Batch,
  Plant;
  //End this section added

  create;
  update;
  delete;

Behavior Definition for Projection

projection implementation in class zbp_c_omsopps_pricing unique;
//strict ( 2 );

define behavior for ZC_OMSOPPS_PRICING alias Pricing
{
  use create (augment);
  use update;
  use delete;
}

Class with the augmentation code

METHOD augment_create.
    DATA: pricing_create TYPE TABLE FOR CREATE zi_omsopps_pricing.

    pricing_create = CORRESPONDING #( entities ).
    LOOP AT pricing_create ASSIGNING FIELD-SYMBOL(<pricing>).
      <pricing>-currency = 'EUR'.
      <pricing>-%control-currency = if_abap_behv=>mk-on.
    ENDLOOP.

    MODIFY AUGMENTING ENTITIES OF zi_omsopps_pricing ENTITY Pricing CREATE FROM pricing_create.

  ENDMETHOD.

So the augment_create method gets called but it never modifies my "Currency" field so Im not sure if my Entity names are incorrect or referenced incorrectly.

Thanks

View Entire Topic
junwu
SAP Champion
SAP Champion
0 Likes

can you check the amount field associated with that currency filed is editable or not?

Rory_A
Explorer
0 Likes
Yes it is editable as well.
Rory_A
Explorer
0 Likes
And I have tried other fields like the Price field and that did not work either.