0% found this document useful (0 votes)
156 views7 pages

EDM Creating Formulas

This document describes how to create a custom formula in SAP for use in formula profiles and the RTP interface. It provides details on defining a function module with the required interface, using template modules, and writing code to process input parameters and calculate output parameters based on business logic. An example formula is created to calculate consumption and demand below and above defined limits, with code snippets showing how the input parameters are read and output is appended.

Uploaded by

bilix76
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
156 views7 pages

EDM Creating Formulas

This document describes how to create a custom formula in SAP for use in formula profiles and the RTP interface. It provides details on defining a function module with the required interface, using template modules, and writing code to process input parameters and calculate output parameters based on business logic. An example formula is created to calculate consumption and demand below and above defined limits, with code snippets showing how the input parameters are read and output is appended.

Uploaded by

bilix76
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

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)


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.
• 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.
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


now I executed this formula in a formula profile.

The values of the input profiles were like this.


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.


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

You might also like