<?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>topic Reduce operator with Secondary key in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-operator-with-secondary-key/m-p/390941#M9642</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to use secondary key with the reduce constructor operator. Below are the code lines.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: lt_index TYPE STANDARD TABLE OF cmm_d_idx
               WITH NON-UNIQUE SORTED KEY ik_obj_id COMPONENTS obj_id.

lt_index = VALUE cmm_t_idx(
           FOR ls_root_extract IN lt_risk_root_extract 
           LET lv_obj_id  = |{ ls_root_extract-fbuda DATE = USER }| &amp;amp; |{ '-                ' &amp;amp;&amp;amp; ls_root_extract-locid &amp;amp;&amp;amp; '-' &amp;amp;&amp;amp; ls_root_extract-ro_type+               7(3) }|
            IN  ( key = ls_root_extract-key
                  obj_id   = lv_obj_id
                  obj_item = REDUCE cmm_idx_obj_item( 
                             INIT lv_itm = 1 FOR ls_idx IN lt_index 
                             USING KEY ik_obj_id 
                             WHERE ( obj_id = lv_obj_id ) 
                             NEXT lv_itm = ls_idx-obj_item + 1 ) 
                  obj_type = ls_root_extract-ro_type ) ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;These line are giving me syntax error as:-&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/22706-error.png" /&gt;&lt;/P&gt;&lt;P&gt;However skipping the where condition giving me error free code. I have tried using the same logic with the old style and that is working fine, so I'm not sure what is missing here.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_index ASSIGNING FIELD-SYMBOL(&amp;lt;fs_idx&amp;gt;) 
                  USING KEY ik_obj_id WHERE obj_id is INITIAL.
* &amp;lt;&amp;lt;Rest of the logic&amp;gt;&amp;gt;
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Feb 2017 04:22:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2017-02-28T04:22:06Z</dc:date>
    <item>
      <title>Reduce operator with Secondary key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-operator-with-secondary-key/m-p/390941#M9642</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to use secondary key with the reduce constructor operator. Below are the code lines.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: lt_index TYPE STANDARD TABLE OF cmm_d_idx
               WITH NON-UNIQUE SORTED KEY ik_obj_id COMPONENTS obj_id.

lt_index = VALUE cmm_t_idx(
           FOR ls_root_extract IN lt_risk_root_extract 
           LET lv_obj_id  = |{ ls_root_extract-fbuda DATE = USER }| &amp;amp; |{ '-                ' &amp;amp;&amp;amp; ls_root_extract-locid &amp;amp;&amp;amp; '-' &amp;amp;&amp;amp; ls_root_extract-ro_type+               7(3) }|
            IN  ( key = ls_root_extract-key
                  obj_id   = lv_obj_id
                  obj_item = REDUCE cmm_idx_obj_item( 
                             INIT lv_itm = 1 FOR ls_idx IN lt_index 
                             USING KEY ik_obj_id 
                             WHERE ( obj_id = lv_obj_id ) 
                             NEXT lv_itm = ls_idx-obj_item + 1 ) 
                  obj_type = ls_root_extract-ro_type ) ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;These line are giving me syntax error as:-&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/22706-error.png" /&gt;&lt;/P&gt;&lt;P&gt;However skipping the where condition giving me error free code. I have tried using the same logic with the old style and that is working fine, so I'm not sure what is missing here.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_index ASSIGNING FIELD-SYMBOL(&amp;lt;fs_idx&amp;gt;) 
                  USING KEY ik_obj_id WHERE obj_id is INITIAL.
* &amp;lt;&amp;lt;Rest of the logic&amp;gt;&amp;gt;
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2017 04:22:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-operator-with-secondary-key/m-p/390941#M9642</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-02-28T04:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Reduce operator with Secondary key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-operator-with-secondary-key/m-p/390942#M9643</link>
      <description>&lt;P&gt;In a simplified example &lt;STRONG&gt;both&lt;/STRONG&gt; either give syntax errors or not:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES itab TYPE STANDARD TABLE OF spfli
      WITH EMPTY KEY
      WITH NON-UNIQUE SORTED KEY mkey COMPONENTS cityfrom cityto.
DATA itab TYPE itab.
LOOP AT itab INTO DATA(wb) USING KEY mkey WHERE carrid  = '...'. "Syntax error
ENDLOOP.
DATA(jtab) = VALUE itab( FOR wa IN itab USING KEY mkey           "Syntax error
                                        WHERE ( carrid = '...' )
                         ( wa ) ).
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE&gt;TYPES itab TYPE STANDARD TABLE OF spfli
      WITH EMPTY KEY
      WITH NON-UNIQUE SORTED KEY mkey COMPONENTS cityfrom cityto.
DATA itab TYPE itab.
LOOP AT itab INTO DATA(wb) USING KEY mkey WHERE cityfrom  = '...'. "No Syntax error
ENDLOOP.
DATA(jtab) = VALUE itab( FOR wa IN itab USING KEY mkey             "No Syntax error
                                        WHERE ( cityfrom = '...' )
                         ( wa ) ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Back to 7.40, SP08, Kernel Patch Level 14. And that is as documented.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 07:15:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-operator-with-secondary-key/m-p/390942#M9643</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-02-28T07:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Reduce operator with Secondary key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-operator-with-secondary-key/m-p/390943#M9644</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error message for your expression is correct. &lt;/P&gt;&lt;P&gt;There is a type mismatch in the WHERE condition&lt;/P&gt;&lt;P&gt;Your&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LET lv_obj_id = |{ ls ... &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is of type string.&lt;/P&gt;&lt;P&gt;Put a CONV around the RHS, to make lv_obj_id the same type as obj_id.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 07:30:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-operator-with-secondary-key/m-p/390943#M9644</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-02-28T07:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reduce operator with Secondary key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-operator-with-secondary-key/m-p/390944#M9645</link>
      <description>&lt;P&gt;My bad.. Thanks it has resolved the issue.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 08:52:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-operator-with-secondary-key/m-p/390944#M9645</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-02-28T08:52:21Z</dc:date>
    </item>
  </channel>
</rss>

