cancel
Showing results for 
Search instead for 
Did you mean: 

BPC Master Data Deletion through ABAP code

Former Member
0 Kudos
522

Hi All,

I have a requirement of deleting the orphan nodes for one of the dimension in BPC using ABAP code.

Please let me know any standard program or classes for deleting the master data from dimension.

Regards

Pratibha Biradar

View Entire Topic
rishi4892
Participant
0 Kudos

Hi Pratibha,

Here is the code to add master data, you can change the flag to 'D' to delete, i have not checked it for delete, it is working for adding.

DATA: ls_message TYPE uj0_s_message,

lt_messages TYPE uj0_t_message,

l_success TYPE uj_flg,

l_appset_id TYPE uj_appset_id,

l_dimension_id TYPE uj_dim_name,

lo_member_mgr TYPE REF TO if_uja_member_manager,

lo_dimension TYPE REF TO if_uja_dimension_manager,

lo_master_data_store TYPE REF TO if_ujam_master_data_store,

lo_context TYPE REF TO if_uj_context,

ls_dimension TYPE uja_s_dimension,

lt_errors TYPE uja_t_members_error,

lr_members TYPE REF TO data,

lr_data TYPE REF TO data.

FIELD-SYMBOLS:

<lt_member_data> TYPE STANDARD TABLE,

<ls_member_data> TYPE any,

<lv_field> TYPE any.

TRY.

    lo_context = cl_uj_context=>get_cur_context( ).

    cl_uj_context=>set_cur_context(

    i_appset_id = l_appset_id

    i_module_name = lo_context->d_calling_module

    is_user = lo_context->ds_user

    ).

    lo_dimension = cl_uja_bpc_admin_factory=>get_dimension_manager(

    i_appset_id = l_appset_id

    i_dimension_id = l_dimension_id

    ).

    lo_dimension->get(

    EXPORTING

    if_with_hier_maxlevel = abap_false

    IMPORTING

    es_dimension = ls_dimension

    ).

    CREATE OBJECT lo_master_data_store TYPE cl_ujam_master_data_store.

* creating masterdata table

    lr_members = lo_master_data_store->get_table_buffer( ls_dimension ).

    ASSIGN lr_members->* TO <lt_member_data>.

* Add members to <LT_MEMBER_DATA>, these are the member that will be saved.

    CREATE DATA lr_data LIKE LINE OF <lt_member_data>.

    ASSIGN lr_data->* TO <ls_member_data>.

* Fill each field, such as ID, and EVDESCRIPTION, update other fields here as well as

* any properties that need to be updated.

    ASSIGN COMPONENT 'ID' OF STRUCTURE <ls_member_data> TO <lv_field>.

    IF sy-subrc = 0.

      <lv_field> = 'ProductD'.

    ENDIF.

    ASSIGN COMPONENT 'MBR_NAME' OF STRUCTURE <ls_member_data> TO <lv_field>.

    IF sy-subrc = 0.

      <lv_field> = 'ProductD'.

    ENDIF.

    ASSIGN COMPONENT 'EVDESCRIPTION' OF STRUCTURE <ls_member_data> TO <lv_field>.

    IF sy-subrc = 0.

      <lv_field> = 'Product D Update'.

    ENDIF.

    ASSIGN COMPONENT 'PARENTH1' OF STRUCTURE <ls_member_data> TO <lv_field>.

    IF sy-subrc = 0.

      <lv_field> = 'TotalProduct'.

    ENDIF.

    ASSIGN COMPONENT 'OBJVERS' OF STRUCTURE <ls_member_data> TO <lv_field>.

    IF sy-subrc = 0.

      <lv_field> = 'A'. "Version flag, should be "A" for Active

    ENDIF.

    ASSIGN COMPONENT 'ROWFLAG' OF STRUCTURE <ls_member_data> TO <lv_field>.

    IF sy-subrc = 0.

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Here you can change it to 'D' for Deleting """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

      <lv_field> = 'I'. " This is an action flag, I=Insert, M=Modify """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

    ENDIF.

    APPEND <ls_member_data> TO <lt_member_data>. " Add to the table.

* Create member manager

    lo_member_mgr = cl_uja_bpc_admin_factory=>get_member_manager(

    i_appset_id = l_appset_id

    i_dimension_id = l_dimension_id ).

****

* Save the members UNCOMMENT ONLY when you want to write the data!!!!!

****

* lo_member_mgr->save(

* EXPORTING

* ir_members = lr_members " List of members to save

* IMPORTING

* et_errors = lt_errors

* ).

****

* NOW PROCESS THE DIMENSION

****

    DATA: ls_dimensions TYPE uja_s_dim_name,

    lt_dimensions TYPE uja_t_dim_name.

    CLEAR ls_dimensions. REFRESH lt_dimensions.

    ls_dimensions-dimension = l_dimension_id. " Add dimensions to the list

    APPEND ls_dimensions TO lt_dimensions.

    lo_member_mgr->process(

    EXPORTING

    it_dim_list = lt_dimensions

    if_set_offline = abap_false

    if_validate = abap_true

    IMPORTING

    ef_success = l_success

    et_message_lines = lt_messages ).

  CATCH cx_uj_no_auth .

ENDTRY.

hope this will help,

thanks,

Rishi

Former Member
0 Kudos

Thank you so much Rishi.

I will check changing the flag to 'D' for one of the dummy master data and try deleting.

Will let you know the results.

Regards

Prtaibha

Former Member
0 Kudos

Hello Rishi,

I tried using this piece of code and its able to write the data to BPC dimension but the processing block gets in to error message. When I try to process the dimension manually, it says detected duplicate member but the id appears only once in the list. Could you please tell what is the field MBR_NAME in your code. I assume its the same as member id to be added.

Regards

Nikhil

former_member186338
Active Contributor
0 Kudos

Sorry, but it's better to open a new discussion and provide the code you are using to delete member!

In my tests the delete is working fine.

P.S. And can you explain the idea to delete master data? What is the business logic behind it?

rishi4892
Participant
0 Kudos

MBR_NAME is the Dimension Property. If you are getting problem in manually updating Dimension from web client. Run Program "UJA_REFRESH_DIM_CACHE". and reopen the web client to update Dimension Members.