<?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: Lookup formula in Calculation function in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/lookup-formula-in-calculation-function/qaa-p/14409951#M4943285</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/2307192"&gt;@helga03&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In PaPM Cloud, the way you did it would work. For OnPrem, I remembered &lt;A href="https://community.sap.com/t5/financial-management-q-a/lookup-in-a-calculation-function/qaq-p/12700164" target="_blank" rel="noopener"&gt;this blog post&lt;/A&gt; where the reply suggested using&amp;nbsp;&lt;SPAN&gt;parentheses&lt;/SPAN&gt; to avoid parsing as a string. Try this one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;13854.COUNTERPARTY_TYPE[(COUNTERPARTY_ID=M.COUNTERPARTY_ID)]&lt;/LI-CODE&gt;&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;Leo&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jun 2026 19:56:14 GMT</pubDate>
    <dc:creator>Leonardo-Silva</dc:creator>
    <dc:date>2026-06-02T19:56:14Z</dc:date>
    <item>
      <title>Lookup formula in Calculation function</title>
      <link>https://community.sap.com/t5/technology-q-a/lookup-formula-in-calculation-function/qaq-p/14409406</link>
      <description>&lt;P class=""&gt;&lt;STRONG&gt;Environment:&lt;/STRONG&gt; SAP Profitability and Performance Management 3.0 SP22, On-Premise.&lt;/P&gt;&lt;P class=""&gt;Lookup formula in Calculation function: right-hand join key always quoted as string literal in generated HANA code&lt;/P&gt;&lt;P class=""&gt;Hello,&lt;/P&gt;&lt;P class=""&gt;I am trying to enrich my input data in a Calculation function&amp;nbsp;by pulling fields from another Model Table via a Lookup formula, following the approach from the sample content and older community posts.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Setup:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;Calculation type: Relative&lt;/LI&gt;&lt;LI&gt;Input function: Model Table 13852 (main stream)&lt;/LI&gt;&lt;LI&gt;Lookup tab: Model Table 13854 added&lt;/LI&gt;&lt;LI&gt;In the Action of my first rule, I want to fill the field &lt;CODE&gt;COUNTERPARTY_TYPE&lt;/CODE&gt; from table 13854, joined on &lt;CODE&gt;COUNTERPARTY_ID&lt;/CODE&gt;.&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;STRONG&gt;Formula I entered:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN&gt;13854.COUNTERPARTY_TYPE[COUNTERPARTY_ID=COUNTERPARTY_ID]&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class=""&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt; In the generated HANA code, the right-hand side of the join condition is always wrapped in single quotes, so it is treated as a string literal instead of a field reference from the main stream:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;sql&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN&gt;IFNULL&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class=""&gt;MAX&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;COUNTERPARTY_TYPE&lt;SPAN class=""&gt;)&lt;/SPAN&gt; &lt;SPAN class=""&gt;FROM&lt;/SPAN&gt; &lt;SPAN class=""&gt;"SAPDB"&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Y820HZL000513854"&lt;/SPAN&gt;
&lt;/SPAN&gt;&lt;SPAN&gt;        &lt;SPAN class=""&gt;WHERE&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;COUNTERPARTY_ID &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;'COUNTERPARTY_ID'&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; TO_NVARCHAR&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;''&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt; &lt;SPAN class=""&gt;AS&lt;/SPAN&gt; COUNTERPARTY_TYPE&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class=""&gt;Because of this, the lookup never matches any row and always returns the empty default. The enriched field stays blank, and all my downstream rules that depend on it do not trigger.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;What I already tried&lt;/STRONG&gt; (each one re-activated and re-checked in the generated code):&lt;/P&gt;&lt;DIV class=""&gt;Formula Generated WHERE clause &lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;CODE&gt;...[COUNTERPARTY_ID=M.COUNTERPARTY_ID]&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE&gt;WHERE (COUNTERPARTY_ID = 'M.COUNTERPARTY_ID')&lt;/CODE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;CODE&gt;...[COUNTERPARTY_ID=COUNTERPARTY_ID]&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE&gt;WHERE (COUNTERPARTY_ID = 'COUNTERPARTY_ID')&lt;/CODE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;CODE&gt;...[COUNTERPARTY_ID=$COUNTERPARTY_ID]&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE&gt;WHERE (COUNTERPARTY_ID = '$COUNTERPARTY_ID')&lt;/CODE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P class=""&gt;In every case the right-hand value is quoted as a literal string. The main stream is aliased as &lt;CODE&gt;AS M&lt;/CODE&gt; in the generated code, so I expected &lt;CODE&gt;M.COUNTERPARTY_ID&lt;/CODE&gt; to work as a field reference, but it is quoted too.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;My questions:&lt;/STRONG&gt;&lt;/P&gt;&lt;OL class=""&gt;&lt;LI&gt;How do I enter the main-stream field on the right-hand side of the lookup condition so that it is interpreted as a &lt;STRONG&gt;field reference&lt;/STRONG&gt; and not as a string literal?&lt;/LI&gt;&lt;LI&gt;Is there a dedicated field picker in the formula editor for this, instead of typing the field name as text?&lt;/LI&gt;&lt;LI&gt;Is the bracket lookup syntax &lt;CODE&gt;FID.FIELD[KEY=KEY]&lt;/CODE&gt; still supported in 3.0 SP22, or has the recommended approach changed (e.g. using the Lookup tab join configuration instead of a formula)&lt;/LI&gt;&lt;/OL&gt;&lt;P class=""&gt;Any guidance on the correct syntax or configuration would be greatly appreciated. Thank you!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="helga03_0-1780382956087.png"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/417309i6819D9AC341142CE/image-size/medium?v=v2&amp;amp;px=400" alt="helga03_0-1780382956087.png" title="helga03_0-1780382956087.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="helga03_1-1780382972879.png"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/417310iC6C13C65C501B235/image-size/medium?v=v2&amp;amp;px=400" alt="helga03_1-1780382972879.png" title="helga03_1-1780382972879.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="helga03_2-1780383005521.png"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/417313iA38814579F83D1BC/image-size/medium?v=v2&amp;amp;px=400" alt="helga03_2-1780383005521.png" title="helga03_2-1780383005521.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2026 06:51:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/lookup-formula-in-calculation-function/qaq-p/14409406</guid>
      <dc:creator>helga03</dc:creator>
      <dc:date>2026-06-02T06:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup formula in Calculation function</title>
      <link>https://community.sap.com/t5/technology-q-a/lookup-formula-in-calculation-function/qaa-p/14409951#M4943285</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/2307192"&gt;@helga03&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In PaPM Cloud, the way you did it would work. For OnPrem, I remembered &lt;A href="https://community.sap.com/t5/financial-management-q-a/lookup-in-a-calculation-function/qaq-p/12700164" target="_blank" rel="noopener"&gt;this blog post&lt;/A&gt; where the reply suggested using&amp;nbsp;&lt;SPAN&gt;parentheses&lt;/SPAN&gt; to avoid parsing as a string. Try this one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;13854.COUNTERPARTY_TYPE[(COUNTERPARTY_ID=M.COUNTERPARTY_ID)]&lt;/LI-CODE&gt;&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;Leo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2026 19:56:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/lookup-formula-in-calculation-function/qaa-p/14409951#M4943285</guid>
      <dc:creator>Leonardo-Silva</dc:creator>
      <dc:date>2026-06-02T19:56:14Z</dc:date>
    </item>
  </channel>
</rss>

