Skip to Content

How to update cube from badi in bpc 10

Hi Experts,

i have written code to round decimals values , i have fetched data sucessfully from cube to badi but i am not understanding how to update cube from badi

ie after rounding decimal values.

please find my below code which is performing rounding on decimal values and if possible how to write code for updating cube

note:: no need of reading my entire code please check which i have marked in red color.

...................................................................................start of code.........................................................................................................

METHOD if_uj_custom_logic~execute.


DATA: lo_dataref TYPE REF TO data.
TYPES: BEGIN OF ty_itab,
account TYPE ujz_id,
activity TYPE ujz_id,
brand TYPE ujz_id,
car_model_year TYPE ujz_id,
category TYPE ujz_id,
company TYPE ujz_id,
models TYPE ujz_id,
month_matrix TYPE ujz_id,
mps TYPE ujz_id,
nsc TYPE ujz_id,
rptcurrency TYPE ujz_id,
time TYPE ujz_id,
signeddata TYPE uj_sdata,
END OF ty_itab.

DATA: lv_environment_id TYPE uj_appset_id VALUE X,
lv_application_id TYPE uj_appl_id VALUE 'x',
lt_dim_list TYPE uja_t_dim_list,
lo_appl_mgr TYPE REF TO if_uja_application_manager,
lo_query TYPE REF TO if_ujo_query,
lr_data TYPE REF TO data,
lt_message TYPE uj0_t_message,
ls_application TYPE uja_s_application,
ls_dimensions TYPE uja_s_dimension,
lt_itab TYPE TABLE OF ty_itab,
ls_itab TYPE ty_itab,
wa_time TYPE string,
wa_time1 TYPE string,
wa_company TYPE ujz_id,
* ls_param TYPE ujk_s_script_logic_hashentry,
* it_param TYPE ujk_t_script_logic_hashtable,
W_ACCOUNT TYPE P.

FIELD-SYMBOLS: <lt_query_result> TYPE STANDARD TABLE,
* <lt_query_result> TYPE STANDARD TABLE,
<ls_query_result> TYPE any,
<ls_query> TYPE any,
* <fs_val> TYPE any,
* <fs_val1> TYPE any,
* <fs_val2> TYPE any,
* <fs_val3> TYPE any,
* <fs_val4> TYPE any,
* <fs_val5> TYPE any,
* <fs_val6> TYPE any,
<ls_data> type STANDARD TABLE ,
<ls_itab> type any,
<lv_acc> type any,
<lv_kyfg> type p.

* start of methos for reading dimensions and their properties
try.
lo_appl_mgr = cl_uja_bpc_admin_factory=>get_application_manager(

i_appset_id = lv_environment_id

i_application_id = lv_application_id ).

CLEAR ls_application.

lo_appl_mgr->get(

EXPORTING

if_with_measures = abap_false " BPC: Generic indicator

if_summary = abap_false " BPC: Generic indicator

IMPORTING

es_application = ls_application ). " Applications table type

REFRESH lt_dim_list.

LOOP AT ls_application-dimensions INTO ls_dimensions.

APPEND ls_dimensions-dimension TO lt_dim_list.

ENDLOOP.

lo_appl_mgr->create_data_ref(

EXPORTING

i_data_type = 'T'

it_dim_name = lt_dim_list

if_tech_name = abap_false

if_signeddata = abap_true

IMPORTING

er_data = lr_data ).

ASSIGN lr_data->* TO <lt_query_result>.
CATCH cx_uja_admin_error.
catch cx_uj_static_check.
endtry.
* lo_query = cl_ujo_query_factory=>get_query_adapter(
*
* i_appset_id = lv_environment_id
*
* i_appl_id = lv_application_id
*
* ).

* lo_query->run_rsdri_query(
*
* EXPORTING
*
* it_dim_name = lt_dim_list " BPC: Dimension List
*
*
*
* if_check_security = abap_false " BPC: Generic indicator
*
*
*
* IMPORTING
*
* et_data = <lt_query_result>
*
*
*
* et_message = lt_message " BPC: Messages
*
*
*
* ).
TRY.
lo_query = cl_ujo_query_factory=>get_query_adapter(
i_appset_id = lv_environment_id
i_appl_id = lv_application_id
).

lo_query->run_rsdri_query(
EXPORTING
it_dim_name = lt_dim_list " BPC: Dimension List
* it_range = lt_range " BPC: Selection condition
if_check_security = abap_false " BPC: Generic indicator

IMPORTING
et_data = <lt_query_result>

et_message = lt_message

).

CATCH cx_ujo_read. " Exception of common read
ENDTRY.

**************************************************************
CREATE DATA lo_dataref LIKE LINE OF ct_data.
ASSIGN lo_dataref->* TO <ls_data>.

CREATE DATA lo_dataref LIKE LINE OF ct_data.
ASSIGN lo_dataref->* TO <ls_query_result>.

CREATE DATA lr_data LIKE LINE OF lt_itab.
ASSIGN lr_data->* TO <ls_itab>.

LOOP AT <lt_query_result> ASSIGNING <ls_query_result>.
APPEND <ls_query_result> TO lt_itab.
ENDLOOP.

LOOP AT ct_data ASSIGNING <ls_data> ."WHERE account eq 'WS_QTY'.
ASSIGN COMPONENT `ACCOUNT` OF STRUCTURE <ls_data> TO <lv_acc>.
* ASSIGN COMPONENT `ACTIVITY` OF STRUCTURE <ls_data> TO <lv_acc>.
* ASSIGN COMPONENT `BRAND` OF STRUCTURE <ls_data> TO <lv_acc>.
* ASSIGN COMPONENT `ACCOUNT` OF STRUCTURE <ls_data> TO <lv_acc>.
* ASSIGN COMPONENT `ACCOUNT` OF STRUCTURE <ls_data> TO <lv_acc>.
* ASSIGN COMPONENT `ACCOUNT` OF STRUCTURE <ls_data> TO <lv_acc>.
IF <lv_acc> EQ 'WS_QTY' .




* ASSIGN COMPONENT `ACCOUNT` OF STRUCTURE <ls_data> TO <lv_acc>.
* READ TABLE lt_itab INTO <ls_data> WITH TABLE KEY ACCOUNT = 'WS_QTY'.

*
*
*clear <lv_kyfg>.

IF sy-subrc EQ 0.
ASSIGN COMPONENT `SIGNEDDATA` OF STRUCTURE <ls_data> TO <lv_kyfg>.
IF NOT <lv_kyfg> IS INITIAL.
W_ACCOUNT = <lv_kyfg>.
clear <lv_kyfg>.
<lv_kyfg> = W_ACCOUNT.
* modify <ls_data> from <lv_kyfg>.
* GET REFERENCE OF <ls_data> INTO ct_data.
modify ct_data from <ls_data> ."i am trying to update in this way but its not working

endif.
endif.
endif.
endloop.

ENDMETHOD.

...................................

Thank you

siva

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Aug 30, 2013 at 10:38 AM

    If you have new/changed values in ct_data at the end of badi execution and badi parameter WRITE=ON then the data will be written to the cube.

    Vadim

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 30, 2013 at 09:30 AM

    Check the resulting contents of the ct_data and check the package log afterwards. If the contents of the ct_data are exactly the same as the same contents in the fact table, the system considers the write-back to be the same and doesn't write data back.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.