![](/style/images/good.png)
![](/style/images/bad.png)
Fiori List Report : BOPF Draft/Copy Error : Active Entity Key already exists/is...
source link: https://answers.sap.com/questions/13559078/bopf-draftcopy-error-active-entity-key-already-exi.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Fiori List Report : BOPF Draft/Copy Error : Active Entity Key already exists/is initial
Trying to implement copy functionality in List Report template.
When I attempt to copy an item I am getting the error "Copy draft to active: Active Entity Key already exists"
When I attempt to create an item I am getting the error "Copy draft to active: Active Entity Key component is initial"
Any help would be much appreciated, thank you.
///////Copy Action Class/////////<br><br>class -------- definition public inheriting from /BOBF/CL_LIB_A_SUPERCL_SIMPLE final create public . public section. methods /BOBF/IF_FRW_ACTION~EXECUTE redefinition . protected section. private section. ENDCLASS. CLASS -------- IMPLEMENTATION. method /BOBF/IF_FRW_ACTION~EXECUTE. DATA: lr_head_ref TYPE REF TO data. DATA(lt_head) = VALUE ztyfin_cdsv_i_loc_dep_as( ). DATA ls_head_ref TYPE zsyfin_cdsv_i_loc_dep_as. " Retrieve the data from the Node io_read->retrieve( EXPORTING iv_node = is_ctx-node_key it_key = it_key IMPORTING et_data = lt_head ). "Copy the data from retrieved node LOOP AT lt_head REFERENCE INTO DATA(lr_head). ASSIGN lr_head->* TO FIELD-SYMBOL(<fs_head>). ls_head_ref-set_id = <fs_head>-set_id. ls_head_ref-acctg_loc_dep = <fs_head>-acctg_loc_dep. ls_head_ref-deptid = <fs_head>-deptid. ls_head_ref-es_bukrs = <fs_head>-es_bukrs. ls_head_ref-effdt = <fs_head>-effdt. ls_head_ref-eff_status = <fs_head>-eff_status. ls_head_ref-desc = <fs_head>-desc. "Copy field data CREATE DATA lr_head_ref TYPE zsyfin_cdsv_i_loc_dep_as. ASSIGN lr_head_ref->* TO FIELD-SYMBOL(<fs_head_ref>). IF <fs_head_ref> IS ASSIGNED. <fs_head_ref> = ls_head_ref. ENDIF. "Create Record io_modify->create( EXPORTING iv_node = is_ctx-node_key is_data = lr_head_ref IMPORTING ev_key = DATA(lv_copy_key) ) ENDLOOP. endmethod. ENDCLASS.
/////// Interface View ////// @AbapCatalog.viewEnhancementCategory: [#NONE] @AbapCatalog.sqlViewName: 'YFINLOCDEPTAS' @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'New Interface View for Loc Dept' @Metadata.ignorePropagatedAnnotations: true @ObjectModel.semanticKey: ['set_id', 'acctg_loc_dep', 'deptid', 'es_bukrs'] @ObjectModel.modelCategory: #BUSINESS_OBJECT @ObjectModel.compositionRoot: true @ObjectModel.transactionalProcessingEnabled: true @ObjectModel.writeActivePersistence: 'yfin_loc_dept' @ObjectModel.createEnabled: true @ObjectModel.deleteEnabled: true @ObjectModel.updateEnabled: true @ObjectModel.draftEnabled: true @ObjectModel.writeDraftPersistence: 'yfin_loc_d_as' define view -------- as select from ------- { key set_id, key acctg_loc_dep, key deptid, key es_bukrs, effdt, eff_status, desc<br>}<br>
/////// Consumption View //////<br> @AbapCatalog.sqlViewName: 'YFINLOCDEPAS' @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'New Consumption view for Loc Dept' @Metadata.allowExtensions: true @ObjectModel.semanticKey: ['set_id', 'acctg_loc_dep', 'deptid', 'es_bukrs'] @ObjectModel.transactionalProcessingDelegated: true @ObjectModel.draftEnabled: true @ObjectModel.createEnabled: true @ObjectModel.deleteEnabled: true @ObjectModel.updateEnabled: true @ObjectModel.compositionRoot: true define view --------- as select from ---------- { @EndUserText.label: 'Set ID' key set_id, @EndUserText.label: 'Acctg Loc Dep' key acctg_loc_dep, @EndUserText.label: 'Department ID' key deptid, @EndUserText.label: 'Company Code' key es_bukrs, @Consumption.filter: { selectionType: #INTERVAL } @EndUserText.label: 'Effective Date' effdt, @EndUserText.label: 'Status' eff_status, @EndUserText.label: 'Description' desc }
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK