<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: How to create per section variable that is readable in same-section formula? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742108#M4782522</link>
    <description>&lt;P&gt;How do you mean? If I define a global variable in detail a and one in detail b, they will both be "true" aka their respective value throughout the entire report, will they not?&lt;/P&gt;&lt;P&gt;It seems the global variables are declared independently of where the formula that declares them is placed.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jul 2023 21:30:24 GMT</pubDate>
    <dc:creator>alexsr700</dc:creator>
    <dc:date>2023-07-28T21:30:24Z</dc:date>
    <item>
      <title>How to create per section variable that is readable in same-section formula?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaq-p/12742103</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;
  &lt;P&gt;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).&lt;/P&gt;
  &lt;P&gt;I now have a new approach but I seem to be getting one detail wrong.&lt;/P&gt;
  &lt;P&gt;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.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;//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&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2190457-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2190458-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;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?&lt;/P&gt;
  &lt;P&gt;Thank you&lt;/P&gt;
  &lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 06:53:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaq-p/12742103</guid>
      <dc:creator>alexsr700</dc:creator>
      <dc:date>2023-07-28T06:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to create per section variable that is readable in same-section formula?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742104#M4782518</link>
      <description>&lt;P&gt;As an additional comment to not crowd the first post.&lt;/P&gt;&lt;P&gt;The global stringvar isn't even changed if I repeat formula a in the footer:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2190459-image.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2190460-image.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 07:03:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742104#M4782518</guid>
      <dc:creator>alexsr700</dc:creator>
      <dc:date>2023-07-28T07:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to create per section variable that is readable in same-section formula?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742105#M4782519</link>
      <description>&lt;P&gt;Try adding "WhilePrintingRecords;" to the top of your formula.&lt;/P&gt;&lt;P&gt;-Dell&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 14:28:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742105#M4782519</guid>
      <dc:creator>DellSC</dc:creator>
      <dc:date>2023-07-28T14:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to create per section variable that is readable in same-section formula?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742106#M4782520</link>
      <description>&lt;P&gt;Already tried WhileReading and WhilePrinting &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I use whileprintingrecords, then both detail a and b return "1", so both think section="a".&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 15:01:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742106#M4782520</guid>
      <dc:creator>alexsr700</dc:creator>
      <dc:date>2023-07-28T15:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to create per section variable that is readable in same-section formula?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742107#M4782521</link>
      <description>&lt;P&gt;You may have to use two different variables for the total.&lt;/P&gt;&lt;P&gt;-Dell&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 15:23:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742107#M4782521</guid>
      <dc:creator>DellSC</dc:creator>
      <dc:date>2023-07-28T15:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create per section variable that is readable in same-section formula?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742108#M4782522</link>
      <description>&lt;P&gt;How do you mean? If I define a global variable in detail a and one in detail b, they will both be "true" aka their respective value throughout the entire report, will they not?&lt;/P&gt;&lt;P&gt;It seems the global variables are declared independently of where the formula that declares them is placed.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 21:30:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742108#M4782522</guid>
      <dc:creator>alexsr700</dc:creator>
      <dc:date>2023-07-28T21:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create per section variable that is readable in same-section formula?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742109#M4782523</link>
      <description>&lt;P&gt;I'm trying to think around this.  Also, looking at your formulas - try taking "Global" off the declaration of section in Formula A.  If you're going to us a modifier on a variable, you have to use the same modifier the first time you use the variable in any formula.  Otherwise Crystal might think you have two different variables.&lt;/P&gt;&lt;P&gt;For testing purposes, try this:&lt;/P&gt;&lt;P&gt;1.  Create another formula that will give you the value of section at any point in time:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;{@CurrentSection}
StringVar section;
section&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2.  Instead of using  @a and @b in your report as above, use {@CurrentSection}.&lt;/P&gt;&lt;P&gt;-Dell&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2023 14:20:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-create-per-section-variable-that-is-readable-in-same-section-formula/qaa-p/12742109#M4782523</guid>
      <dc:creator>DellSC</dc:creator>
      <dc:date>2023-07-31T14:20:34Z</dc:date>
    </item>
  </channel>
</rss>

