cancel
Showing results for 
Search instead for 
Did you mean: 

BPC Master Data Deletion through ABAP code

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

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.

Former Member
0 Kudos

Hi Pratibha,

You can try load the used master data only into BPC. and don't load the unused ones.

Andy

Former Member
0 Kudos

Hi Andy,

We are using 'UPDATE' option for loading the master data as it is happening in step wise process.If I would have used 'OVERWRITE' option then we wouldn't have any faced this issue which will over write every time I load the master data.

The master data in BPC will become Orphan node when you delete it in ECC system .The master data load is happening from ECC->BW->BPC.

So instead of keeping orphan nodes in BPC system,they want to delete.I am speaking regarding Cost Center master data deletion.Business is using the some cost center for some duration for specific requirement  and after that they are deleting in ECC system which is becoming orphan node in BPC.

Regards

Pratibha

former_member186338
Active Contributor
0 Kudos

The process looks like:

1. Cost center is present in ECC and BPC

2. Some data exists on this CC

3. This CC is deleted in ECC

4. You want to delete it in BPC? You need to delete data first...

Vadim

Former Member
0 Kudos

Hi Pratibha,

I assume you load hierarchy as well? you are talking about the old parent nodes that stayed behind after you deleted its children?

that's an interesting question, I think you have to use over write to get rid of those parent nodes.

Andy

Former Member
0 Kudos

Yes Vadim.You are right.

I want to delete in BPC and if transaction data is associated with it then I don't want to delete that master data until business verifies transaction data and asks us to delete the master data.

Regards

Pratibha

former_member186338
Active Contributor
0 Kudos

And how do you want to launch this process (trigger by?) and how do you want to compare BPC master data with ECC master data?

Vadim

Former Member
0 Kudos

I had plans of writing ABAP program which will identify all the orphan nodes and check any transaction data exist with respect to that.If transaction data is not there then delete it else list out all the cost centers which has data and notify the users.

I can call this ABAP program in BW process chain and schedule it accordingly user requirement.

For deletion process I am not getting any standard program or class so that it can also take care of checking the associated transaction data.

Regards

Pratibha

former_member186338
Active Contributor
0 Kudos

Please, look on the code of Master Data On the Fly, rowflag here is set to "I",  change it to "D". Read here:

Vadim

Former Member
0 Kudos

Thanks for your reply Vadim.

Could you please let me know where exactly I have to set rowflag to 'D'.

Regards

Pratibha

former_member186338
Active Contributor
0 Kudos

Sorry, but you have to look and understand all lines of this code... And other parts of this code have to be changed.

Vadim

Former Member
0 Kudos

HI Vadim,

I am working on BPC 7.5 version so I couldn't find any relevant standard class or BADI mentioned in the above link you provided.

Could you please provide the details with respect to BPC 7.5 version for deleting the master data through ABAP.

Regards

Pratibha

former_member186338
Active Contributor
0 Kudos

Then, please read this document:

It's for BPC 7.5.

And it's a good idea to post your BPC version when you start a discussion!

Vadim

Former Member
0 Kudos

Thanks for your help..

I am looking at the method 'CREATE' of class "ZUJ_CL_MDOF" but I couldn't find where the rowflag has to be changed to 'D'.Could please anyone help me in finding which method to be used and where the rowflag has to be set.

Regards

Pratibha

former_member186338
Active Contributor
0 Kudos

Please, ask some qualified ABAP developer to help you! Changing the flag is not the only thing that have to be changed in this code.

Vadim

former_member186338
Active Contributor
0 Kudos

Hi Pratibha,

Please explain in details, why do you want to do it in ABAP? Also before deletion of master data you have to remove all transactional data associated with this master data.

To have an idea, please read:

Vadim

Former Member
0 Kudos

Hi Vadim,

Thanks for your reply.I do know that if transaction data is associated with the master data then process itself doesn't allow me to delete.

Client has requirement of deleting master data which they are not going to use in BPC and which doesn't have any transaction data with it.Business used to manually delete the master data but they want to automate the process instead of user going and deleting.

Please suggest any best way of deleting the master data in BPC.

Regards

Pratibha Biradar

former_member186338
Active Contributor
0 Kudos

Hi Pratibha,

Still the requirements are not clear to me! In order to delete empty master data you need to create it at first OK, it's possible to have some empty master data at some moment - then you manually delete it, but what do you want to automate? How the unused master data is creating in the system?

Vadim