- Introduction
In business scenarios like designing reconciliation reports in BPC, there is a need to read data from the BPC models into local tables and build reports on the data fetched from the models. This post explains the way to read Master data from the BPC dimensions. In BPC we have various methods to read master data for text/attribute and hierarchy data for base member and Node values from the dimensions.
Although the Master data is stored in tables at the backend we cannot directly use the table names to read as the technical names of the dimensions are subject to change and it is suggested not to use the technical names in BPC.BPC has provided standard classes and interfaces to read data from the models. UJA is the ABAP Package that contains all the modeling and metadata related interfaces. The modeling functionality is driven by a class called CL_UJA_BPC_ADMIN_FACTORY. This class is the main entry point for all modeling related operations and is the dynamic entry point to handle modeling operations.
- Reading Master Data
Master data read includes fetching Attributes, Text and Hierarchies from a dimension for a given appset id. CL_UJA_DIM is the standard dimension class provided by SAP to read dimension master data for an appset id.
- Attributes and Hierarchies
IF_UJA_DIM_DATA is the interface used to perform all the operations specific to a dimension and it is implemented in the class CL_UJA_DIM. READ_MBR_DATA and the method READ_MBR_DATA of this interface is used to read the dimension master data (Attributes/Text/Hierarchies).
The importing parameters of the method READ_MBR_DATA used while reading attributes and hierarchies:
- IT_SEL holds the filters on the attribute values to be fetched. Only the intersection of values given in IT_SEL will be read from the dimension.
- IT_SEL_MBR holds the attribute that need to be fetched.
*- Code logic to read attributes and hierarchies
*- Data declarations DATA: lo_dim_reader TYPE REF TO cl_uja_dim, dyn_table TYPE REF TO data. lt_dim_data TYPE REF TO data, ls_mbr TYPE uj_attr_name, lt_attr_list TYPE uja_t_attr_name. FIELD-SYMBOLS: <fs_t_txt_data> TYPE STANDARD TABLE. *- Create Instance object for dim class TRY. CREATE OBJECT lo_dim_reader EXPORTING i_appset_id = lc_appset i_dimension = 'COMPANY_CODE' CATCH cx_uja_admin_error . ENDTRY. *- Parameter to get text ls_mbr = 'EVDESCRIPTION'. APPEND ls_mbr TO lt_attr_list. *- Call the method READ_MBR_DATA and get the text data into reference table LT_DIM_DATA. TRY. CALL METHOD lo_dim_reader->if_uja_dim_data~read_mbr_data EXPORTING it_attr_list = lt_attr_list IMPORTING er_data = lt_dim_data. CATCH cx_uja_admin_error. ENDTRY. ASSIGN lt_dim_data->* TO <fs_t_txt_data>. *<fs_t_txt_data> has Company code and corresponding short, medium, long descriptions.
- Text
The method that reads attributes and hierarchies is as well used to read the text of a dimension. When reading attributes and hierarchies, descriptions are not fetched. To get texts a parameter called ‘EVDESCRIPTION’ is passed to the importing parameter IT_ATTR_LIST of the method READ_MBR_DATA.
*- Code logic to read text of a dimension
*- Data declarations DATA: lo_dim_reader TYPE REF TO cl_uja_dim, dyn_table TYPE REF TO data. lt_dim_data TYPE REF TO data, ls_mbr TYPE uj_attr_name, lt_attr_list TYPE uja_t_attr_name. FIELD-SYMBOLS: <fs_t_txt_data> TYPE STANDARD TABLE. *- Create Instance object for dim class TRY. CREATE OBJECT lo_dim_reader EXPORTING i_appset_id = lc_appset i_dimension = 'COMPANY_CODE' CATCH cx_uja_admin_error . ENDTRY. *- Parameter to get text ls_mbr = 'EVDESCRIPTION'. APPEND ls_mbr TO lt_attr_list. *- Call the method READ_MBR_DATA and get the text data into reference table LT_DIM_DATA. TRY. CALL METHOD lo_dim_reader->if_uja_dim_data~read_mbr_data EXPORTING it_attr_list = lt_attr_list IMPORTING er_data = lt_dim_data. CATCH cx_uja_admin_error. ENDTRY. ASSIGN lt_dim_data->* TO <fs_t_txt_data>. *<fs_t_txt_data> has Company code and corresponding short, medium, long descriptions.
Hope you enjoyed reading the article.