Hi Laura,
To create the BADI customization in BPC, you can use below link as reference.
In my logic, I use class IF_UJO_QUERY to get the query adapter and to get the data from the children.
DATA: lo_query TYPE REF TO if_ujo_query
"Get the data from Notes Application
TRY.
"Get Query Adapter based on environment and application
lo_query = cl_ujo_query_factory=>get_query_adapter(
i_appset_id = appset_id
i_appl_id = appl_id
).
"Executing query to get the data in Notes Application
lo_query->run_rsdri_query(
EXPORTING
it_dim_name = lit_dim_list " BPC: Dimension List
it_range = lit_range " BPC: Selection condition
if_check_security = abap_false " BPC: Generic indicator
IMPORTING
et_data = <lfs_query_result>
* et_message = lit_message " BPC: Messages
).
" Exception of common read
CATCH cx_ujo_read. "#EC NO_HANDLER
"Update Execution Log of BPC BADI
"Error in reading data of Group Children
CALL METHOD zcl_bpc_badi_collect_data=>update_message
EXPORTING
im_message_type = message_type_error
im_message_no = '015'.
error_flag = abap_true.
"Free all memories reserved for the following objects
REFRESH: lit_dim_list,
lit_range.
FREE: lo_query,
lit_dim_list,
lit_range.
UNASSIGN <lfs_query_result>.
RETURN.
ENDTRY.
.
Then after the data is obtained from the children, you can write the data into the specific cube by changing the Group member into the top group by using below code.
"Write the result data into Consolidation model
TRY.
CALL METHOD cl_ujk_write=>write
EXPORTING
i_appset_id = appset_id
i_appl_id = text-con
IMPORTING
et_data = <lfs_cons_data>.
CATCH cx_uj_static_check .
"Update Execution Log of BPC BADI
"Error in writing the data into Consolidation Model
CALL METHOD zcl_bpc_badi_collect_data=>update_message
EXPORTING
im_message_type = message_type_error
im_message_no = '46'.
error_flag = abap_true.
ENDTRY.
Some of the parameters used in the code are dependent to my local environment, so I think you might need to change it a little bit.
Thanks.
Regards,
Siswono