BPC的模型数据处理

取得模型维度的下层结构

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

DATA:
    lt_dim_member TYPE uja_t_dim_member.

"数据审计维度
PERFORM frm_get_dim_children USING 'BPC_CONSOLIDATION' 'C_AUDITTRAIL' 'PARENTH2' 'DG10' CHANGING lt_dim_member.

FORM frm_get_dim_children  USING i_appset_id   TYPE uj_appset_id
                                 i_dimension   TYPE uj_dim_name
                                 i_hier_name   TYPE uj_hier_name
                                 i_parent_mbr  TYPE uj_dim_member
                        CHANGING it_dim_member TYPE uja_t_dim_member.

  DATA: lo_dim         TYPE REF TO cl_uja_dim.
  CLEAR: it_dim_member.
  TRY.
      CLEAR:lo_dim.
      CREATE OBJECT lo_dim
        EXPORTING
          i_appset_id = i_appset_id "zcl_bpcp_common=>c_appset_id "环境ID
          i_dimension = i_dimension. "cns_dimension_customer.  "维度ID
      CALL METHOD lo_dim->get_children_mbr
        EXPORTING
          i_hier_name      = i_hier_name "默认为PARENTH1,可省略
          i_parent_mbr     = i_parent_mbr "父节点ID
          if_only_base_mbr = 'X'
 *         if_self          = 'X' "包含自身
        IMPORTING
          et_member        = it_dim_member.
    CATCH cx_uja_admin_error.
  ENDTRY.

ENDFORM.

定义模型内表

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
DATA:
    lt_result    TYPE REF TO data,
FIELD-SYMBOLS: <lt_data> TYPE STANDARD TABLE.

"参考模型结构定义内表
PERFORM frm_get_dyn_structure_table USING 'HUAYI_CONSOLIDATION' 'C_CONSOLIDATION' CHANGING lo_dataref.
ASSIGN lo_dataref->* TO <lt_data>.

FORM frm_get_dyn_structure_table  USING    i_appset_id TYPE uj_appset_id
                                        i_appl_id TYPE uj_appl_id
                                  CHANGING lo_dataref TYPE REF TO data.
  DATA: lo_appl_mgr TYPE REF TO if_uja_application_manager,
        lt_dim_name TYPE ujq_t_dim.
*        lo_dataref  TYPE REF TO data.
  FIELD-SYMBOLS: <lt_data>      TYPE STANDARD TABLE.
  FREE:lo_dataref.
  TRY.
      lo_appl_mgr = cl_uja_bpc_admin_factory=>get_application_manager( i_appset_id      = i_appset_id
                                                                       i_application_id = i_appl_id ).
      CALL METHOD lo_appl_mgr->create_data_ref
        EXPORTING
          i_data_type  = 'T'
          it_dim_name  = lt_dim_name
          if_tech_name = space
        IMPORTING
          er_data      = lo_dataref.
    CATCH cx_uja_admin_error
          cx_uj_no_auth
          cx_uj_static_check.                           "#EC NO_HANDLER
  ENDTRY.
ENDFORM.

取得模型数据

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

DATA:
    lt_result    TYPE REF TO data,
    lt_sel   TYPE uj0_t_sel,

FIELD-SYMBOLS: <lt_result> TYPE STANDARD TABLE.
FIELD-SYMBOLS: <lt_data> TYPE STANDARD TABLE.

"设置过滤器
lt_sel = VALUE #( BASE lt_sel ( dimension = 'C_CATEGORY'    option = 'EQ' sign = 'I' low = 'ACTUAL' ) ).
lt_sel = VALUE #( BASE lt_sel ( dimension = 'C_SCOPE'       option = 'EQ' sign = 'I' low = 'F_NONE' ) ).

PERFORM frm_get_zbpc_model_data USING 'HUAYI_CONSOLIDATION' 'C_CONSOLIDATION'   lt_sel CHANGING lt_result.
ASSIGN lt_result->* TO <lt_result>.
LOOP AT <lt_result> ASSIGNING FIELD-SYMBOL(<fs_result>).

ENDLOOP.

FORM frm_get_zbpc_model_data   USING   i_appset_id TYPE uj_appset_id
                                              i_appl_id TYPE uj_appl_id
                                              pt_sel TYPE uj0_t_sel
                                     CHANGING pt_result TYPE REF TO data.

  DATA: lt_dim_list TYPE uja_t_dim_list,
        lo_query    TYPE REF TO if_ujo_query,
        lt_message  TYPE uj0_t_message.

  FIELD-SYMBOLS: <lt_query_result> TYPE STANDARD TABLE.

  FREE: pt_result.
  REFRESH lt_dim_list.

  CALL METHOD cl_ujp_utility=>get_dim_list
    EXPORTING
      i_appset_id      = i_appset_id
      i_application_id = i_appl_id
    IMPORTING
      et_dim_list      = lt_dim_list.


  CALL METHOD cl_ujp_utility=>create_data_ref
    EXPORTING
      i_appset_id      = i_appset_id
      i_application_id = i_appl_id
      i_data_type      = if_uja_application_manager=>gc_type_table
    IMPORTING
      er_data          = pt_result.

  ASSIGN pt_result->* TO <lt_query_result>.

  TRY.
      lo_query = cl_ujo_query_factory=>get_query_adapter( i_appset_id = i_appset_id i_appl_id = i_appl_id ).

      lo_query->run_rsdri_query(
        EXPORTING
          it_dim_name       = lt_dim_list " BPC: Dimension List
          it_range          = pt_sel " BPC: Selection condition
          if_check_security = abap_false " BPC: Generic indicator
        IMPORTING
          et_data           = <lt_query_result>
          et_message        = lt_message " BPC: Messages
      ).
    CATCH cx_ujo_read. " Exception of common read
  ENDTRY.
ENDFORM.
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus