继续示例
loop at LT_WBS into LS_WBS.
clear LT_BPAK.
select single OBJNR into LT_BPAK-E_OBJNR
from PRPS
where PSPNR = LS_WBS-PSPNR.
LT_BPAK-E_VORGA = 'KSTP'.
LT_BPAK-E_VERSN = '000'.
LT_BPAK-TWAER = CNS_WAERS.
LT_BPAK-WERT = LS_WBS-ZGSSUM.
append LT_BPAK.
endloop.
call function 'KBPP_EXTERN_UPDATE_CO'
exporting
I_BUDGET_ACTIVITY = 'KSTP'
* I_BUDGET_ACTIV_SUP_RET = ' '
* I_COMMIT_DATA = ' '
I_DELTA_AMOUNTS = '' "X表示追加,空表示替代
I_ROLLUP_DATA = '' "X表示向顶层汇总
* I_CHECK_PLAN_DATA = ''
* I_APPLICATION =
I_COMMIT_ALL = 'X'
* IMPORTING
* E_ERRORS_FOUND =
tables
IT_BPAK = LT_BPAK
IT_RETURN = LT_RETURN
exceptions
NO_UPDATE = 1
others = 2
.
if SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
message E000 with '项目' P_PSPID '概算更新失败,请检查后再试!'.
else.
message S000 with '项目' P_PSPID '概算更新成功。'.
endif.
另一个示例
****Updating the Budget update ( WRTTP = 41 and VORGA = KBUD)
IF wa_final-budg_upd NE 0.
wa_bpak-s_profil = v_bprof.
wa_bpak-twaer = v_twaer.
wa_bpak-e_objnr = wa_final-objnr.
wa_bpak-s_wrttp = c_41.
wa_bpak-s_vorga = c_kbud.
wa_bpak-wert = wa_final-budg_upd.
APPEND wa_bpak TO it_bpak.
CALL FUNCTION 'KBPP_EXTERN_UPDATE_CO'
EXPORTING
i_budget_activity = wa_bpak-s_vorga
i_budget_activ_sup_ret = ' '
i_commit_data = c_x
i_delta_amounts = ' '
i_rollup_data = c_x
i_check_plan_data = c_x
TABLES
it_bpak = it_bpak
it_return = it_return.
IF NOT it_return IS INITIAL.
LOOP AT it_return INTO wa_return WHERE type = c_e.
wa_error-budg_upd = wa_return-message.
ENDLOOP.
ELSE.
wa_error-budg_upd = text-003. "'Updated'.
PERFORM transaction_commit.
ENDIF.
ELSE.
wa_error-budg_upd = text-004.
ENDIF.
第三个示例
Read data from CJ30 or budget of a project
*&---------------------------------------------------------------------*
*$*$ Exit : EXIT_SAPLCNAU_002 *$*$
*$*$ Project : ZPS0000 *$*$
*$*$ Enhancement : CNEX0002 *$*$
*$*$ -------------------------------------------------------------- *$*$
*&---------------------------------------------------------------------*
*& Include ZXCN1U06 *
*&---------------------------------------------------------------------*
*declaracao de dados para tratamento das transacoes CJ30,CJ32,CJ37,cj38
DATA: tvarvc TYPE tvarvc.
DATA: v_text(40) TYPE c.
DATA: i_tget_exp LIKE bpge_id.
DATA: li_qtdreg TYPE i.
FIELD-SYMBOLS: <fs_tge> TYPE STANDARD TABLE.
FIELD-SYMBOLS: <fs_tget> TYPE bpge_id.
FIELD-SYMBOLS: <fs_tget_aux> TYPE bpge_id.
IF sy-tcode EQ 'CJ30' OR
sy-tcode EQ 'CJ32' OR
sy-tcode EQ 'CJ37' OR
sy-tcode EQ 'CJ38'.
v_text = '(SAPLKBPP)T_GE[]'.
ASSIGN (v_text) TO <fs_tge>.
IF <fs_tge> IS ASSIGNED.
li_qtdreg = lines( <fs_tge> ).
LOOP AT <fs_tge> ASSIGNING <fs_tget>.
CASE sy-tcode.
WHEN 'CJ30' OR 'CJ32'.
IF <fs_tget>-vorga = 'KBUD'.
MOVE <fs_tget> TO i_tget_exp.
* Export to class ZCL_IM__IM_BEHAVIOUR
EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
EXIT.
ENDIF.
WHEN 'CJ37'.
IF <fs_tget>-vorga = 'KBN0'.
MOVE <fs_tget> TO i_tget_exp.
* Export to class ZCL_IM__IM_BEHAVIOUR
EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
EXIT.
ELSEIF sy-tabix = li_qtdreg.
READ TABLE <fs_tge> INDEX 1 ASSIGNING <fs_tget_aux>.
MOVE <fs_tget_aux> TO i_tget_exp.
CLEAR: i_tget_exp-wtges.
* Export to class ZCL_IM__IM_BEHAVIOUR
EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
ENDIF.
WHEN 'CJ38'.
IF <fs_tget>-vorga = 'KBR0'.
MOVE <fs_tget> TO i_tget_exp.
* Export to class ZCL_IM__IM_BEHAVIOUR
EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
EXIT.
ELSEIF sy-tabix = li_qtdreg.
READ TABLE <fs_tge> INDEX 1 ASSIGNING <fs_tget_aux>.
MOVE <fs_tget_aux> TO i_tget_exp.
CLEAR: i_tget_exp-wtges.
* Export to class ZCL_IM__IM_BEHAVIOUR
EXPORT i_tget_exp TO MEMORY ID 'i_tget_exp'.
ENDIF.
ENDCASE.
ENDLOOP.
ENDIF.
*&---------------------------------------------------------------------*
*$*$ Class : ZCL_IM__IM_BEHAVIOUR *$*$
*$*$ BAdI : IM_BEHAVIOUR *$*$
*$*$ Implementation : Z_IM_BEHAVIOUR *$*$
*&---------------------------------------------------------------------*
METHOD if_ex_im_behaviour~get_behaviour .
* Declaracao de dados para implementacao das transacoes CJ30, CJ32,CJ38
DATA: tvarvc TYPE tvarvc.
DATA: v_text(40) TYPE c.
DATA: i_tget_exp TYPE bpge_id.
FIELD-SYMBOLS: <fs_tge> TYPE ANY TABLE,
<fs_tget> TYPE bpge_id.
IF sy-tcode EQ 'CJ30' OR
sy-tcode EQ 'CJ32' OR
sy-tcode EQ 'CJ37' OR
sy-tcode EQ 'CJ38'.
* Import da EXIT_SAPLCNAU_002
IMPORT i_tget_exp TO i_tget_exp FROM MEMORY ID 'i_tget_exp'.
v_text = '(SAPLKBPP)T_GE[]'.
ASSIGN (v_text) TO <fs_tge>.
LOOP AT <fs_tge> ASSIGNING <fs_tget>.
IF <fs_tget>-epos = 'X'.
* Conditions CJ30
IF ( sy-tcode = 'CJ30' AND <fs_tget>-vorga = 'KBUD' ) AND
( ( <fs_tget>-objnr EQ i_tget_exp-objnr AND
<fs_tget>-wtges NE i_tget_exp-wtges ) OR
( <fs_tget>-wtges NE i_tget_exp-wtges AND
i_tget_exp-objnr IS INITIAL ) )
* Conditions CJ32
OR ( sy-tcode = 'CJ32' AND <fs_tget>-vorga = '*ADD' )
* Conditions CJ37
OR ( sy-tcode = 'CJ37' AND <fs_tget>-vorga = 'KBN0' ) AND
( <fs_tget>-objnr EQ i_tget_exp-objnr AND
<fs_tget>-wtges NE i_tget_exp-wtges )
* Conditions CJ38
OR ( sy-tcode = 'CJ38' AND <fs_tget>-vorga = 'KBR0' ) AND
( <fs_tget>-objnr EQ i_tget_exp-objnr AND
<fs_tget>-wtges NE i_tget_exp-wtges ).
SELECT SINGLE *
FROM tvarvc
INTO tvarvc
WHERE name = 'PS_CONT_ORC_N1'
AND low = sy-uname.
IF sy-subrc NE 0.
MESSAGE ID 'ZPS' TYPE 'E' NUMBER '117' WITH sy-uname.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF. " Fim CJ30, CJ32, CJ37 e CJ38
ENDIF.
ENDMETHOD. "if_ex_im_behaviour~get_behaviour