SAP for Utilities Blogs
Discover insights and practical tips to optimize operations, reduce costs, and deliver reliable energy with SAP technology. Contribute your own blog post!
cancel
Showing results for 
Search instead for 
Did you mean: 
mohammedmuzammil
Participant
0 Kudos
2,891

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_value-type 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.

1 Comment