<?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: Dynamic IN condition for LOOP AT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682045#M2017056</link>
    <description>&lt;P&gt;Please ask complete questions.&lt;/P&gt;&lt;P&gt;To clarify your question and to make it simple, you'd better post a minimal reproducible code like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : BEGIN OF wa,
         acc_number TYPE hkont,
       END OF wa,
       itab LIKE TABLE OF wa.
DATA : r_range1  TYPE RANGE OF hkont, wa_range1 LIKE LINE OF r_range1,
       r_range2  TYPE RANGE OF hkont, wa_range2 LIKE LINE OF r_range2,
       r_range3  TYPE RANGE OF hkont, wa_range3 LIKE LINE OF r_range3.
TYPES : BEGIN OF ty_range,
          rname TYPE c LENGTH 10,
        END OF ty_range.
DATA : it_range TYPE TABLE OF ty_range,
       wa_range TYPE ty_range.

itab = VALUE #( ( acc_number = '150' ) ( acc_number = '222' )
                ( acc_number = '300' ) ( acc_number = '391' ) ).
r_range1 = VALUE #( ( sign = 'I' option = 'CP' low = '1*' ) ).
r_range2 = VALUE #( ( sign = 'I' option = 'CP' low = '3*' ) ).
r_range3 = VALUE #( ( sign = 'E' option = 'CP' low = '*' ) ).

APPEND VALUE #( rname = 'R_RANGE1' ) TO it_range.
APPEND VALUE #( rname = 'R_RANGE2' ) TO it_range.
APPEND VALUE #( rname = 'R_RANGE3' ) TO it_range.

LOOP AT it_range INTO wa_range.
  LOOP AT itab INTO wa WHERE (acc number) IN it_range-rname. " SYNTAX ERROR
    WRITE / wa-acc_number.
  ENDLOOP.
ENDLOOP.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Syntax error at the line LOOP AT itab INTO wa, and you don't know how to solve.&lt;/P&gt;&lt;P&gt;The solution should be more clear if you debug your code.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Rname is too short&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The answer depends on the ABAP version you are using.&lt;/P&gt;&lt;P&gt;This should always work:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  FIELD-SYMBOLS &amp;lt;table&amp;gt; TYPE table.
  ASSIGN (wa_range-rname) TO &amp;lt;table&amp;gt;.
  LOOP AT itab INTO wa WHERE acc_number IN &amp;lt;table&amp;gt;.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The proposal by Raymond works from an ABAP release &amp;gt; 7.52 (I don't know which one exactly but it's easy to check):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  LOOP AT itab INTO wa WHERE acc_number IN (wa_range-rname)&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Feb 2023 08:15:28 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2023-02-16T08:15:28Z</dc:date>
    <item>
      <title>Dynamic IN condition for LOOP AT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682039#M2017050</link>
      <description>&lt;P&gt;Hi Abap guru,&lt;/P&gt;
  &lt;P&gt;I need to loop the internal table where the racct in a certain range, but it will take a lot of code if i hard coded every single range. I'm new to abap so i don't know if its possible or not. Here's my code : &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;DATA: r_range1  TYPE RANGE OF hkont,
      wa_range1 LIKE LINE OF r_range1.

LOOP AT it_range INTO wa_range.
  PERFORM f_count.
ENDLOOP.

FORM f_count.
LOOP AT it_fazg INTO wa_fazg WHERE racct IN r_range1." before
  LOOP AT it_itb1 INTO wa_itb1 WHERE racct IN wa_range-rname. " it gets me an error
  "RNAME is not an internal table"
    " calculations
  ENDLOOP.
ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The it_range only consist of one row of data (rname) like r_range1, r_range2, r_range3.&lt;/P&gt;
  &lt;P&gt;Please help me solve this problem. Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 01:50:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682039#M2017050</guid>
      <dc:creator>hanafganesa</dc:creator>
      <dc:date>2023-02-15T01:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IN condition for LOOP AT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682040#M2017051</link>
      <description>&lt;P&gt;I don't understand what you want to do. The code is misleading, misses variables and cannot compile. Currently it's impossible to answer. What is R_RANGE2, R_RANGE3? What is WA_RANGE? Etc.&lt;/P&gt;&lt;P&gt;Please clarify.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 09:15:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682040#M2017051</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-02-15T09:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IN condition for LOOP AT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682041#M2017052</link>
      <description>&lt;P&gt;Try &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IN (wa_range-rname).&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or use ASSIGN&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 15:45:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682041#M2017052</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2023-02-15T15:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IN condition for LOOP AT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682042#M2017053</link>
      <description>&lt;P&gt;Hi Sandra,&lt;/P&gt;&lt;P&gt;I wanted to have a dynamic IN condition for example:&lt;/P&gt;&lt;P&gt;LOOP AT (an internal table) INTO (work area) WHERE (the account number of the data looped) IN (range) --&amp;gt; i wanted this to be dynamic so i don't need to code for different 20+ range&lt;/P&gt;&lt;P&gt;So i came up with looping the internal table that consist of ranges name. For example i have ranges:&lt;/P&gt;&lt;P&gt;DATA : r_range1 TYPE RANGE OF hkont, wa_range1 LIKE LINE OF r_range1,&lt;/P&gt;&lt;P&gt;r_range2 TYPE RANGE OF hkont, wa_range2 LIKE LINE OF r_range2,&lt;/P&gt;&lt;P&gt;r_range3 TYPE RANGE OF hkont, wa_range3 LIKE LINE OF r_range3.&lt;/P&gt;&lt;P&gt;And so on.&lt;/P&gt;&lt;P&gt;I made an internal table :&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF ty_range,&lt;/P&gt;&lt;P&gt;rname TYPE c,&lt;/P&gt;&lt;P&gt;END OF ty_range.&lt;/P&gt;&lt;P&gt;DATA : it_range TYPE TABLE OF ty_range,&lt;/P&gt;&lt;P&gt;wa_range TYPE ty_range.&lt;/P&gt;&lt;P&gt;For those ranges name so that i can call later on. So i append names of ranges that i have it_range:&lt;/P&gt;&lt;P&gt;APPEND VALUE #( rname = 'r_range1' ) TO it_range.&lt;/P&gt;&lt;P&gt;APPEND VALUE #( rname = 'r_range2' ) TO it_range.&lt;/P&gt;&lt;P&gt;APPEND VALUE #( rname = 'r_range3' ) TO it_range.&lt;/P&gt;&lt;P&gt;So that i can make dynamic IN (range) condition.&lt;/P&gt;&lt;P&gt;The loop before dynamic IN condition:&lt;/P&gt;&lt;P&gt;LOOP AT (internal table) INTO (work area) WHERE (acc number) IN r_range1.&lt;/P&gt;&lt;P&gt;The loop after dynamic IN condition: (i need this to be working)&lt;/P&gt;&lt;P&gt;LOOP AT (internal table) INTO (work area) WHERE (acc number) IN it_range-rname.&lt;/P&gt;&lt;P&gt;Its not working atm, whether i used ( it_range-rname ) or [ it_range-rname ]&lt;/P&gt;&lt;P&gt; SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}.L0S52 {
color: #0000FF;
}.L0&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 01:52:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682042#M2017053</guid>
      <dc:creator>hanafganesa</dc:creator>
      <dc:date>2023-02-16T01:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IN condition for LOOP AT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682043#M2017054</link>
      <description>&lt;P&gt;Hi Raymond,&lt;/P&gt;&lt;P&gt;I tried&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IN ( wa_range-rname )

also

IN &amp;lt;fs_range&amp;gt;-rname&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;both gaves me an error "rname" is not an internal table.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2139675-gambar.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 02:35:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682043#M2017054</guid>
      <dc:creator>hanafganesa</dc:creator>
      <dc:date>2023-02-16T02:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IN condition for LOOP AT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682044#M2017055</link>
      <description>&lt;P&gt;Please edit your question and paste the code. Select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!&lt;/P&gt;&lt;P&gt;Code formatted appears like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : r_range1 TYPE RANGE OF hkont, wa_range1 LIKE LINE OF r_range1,&lt;BR /&gt;       r_range2 TYPE RANGE OF hkont, wa_range2 LIKE LINE OF r_range2,&lt;BR /&gt;       r_range3 TYPE RANGE OF hkont, wa_range3 LIKE LINE OF r_range3.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And so on.&lt;/P&gt;&lt;P&gt;I made an internal table :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES : BEGIN OF ty_range,&lt;BR /&gt;          rname TYPE c,&lt;BR /&gt;        END OF ty_range.&lt;BR /&gt;DATA : it_range TYPE TABLE OF ty_range,&lt;BR /&gt;       wa_range TYPE ty_range.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For those ranges name so that i can call later on. So i append names of ranges that i have it_range:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;APPEND VALUE #( rname = 'r_range1' ) TO it_range.&lt;BR /&gt;APPEND VALUE #( rname = 'r_range2' ) TO it_range.&lt;BR /&gt;APPEND VALUE #( rname = 'r_range3' ) TO it_range.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So that I can make dynamic IN (range) condition.&lt;/P&gt;&lt;P&gt;The loop before dynamic IN condition:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT (internal table) INTO (work area) WHERE (acc number) IN r_range1.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The loop after dynamic IN condition: (i need this to be working)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT (internal table) INTO (work area) WHERE (acc number) IN it_range-rname.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Its not working atm, whether i used &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;( it_range-rname ) &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; [ it_range-rname ]&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2023 07:48:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682044#M2017055</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-02-16T07:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IN condition for LOOP AT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682045#M2017056</link>
      <description>&lt;P&gt;Please ask complete questions.&lt;/P&gt;&lt;P&gt;To clarify your question and to make it simple, you'd better post a minimal reproducible code like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : BEGIN OF wa,
         acc_number TYPE hkont,
       END OF wa,
       itab LIKE TABLE OF wa.
DATA : r_range1  TYPE RANGE OF hkont, wa_range1 LIKE LINE OF r_range1,
       r_range2  TYPE RANGE OF hkont, wa_range2 LIKE LINE OF r_range2,
       r_range3  TYPE RANGE OF hkont, wa_range3 LIKE LINE OF r_range3.
TYPES : BEGIN OF ty_range,
          rname TYPE c LENGTH 10,
        END OF ty_range.
DATA : it_range TYPE TABLE OF ty_range,
       wa_range TYPE ty_range.

itab = VALUE #( ( acc_number = '150' ) ( acc_number = '222' )
                ( acc_number = '300' ) ( acc_number = '391' ) ).
r_range1 = VALUE #( ( sign = 'I' option = 'CP' low = '1*' ) ).
r_range2 = VALUE #( ( sign = 'I' option = 'CP' low = '3*' ) ).
r_range3 = VALUE #( ( sign = 'E' option = 'CP' low = '*' ) ).

APPEND VALUE #( rname = 'R_RANGE1' ) TO it_range.
APPEND VALUE #( rname = 'R_RANGE2' ) TO it_range.
APPEND VALUE #( rname = 'R_RANGE3' ) TO it_range.

LOOP AT it_range INTO wa_range.
  LOOP AT itab INTO wa WHERE (acc number) IN it_range-rname. " SYNTAX ERROR
    WRITE / wa-acc_number.
  ENDLOOP.
ENDLOOP.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Syntax error at the line LOOP AT itab INTO wa, and you don't know how to solve.&lt;/P&gt;&lt;P&gt;The solution should be more clear if you debug your code.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Rname is too short&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The answer depends on the ABAP version you are using.&lt;/P&gt;&lt;P&gt;This should always work:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  FIELD-SYMBOLS &amp;lt;table&amp;gt; TYPE table.
  ASSIGN (wa_range-rname) TO &amp;lt;table&amp;gt;.
  LOOP AT itab INTO wa WHERE acc_number IN &amp;lt;table&amp;gt;.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The proposal by Raymond works from an ABAP release &amp;gt; 7.52 (I don't know which one exactly but it's easy to check):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  LOOP AT itab INTO wa WHERE acc_number IN (wa_range-rname)&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2023 08:15:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682045#M2017056</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-02-16T08:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IN condition for LOOP AT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682046#M2017057</link>
      <description>&lt;P&gt;OP apparently didn't notice my 'or use ASSIGN'  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 15:32:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682046#M2017057</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2023-02-16T15:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IN condition for LOOP AT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682047#M2017058</link>
      <description>&lt;P&gt;Thanks! Next time i will use this as a guide to ask a question.&lt;/P&gt;&lt;P&gt;also i notice the 'or use ASSIGN' and still trying it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 03:12:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-in-condition-for-loop-at/m-p/12682047#M2017058</guid>
      <dc:creator>hanafganesa</dc:creator>
      <dc:date>2023-02-17T03:12:56Z</dc:date>
    </item>
  </channel>
</rss>

