Category Archives: SAP REFX

FM To calculate Contract Next Adjustment Date

In REFX transaction RECN (Contract), you can check the Next Adjustment Date (calculated) in the tab Adjustments / Sub Tab Conditions in column Next Poss Adjustment.

The following FM reproduces the same calculation which uses method GET_NEXTADJMDATE of the interface IF_RECD_CONDITION.

FUNCTION ZREFX_CNT_INDEX_NEXTADJMDATE .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_RECNNR) TYPE  RECNNUMBER
*"     REFERENCE(I_BUKRS) TYPE  BUKRS
*"  EXPORTING
*"     REFERENCE(E_NEXTADJMDATE) TYPE  REAJNEXTADJMDATE
*"----------------------------------------------------------------------

  statics:
    lrt_recntype type range of RECNCONTRACTTYPE WITH HEADER LINE,
    lrt_condtype type range of RECDCONDTYPE WITH HEADER LINE.

  data:
    l_numb type     RECDCONDNUMBER,
    lo_condition_mngr TYPE REF TO IF_RECD_CONDITION_MNGR,
    lo_condition    TYPE REF TO IF_RECD_CONDITION,
    ls_condition TYPE RECD_CONDITION,
    l_next TYPE REAJNEXTADJMDATE,
    l_max type  REAJNEXTADJMDATE,
    lo_contract     TYPE REF TO if_recn_contract,
    ls_contract     TYPE recn_contract.

  if lrt_recntype[] is initial.
*    No filtering on condtions for the moment
*    If necessary to filter on rent, need to add
*    1FI, 1BC, 1CC 1DIMF?, 1PFO, 1ER, 1WO	, 1VE, 1UC
*    lrt_condtype-sign = 'I'.
*    lrt_condtype-option = 'BT'.
*    lrt_condtype-low = '0010'.
*    lrt_condtype-high = '0019'.
*    append lrt_condtype.

    lrt_recntype-sign = 'I'.
    lrt_recntype-option = 'EQ'.
    lrt_recntype-low = 'ZRDD'.
    lrt_recntype-high = ''.
    append lrt_recntype.
    lrt_recntype-sign = 'I'.
    lrt_recntype-option = 'EQ'.
    lrt_recntype-low = 'ZRIN'.
    lrt_recntype-high = ''.
    append lrt_recntype.
  endif.

  clear E_NEXTADJMDATE.

  select single * from vicncn into CORRESPONDING FIELDS OF ls_contract
    WHERE recnnr = i_recnnr
      and bukrs = i_bukrs.

  check ls_contract-recntype in lrt_recntype.
  check ls_contract-RECNENDABS > sy-datum.

*     get object
  CALL METHOD cf_recn_contract=>find_by_detail
    EXPORTING
      is_detail   = ls_contract
    RECEIVING
      ro_instance = lo_contract
    EXCEPTIONS
      OTHERS      = 0.

  IF lo_contract IS BOUND.
    lo_condition_mngr = lo_contract->get_condition_mngr( ).

    l_numb = '0001'.

    do.
      CALL METHOD lo_condition_mngr->GET_CONDITION
        EXPORTING
          ID_NUMBER    = l_numb
        RECEIVING
          RO_CONDITION = lo_condition.
      if lo_condition is not BOUND.
        exit.
      endif.
      CALL METHOD LO_CONDITION->GET_DETAIL
        RECEIVING
          RS_DETAIL = ls_condition.

      if ls_condition-condtype in lrt_condtype.
        CALL METHOD lo_condition->GET_NEXTADJMDATE
          RECEIVING
            RD_NEXTADJMDATE = l_next.
        if E_NEXTADJMDATE < l_next.
          E_NEXTADJMDATE = l_next.
        endif.
      endif.
      l_numb = l_numb + 1.
    enddo.
  endif.
ENDFUNCTION.

The FM is available in SLNK format here.
Download – FUGR_ZREFX_INDEXATION.slnk – 7.7 kB – 232   downloads

How to create an instance of CL_RECN_CONTRACT

To create an instance of the Contract object, for a given contract you can use method FIND_BY_DETAIL of the Factory Class CF_RECN_CONTRACT. Here is an example code:

data:
lo_contract TYPE REF TO if_recn_contract,
ls_contract TYPE recn_contract.

select single * from vicncn into CORRESPONDING FIELDS OF ls_contract
WHERE recnnr = i_recnnr
and bukrs = i_bukrs.

* get object

CALL METHOD cf_recn_contract=>find_by_detail
EXPORTING
is_detail = ls_contract
RECEIVING
ro_instance = lo_contract
EXCEPTIONS
OTHERS = 0.

 

SAP REFX Conditions – BW Conditions DSO and One Time Conditions

Data from the standard REFX exctractor 0REFX_1 can be loaded into a DSO with keys related to the RE Object (Object ID, Company Code, Building, Rental Space…) the condition Type and a validity date (ex:0DATEFROM). The condition amounts are provided with cumulative Key Figures (see 0COND_CHG) in relation to time.

This works fine for normal condition type  that can have a start date, an end date and in some cases 1 or more dates where the value of the condition changes.

Ex:

Condition start 01.01.2013 value 100. Condition change on 1.1.2014 value 80. Condition end on 31.21.2014. This results in 3 0REFX_1 records as follow:
VALUEVALIDFROM = 01.01.2013 COND_CHG = 100
VALUEVALIDFROM = 01.01.2014 COND_CHG = -20
VALUEVALIDFROM = 31.12.2014 COND_CHG = -80

There is however one problem with this configuration when a contract contains multiple one-time conditions related to the same condition type whose respective start and end dates are adjacent. 

Ex:

One-Time Condition start 01.01.2013 value 100. Condition ends on 31.12..2013.
Second One-Time  Condition start 01.01.2014 value 80. Condition ends on 31.12..2014.

This results in 4 0REFX_1 records as follow:
VALUEVALIDFROM = 01.01.2013 COND_CHG = 100
VALUEVALIDFROM = 01.01.2014 COND_CHG = -100
VALUEVALIDFROM = 01.01.2014 COND_CHG = 80
VALUEVALIDFROM = 01.01.2015 COND_CHG = -80

You see that here there are 2 records on the 1.1.2014.  If the transformation rule is set to overwrite, one record will be lost.

What can be done in BW: Make sure that 2 distinct 0REFX_1 records with similar keys do not have the same valid from date. to do this. Locate  possible cases by identifiying the one time condition record and then shift the valid from date by 1 day in the past (and make sure no more overlaps exists any more).

However it is not easy to identify one time conditions in the standard extractor 0REFX_1

To do this you need field UNIQUECOND. This field is available in the extract structure REIS_CONDITION_TRAN and the FM that is executed by the extractor will fill this field. However the field is set to not visible in ROOSFIELD, thus it is not visible in the extraction. A field in an extract structure is set to invisible when field ROOSFIELD-SELECTION equals ‘A’. This can be changed directly in the table by creating and running a small ABAP program. This change is not transportable, you will need to do this in acceptance and production too, and then transport the extractor after having removed the ‘Hide’ flag in RSA6 for the now visible UNIQUECOND field.

*&---------------------------------------------------------------------*
*& Report  ZOREFX_1_ROOSFIELD_UNIQUECOND
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zorefx_1_roosfield_uniquecond.
DATA: ls_roosfield TYPE roosfield.

SELECT SINGLE * FROM roosfield
  INTO ls_roosfield
  WHERE oltpsource = '0REFX_1'
    AND objvers = 'A'
    AND field = 'UNIQUECOND'.

IF sy-subrc = 0.
  ls_roosfield-selection = ''.
  MODIFY roosfield FROM ls_roosfield.
  COMMIT WORK.
ENDIF.

See also note 931669 – BW conditions: Validity of one-time conditions

SAP REFX BW Business Content

———————-

REIS_CASHFLOW_TRAN_GET – 0REFX_6 (il y a une err dans le code entre fs et struct… pour FISCPER

———————-

List of SAP REFX BW Extractors

Available REFX Data sources
   0REFX                          Flexible Real Estate Management
Transactional sources
        0REFX_12
        0REFX_1                           RE: Conditions (Flow Data)
        0REFX_11                          Relationship Architecture <> Usage
        0REFX_13                          Differing Measurements (Contract)
        0REFX_14                          Occupancy (Period View)
        0REFX_2                           RE: Measurements (Flow Data)
        0REFX_3                           RE: CO Data
        0REFX_4                           RE: CO Actual Items (Flow Data)
        0REFX_5                           RE: Rental Object Vacancy
        0REFX_6                           RE: Cash Flow
        0REFX_7                           RE: Occupancy
        0REFX_8                           RE: Assets for Real Estate Objects
        0REFX_9                           RE: CO Data – Statistical Key Figures
        0REFX-IO                       Flexible Real Estate Management Master Data
           0ARCHFUNC_ATTR                    Architectural Function
           0ARCHFUNC_TEXT                    Architectural Function
           0ARCHOBJECT_ATTR                  Architectural Object
           0ARCHOBJECT_HIER                  Architectural Object (Hierarchy)
           0ARCHOBJECT_TEXT                  Architectural Object
           0ARCHRELSHP_TEXT                  Architecture-Usage Relationship Type
           0ARCHTYPE_TEXT                    Architectural Object Type
           0ARCHUSAGE_TEXT                   Common Usage
           0AUTHGRP_TEXT                     Authorization Group
           0BUSENTITY_ATTR                   RE: Business Entity (Attributes)
           0BUSENTITY_TEXT                   RE: Business Entity (Texts)
           0CFORIGIN                         Cash Flow Origin
           0CFSTATUS                         Cash Flow Status
           0CONDFRUNIT                       RE: Frequency Unit
           0CONDPURP                         RE: Condition Purpose
           0CONDPURP_ATTR                    RE: Condition Purpose Attributes
           0CONTRCATEG                       RE: Real Estate Contract Category (Texts)
           0CONTRELOBJ_TEXT                  RE: Contract/Object Relationship
           0CONTROBJGR_TEXT                  RE: Object Group Contract Text
           0MEASTYPE_TEXT                    Measurement Type
           0NOTREASON                        RE: Reason for Notice
           0PROP_TYPE_TEXT                   RE: Propery Type
           0REAVAIL                          RE: Availability of Real Estate Object (Texts)
           0REBPROLE                         RE: Business Partner Role
           0REBUILDING_ATTR                  RE: Building
           0REBUILDING_TEXT                  RE: Building (Texts)
           0RECDTYPE_TEXT                    Condition Type
           0RECONTRACT_ATTR                  RE: Contract
           0RECONTRACT_TEXT                  RE: Contract (Texts)
           0REFIXFIT_TEXT                    Fixt./Fitt. Category
           0REFX_BPOBJASSIGN                 Assignment Business Partner – RE Object
           0RELOCCLA_TEXT                    Location Class
           0RENEWALRAT                       Type of Automatic Renewal
            0RENEWALRLE                       RE: Renewal Rule
            0RENEWALRTY                       Renewal Type
            0RENTOBJECT_ATTR                  RE: Rental Object
            0RENTOBJECT_TEXT                  RE: Rental Object (Texts)
            0RENTTYPE                         RE: Type of Rental Object (Text)
            0REOBJECT_DEL_ATTR                Deleted Real Estate Objects
            0REOBJECT_HIER                    RE: Real Estate Object (Hierarchy)
            0REOBJTYPE_TEXT                   RE: Object Types
            0REOCCUP                          RE: Vacancy of Real Estate Objects (Texts)
            0REPROPERTY_ATTR                  RE: Property
            0REPROPERTY_TEXT                  RE: Property (Texts)
            0RERELTGTY_TEXT                   Target Object Type for Relationships
            0RERENTLIST_TEXT                  Representative List of Rents
            0RE_FLW_TP_TEXT                   RE: Flow Type
            0SETTLEUNIT_ATTR                  RE: Settlement Unit (Attributes)
            0SETTLEUNIT_TEXT                  RE: Settlement Unit (Texts)
            0SETTLEVAR                        RE: Settlement Variant
            0SRVCHRGKEY                       RE: Service Charge Key
            0STATUSRES1_TEXT                  Status: Condition
            0STATUSRES2_TEXT                  Status: Lock
            0STATUSREU1_TEXT                  Status: User 1
            0STATUSREU2_TEXT                  Status: User 2
            0STATUSREU3_TEXT                  Status: User 3
            0STATUSREU4_TEXT                  Status: User 4
            0STATUSREU5_TEXT                  Status: User 5
            0SU_TYPE                          RE: Type of Settlement Unit (Texts)
            0VACREAS_TEXT                     Vacancy Reason (RE-FX)

REFX Contract Index Adjustment Data Extraction

The program below lists all the indexations that have occurred for a REFX lease contracts. ( For contracts that have not had or will never have any indexations, some info is available in table VIAJSEPCINDX (fields INDEXSERIES and INDEXBASEYEAR) )

For a given contract ID it derives the INTRENO (internal object ID).

The INTRENO is used to get all relevant records in VIAJRECORD. The records that correspond to past indexations have a status 3 in field ADJMDRECORDSTAT (‘Adjustment Complete’).
Other useful info => ADJMFROMOLD and ADJMFROMCALC (previous index date and index adjustement date)

Each record in VIAJRECORD is linked to a record in VIAJRECINDX via PROCESSGUID + INTRENO.

In VIAJRECINDX you can retrieve INDEXSERIES/INDEXBASEYEAR + ADJMINDEXBASE (index value at adjustement date) and FIRSTINDEXBASE (reference index at initial date of index calculations).

The program can be downloaded in SAPLINK format here


*&———————————————————————*
*& Report ZREFX_CNT_INDX_DATA
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT zrefx_cnt_indx_data.
DATA:
ls_viajrecindx TYPE viajrecindx,
ls_viajrecord TYPE viajrecord,
lt_viajrecindx TYPE TABLE OF viajrecindx,
lt_viajrecord TYPE TABLE OF viajrecord.

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.

REFRESH lt_viajrecord.
REFRESH lt_viajrecindx.

SELECT * FROM viajrecord
INTO TABLE lt_viajrecord
WHERE adjmdrecordstat = ‘3’
AND intreno = ls_contract-intreno.

SELECT * FROM viajrecindx
INTO TABLE lt_viajrecindx
FOR ALL ENTRIES IN lt_viajrecord
WHERE processguid = lt_viajrecord-processguid
and intreno = lt_viajrecord-intreno.

LOOP AT lt_viajrecord INTO ls_viajrecord.
read table lt_viajrecindx into ls_viajrecindx
with key processguid = ls_viajrecord-processguid
intreno = ls_viajrecord-intreno.
NEW-LINE.
WRITE: ls_contract-recnnr, ‘:’, ls_viajrecindx-firstindexbase ,’:’, ls_viajrecindx-indexseries ,’:’, ls_viajrecindx-indexbaseyear , ‘:’, ls_viajrecord-adjmfromold, ‘:’,’:’, ls_viajrecord-adjmfromcalc, ‘:’, ls_viajrecindx-adjmindexbase.
ENDLOOP.
ENDSELECT.

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 – 335   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.

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.

0RECONTRACT_ATTR, NEXT POSSIBLE CONTRACT END DATE

SAP Note 1543274 explains how to extract the Next Possible Contract End Date for each contract.

This information is not stored in the REFX contract tables but is derived from several element such asthe contract end date, the renewal rules and the notice periods.

In theory this calculated date should be the same as the one that is visible in transaction RECN in field. (xxx)

I have implement the SAP Note but I noticed that the extractor derives an incorrect date.

After debugging the extractor I found that at one point in theextractor code all possible end dates since the beginning of the contract are stored in an internal table and then  the 1st date in used for the extraction.

This is incorrect as there are dates that are in the past.

To correct the issue I modified the PERFORM cn_next_end_get in the include file LREIS_MASTERDATA_EXTRACTIONF02 that is called by the extractor to delete from the derived list all dates in the past.

Look for the statement “SORT lt_rnsim BY rnextdate.” and insert a single statement after that.

  SORT lt_rnsim BY rnextdate.

*{   INSERT         DEVK900261                                        1
“Next Possible End Date (simulaiton) does not work as expected
“The result of the simulation contains all end dates since begin of contract
“Thus by selecting the 1st row in the sorted table a date in the past can
“be selected.
“This modification corrects this behaviour by deleting from the table all entries
“where rnextdate is in the past
  delete lt_rnsim where rnextdate < sy-datum.
*}   INSERT
  READ TABLE lt_rnsim INTO ls_rnsim INDEX 1.