text BPC BAdI实现UJ_CUSTOM_LOGIC

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text BPC BAdI实现UJ_CUSTOM_LOGIC相关的知识,希望对你有一定的参考价值。

*&---------------------------------------------------------------------*
*& Env.      : BPC_PIHC
*& Model     : OPEX
*&---------------------------------------------------------------------*
*& Revision Log:
*& Ver#   Date        Dev            Descr
*& -----  -----       -----          -----
*& 0001   02.04.2015  Rijdzuan   Initial
*&---------------------------------------------------------------------*
*& Information:
*& Engine untuk membuat journal dari opex ke financial
*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*& DECLARATION & INITIALIZE
*&---------------------------------------------------------------------*

DATA: LR_DATA TYPE REF TO DATA. 

DATA: ld_log TYPE string,
ld_log_flag TYPE flag.
DATA: ld_line TYPE i,
ld_linet(50).

DATA: LX_MESSAGES  TYPE UJ0_S_MESSAGE,
          LT_MESSAGES  TYPE UJ0_T_MESSAGE,
          LS_WB_STATUS TYPE UJO_S_WB_STATUS,
          L_SUCCESS    TYPE UJ_FLG,
          LT_ERRORS    TYPE UJA_T_MEMBERS_ERROR. 

** TYPE REF
DATA: LT_FINAL TYPE REF TO DATA,
LR_FINAL TYPE REF TO DATA.
FIELD-SYMBOLS: <LT_FINAL> TYPE STANDARD TABLE,
<LS_FINAL> TYPE ANY.

** Create final data
CREATE DATA LT_FINAL LIKE CT_DATA.
ASSIGN LT_FINAL->* TO <LT_FINAL>.
CREATE DATA LR_FINAL LIKE LINE OF CT_DATA.
ASSIGN LR_FINAL->* TO <LS_FINAL>.

FIELD-SYMBOLS: <LT_RECORD>     TYPE STANDARD TABLE,
                   <LT_RECORD_DEL> TYPE STANDARD TABLE,
                   <LS_RECORD>     TYPE ANY,
                   <LS_RECORD_DEL> TYPE ANY,
                   <LS_SIGNEDDATA> TYPE ANY. 

*&---------------------------------------------------------------------*
*& RANGE DEFINE
*&---------------------------------------------------------------------*

LX_SELECTION TYPE UJ0_S_RANGE.
LT_SELECTION TYPE UJ0_T_RANGE.
LX_SELECTION_DIM TYPE UJ0_S_SEL.
LT_SELECTION_DIM TYPE UJ0_T_SEL.

"Range Dimension
DEFINE MC_SEL_DIMENSION.
      &1-DIMENSION = &2.
      &1-ATTRIBUTE = &3.
      &1-SIGN = 'I'.
      &1-OPTION = 'EQ'.
      &1-LOW = &4.
      APPEND &1 TO &5.
    END-OF-DEFINITION.
"Range Model
    DEFINE MC_SEL_MODEL.
      CLEAR &1.
      &1-sign = 'I'.
      &1-option = 'EQ'.
      &1-dimension = &2.
      &1-low = &3.
      APPEND &1 to &4.
    END-OF-DEFINITION.

"Range of Member
    DEFINE MC_SEL_RANGE.
      CLEAR &1.
      &1-sign = 'I'.
      &1-option = 'EQ '.
      &1-low = &2.
      APPEND &1 to &3.
    END-OF-DEFINITION. 


*&---------------------------------------------------------------------*
*& INPUT VALIDATION
*&---------------------------------------------------------------------*

CALL METHOD ZBPC_CL_GET_DIMENSION_MEMBER=>READ_CV_DATA
EXPORTING
IT_CV = IT_CV
IMPORTING
ET_CYCLE = LT_CYCLE
ET_CATEGORY = LT_CATEGORY
ET_ENTITY = LT_ENTITY
ET_TIME = LT_TIME.

"Category
LOOP AT LT_CATEGORY TRANSPORTING NO FIELDS
WHERE ID EQ 'Actual'.

** Raise exception
LD_LOG = 'Input Actual Category is not allowed'.
CL_UJK_LOGGER=>LOG( I_OBJECT = LD_LOG ).
RAISE EXCEPTION TYPE CX_UJ_CUSTOM_LOGIC.

ENDLOOP.

"Cycle
IF LT_CYCLE[] IS INITIAL.
** Raise exception
LD_LOG = 'Please input one CYCLE'.
CL_UJK_LOGGER=>LOG( I_OBJECT = LD_LOG ).
RAISE EXCEPTION TYPE CX_UJ_CUSTOM_LOGIC.
ELSE.
READ TABLE LT_CYCLE ASSIGNING <LS_CYCLE> INDEX 2.
IF SY-SUBRC EQ 0.
** Raise exception
LD_LOG = 'Please input one CYCLE'.
CL_UJK_LOGGER=>LOG( I_OBJECT = LD_LOG ).
RAISE EXCEPTION TYPE CX_UJ_CUSTOM_LOGIC.
ENDIF.
ENDIF.

     

*&---------------------------------------------------------------------*
*& GET MODEL FROM CT_DATA
*&---------------------------------------------------------------------*
BREAK-POINT.
CALL METHOD ZBPC_CL_BADI=>TRANSFORM_CT_DATA
EXPORTING
IT_DATA = CT_DATA
IMPORTING
ET_DATA_MODEL = LT_SOURCE.

*&---------------------------------------------------------------------*
*& GET INPUT MEMBER
*&---------------------------------------------------------------------*

DATA: lx_cv TYPE ujk_s_cv,
lt_member TYPE uja_t_dim_member,
lx_member TYPE uj_dim_member.

DEFINE mc_selection_dim.
CLEAR &1.
&1-sign = 'I'.
&1-option = 'EQ'.
&1-low = &2.
&1-dimension = &3.
APPEND &1 to &4.
END-OF-DEFINITION.

CLEAR: lt_selection_dim.
LOOP AT it_cv INTO lx_cv
WHERE user_specified = 'X'.

lt_member = lx_cv-member.
LOOP AT lt_member INTO lx_member.

mc_selection_dim lx_selection_dim
lx_member lx_cv-dimension lt_selection_dim.

ENDLOOP.

ENDLOOP.

CALL METHOD zbpc_cl_get_model_record=>fetch2
EXPORTING
i_appset_id = i_appset_id
i_appl_id = <ls_uja_appl>-application_id
it_selection = lt_selection_dim
IMPORTING
er_data = lr_data.

*&---------------------------------------------------------------------*
*& GET MODEL WITH SELECTION
*&---------------------------------------------------------------------*

DEFINE mc_dim_selection.
CLEAR &1.
&1-sign = 'I'.
&1-option = 'EQ'.
&1-dimension = &2.
&1-low = &3.
APPEND &1 to &4.
END-OF-DEFINITION.


** "Category
LOOP AT LT_CATEGORY ASSIGNING <LS_CATEGORY>.
MC_DIM_SELECTION LX_ASSUMPTION_SEL 'CATEGORY'
<LS_CATEGORY>-ID LT_ASSUMPTION_SEL.
ENDLOOP.

** "Cycle
LOOP AT LT_CYCLE ASSIGNING <LS_CYCLE>.
MC_DIM_SELECTION LX_ASSUMPTION_SEL 'CYCLE'
<LS_CYCLE>-ID LT_ASSUMPTION_SEL.
ENDLOOP.

** "Rptcurrency
MC_DIM_SELECTION LX_ASSUMPTION_SEL 'RPTCURRENCY'
'USD' LT_ASSUMPTION_SEL.

CALL METHOD ZBPC_CL_GET_MODEL_RECORD=>FETCH
EXPORTING
I_APPSET_ID = I_APPSET_ID
I_APPL_ID = 'Assumption'
IT_SELECTION = LT_ASSUMPTION_SEL
IMPORTING
T_ASSUMPTION = LT_ASSUMPTION_ICP.

CALL METHOD zbpc_cl_get_model_record=>fetch2
EXPORTING
i_appset_id = i_appset_id
i_appl_id = <ls_uja_appl>-application_id
it_selection = lt_selection_dim
IMPORTING
er_data = lr_data.

*&---------------------------------------------------------------------*
*& GET DIMENSION WITH SELECTION
*&---------------------------------------------------------------------*

DATA: LT_POSTRULE TYPE ZBPC_TT_POSTING_RULE_DIM,
LX_POSTRULE TYPE ZBPC_TY_POSTING_RULE_DIM.
DATA: LT_R_POSTRULE TYPE UJ0_T_SEL,
LX_R_POSTRULE TYPE UJ0_S_SEL.

LX_R_POSTRULE-DIMENSION = 'POSTING_RULE'.
LX_R_POSTRULE-ATTRIBUTE = 'MODEL'.
LX_R_POSTRULE-SIGN = 'I'.
LX_R_POSTRULE-OPTION = 'EQ'.
LX_R_POSTRULE-LOW = 'CONSOLIDATION'.
APPEND LX_R_POSTRULE TO LT_R_POSTRULE.

CALL METHOD ZBPC_CL_GET_DIMENSION_MEMBER=>READ_MBR_DATA
EXPORTING
I_APPSET_ID = I_APPSET_ID "'BPC_PIHC'
I_DIMENSION = 'POSTING_RULE'
IT_SEL = LT_R_POSTRULE
IMPORTING
ET_POSTING_RULE = LT_POSTRULE.
IF LT_POSTRULE[] IS INITIAL.
** Raise exception
CLEAR: CT_DATA.
LD_LOG = 'Please maintain appropiate Posting Rule'.
CL_UJK_LOGGER=>LOG( I_OBJECT = LD_LOG ).
RAISE EXCEPTION TYPE CX_UJ_CUSTOM_LOGIC.
EXIT.
ENDIF.

*&---------------------------------------------------------------------*
*& FINAL
*&---------------------------------------------------------------------*

** Overwrite callback
IF <LT_FINAL> IS INITIAL.
** Raise exception
CLEAR: CT_DATA.
LD_LOG = 'No final data to be processed'.
CL_UJK_LOGGER=>LOG( I_OBJECT = LD_LOG ).
RAISE EXCEPTION TYPE CX_UJ_CUSTOM_LOGIC.
EXIT.
ELSE.
CT_DATA[] = <LT_FINAL>.
ENDIF.

以上是关于text BPC BAdI实现UJ_CUSTOM_LOGIC的主要内容,如果未能解决你的问题,请参考以下文章

BPC Hierarchy

SAP,ABAP中BADI的定义,接口,类,实现,方法

谁告诉我SAP,ABAP中BADI的BADI定义,接口,类,实现,方法,这几个概念之间的关系是啥啊

20170520 BADI增强学习

SAP 4代增强

SAP 金税接口增强 BADI