bpc 数据处理

UJKT
程序:UJO_SQE_TEST
BADI:UJ_CUSTOM_LOGIC


*
XDIM_MEMBERSET Z_ACCOUNT = PL04 *START_BADI PL04_STEP1 WRITE = ON QUERY = ON *END_BADI
*定义模型
    types:begin of ty_planning,
            measure      type c length 32,
            z_account    type c length 32,
            z_category   type c length 32,
            z_class      type c length 32,
            z_currency   type c length 32,
            z_datasource type c length 32,
            z_entity     type c length 32,
            z_line       type c length 32,
            z_misc1      type c length 32,
            z_misc2      type c length 32,
            z_product    type c length 32,
            z_time       type c length 32,
            z_view       type c length 32,
            signdata     type /b28/oisdata,
          end of ty_planning.

***定于宏
    define sel.
      CLEAR LS_SEL.
      LS_SEL-DIMENSION = &1.
      LS_SEL-ATTRIBUTE = 'ID'.
      LS_SEL-SIGN = 'I'.
      LS_SEL-OPTION = 'BT'.
      LS_SEL-LOW = &2.
      LS_SEL-HIGH = &3.
      APPEND LS_SEL TO LT_SEL.
    end-of-definition.

***取上年实际数
    sel   'Z_ACCOUNT'       'PL02'              'PL01'.                   "未税收入
    sel   'Z_CATEGORY'      'ACTUAL'            'ACTUAL'.                 "实际数
    sel   'Z_CLASS'         'CLASS_NONE'        'CLASS_NONE'.
    sel   'Z_CURRENCY'      'CURRENCY_NONE'     'CURRENCY_NONE'.
    sel   'Z_DATASOURCE'    'FINAL'             'FINAL'.
    sel   'Z_ENTITY'        'BCSYB.INP'         'BCSYB.INP'.                "北京超市事业部
    sel   'Z_LINE'          'LINE_NONE'         'LINE_NONE'.
    sel   'Z_MISC1'         'MISC1_NONE'        'MISC1_NONE'.
    sel   'Z_MISC2'         'MISC2_NONE'        'MISC2_NONE'.
    sel   'Z_PRODUCT'       'BJ.INP'            'BJ.INP'.                 "产品总计
    sel   'Z_TIME'          '2019.INP'          '2019.INP'.               "时间
    sel   'Z_VIEW'          'VIEW_NONE'         'VIEW_NONE'.

****取上年实际数
    call function 'ZBPC_GET_DATA'
      exporting
        i_appset  = i_appset_id
        i_appl_id = i_appl_id
        it_range  = lt_sel
      tables
        et_data   = it_temp.
FUNCTION ZBPC_GET_DATA.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     REFERENCE(I_APPSET) TYPE  UJ_APPSET_ID
*"     REFERENCE(I_APPL_ID) TYPE  UJ_APPL_ID
*"     REFERENCE(IT_RANGE) TYPE  UJ0_T_SEL
*"  TABLES
*"      ET_DATA
*"----------------------------------------------------------------------

data: 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_data type ref to data,
         lt_message type uj0_t_message.

field-symbols: <lt_tx_data> type standard table,
                             <ls_data> type any.

*i_appl_id = 'Sales'.

create object lo_appl
 exporting
   i_appset_id = i_appset
   i_application_id = i_appl_id.

refresh lt_appl_dim.
lo_appl->get_appl_dim(
  exporting
  i_appl_id = i_appl_id
  importing
    et_appl_dim = lt_appl_dim ).

refresh 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.

ls_dim_name = 'MEASURES'.

append ls_dim_name to lt_dim_name.

sort  lt_dim_name.

try.
  lo_model = cl_uj_model=>get_model( i_appset ).
  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.

assign lo_dataref->* to <lt_tx_data>.
create data lt_data like line of <lt_tx_data>.
assign lt_data->* to <ls_data>.

try.
  lo_query = cl_ujo_query_factory=>get_query_adapter(
   i_appset_id = i_appset
   i_appl_id = i_appl_id
   ).

  lo_query->run_rsdri_query(
  exporting
    it_dim_name = lt_dim_name
    it_range = it_range
    if_CHECK_SECURITY = ABAP_FALSE
   IMPORTING
     ET_DATA  = <LT_TX_DATA>
     ET_MESSAGE   = LT_MESSAGE
     ).
     CATCH  CX_UJO_READ.



 ENDTRY.
 LOOP AT <LT_TX_DATA> INTO <LS_DATA>.
   APPEND <LS_DATA> TO ET_DATA.

 ENDLOOP.
 ENDFUNCTION.
原文地址:https://www.cnblogs.com/ckstock/p/11980934.html