<?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: ABAP syntax for field check in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586518#M1566812</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Press F1 on ASSIGN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Jan 2011 16:45:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-01-26T16:45:07Z</dc:date>
    <item>
      <title>ABAP syntax for field check</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586516#M1566810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone advise if there is a way to check if a list of fields has value in it?  I can write the if/then statement to check but I want to see whether there are other options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data: field_1 type menge_d,&lt;/P&gt;&lt;P&gt;         field_2 type menge_d,&lt;/P&gt;&lt;P&gt;         field_3 type menge_d,&lt;/P&gt;&lt;P&gt;         field_4 type menge_d,&lt;/P&gt;&lt;P&gt;         field_5 type menge_d,&lt;/P&gt;&lt;P&gt;         field_6 type menge_d,&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;In ABAP code, these fields will get assigned a quantity.  How can I check if to see if at least 4 of these six fieldts has data assigned to it.  It can be in any combination but at least 4 fields should have data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently, I have this code but want to see if there are other intelligent ways of doing it than these redundant IFs statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If field_1 &amp;gt; 0.&lt;/P&gt;&lt;P&gt;  count = count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;If field_2 &amp;gt; 0.&lt;/P&gt;&lt;P&gt;  count = count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;If field_3 &amp;gt; 0.&lt;/P&gt;&lt;P&gt;  count = count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;If field_4 &amp;gt; 0.&lt;/P&gt;&lt;P&gt;  count = count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;If field_5 &amp;gt; 0.&lt;/P&gt;&lt;P&gt;  count = count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;If field_6 &amp;gt; 0.&lt;/P&gt;&lt;P&gt;  count = count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after this, I check if count &amp;gt; = 4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 15:44:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586516#M1566810</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T15:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP syntax for field check</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586517#M1566811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use 6 times the form&lt;/P&gt;&lt;P&gt;perform f_check using field_1 &lt;/P&gt;&lt;P&gt;                           changing count.&lt;/P&gt;&lt;P&gt;where the form contains the if.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;otherwise you could:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols &amp;lt;field&amp;gt; type any.&lt;/P&gt;&lt;P&gt;data: field_data(10).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do 6 times.&lt;/P&gt;&lt;P&gt;concatenate 'field_' si-index into field_data.&lt;/P&gt;&lt;P&gt;assign (field_data) to &amp;lt;field&amp;gt;.&lt;/P&gt;&lt;P&gt;if &amp;lt;field&amp;gt; gt 0.&lt;/P&gt;&lt;P&gt;count = count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards.&lt;/P&gt;&lt;P&gt;andrea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 16:38:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586517#M1566811</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T16:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP syntax for field check</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586518#M1566812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Press F1 on ASSIGN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 16:45:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586518#M1566812</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T16:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP syntax for field check</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586519#M1566813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You know what, for these six cases I would just leave it as is. You could reduce the number of lines somewhat by introducing constructions with field symbols or similar, but then your program becomes much more complex and difficult to understand and maintain.&lt;/P&gt;&lt;P&gt;-&amp;gt; "keep it simple, stupid", as much as possible and reasonable.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 16:45:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586519#M1566813</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2011-01-26T16:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP syntax for field check</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586520#M1566814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can build the fieldname dynamically in a loop and check for value not initial, i.e.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data:
  lv_fieldname type fieldname,
  lv_num1      type n length 1,
  lv_count     type int4.
field-symbols:
  &amp;lt;any&amp;gt; type any.
DO 6 times.
  add 1 to  lv_num1.
  concatenate 'FIELD_'  lv_num1 into lv_fieldname.
  assign (lv_fieldname) to &amp;lt;any&amp;gt;.
  check:
    sy-subrc = 0,
    &amp;lt;any&amp;gt; is not initial.
  add 1 to lv_count.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not much less than your code, but fully transparent and easy to adjust. LV-count has the number of values assigned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 16:47:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586520#M1566814</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-01-26T16:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP syntax for field check</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586521#M1566815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming all the variables will have either a positive value or zero, the following would work. When variables can contain negative values, you will have to add ABS() within SIGN().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
report y_test.

data: l_data1 type i VALUE 1,
      l_data2 type i value 1,
      l_data3 type i value 1,
      l_data4 type i value 1,
      l_data5 type i value 0,
      l_data6 type i value 0,

      l_result type i.

l_result = sign( l_data1 ) + sign( l_data2 ) +
           sign( l_data3 ) + sign( l_data4 ) +
           sign( l_data5 ) + sign( l_data6 ).
if l_result &amp;lt; 4.
  write: / 'Less than 4'.
else.
  write: / '4 or more'.
endif.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 18:40:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586521#M1566815</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T18:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP syntax for field check</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586522#M1566816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sudhi Karkada,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;great idea!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As we can not use &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sign( abs( l_data1 ) ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;before EHP2 (?), for the time being i'd like to suggest&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;l_result = sign( l_data1 ) * sign( l_data1 ) + 
           sign( l_data2 ) * sign( l_data2 ) +
           sign( l_data3 ) * sign( l_data3 ) + 
           sign( l_data4 ) * sign( l_data4 ) +
           sign( l_data5 ) * sign( l_data5 ) + 
           sign( l_data6 ) * sign( l_data6 ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This way negative values ( -1&lt;STRONG&gt;-1) and positive values (1&lt;/STRONG&gt;1) will add 1 while initial (0*0) will add zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 21:19:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-syntax-for-field-check/m-p/7586522#M1566816</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-01-26T21:19:21Z</dc:date>
    </item>
  </channel>
</rss>

