<?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: internal table calculations in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059634#M425523</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;Please try something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: ZTABLE.

DATA:  COUNT_X TYPE I.

SELECT COUNT( FIELD1 )
INTO COUNT_X 
FROM ZTABLE
WHERE FIELD1 LIKE '008%'.

WRITE: / COUNT_X.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 18 Mar 2007 13:58:25 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-03-18T13:58:25Z</dc:date>
    <item>
      <title>internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059631#M425520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HELLO FRIENDS,&lt;/P&gt;&lt;P&gt;I have a scenario where, i need to check the entries i a ztable for a field, i have to count how many entries in the field have value X, and how many entries have value Y, &lt;/P&gt;&lt;P&gt;Total number of X entries has to be multiplied by value *, and total number of entries of Y got to be multiplied by 4, and &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;total has tobe added.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If any one can give me little detailed code, along with declarations, it will be really greatfull to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 13:48:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059631#M425520</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T13:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059632#M425521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry friends , i forgot toput the condition,&lt;/P&gt;&lt;P&gt;the fields with entries X are those char strings which tart with 008 in the start of the string out of 10 charecters. the field is a 10 charecter string.&lt;/P&gt;&lt;P&gt;thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 13:51:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059632#M425521</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T13:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059633#M425522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the field with entries Y are those  who donot have 008 at their starting of the 10 char string.&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 13:52:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059633#M425522</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T13:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059634#M425523</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;Please try something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: ZTABLE.

DATA:  COUNT_X TYPE I.

SELECT COUNT( FIELD1 )
INTO COUNT_X 
FROM ZTABLE
WHERE FIELD1 LIKE '008%'.

WRITE: / COUNT_X.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 13:58:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059634#M425523</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T13:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059635#M425524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;check this code ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data :&lt;/P&gt;&lt;P&gt;  w_count type i.&lt;/P&gt;&lt;P&gt;  w_count1 type i.&lt;/P&gt;&lt;P&gt;w_sum type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select count( field1 )&lt;/P&gt;&lt;P&gt;from ztable&lt;/P&gt;&lt;P&gt;into w_count&lt;/P&gt;&lt;P&gt;where field1 like '008%'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select count( field1 )&lt;/P&gt;&lt;P&gt;from ztable&lt;/P&gt;&lt;P&gt;into w_count1&lt;/P&gt;&lt;P&gt;where field1 not like '008%'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;w_sum = w_count + w_count1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write : w_count , w_count1 , w_sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards, &lt;/P&gt;&lt;P&gt;sai ramesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 14:01:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059635#M425524</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T14:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059636#M425525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ferry thanks for your reply,&lt;/P&gt;&lt;P&gt;but when i execute it says.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count( field1) is only valid in the extended form  count( distinct field1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can u plz look in to it.&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 14:07:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059636#M425525</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T14:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059637#M425526</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;Please try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: ZTABLE.
 
DATA: COUNT_X TYPE I,
      COUNT_Y TYPE I,
      TOTALS  TYPE I.
      
RANGES: R_FIED1 FOR ZTABLE-FIELD1.

R_FIELD1-SIGN = 'I'.
R_FIELD1-OPTION = 'NP'.
R_FIELD1-LOW = '008%'.
APPEND R_FIELD1.

SELECT COUNT( DISTINCT FIELD1 )
INTO COUNT_X 
FROM ZTABLE
WHERE FIELD1 LIKE '008%'.

WRITE: / COUNT_X.
 
SELECT COUNT( DISTINCT FIELD1 )
INTO COUNT_Y 
FROM ZTABLE
WHERE FIELD1 IN R_FIELD1.

WRITE: / COUNT_Y.

OR 

SELECT FIELD1 COUNT( * )
INTO COUNT_X 
FROM ZTABLE
WHERE FIELD1 LIKE '008%'.
 
WRITE: / COUNT_X.

SELECT FIELD1 COUNT( * )
INTO COUNT_Y 
FROM ZTABLE
WHERE FIELD1 IN R_FIELD1.
 
WRITE: / COUNT_Y.

SKIP.
COUNT_X = COUNT_X * &amp;lt;...&amp;gt;.    &amp;lt;--- any number
COUNT_Y = COUNT_Y * 4.
TOTALS  = COUNT_X + COUNT_Y.

WRITE: / COUNT_X, COUNT_Y, TOTALS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 14:12:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059637#M425526</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T14:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059638#M425527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks ferry,&lt;/P&gt;&lt;P&gt;the first one was only giving distinct values, there are duplicate values too, we nee to count them too. and the second option was giving error  saying there should be a goup by cluse.&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;P&gt;can u once again plz look into it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 14:35:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059638#M425527</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T14:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059639#M425528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;friends what i feel is , &lt;/P&gt;&lt;P&gt;if we create an internal table and only copy those field1 values into that itab where&lt;/P&gt;&lt;P&gt;the field1 contains '008%' and we can use sy-dbcnt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i dont know how to code this logic,&lt;/P&gt;&lt;P&gt;can any one plz give me code for this logic thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 14:46:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059639#M425528</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T14:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: internal table calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059640#M425529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks ferry and ramesh,&lt;/P&gt;&lt;P&gt;i used both of ur code to write the code.&lt;/P&gt;&lt;P&gt;now its working.&lt;/P&gt;&lt;P&gt;thank you so much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have a last question, if i use this logic of bringing all fields from database and then checking the sy-dbcnt  a good way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please suggest  me what to do.&lt;/P&gt;&lt;P&gt;thanks once again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Mar 2007 15:37:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-calculations/m-p/2059640#M425529</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-18T15:37:42Z</dc:date>
    </item>
  </channel>
</rss>

