on 2016 Jun 24 12:10 PM
Hi All -
I am working for BPC Embedded Planning BW 7.5 .
We have z-table having formula maintained -
| Account (Output) | Sequence | Operator | Account Ref. |
|---|---|---|---|
| 100101 | 1 | START | 30101 |
| 100101 | 2 | PLUS | 30102 |
| 100101 | 3 | MINUS | 30103 |
| 100101 | 4 | PLUS | 30104 |
| 100101 | 5 | END |
and we have transaction data:
| Account | Year | Amount |
|---|---|---|
| 30101 | 2016 | 10 |
| 30102 | 2016 | 5 |
| 30103 | 2016 | 20 |
| 30104 | 2016 | 30 |
The plan is to have program to calculate based on that table to be like this:
100101 = 10 + 5 - 20 + 30
100101 = 25
I have a plan to put the aritmatics into string - and function module calculate it for me.
Do you know what ABAP standard function module that can do it?
Many thanks,
Daniel N.
Request clarification before answering.
You could play with FM EVAL_FORMULA, but using this FM will need more time than coding it yourself.
Regards,
Raymond
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not long, if there's a good example 😉 :
DATA d(255) TYPE c.
DATA l_prog TYPE syrepid.
DATA l_sr TYPE syrepid.
DATA a TYPE f.
DATA b TYPE I.
d = `2.5 * ( PIX + abs( -1 ) )`.
l_prog = sy-repid.
l_sr = 'MYROUTINE'.
CALL FUNCTION 'EVAL_FORMULA'
EXPORTING
formula = d
program = l_prog
routine = l_sr
IMPORTING
value = a
EXCEPTIONS
division_by_zero = 1
exp_error = 2
formula_table_not_valid = 3
invalid_expression = 4
invalid_value = 5
log_error = 6
parameter_error = 7
sqrt_error = 8
units_not_valid = 9
missing_parameter = 10
OTHERS = 11.
b = a.
ASSERT B = 10.
FORM myroutine
USING
i_var TYPE c
CHANGING
e_value TYPE f
e_subrc TYPE p.
CASE i_var.
WHEN `PIX`. e_value = 3.
WHEN OTHERS. e_subrc = 1.
ENDCASE.
ENDFORM.And a good documentation:
convert it to a subroutine in ABAP (have a standard interface) and generate a subroutine pool.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As far as I know there is no dynamic way to do arithmetic calculations (variant of dynamic SELECT ... WHERE (cond_syntax) ). You can only dynamicaly create report (INSERT REPORT).
Also there is this "Internally released" function EVAL_FORMULA which works with arithmetic expresions in string format. Program to evaluate formula in a string - ABAP Development - SCN Wiki
But I would rather go simple step-by-step way:
CASE operator.
WHEN '+'.
result = a + b.
....
ENDCASE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't understand whether it's a pure ABAP question, then the answer is no (i.e. do it yourself, it seems to be a quite simple logic), or if it's related to BPC that I don't know, in which your Z-table was generated by a standard BPC process, and in that case I would recommend to post to the BPC forum.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if I have standard ABAP Function module where it can compute the arithmetic on the string - the Function Module will handle it.
What I need to do is to put all values of the account into 1 string - the function module will take care of it.
Does it answer your question?
Many thanks,
Daniel N .
| User | Count |
|---|---|
| 8 | |
| 8 | |
| 7 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.