<?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 Query Code for Count Function in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224766#M769117</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you ONLY need number of  requistions following code works...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : BEGIN OF itab OCCURS 0,&lt;/P&gt;&lt;P&gt;        banfn LIKE eban-banfn, &lt;/P&gt;&lt;P&gt;        ebeln LIKE ekko-ebeln,&lt;/P&gt;&lt;P&gt;       END OF itab.&lt;/P&gt;&lt;P&gt;DATA : count(2) TYPE p.&lt;/P&gt;&lt;P&gt;DATA : no_of_records(3) TYPE p.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"your code goes here to get POs and Reqs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT itab BY banfn ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab.&lt;/P&gt;&lt;P&gt;  ADD 1 TO count.&lt;/P&gt;&lt;P&gt;  AT END OF banfn.&lt;/P&gt;&lt;P&gt;    IF count GE 2.&lt;/P&gt;&lt;P&gt;      ADD count TO no_of_records.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    CLEAR count.&lt;/P&gt;&lt;P&gt;  ENDAT.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; no_of_records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Jan 2008 16:24:38 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-02T16:24:38Z</dc:date>
    <item>
      <title>ABAP Query Code for Count Function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224765#M769116</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;I have an ABAP Query and just created a new field which requires ABAP Code to do the following :-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The report is for Purchase Orders and Purchase Requisitions. 2 Purchase Orders may have the same requisition, so what I want to do is count the number of the same requisitions in the report&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PO                Req             Count&lt;/P&gt;&lt;P&gt;45000001     10015              2&lt;/P&gt;&lt;P&gt;45000020     10015              2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can some one please provide with the full code? Points will be awarded&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, 02 Jan 2008 15:45:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224765#M769116</guid>
      <dc:creator>adeel_sarwar</dc:creator>
      <dc:date>2008-01-02T15:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Query Code for Count Function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224766#M769117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you ONLY need number of  requistions following code works...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : BEGIN OF itab OCCURS 0,&lt;/P&gt;&lt;P&gt;        banfn LIKE eban-banfn, &lt;/P&gt;&lt;P&gt;        ebeln LIKE ekko-ebeln,&lt;/P&gt;&lt;P&gt;       END OF itab.&lt;/P&gt;&lt;P&gt;DATA : count(2) TYPE p.&lt;/P&gt;&lt;P&gt;DATA : no_of_records(3) TYPE p.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"your code goes here to get POs and Reqs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT itab BY banfn ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab.&lt;/P&gt;&lt;P&gt;  ADD 1 TO count.&lt;/P&gt;&lt;P&gt;  AT END OF banfn.&lt;/P&gt;&lt;P&gt;    IF count GE 2.&lt;/P&gt;&lt;P&gt;      ADD count TO no_of_records.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    CLEAR count.&lt;/P&gt;&lt;P&gt;  ENDAT.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; no_of_records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2008 16:24:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224766#M769117</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-02T16:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Query Code for Count Function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224767#M769118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Adeel, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort the table by Purchase Requisitions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at Itab.&lt;/P&gt;&lt;P&gt;count = count + 1.&lt;/P&gt;&lt;P&gt;At New Req.&lt;/P&gt;&lt;P&gt;    Count is the number of same requisitions.&lt;/P&gt;&lt;P&gt;    Here you can modify the table Itab where req = itab-req and Count = count.&lt;/P&gt;&lt;P&gt;Endat.&lt;/P&gt;&lt;P&gt;Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;Lokesh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Lokesh Aggarwal on Jan 2, 2008 5:01 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2008 16:59:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224767#M769118</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-02T16:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Query Code for Count Function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224768#M769119</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;No errors in the below code but it is bringing a value 0 even though there are duplicates in the table which is suggesting to me that the code is not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated. Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : BEGIN OF itab OCCURS 0,&lt;/P&gt;&lt;P&gt;        aufnr LIKE ekkn-aufnr,&lt;/P&gt;&lt;P&gt;       END OF itab.&lt;/P&gt;&lt;P&gt;DATA : count(2) TYPE p.&lt;/P&gt;&lt;P&gt;DATA : no_of_records(3) TYPE p.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clear no_of_records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select aufnr from ekkn into itab.&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT itab BY aufnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab.&lt;/P&gt;&lt;P&gt;  ADD 1 TO count.&lt;/P&gt;&lt;P&gt;  AT END OF aufnr.&lt;/P&gt;&lt;P&gt;    IF count GE 2.&lt;/P&gt;&lt;P&gt;      ADD count TO no_of_records.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    CLEAR count.&lt;/P&gt;&lt;P&gt;  ENDAT.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'Good Bye'.&lt;/P&gt;&lt;P&gt;DUPLICATES = NO_of_records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2008 16:40:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224768#M769119</guid>
      <dc:creator>adeel_sarwar</dc:creator>
      <dc:date>2008-01-03T16:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Query Code for Count Function</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224769#M769120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ABAP Programmer used&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2008 21:52:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-code-for-count-function/m-p/3224769#M769120</guid>
      <dc:creator>adeel_sarwar</dc:creator>
      <dc:date>2008-03-03T21:52:07Z</dc:date>
    </item>
  </channel>
</rss>

