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

ABAP RAP Unmanaged API not Triggering SAVE method

AbhishekSharma
Active Contributor
0 Kudos
912

Hi Gurus,

I have created V4 API using Unmanaged RAP Scenario... When I am trying to create record using API in Gateway test tool, records are getting creating in Draft mode and they are not getting Saved. SAVE method is not getting triggered... I have Implemented Early Numbering which is getting triggered along with Create Method...

Everything is working fine when I using testing same service using Preview Option in Eclipse.

Please help what am I missing...

Early Numbering code

METHOD earlynumbering_create.

    DATA: l_tanum         TYPE /scwm/tanum,
          l_returncode(1) TYPE c.
    CALL FUNCTION 'NUMBER_GET_NEXT'
      EXPORTING
        nr_range_nr        = '01'
        object             = wmegc_nrobj_to
        subobject          = 'WD01'
      IMPORTING
        number             = l_tanum
        returncode         = l_returncode
      EXCEPTIONS
        interval_not_found = 1.
    LOOP AT entities ASSIGNING FIELD-SYMBOL(<lfs_entities>).
      l_tanum = l_tanum + 1.
      mapped-warehousetask  =   VALUE #(
        FOR ls_entities IN entities WHERE ( tanum is INITIAL )
        (
            %cid    = ls_entities-%cid
            %is_draft   =   ls_entities-%is_draft
            tanum   =   l_tanum
        )
      ).
    ENDLOOP.
  ENDMETHOD.

Behavior Definition

unmanaged implementation in class zbp_i_openwt unique;
strict;
with draft;
define behavior for ZI_OPENWT alias WarehouseTask
draft table Zordim_o_d
//late numbering
early numbering
lock master
total etag ChangeAt
authorization master ( global )
etag master ChangeAt
{
  create;
  update;
  delete;
  field ( readonly ) Tanum;
  field ( readonly ) CreatedBy;
  field ( readonly ) Letyp;
  field ( readonly ) CreatedAt;
  draft action Edit;
  draft action Activate;
  draft action Discard;
  draft action Resume;
  draft determine action Prepare;
  mapping for /scwm/ordim_o {
    Lgnum   =   lgnum;
    Tanum   =   tanum;
    Letyp   = letyp;
    Procty  = procty;
    Tostat  =   tostat;
    Vlenr   =   vlenr;
    ChangeAt    =   changed_at;
    CreatedAt   =   created_at;
    CreatedBy   =   created_by;
  }
}

CREATE method

  METHOD create.
    DATA: lo_entity_store TYPE REF TO zcl_datastore_rap,
          ls_entity       TYPE /scwm/s_ordim_o_rf.
    lo_entity_store = zcl_datastore_rap=>get_object(  ).
    LOOP AT entities ASSIGNING FIELD-SYMBOL(<lfs_owt>).
      ls_entity-vlenr_o   = <lfs_owt>-vlenr.
      ls_entity-nlpla_o   = <lfs_owt>-nlpla.
      INSERT VALUE #( %cid = <lfs_owt>-%cid ) INTO TABLE mapped-warehousetask.
    ENDLOOP.
    lo_entity_store->put_data( data_in = ls_entity ).
  ENDMETHOD.

Please help.

Thanks-

Accepted Solutions (1)

Accepted Solutions (1)

junwu
SAP Champion
SAP Champion
in the payload for creation, you have to include IsActiveEntity:true
if not, it will create draft, which will not trigger "save sequence"
AbhishekSharma
Active Contributor
0 Kudos
Hi @junwu, thank you for helping me, your suggestion worked...

Answers (1)

Answers (1)

Marian_Zeis
Active Contributor
0 Kudos
AbhishekSharma
Active Contributor
0 Kudos
Hi I am using unmanaged scenario, still I need to mention “with unmanaged save” ?