<?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: VALUE and multiple FOR operators to create internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360815#M7590</link>
    <description>&lt;P&gt;Sometimes, the conclusion is that the question has not an expected answer, but another way to do it. I prefer another way &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Nov 2016 09:50:17 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2016-11-25T09:50:17Z</dc:date>
    <item>
      <title>VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360803#M7578</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm searching for a way to create an internal table using the VALUE #() operator with multiple FOR expressions inside.&lt;/P&gt;&lt;P&gt;While this works of course with a single FOR operator I can't get this working with more than one operator, right now. Maybe it's impossible at all, may be I'm still doing something wrong.&lt;/P&gt;&lt;P&gt;So far I tried: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lt_sel) = VALUE rsparams_tt(
 FOR &amp;lt;v2&amp;gt; IN p_reason
 ( 
 selname = 'P_AUGRU' 
 high = &amp;lt;v2&amp;gt;-high 
 low = &amp;lt;v2&amp;gt;-low 
 option = &amp;lt;v2&amp;gt;-option 
 sign = &amp;lt;v2&amp;gt;-sign 
 )
 FOR &amp;lt;v1&amp;gt; IN p_auart
 ( 
 selname = 'P_AUART' 
 high = &amp;lt;v1&amp;gt;-high 
 low = &amp;lt;v1&amp;gt;-low 
 option = &amp;lt;v1&amp;gt;-option 
 sign = &amp;lt;v1&amp;gt;-sign 
 )
 ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to no avail. &lt;/P&gt;&lt;P&gt;These are non-nested FOR expressions but sequential ones that should create a single internal table from different sources.&lt;/P&gt;&lt;P&gt;So do you have an idea how to get this working?&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 13:20:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360803#M7578</guid>
      <dc:creator>MichiFr</dc:creator>
      <dc:date>2016-11-24T13:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360804#M7579</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;As per the &lt;A href="https://help.sap.com/abapdocu_740/en/abenvalue_constructor_params_itab.htm"&gt;ABAP Documentation&lt;/A&gt;, the syntax is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;... VALUE dtype|#( [let_exp] 
                   [BASE itab] 
                   [FOR for_exp1 
                    FOR for_exp2 
                    ... ] 
                   ( line_spec1 ) 
                   ( line_spec2 ) 
                     ... ) ... 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then, could you retry with the following code ?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lt_sel) = VALUE rsparams_tt(
 FOR &amp;lt;v2&amp;gt; IN p_reason
 FOR &amp;lt;v1&amp;gt; IN p_auart
 ( 
   selname = 'P_AUGRU' 
   high = &amp;lt;v2&amp;gt;-high 
   low = &amp;lt;v2&amp;gt;-low 
   option = &amp;lt;v2&amp;gt;-option 
   sign = &amp;lt;v2&amp;gt;-sign 
 )
 ( 
   selname = 'P_AUART' 
   high = &amp;lt;v1&amp;gt;-high 
   low = &amp;lt;v1&amp;gt;-low 
   option = &amp;lt;v1&amp;gt;-option 
   sign = &amp;lt;v1&amp;gt;-sign 
 )
).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Best regards, Nicolas&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 13:40:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360804#M7579</guid>
      <dc:creator>Nicolas</dc:creator>
      <dc:date>2016-11-24T13:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360805#M7580</link>
      <description>&lt;P&gt;Hello Michael,&lt;/P&gt;&lt;P&gt;How about using auxiliary variables?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lt_sel1)
 = VALUE rsparams_tt( 
      LET 
        sel1 = VALUE rsparams_tt( FOR &amp;lt;so1&amp;gt; IN s_carrid 
               ( selname = 'S_CARRID' 
                 kind = 'S' 
                 sign = &amp;lt;so1&amp;gt;-sign 
                 option = &amp;lt;so1&amp;gt;-option 
                 low = &amp;lt;so1&amp;gt;-low 
                 high = &amp;lt;so1&amp;gt;-high ) )
        sel2 = VALUE rsparams_tt( FOR &amp;lt;so2&amp;gt; IN s_connid 
               ( selname = 'S_CARRID' 
                 kind = 'S' 
                 sign = &amp;lt;so2&amp;gt;-sign 
                 option = &amp;lt;so2&amp;gt;-option 
                 low = &amp;lt;so2&amp;gt;-low 
                 high = &amp;lt;so2&amp;gt;-high ) )
      IN
      ( LINES OF sel1 )
      ( LINES OF sel2 )
    ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;TBH i was not aware that multiple FORs result in a nested loop. &lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 13:48:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360805#M7580</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2016-11-24T13:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360806#M7581</link>
      <description>&lt;P&gt;I know this from the help, however, doing this way you are nesting the FORs, equallly to nested LOOPs and you will get  lines(&amp;lt;v2&amp;gt;)  * lines(&amp;lt;v1&amp;gt;) in the final table.&lt;/P&gt;&lt;P&gt;In my case if the internal table p_reason holds 10 lines and p_auart 5 lines, the result will get 50 lines instead of expected 15 lines.&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 13:53:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360806#M7581</guid>
      <dc:creator>MichiFr</dc:creator>
      <dc:date>2016-11-24T13:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360807#M7582</link>
      <description>&lt;P&gt;That's it - thanks for this suggestion!&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 13:57:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360807#M7582</guid>
      <dc:creator>MichiFr</dc:creator>
      <dc:date>2016-11-24T13:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360808#M7583</link>
      <description>&lt;P&gt;Hi Nicolas,&lt;/P&gt;&lt;P&gt;TBH i was not aware that the Multiple FORs would result in a nested loop &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I read the SAP documentation and then wrote this code snippet to check the behaviour&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES: sflight.
SELECT-OPTIONS:
s_carrid FOR sflight-carrid,
s_connid FOR sflight-connid.
DATA(lt_sel1)
 = VALUE rsparams_tt(
      LET
        sel1 = VALUE rsparams_tt( FOR &amp;lt;so1&amp;gt; IN s_carrid
               ( selname = 'S_CARRID'
                 kind = 'S'
                 sign = &amp;lt;so1&amp;gt;-sign
                 option = &amp;lt;so1&amp;gt;-option
                 low = &amp;lt;so1&amp;gt;-low
                 high = &amp;lt;so1&amp;gt;-high ) )
        sel2 = VALUE rsparams_tt( FOR &amp;lt;so2&amp;gt; IN s_connid
               ( selname = 'S_CARRID'
                 kind = 'S'
                 sign = &amp;lt;so2&amp;gt;-sign
                 option = &amp;lt;so2&amp;gt;-option
                 low = &amp;lt;so2&amp;gt;-low
                 high = &amp;lt;so2&amp;gt;-high ) )
      IN
      ( LINES OF sel1 )
      ( LINES OF sel2 )
    ).
DATA(lt_sel2)
  = VALUE rsparams_tt(
      FOR &amp;lt;so1&amp;gt; IN s_carrid
      FOR &amp;lt;so2&amp;gt; IN s_connid
       ( selname = 'S_CARRID'
         kind = 'S'
         sign = &amp;lt;so1&amp;gt;-sign
         option = &amp;lt;so1&amp;gt;-option
         low = &amp;lt;so1&amp;gt;-low
         high = &amp;lt;so1&amp;gt;-high )
       ( selname = 'S_CARRID'
         kind = 'S'
         sign = &amp;lt;so2&amp;gt;-sign
         option = &amp;lt;so2&amp;gt;-option
         low = &amp;lt;so2&amp;gt;-low
         high = &amp;lt;so2&amp;gt;-high )
    ).
cl_demo_output=&amp;gt;new(
)-&amp;gt;begin_section( |Auxilliary Variables|
)-&amp;gt;write_data( lt_sel1
)-&amp;gt;end_section(
)-&amp;gt;begin_section( |Multiple FORs|
)-&amp;gt;write_data( lt_sel2
)-&amp;gt;end_section(
)-&amp;gt;display( ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;P&gt;PS - I don't use TABLES in productive code &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 14:04:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360808#M7583</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2016-11-24T14:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360809#M7584</link>
      <description>&lt;P&gt;Use VALUE ... FOR behind BASE of VALUE?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 16:45:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360809#M7584</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2016-11-24T16:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360810#M7585</link>
      <description>&lt;P&gt;My comment is off topic, but you could also use the CORRESPONDING constructor to reduce the size of the code.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 17:20:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360810#M7585</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-11-24T17:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360811#M7586</link>
      <description>&lt;P&gt;Hi Horst,&lt;/P&gt;&lt;P&gt;If there are more than 2 sources than the BASE will become nested, isn't it?&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 07:51:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360811#M7586</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2016-11-25T07:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360812#M7587</link>
      <description>&lt;P&gt;Like this ...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lt_sel1)
 = VALUE rsparams_tt(
      LET
        sel1 = VALUE rsparams_tt( FOR &amp;lt;so1&amp;gt; IN s_carrid
               ( VALUE #( BASE CORRESPONDING #( &amp;lt;so1&amp;gt; )
                          selname = 'S_CARRID'
                          kind    = 'S' ) ) )
        sel2 = VALUE rsparams_tt( FOR &amp;lt;so2&amp;gt; IN s_connid
               ( VALUE #( BASE CORRESPONDING #( &amp;lt;so2&amp;gt; )
                          selname = 'S_CONNID'
                          kind    = 'S' ) ) )
      IN
      ( LINES OF sel1 )
      ( LINES OF sel2 )
    ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm not sure about the readability though &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 08:08:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360812#M7587</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2016-11-25T08:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360813#M7588</link>
      <description>&lt;P&gt;Is it a requirement to use only one statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES sflight.&lt;BR /&gt;SELECT-OPTIONS s_carrid FOR sflight-carrid.&lt;BR /&gt;SELECT-OPTIONS s_connid FOR sflight-connid.&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;DATA lt_sel TYPE rsparams_tt.&lt;BR /&gt;lt_sel = VALUE #( FOR &amp;lt;v2&amp;gt; IN S_carrid ( VALUE #( &lt;BR /&gt;         BASE CORRESPONDING #( &amp;lt;v2&amp;gt; ) selname = 'S_CARRID' ) ) ).&lt;BR /&gt;lt_sel = VALUE #( base lt_sel FOR &amp;lt;v1&amp;gt; IN S_cONNid ( VALUE #( &lt;BR /&gt;         BASE CORRESPONDING #( &amp;lt;v1&amp;gt; ) selname = 'S_CONNID' ) ) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Nov 2016 09:38:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360813#M7588</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-11-25T09:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360814#M7589</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;Is it a requirement to use only one statement?&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The OP wanted to use VALUE to fill up an internal table using multiple FORs, hence:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;single VALUE operator,&lt;/LI&gt;&lt;LI&gt;auxiliary variables.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 25 Nov 2016 09:44:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360814#M7589</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2016-11-25T09:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360815#M7590</link>
      <description>&lt;P&gt;Sometimes, the conclusion is that the question has not an expected answer, but another way to do it. I prefer another way &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 09:50:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360815#M7590</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-11-25T09:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE and multiple FOR operators to create internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360816#M7591</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;TYPES itab TYPE TABLE OF i WITH EMPTY KEY.
DATA(itab) = VALUE itab(
               BASE VALUE itab(
                      BASE VALUE itab(
                          FOR i = 10 UNTIL i &amp;gt; 13 ( i ) )
                          FOR i = 20 UNTIL i &amp;gt; 23 ( i ) )
                          FOR i = 30 UNTIL i &amp;gt; 33 ( i ) ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;gives&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;10
11
12
13
20
21
22
23
30
31
32
33&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Each FOR expression adds 4 lines to itab, one package after the other.&lt;/P&gt;&lt;P&gt;So, the very first example above might simply be rewritten as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lt_sel) = VALUE rsparams_tt(
 BASE VALUE rsparams_tt(
   FOR &amp;lt;v2&amp;gt; IN p_reason
   ( 
   selname = 'P_AUGRU' 
   high = &amp;lt;v2&amp;gt;-high 
   low = &amp;lt;v2&amp;gt;-low 
   option = &amp;lt;v2&amp;gt;-option 
   sign = &amp;lt;v2&amp;gt;-sign 
   )
 )
 FOR &amp;lt;v1&amp;gt; IN p_auart
 ( 
 selname = 'P_AUART' 
 high = &amp;lt;v1&amp;gt;-high 
 low = &amp;lt;v1&amp;gt;-low 
 option = &amp;lt;v1&amp;gt;-option 
 sign = &amp;lt;v1&amp;gt;-sign 
 )
 ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Nov 2016 11:27:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-and-multiple-for-operators-to-create-internal-table/m-p/360816#M7591</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2016-11-25T11:27:59Z</dc:date>
    </item>
  </channel>
</rss>

