Axa Assurance Maroc - Insurer Innovation Award 2024
Â
EDM Creating Formulas for Formula Profile & RTP Interface
1. ISU EDM: Creating formulas for use in
Formula Profiles & RTP Interface
This post is about creating your own formula for use in Formula profiles and RTP
Interface.
Formulas are predefined by SAP.
But one can define formulas with specific functions in Customizing for SAP Utilities,
Tools -> System Modifications -> User Defined Enhancement for Energy Data
Management -> Formulas.
For each formula, a function module needs to defined first with the following interface,
CHANGING
REFERENCE (XY_CNTR) TYPE EEDMFORMULACTR
REFERENCE (XY_INP) TYPE TEEDMFORMPARLIST_I
REFERENCE (XY_OUT) TYPE TEEDMFORMPARLIST_O
EXCEPTIONS
GENERAL_FAULT.
One can also use template function modules provided for this purpose.
ISU_EDM_FORMULA_EASY or
ISU_EDM_FORMULA_XXXX.
I intend to create a formula similar to LIMIT04 but with some difference.
My formula has 4 input parameters and 6 Output Parameters.
Input Parameters
1. Measured Consumption (kwh)
2. First Limit for Consumption (kwh)
3. Second Limit for Consumption (kwh)
4. Limit for Demand (KW)
2. Output Parameters
1. Portion below First Limit (kwh)
2. Portion above First Limit (kwh)
3. Portion above second Limit (kwh)
4. Net Demand (Just for Evaluation)(KW)
5. Demand below Limit (KW)
6. Demand above Limit (KW)
So first I created a function module by copying the template function module.
Here I give snippets of the code
âą The 4 Input Parameters
edm_read_input 1.
edm_read_input 2.
edm_read_input 3.
edm_read_input 4.
âą Check if Measured Consumption exceeds First Limit and then if Measured
Consumption exceeds Second Limit
IF xval1 > xval2.
yval1 = xval2.
yval2 = xval1 - xval2.
ELSE.
yval1 = xval1.
yval2 = 0.
ENDIF.
IF xval1 > xval3.
yval3 = xval1 - xval3.
ELSE.
yval3 = 0.
ENDIF.
âą Converting Measured Consumption into Net Demand
yval6 = xval1.
edm_quant_to_demand yval6.
3. âą Calculating Below and Above Limit for Demand
if yval6 > xval4.
yval4 = xval4.
else.
yval4 = yval6.
endif.
if yval6 > xval4.
yval5 = yval6 - xval4.
else.
yval5 = 0.
endif.
âą Appending the result to the Output Parameters
edm_append_output 1.
edm_append_output 2.
edm_append_output 3.
edm_append_output 4.
edm_append_output 5.
edm_append_output 6.
This is how the RTP Formula : Input Parameters Looks like. As you can see the
function module is mentioned and the 4 input parameters are also mentioned.
4. While allocating input parameters we also have to allocate the Calculation Mode
The calculation mode determines how a value is processed when a formula is
executed. It could, for example, enable calculation based on the status of the input
profile value.
SAP has already predefined a number of calculation modes:
âą01 â Value included in calculation
âą02 â Value not included in calculation
âą99 â Value results in cancellation of calculation
When implementing formulas, you can use the constants
co_calcmod_use type e_formulamod value '01',
co_calcmod_not_use type e_formulamod value '02',
co_calcmod_abort type e_formulamod value '99'.
Below are the Output Parameters
5. now I executed this formula in a formula profile.
The values of the input profiles were like this.
6. First Limit for Consumption was at 2000 kwh
Second Limit for Consumption was at 5000 kwh
Demand Limit was at 10000 KW.
The calculation run was executed for the formula.
7. The profile values generated were.
So you see that not much coding is necessary once the logic is clear :)
This is also available in my blog at http://wp.me/p1Ci5j-5h
Do leave a feedback. :D