<?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 Re: FOR iteration with inline declaration in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-iteration-with-inline-declaration/m-p/12161251#M1978034</link>
    <description>&lt;P&gt;The issue is with DATA(lt_workcenter_nodesc) = VALUE #(...):&lt;/P&gt;&lt;P&gt;# means that the compiler has to deduce the type for lt_workcenter_nodesc, and this is never possible if the target type is an internal table, because it could be standard, sorted or hashed, and the key is not defined too.&lt;/P&gt;&lt;P&gt;Solution: you must explicitly define the type:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT ... INTO TABLE @DATA(lt_workcenter) ...
TYPES tt_workcenter LIKE lt_workcenter.
DATA(lt_workcenter_nodesc) = VALUE tt_workcenter( ... ).&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 05 Feb 2020 14:30:00 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2020-02-05T14:30:00Z</dc:date>
    <item>
      <title>FOR iteration with inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-iteration-with-inline-declaration/m-p/12161250#M1978033</link>
      <description>&lt;P&gt;I recently came across the requirement to copy certain items of an internal table, inline declared in an select statement, to another.&lt;/P&gt;
  &lt;P&gt;First I thought I might use the FILTER statement. Turns out I can't find a syntax to inline declare the table in a way filtering can be used (only SORTED or HASHED tables).&lt;BR /&gt;&lt;BR /&gt;Ok so next try: FOR iteration. Resulting in:&lt;BR /&gt;&lt;EM&gt;No type can be derived from the context for the operator "VALUE".&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;First I thought its related to the inline declaration within the select statement for lt_workcenter.&lt;BR /&gt;Turns out its not. More likely its because the FOR iteration does not provide a proper typing like WITH EMPTY KEY at least not in ABAP 750?&lt;BR /&gt;&lt;BR /&gt;Or am I missing something here?&lt;/P&gt;
  &lt;P&gt;Example:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;    SELECT crhd~objty,
           crhd~objid,
           crhd~arbpl,
           crhd~werks,
           crtx~ktext
      INTO TABLE @DATA(lt_workcenter)
      FROM crhd LEFT OUTER JOIN crtx ON  crhd~objty = crtx~objty
                                     AND crhd~objid = crtx~objid
      WHERE crhd~werks IN @mr_werks
        AND crhd~matyp =  '0004' 
        AND crtx~spras =  @sy-langu.

    DATA(lt_workcenter_nodesc) = VALUE #( FOR &amp;lt;fs&amp;gt; IN lt_workcenter WHERE ( ktext = '' ) ( fs&amp;gt; ) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Feb 2020 13:22:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/for-iteration-with-inline-declaration/m-p/12161250#M1978033</guid>
      <dc:creator>former_member38721</dc:creator>
      <dc:date>2020-02-05T13:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: FOR iteration with inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-iteration-with-inline-declaration/m-p/12161251#M1978034</link>
      <description>&lt;P&gt;The issue is with DATA(lt_workcenter_nodesc) = VALUE #(...):&lt;/P&gt;&lt;P&gt;# means that the compiler has to deduce the type for lt_workcenter_nodesc, and this is never possible if the target type is an internal table, because it could be standard, sorted or hashed, and the key is not defined too.&lt;/P&gt;&lt;P&gt;Solution: you must explicitly define the type:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT ... INTO TABLE @DATA(lt_workcenter) ...
TYPES tt_workcenter LIKE lt_workcenter.
DATA(lt_workcenter_nodesc) = VALUE tt_workcenter( ... ).&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Feb 2020 14:30:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/for-iteration-with-inline-declaration/m-p/12161251#M1978034</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-02-05T14:30:00Z</dc:date>
    </item>
  </channel>
</rss>

