Get REFX contract break dates via ABAP

In SAP REFX, only the first contract end date is stored in the contract master data. All the next possible break dates are linked to renewal rules. In transaction RE80 or RECN you can simulate future renewals to see all possible future break dates.

Below is a small program that fills an internal table with the same information as the one provided by the simulation button. The program uses a FM that performs the actions that are behind the contract renewal simulate button.

Download – NUGG_CONTRACT_BREAK_DATES.nugg – 6.3 kB – 342   downloads

Function Module

FUNCTION zrefx_cnt_break_get_list.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_RECNNR) TYPE RECNNUMBER
*" REFERENCE(I_BUKRS) TYPE BUKRS
*" EXPORTING
*" REFERENCE(ET_RNSIM) TYPE RE_T_RENEWAL_SIM
*" EXCEPTIONS
*" NOT_FOUND
*"----------------------------------------------------------------------
DATA:
lo_rn_mngr TYPE REF TO if_recn_renewal_mngr,
lo_rn_rule_mngr TYPE REF TO if_retm_renewal_rule_mngr,
ls_contract TYPE recn_contract,
lo_contract TYPE REF TO if_recn_contract.

" Setup a if_recn_contract object reference
" See FORM recontract_package_get in INCLUDE LREIS_MASTERDATA_EXTRACTIONF01
SELECT SINGLE * FROM vicncn INTO CORRESPONDING FIELDS OF ls_contract
WHERE bukrs = i_bukrs
AND recnnr = i_recnnr.

* get object
CALL METHOD cf_recn_contract=>find_by_detail
EXPORTING
is_detail = ls_contract
RECEIVING
ro_instance = lo_contract
EXCEPTIONS
OTHERS = 0.
" See PERFORM cn_next_end_get in the include file LREIS_MASTERDATA_EXTRACTIONF02
IF lo_contract IS BOUND.
lo_rn_mngr = lo_contract->get_renewal_mngr( ).
CALL METHOD lo_rn_mngr->get_renewal_rule_mngr
RECEIVING
ro_instance = lo_rn_rule_mngr
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.

CALL METHOD lo_rn_rule_mngr->set_sim_defaults
EXPORTING
if_sim_reject_all = abap_true.

CALL METHOD lo_rn_rule_mngr->calc_date_list
EXPORTING
if_simulate = abap_true
IMPORTING
et_rnsim = et_rnsim
EXCEPTIONS
error = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.
ENDIF.
ENDFUNCTION.

Program

*&---------------------------------------------------------------------*
*& Report Z_TEST_CONTRACT_DATA
*&
*&---------------------------------------------------------------------*
*This report returns via ABAP, the break dates that can are obtained
*in transaction RE80 when displaying a contract

REPORT zrefx_cnt_break_data_test.

DATA:
lr_contrtype TYPE RANGE OF recncontracttype,
lrs_contrtype LIKE LINE OF lr_contrtype.

DATA: l_bukrs TYPE bukrs.
SELECT-OPTIONS: s_bukrs FOR l_bukrs.
DATA: l_reccnr TYPE recnnumber.
SELECT-OPTIONS: s_recnnr FOR l_reccnr.

DATA:
ls_contract TYPE recn_contract,
lt_rnsim TYPE re_t_renewal_sim,
ls_rnsim TYPE RETM_RENEWAL_SIM.

"Limit to ZRDD, ZEXT and ZRIN
lrs_contrtype-sign = 'I'.
lrs_contrtype-option = 'EQ'.
lrs_contrtype-low = 'ZRDD'.
APPEND lrs_contrtype TO lr_contrtype.
lrs_contrtype-low = 'ZRIN'.
APPEND lrs_contrtype TO lr_contrtype.
lrs_contrtype-low = 'ZEXT'.
APPEND lrs_contrtype TO lr_contrtype.
SELECT * FROM vicncn INTO ls_contract
WHERE bukrs IN s_bukrs
AND recnnr IN s_recnnr
AND recntype IN lr_contrtype.
CALL FUNCTION 'ZREFX_CNT_BREAK_GET_LIST'
EXPORTING
i_recnnr = ls_contract-recnnr
i_bukrs = ls_contract-bukrs
IMPORTING
ET_RNSIM = lt_rnsim
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF sy-subrc = 1.
NEW-LINE.
WRITE: ls_contract-recnnr, ': No break'.
ELSEif sy-subrc > 1..
NEW-LINE.
WRITE: ls_contract-recnnr, ': Error'.
ELSE.
LOOP AT lt_rnsim INTO ls_rnsim.
NEW-LINE.
WRITE: ls_contract-recnnr, ':', ls_rnsim-RNEXTDATE, ':', ls_rnsim-RNNOTDATE.
ENDLOOP.
ENDIF.

ENDSELECT.

Leave a Reply