cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Badi : Sap bpc : Error while reading transactional data

Former Member
0 Likes
355

HI folks,

I am trying to populate the ct_data though following code . But not getting data in the "5."section, In "4." section it is poulating the lt_Sel properly but in "5." it is neither populating  "lo_dataref" nor "<lt_tx_data>".

IF anyone can help pls give input for the following code.

Thanks in advance

    DATA: lt_sel TYPE uj0_t_sel, "Selection criteria table
        ls_sel TYPE uj0_s_sel,
        ls_cv TYPE ujk_s_cv, " Logic Current View
        lt_dim_member TYPE UJA_T_DIM_MEMBER ,
        ls_dim_member LIKE LINE OF lt_dim_member ,
        lo_appl TYPE REF TO cl_uja_application,
        lt_appl_dim TYPE uja_t_appl_dim,
        ls_appl_dim LIKE LINE OF lt_appl_dim,
        lt_dim_name TYPE ujq_t_dim,
        ls_dim_name LIKE LINE OF lt_dim_name,
        lo_model TYPE REF TO if_uj_model,
        lo_dataref TYPE REF TO data,
        lo_query TYPE REF TO if_ujo_query ,
        lt_message TYPE uj0_t_message .

FIELD-SYMBOLS: <lt_tx_data> TYPE STANDARD TABLE.
*create data wa_ctd_int like line of <lt_tx_data>.

*Declare the dimensions of ct_data which should have same number of dimensions as in the scope ,In this
*example it has 12 fields given below:

TYPES : begin of ty_ctdata,
        account_p type c length 32,
        audittrail type c length 32,
* flow type c length 32,
        legal_entity type c length 32,
        measures type c length 32,
        plant type c length 32,
        product type c length 32,
        profit_center type c length 32,
        rptcurrency type c length 32,
        time type c length 32,
        version type c length 32,
        zones type c length 32,
        signeddata type /b28/oisdata ,"(11) type p decimals 7,
end of ty_ctdata.

DATA : it_ctd_int type standard table of ty_ctdata , " Initial temporary table.
       wa_ctd_int type ty_ctdata .
**---------------End of Data Declaration----------------------**

*---- 2. Create an object for the input parameters such i_appset_id, i_appl_id.-------*
CREATE OBJECT lo_appl
EXPORTING
i_appset_id = i_appset_id
i_application_id = i_appl_id.

*---- 3. Use this object to read the dimension for the i_appl_id & Append ' Measures ' to the dimension table-----*
REFRESH lt_appl_dim.

lo_appl->get_appl_dim(
EXPORTING
i_appl_id = i_appl_id
IMPORTING
et_appl_dim = lt_appl_dim )."Dimension table

REFRESH lt_dim_name.

**Populate dimension table 'lt_dim_name'.
LOOP AT lt_appl_dim INTO ls_appl_dim.
ls_dim_name = ls_appl_dim-dimension.
APPEND ls_dim_name TO lt_dim_name.
CLEAR ls_dim_name.
ENDLOOP.

*--4. Prepare Selection range table say for ex : 'lt_sel ' for each dimension passing values to fields
*Dimension ,Attribute, Option ,Sign , low ----*.

loop at lt_dim_name INTO ls_dim_name .
CLEAR : ls_cv .
* Read from scope for each dimension from current view table*
READ TABLE it_cv INTO ls_cv WITH KEY dimension = ls_dim_name .
IF sy-subrc = 0.
LOOP AT ls_cv-member into ls_dim_member.
ls_sel-dimension = ls_cv-dimension.
ls_sel-attribute = 'ID'.
ls_sel-sign = 'I'.
ls_sel-option = 'EQ'.
ls_sel-low = ls_dim_member.
APPEND ls_sel TO lt_sel.
CLEAR ls_dim_member.
ENDLOOP.
CLEAR lt_dim_member.
ENDIF.
ENDLOOP.

*---5. Create a reference structure similar to ct_data using the method -----*
*' create_tx_data_ref ' .
TRY.
lo_model = cl_uj_model=>get_model( i_appset_id ).
lo_model->create_tx_data_ref(
EXPORTING
i_appl_name = i_appl_id
i_type = 'T'
it_dim_name = lt_dim_name
if_tech_name = space
IMPORTING
er_data = lo_dataref ).
CATCH cx_uj_static_check.
ENDTRY.
* Assigning the structure to table
ASSIGN lo_dataref->* TO <lt_tx_data>.
**Run a query using method ' run_rsdri_query ' **
BREAK-POINT.
TRY.
lo_query = cl_ujo_query_factory=>get_query_adapter(
i_appset_id = i_appset_id
i_appl_id = i_appl_id
).
** Run Query to populate ct_data based on dimensions , selection criteria **.
lo_query->run_rsdri_query(
EXPORTING
it_dim_name = lt_dim_name " BPC: Dimension List
it_range = lt_sel " BPC: Selection condition
if_check_security = ABAP_FALSE " BPC: Generic indicator
IMPORTING
et_data = <lt_tx_data>
et_message = lt_message " BPC: Messages
).
CATCH cx_ujo_read. " Exception of common read
ENDTRY.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Can you check what values you have in lt_sel when it stops at your break-point? Put those values in LISTCUBE and check if it brings any data.

Answers (4)

Answers (4)

former_member5472
Active Contributor
0 Likes

This message was moderated.

Former Member
0 Likes

Hi,

Thnx for the reply , got the solution

former_member5472
Active Contributor
0 Likes

Hi,

Please try restricting your currency dimension to single value and then try executing the code. I think you are re-using the code  from http://scn.sap.com/docs/DOC-35054.

If so then please go over the points to remeber and see restrciting the currency dimension with single value  is fetching data fro you ?

Prat

former_member186338
Active Contributor
0 Likes

Can you explain the idea of this badi in general?

Vadim