Skip to Content
0
Jul 28, 2023 at 06:53 AM

How to create per section variable that is readable in same-section formula?

84 Views Last edit Jul 28, 2023 at 07:14 AM 5 rev

Good morning,

unfortunately my initial approach for using a formula to identify the section the formula is iused in, was not possible with built-in methods (https://answers.sap.com/questions/13931185/possible-to-use-if-with-referal-to-eg-details-b.html).

I now have a new approach but I seem to be getting one detail wrong.

Idea is to have a global stringvar as identifier in each section that changes value with section change. And then use this stringvar in a formula within that section.

//formula a
global stringvar section:="a"

//formula b
stringvar section:="b"

//formula test
stringvar section;
local numbervar test;

If section="a" Then
    test:=1
Else If section="b" Then
    test:=2;
test

However, the stringvar section is being shown correctly in each section but the result of test is always the same (that for the second section.

image.png

image.png

Does anybody see what I am doing wrong? Are formulas being executed even if they have not been used yet, i.e. global variable is declared before the formula is even being used?

Thank you

Alex

Attachments

image.png (11.7 kB)
image.png (7.4 kB)