Skip to Content
0

Detected duplicate member ID 'xxxx' when saving dimension's members using Abap code

Jan 19, 2017 at 07:23 AM

76

avatar image
Former Member

Hi,

I am trying to save a new member to a PBC dimension, but always I have this error Detected duplicate member ID 'I175' despite there is no duplication in the data.

My code to save members is :

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

function zbw_bpc_dim_insert .

*"----------------------------------------------------------------------

*"*"Local Interface:

*"----------------------------------------------------------------------

  data:

    v_appset_id          type uj_appset_id value 'UNRWA_RBM_TRAINING',

    v_appl_id            type uj_appl_id value 'RBM_Model',

    v_dimension_id       type uj_dim_name value 'INDICATORS_RBM',

    w_message            type uj0_s_message,

    i_messages           type uj0_t_message,

    v_success            type uj_flg,



    or_member_mgr        type ref to if_uja_member_manager,

    or_dimension         type ref to if_uja_dimension_manager,

    or_master_data_store type ref to if_ujam_master_data_store,

    or_context           type ref to if_uj_context,

    w_dimension          type uja_s_dimension,

    i_erros              type uja_t_members_error,

    i_save_messages      type uj0_t_message,

    i_save_excp          type uj0_t_message,

    i_members            type ref to data,

    w_data               type ref to data.



  field-symbols:

    <fs_t_memeber_data> type standard table,

    <fs_member_data>    type any,

    <fs_field>          type any.



  try.

      or_context = cl_uj_context=>get_cur_context( ).



      cl_uj_context=>set_cur_context(

       i_appset_id = v_appset_id

       i_appl_id = v_appl_id

       i_module_name = or_context->d_calling_module

       is_user = or_context->ds_user

      ).



      or_dimension = cl_uja_bpc_admin_factory=>get_dimension_manager(

      i_appset_id = v_appset_id

      i_application_id = v_appl_id

      i_dimension_id = v_dimension_id

      ).

      or_dimension->get(

       exporting

         if_with_hier_maxlevel = abap_false

       importing

        es_dimension = w_dimension

      ).



      create object or_master_data_store type cl_ujam_master_data_store.



      "create masterdata table

      i_members = or_master_data_store->get_table_buffer( w_dimension ).

      assign i_members->* to <fs_t_memeber_data>.



      "Add memebers

      create data w_data like line of <fs_t_memeber_data>.

      assign w_data->* to <fs_member_data>.



      "Fill each field, such as ID, and EVDDESCRIPTION, ..etc

      assign component 'ID' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'I175'.

      endif.



*      assign component 'MBR_NAME' of structure <fs_member_data> to <fs_field>.

*      if sy-subrc = 0.

*        <fs_field> = 'adham MBR_NAME'.

*      endif.



      assign component 'EVDESCRIPTION' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'adham EVDESCRIPTION1'.

      endif.



      assign component 'OBJVERS' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'A'.

      endif.



      assign component 'ROWFLAG' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'I'.

      endif.



      assign component 'PROGRAMME' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'health1'.

      endif.



      assign component 'INDICATOR_TYPE' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'QT'.

      endif.



      assign component 'AGG_AW' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'Sum AW'.

      endif.

      assign component 'AGG_FO' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'Sum FO'.

      endif.

      assign component 'CALC' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'N'.

      endif.

      assign component 'LEVEL_TYPE' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'OT'.

      endif.

      assign component 'MEASURE' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'N'.

      endif.

      assign component 'PATTERN' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'INC'.

      endif.



      assign component 'STATUS' of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'Y'.

      endif.



      assign component 'TARGET_TYPE'of structure <fs_member_data> to <fs_field>.

      if sy-subrc = 0.

        <fs_field> = 'Equal'.

      endif.



      append <fs_member_data> to <fs_t_memeber_data>.



      "Create member manager

      or_member_mgr = cl_uja_bpc_admin_factory=>get_member_manager(

       i_appset_id = v_appset_id

       i_application_id = v_appl_id

       i_dimension_id = v_dimension_id

      ).



      "Save the memebers

      or_member_mgr->save(

       exporting

        ir_members = i_members

       importing

        et_errors = i_erros

        et_exception_messages = i_save_excp

        et_messages = i_save_messages

      ).



      "process the dimensaion

      data: w_dimensions type uja_s_dim_name,

            i_dimensions type uja_t_dim_name.



      clear w_dimensions.

      refresh i_dimensions.



      w_dimensions-dimension = v_dimension_id. "Add dims to the list

      append w_dimensions to i_dimensions.



      or_member_mgr->process(

       exporting

       it_dim_list = i_dimensions

       if_set_offline = abap_false

       if_validate = abap_true

       importing

        ef_success = v_success

        et_message_lines = i_messages

      ).



    catch cx_uj_no_auth.

      message 'No auth' type 'E'.

  endtry.

endfunction.
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Vadim Kalinin Jan 19, 2017 at 08:26 AM
0

I am unable to help you without debugging of your code and detailed info about dimension used. Please read the document:

http://www.sap.com/documents/2015/08/6c91e080-5b7c-0010-82c7-eda71af511fa.html#

and compare your code with D. Example: Process Dimensions and Save Members

Show 6 Share
10 |10000 characters needed characters left characters exceeded

P.S. I also don't see the code to process dimension...

assign component'CALC'o...

looks strange...

Also no hierarchy assignments done...

0
Former Member
Vadim Kalinin

Sorry, I am new to PBC processing .. what do you mean in hierarchy assignments ?

Actually I am following same code in the document you shared.

0

Please show the screenshot of dimension INDICATORS_RBM administration! To see properties and hierarchies!

Do you process dimension manually?

0
Former Member
Vadim Kalinin

here is screenshot

s1.png (83.4 kB)
0
Former Member
Former Member

PS. I can process the dimension members manually

0
Former Member
Vadim Kalinin

There is no hierarchy, but there is texts .. should I save texts as well ? I think so ...

0
Vadim Kalinin Jan 19, 2017 at 07:58 AM
0

Sorry, but in your code ID I175 is fixed! Second run will have duplicate error.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

I got this error from the first run!

0
Vadim Kalinin Jan 19, 2017 at 09:09 AM
0

In your code missing lines:

ASSIGN COMPONENT 'MBR_NAME' OF STRUCTURE <fs_member_data> TO <fs_field>.

IF sy - subrc = 0.

<fs_field> = 'I175'.

ENDIF.

Has to be the same as ID!

Remove code:

assign component 'CALC' of structure <fs_member_data> to <fs_field>.
if sy-subrc = 0.
<fs_field> = 'N'.
endif.

Add dimension processing code!

And process dimension manually!

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank you sir, it is working now. After saving the texts (Member Id and it's description) it saves the member correctly now!

0

Then Accept the correct answer and close the question!

0

Please read also this useful document:

https://archive.sap.com/documents/docs/DOC-4276

code can be imported from transport.

0