Get REFX contract notice periods via ABAP.

In SAP REFX, contract notice periods are not stored data. They are calculated based on the notice rules that have been assigned to the contract.

In the contract maintenance display, a simulate button allows the user to preview all the notice periods of the contract.

Below is a small program that fills an internal table with the same information as the one provided by the simulation button.

The program calls the simulation  method as in the contract maintenance screen.

You can find a FM and program as below at the following addres

*&———————————————————————*
*& Report Z_TEST_CONTRACT_DATA
*&
*&———————————————————————*
*This report returns via ABAP, the notice dates that can are obtained
*in transactino RE80 when displaying a contract

REPORT zrefx_cnt_notice_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_bukrs.
PARAMETERS: p_lndlrd TYPE c AS CHECKBOX.

DATA:
ls_contract TYPE recn_contract,
lt_ntsim TYPE re_t_notice_sim,
ls_ntsim TYPE retm_notice_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_NOTICE_GET_LIST’
EXPORTING
i_recnnr = ls_contract-recnnr
i_bukrs = ls_contract-bukrs
i_landlord = ‘1’
IMPORTING
et_ntsim = lt_ntsim
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.

IF sy-subrc = 1.
NEW-LINE.
WRITE: ls_contract-recnnr, ‘: No notice’.
ELSEif sy-subrc > 1..
NEW-LINE.
WRITE: ls_contract-recnnr, ‘: Error’.
ELSE.
LOOP AT lt_ntsim INTO ls_ntsim.
NEW-LINE.
WRITE: ls_contract-recnnr, ‘:’, ls_ntsim-ntreceiptfrom, ‘:’, ls_ntsim-ntreceiptto, ‘:’, ls_ntsim-ntcalculated.
ENDLOOP.
ENDIF.

ENDSELECT.

FM

FUNCTION zrefx_cnt_notice_get_list.
*”———————————————————————-
*”*”Local Interface:
*” IMPORTING
*” REFERENCE(I_RECNNR) TYPE RECNNUMBER
*” REFERENCE(I_BUKRS) TYPE BUKRS
*” REFERENCE(I_LANDLORD) TYPE FLAG DEFAULT ‘1’
*” EXPORTING
*” REFERENCE(ET_NTSIM) TYPE RE_T_NOTICE_SIM
*” EXCEPTIONS
*” NOT_FOUND
*”———————————————————————-
DATA:
lo_notice_obj_mngr TYPE REF TO if_retm_specific_term_mngr,
lt_contract TYPE re_t_contract,
lo_notice_mngr TYPE REF TO if_retm_notice_mngr,
lo_notice_proc_mngr TYPE REF TO if_retm_notice_proc_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.
” Setup the notice_proc_mngr object
” See IF_REAJ_METHOD~GET_PARENT_POINTER for similar code
IF lo_contract IS BOUND.
* get notice manager
lo_notice_mngr = lo_contract->get_term_notice_mngr( ).
IF lo_notice_mngr IS BOUND.
* get notice proc manager
CALL METHOD lo_notice_mngr->get_notice_proc_mngr
RECEIVING
ro_notice_proc_mngr = lo_notice_proc_mngr
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
CLEAR lo_notice_proc_mngr.
raise not_found.
ENDIF.
ENDIF.
ENDIF.

” Choose party (has no impact on result if term applies to BOTH)
” see FORM on_ntsim_toggle_prty INCLUDE LRETM_GUI_NTSIM_POPUPF01
IF i_landlord = ‘X’.
CALL METHOD lo_notice_proc_mngr->set_sim_defaults
EXPORTING
id_sim_ntprocprty = retm2_ntprocprty-landlord.
ELSE.
CALL METHOD lo_notice_proc_mngr->set_sim_defaults
EXPORTING
id_sim_ntprocprty = retm2_ntprocprty-tenant.
ENDIF.

” Get the list of all notices
” See FORM GRID_GET_DATA from INCLUDE LRETM_GUI_NTSIMF01

CALL METHOD lo_notice_proc_mngr->calc_date_list
EXPORTING
if_simulate = abap_true
IMPORTING
et_ntsim = et_ntsim
EXCEPTIONS
error = 1
OTHERS = 2.
if sy-subrc <> 0.
raise others.
endif.

ENDFUNCTION.

Leave a Reply