My project had a requirement to add up actual values(actual and actual-manual) and copy to forecast values in the Financial Planning of the PPM Module. Even though this sounds very simple, anyone who knows PPM tables knows that it is more than what meets the eye.
I struggled a lot to find an apt way of achieving this. I tried many other processes like Function Module(FM) /RPM/FIN_PLAN_SAVE_DB. The problem with this FM was that all entries in the plan table belonging to a group had to be passed to this FM even when we had to update just one record in that group. I also explored the BADIs /RPM/EX_FIN_B_PLAN_BADI, /RPM/EX_FIN_PLAN, /RPM/FIN_CAP_PLAN . But I wanted something that can be called within an FM which updates the /RPM/FIN_PLAN table with plan details. Finally, while debugging I stumbled upon the API /rpm/cl_fin_cap_planning_api. This API was best suited for my requirement as I only had to pass the changed entry and it internally selects the rest of the plan entries in the group. I spent a lot of researching how to make use of this API specially to know how to pass the context to the API. I am writing this blog post to help my fellow developers.
Read More: C_TAW12_750
The steps described in this blog post can also be used to update Capacity Planning tables.
Requirement: There are 2 views to capture actual cost – Actual(comes from ECC) and Actual-Manual(entered manually). The requirement is that the Forecast view should be calculated by adding the two costs – Actual and Actual-Manual.
This blog post is a step-by-step how-to guide to achieve this objective.
Steps:
1. Get guid from table /RPM/ITEM_D for the external_id in the input table(IT_PROJ)
2. Get required fields into 1 table using join from /rpm/item_d /rpm/fin_cat, /rpm/fin_group /rpm/fin_plan
3. Add the values of actual and actual-manual costs of corresponding months and categories
4. Update the forecast costs using API. Use get_plan_info method to pass the context**. Call initialize_planning method and finally fin_groups_modify to update values. The API is well designed in the sense that only the changed fin_plan entries need to be passed and the API handles the rest.
** very crucial part..took me a while to figure out how to pass the context
5. Very important to call the cl_inm_ppm_services=>save to commit work.
6. Capture the messages and display.
I have given the required code of the RFC FM below. The FM takes one or more External_id(s) of the Project(/RPM/ITEM_D-EXTERNAL_ID) as the input, calculates the Forecast view and in turn updates the tables(/RPM/FIN_PLAN, /RPM/FIN_GROUP) for the same.
FM Interface:
No comments:
Post a Comment