Financial Management Blogs by Members
Dive into a treasure trove of SAP financial management wisdom shared by a vibrant community of bloggers. Submit a blog post of your own to share knowledge.
cancel
Showing results for 
Search instead for 
Did you mean: 
Amogh_Kulkarni
Explorer
2,502
Introduction :

SAP Profitability and Performance Management (PaPM) Remote Function Adapter offers you the capability to use powerful coding language like Python and JavaScript.

This blog will help you understand and configure how to make use of the Python function and code a simple logic to calculate the difference between two dates using a Python library in PaPM

Challenge :


I am sure that you must have faced this nagging question of how to calculate difference between two dates irrespective of the technology that you must be working on. To solve this, you have to first convert the date fields into date formats and then write logics to calculate the difference between the two dates.

In SAP Profitability and Performance Management (PaPM), i too faced this challenge, specially when my source data was in STRING format as compared to DATE format.

Solution :


As usual, I tried to overcome this challenge by using a CALCULATE function but for this, I had to first convert the STRING data type to DATE by using TO_DATE function.  Now this is a tried and tested methodology but I thought to myself why not try something different and that is when i was encouraged to look at the Python function type from the Remote Function Adapter family in SAP Profitability and Performance Management (PaPM).

  1. Create two date type fields 'Start Date' (STR_DATE) and 'End Date' (END_DATE' in your environment and create a Model Table called as 'Dates Data' with these fields and populate it with some date entries as shown below: -

  2. Created a field called as NUM_DAYS (Number of Days) in the environment.

  3. Created a Remote Function Adapter - Python - 'Date Difference' and linked it with the Model Table 'Dates Data' as shown below

  4. Now comes the interesting part :).

    1. In the Python function 'Date Difference' , select the Input and assign the source model table, in this case 'Dates Data' to link the model table with the python function as shown below

    2. In the 'Signature', select the

      1. 'Start Date' and 'End Date' fields (which are from your model table 'Dates Data' as part of 'Selection'

      2. 'Number of Days' field (which you created earlier in the environment (step 2)) as part of 'Actions



    3. Here is the PYTHON code that calculates the difference between the Start Date and the End Date and populates in the Number of Days field

    4. Save and Activate the Python Function 'Date Difference'


    5. Execute the Python function and see the results




As shown, the Python Code has executed and has populated the difference between the End Date and the Start Date in the 'Number of Days' field.

Conclusion :


We can use a simple PYTHON logic to calculate the difference between two dates using the Python - Remote Function Adapter.

References :


I would like to give credit for following references that helped in writing this blog


https://answers.sap.com/questions/13589848/ppm-cloud-remote-function-adapter.html

Summary :


To wrap up, I have shown how we can use ‘SAP Profitability and Performance Management (PaPM) Python – Remote Function Adapter’ function type to calculate differences between two dates

I thank you for reading through my second blog in SAP Profitability and Performance Management (PaPM).

Kindly requesting you to leave your feedback and comments.

I would encourage you to follow the topics in for more enlightenment on SAP Profitability and Performance Management (PaPM).

https://community.sap.com/topics/profitability-and-performance-management

Thanks

Amogh Kulkarni
7 Comments
Labels in this area
Top kudoed authors