This document will explain one of the ways to create a generic function module to extract comments for a given BPC model.
- SAP BPC 10.0 on SAP NW BW(7.31)
SAP BPC can be leveraged as a sales forecast input tool to support forecast gathering process for SAP APO. The data at the start of the planning run is extracted into SAP BPC. The planners enter/modify the sales forecast numbers along with comments and submit. Their input - numbers and comments then need to be sent back to SAP APO. Numbers can be updated via BW InfoCubes - both in SAP BW and SAP APO. However, there is no direct way to extract comments.
The table of comments for each BPC model is generated/re-generated at the time of model creation/modification. The number of fields can be variable and therefore it is not advisable to create extractor on top of it.
We cannot use the concept of dynamic internal table as it is not support for an RFC-enabled function module.
We know that every time a BPC model is created or modified, its corresponding comments table is generated. The naming convention of the comments table follow a set logic.
Comment table Name = '/1CPMB/' + 2 Characters after the first 6 characters from the Model Technical Name + 3 Characters after the first 9 characters of the Model Technical Name + 'CMT'
* '+' stands for concatenation
Also, we need to ensure that the comments stored in this table can also be accessed in APO so that they can be uploaded into the APO planning book through respective BAPI.
Let us understand the comments table. The comments table will have the following 8 fields for each model:
The remaining fields will be the dimensions of the model - which is the variable we have to deal with. We will therefore create a structure that will have all these fields and a generic field. This structure can now be used for getting data from any BPC comments table.
What this generic field will do is that it will contain values from all the dimensions of the model that were present against a given comment. There could be better ways to handle this scenario but this is one which I could think of. Now we have the values concatenated, we will also need a way to know which value belongs to which dimension. We will create a data element as show below:
This data element will be given as the type for the export parameter. Here are the function module parameters:
The code will use the import parameters to determine the technical name of the model from the table UJA_APPL. Using that technical name, the comments table name will be derived based on the aforementioned logic.
With the use of field-symbols, we can read the data dynamically and then transfer into the respective fields of the output table ET_COMMENTS. Refer the attachment for the entire code.
On executing this FM, here is how the input screen will look like:
Here is how the output will be:
On looking at the entries of ET_COMMENTS:
I am sure there will be many more refined ways to do it. This is one of the approach that can be used to extract comments dynamically from BPC NW system to another connected SAP system for any BPC model.
if you create model ID with lowercase letters, you need to tweak the FM to accept it or check the Uppercase/Lowercase check box at the run time in the Input screen.