Skip to Content
Author's profile photo Mohammed Muzammil

How to end the installation facts time slice ( through programming )

Scope: This document provides a solution to the requirement “ending the existing installation facts time slice to a specific date via ABAP program”.

Background: We implemented the solution for the above requirement in my current assignment. Before sharing it as a document here, I searched in SCN to see if the solution is already available however could not find any. Below are few unanswered threads on this topic.


http://scn.sap.com/thread/1165065

http://scn.sap.com/thread/10754

http://scn.sap.com/thread/3305647


So I hope this piece of information will be useful to the SAP IS-U developers out there!

Solution: The BAPI BAPI_UTILINSTALLATION_CHANFACT can be used to achieve this task. Say suppose, there exists a time slice starting 1st January 2016 till 31st December 9999 for an operand XYZ ( assume the operand category as USERDEF ) with a value 123. Now we need to end the time slice to a date 31st March 2016, then the code for this would be as below.


************************************************************************************************************

*—-Data Declaration

************************************************************************************************************

DATA : 

  lit_instln_facts_upd      TYPE STANDARD TABLE OF bapi_instln_userdef,

  lwa_instln_facts_upd    TYPE  bapi_instln_userdef,  

  lwa_bapi_return_value  TYPE  bapireturn1,              

  l_installation                TYPE anlage.  

************************************************************************************************************

*—-Populate the internal table

************************************************************************************************************

      lwa_instln_facts_upd-operand  = ‘XYZ’.

      lwa_instln_facts_upd-fromdate =  ‘20160401’.    “time slice starting 1st April 2016               

      lwa_instln_facts_upd-duedate  = ‘99991231’.     “time slice ending 31st December 9999

      lwa_instln_facts_upd-udefval1  =  ‘123’.                             

     APPEND lwa_instln_facts_upd TO lit_instln_facts_upd.

************************************************************************************************************

*—-Call the BAPI for the update.

************************************************************************************************************

      CALL FUNCTION ‘BAPI_UTILINSTALLATION_CHANFACT’

        EXPORTING

          number               = l_installation  “Pass the installation number to this variable

          updforce             = ‘X’

          auto_delete       = ‘X’     “This is the important parameter performing the deletion operation

        IMPORTING

          return                  = lwa_bapi_return_value

        TABLES

          userdeftable        = lit_instln_facts_upd.

     IF lwa_bapi_return_valuetype NE ‘E’.

          COMMIT WORK.

     ENDIF.


The trick here is to delete the time slice starting from 1st April 2016 till 31st December 9999, so that what gets left is the time slice starting 1st January 2016 till 31st March 2016.


Summary: We have learnt the idea / solution to end the installation facts time slice to a specific date using the BAPI BAPI_UTILINSTALLATION_CHANFACT.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Ruggero Ruggiero
      Ruggero Ruggiero

      Hello,

      before all excuse me for my bad english.

      I'd like to use this trick to end some installation fact time slices from VBA, but i get error on AUTO_DELETE value setting.

      I regularly use BAPI_UTILINSTALLATION_CHANFACT from VBA to create/modify records in ETTIFN table.

      I suppose AUTO_DELETE parameter definition is similar to UPDFORCE parameter, but maybe i'm wrong.

      Here the way i use UPDFORCE parameter in my VBA code:

      Dim objForce As Object
      Set objForce = objRfcFunc.Exports("UPDFORCE")
      objForce.Value = "X"

      If i do the same with AUTO_DELETE i got error, it seems the parameter is not defined into BAPI.

      Can you help me, pls?

      Thanks in advance.