<?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: highest value in output in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/highest-value-in-output/m-p/5485051#M1255491</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;Try this code..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT gt_bseg BY belnr bukrs gjahr hkont zuonr DESCENDING.
LOOP AT gt_bseg.
  AT NEW hkont.
    MOVE gt_bseg-bukrs TO gt_final-bukrs.
    MOVE gt_bseg-belnr TO gt_final-belnr.
    MOVE gt_bseg-gjahr TO gt_final-gjahr.
    MOVE gt_bseg-wrbtr TO gt_final-wrbtr.
    MOVE gt_bseg-hkont TO gt_final-hkont.
    MOVE gt_bseg-zuonr TO gt_final-zuonr.
    MOVE gt_bseg-pswsl TO gt_final-pswsl.
  ENDIF.

  gt_final-dmbtr = gt_final-dmbtr + gt_bseg-dmbtr.

  AT END OF  hkont.
    READ TABLE gt_bkpf WITH KEY bukrs = gt_bseg-bukrs
              belnr = gt_bseg-belnr
              gjahr = gt_bseg-gjahr
              BINARY SEARCH.
    IF sy-subrc = 0.
      MOVE gt_bkpf-budat TO gt_final-budat.
      MOVE gt_bkpf-blart TO gt_final-blart.
      MOVE gt_bkpf-bldat TO gt_final-bldat.
    ENDIF.
    APPEND gt_final.
    CLEAR gt_final.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Apr 2009 07:34:09 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-17T07:34:09Z</dc:date>
    <item>
      <title>highest value in output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/highest-value-in-output/m-p/5485048#M1255488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the report i need to fetch the data based on BELNR BUKRS  HKONT and ZUONR &lt;/P&gt;&lt;P&gt;For eg: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for a particular belnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BELNR    BUKRS    GJAHR    HKONT   ZUONR   DMBTR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5004          0005       2008        3421       TM0000        54&lt;/P&gt;&lt;P&gt;5004          0005       2008         3421      TM3421        60&lt;/P&gt;&lt;P&gt;5004          0005       2008         3421       TM3426       20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output should display as   only one line item with highest ZUONR and sum of the DMBTR as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BELNR    BUKRS    GJAHR    HKONT   ZUONR   DMBTR&lt;/P&gt;&lt;P&gt;5004          0005       2008         3421      TM3426       134&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please help me how to WRITE CODE get the highest ZUONR field in output and sum of the DMBTR FIELD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MY code is , all the data is in gt_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT GT_BSEG. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    MOVE GT_BSEG-BUKRS  TO GT_FINAL-BUKRS.&lt;/P&gt;&lt;P&gt;    MOVE GT_BSEG-BELNR  TO GT_FINAL-BELNR.&lt;/P&gt;&lt;P&gt;   MOVE GT_BSEG-GJAHR  TO GT_FINAL-GJAHR.&lt;/P&gt;&lt;P&gt;    MOVE GT_BSEG-DMBTR  TO GT_FINAL-DMBTR.&lt;/P&gt;&lt;P&gt;   MOVE GT_BSEG-WRBTR  TO GT_FINAL-WRBTR.&lt;/P&gt;&lt;P&gt;   MOVE GT_BSEG-HKONT  TO GT_FINAL-HKONT.&lt;/P&gt;&lt;P&gt;    MOVE GT_BSEG-ZUONR  TO GT_FINAL-ZUONR.&lt;/P&gt;&lt;P&gt;    MOVE GT_BSEG-PSWSL  TO GT_FINAL-PSWSL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    READ TABLE GT_BKPF WITH KEY BUKRS = GT_BSEG-BUKRS&lt;/P&gt;&lt;P&gt;                               BELNR = GT_BSEG-BELNR&lt;/P&gt;&lt;P&gt;                               GJAHR = GT_BSEG-GJAHR&lt;/P&gt;&lt;P&gt;                                BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;      MOVE GT_BKPF-BUDAT TO GT_FINAL-BUDAT.&lt;/P&gt;&lt;P&gt;      MOVE GT_BKPF-BLART TO GT_FINAL-BLART.&lt;/P&gt;&lt;P&gt;      MOVE GT_BKPF-BLDAT TO GT_FINAL-BLDAT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   APPEND GT_FINAL.&lt;/P&gt;&lt;P&gt;   CLEAR GT_FINAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;please help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2009 07:21:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/highest-value-in-output/m-p/5485048#M1255488</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-17T07:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: highest value in output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/highest-value-in-output/m-p/5485049#M1255489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LOOP AT GT_BSEG. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE GT_BSEG-BUKRS TO GT_FINAL-BUKRS.&lt;/P&gt;&lt;P&gt;MOVE GT_BSEG-BELNR TO GT_FINAL-BELNR.&lt;/P&gt;&lt;P&gt;MOVE GT_BSEG-GJAHR TO GT_FINAL-GJAHR.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MOVE GT_BSEG-DMBTR TO GT_FINAL-DMBTR.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;GT_FINAL-DMBTR = GT_BSEG-DMBTR + GT_FINAL-DMBTR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE GT_BSEG-WRBTR TO GT_FINAL-WRBTR.&lt;/P&gt;&lt;P&gt;MOVE GT_BSEG-HKONT TO GT_FINAL-HKONT.&lt;/P&gt;&lt;P&gt;MOVE GT_BSEG-ZUONR TO GT_FINAL-ZUONR.&lt;/P&gt;&lt;P&gt;MOVE GT_BSEG-PSWSL TO GT_FINAL-PSWSL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE GT_BKPF WITH KEY BUKRS = GT_BSEG-BUKRS&lt;/P&gt;&lt;P&gt;BELNR = GT_BSEG-BELNR&lt;/P&gt;&lt;P&gt;GJAHR = GT_BSEG-GJAHR&lt;/P&gt;&lt;P&gt;BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;MOVE GT_BKPF-BUDAT TO GT_FINAL-BUDAT.&lt;/P&gt;&lt;P&gt;MOVE GT_BKPF-BLART TO GT_FINAL-BLART.&lt;/P&gt;&lt;P&gt;MOVE GT_BKPF-BLDAT TO GT_FINAL-BLDAT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND GT_FINAL.&lt;/P&gt;&lt;P&gt;CLEAR GT_FINAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort gt_final by ZUONR descending dmbtr descenfing .&lt;/P&gt;&lt;P&gt;In the first line you will get the highest ZUONR.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2009 07:25:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/highest-value-in-output/m-p/5485049#M1255489</guid>
      <dc:creator>Sandeep_Panghal</dc:creator>
      <dc:date>2009-04-17T07:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: highest value in output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/highest-value-in-output/m-p/5485050#M1255490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try these codes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT GT_BSEG BY ZUONR DESCENDING.

LOOP AT GT_BSEG.
IF Sy-tabix = 1.
MOVE GT_BSEG to GT_FINAL.                      " First Row in the table will have Highest ZUONR
ENDIF.
GT_FINAL-DMBTR = GT_FINAL-DMBTR + GT_BSEG-DMBTR.      " Sum of all DMBTR.
ENDLOOP.

APPEND GT_FINAL.       " Update ROW&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gurpreet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2009 07:29:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/highest-value-in-output/m-p/5485050#M1255490</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-17T07:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: highest value in output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/highest-value-in-output/m-p/5485051#M1255491</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;Try this code..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT gt_bseg BY belnr bukrs gjahr hkont zuonr DESCENDING.
LOOP AT gt_bseg.
  AT NEW hkont.
    MOVE gt_bseg-bukrs TO gt_final-bukrs.
    MOVE gt_bseg-belnr TO gt_final-belnr.
    MOVE gt_bseg-gjahr TO gt_final-gjahr.
    MOVE gt_bseg-wrbtr TO gt_final-wrbtr.
    MOVE gt_bseg-hkont TO gt_final-hkont.
    MOVE gt_bseg-zuonr TO gt_final-zuonr.
    MOVE gt_bseg-pswsl TO gt_final-pswsl.
  ENDIF.

  gt_final-dmbtr = gt_final-dmbtr + gt_bseg-dmbtr.

  AT END OF  hkont.
    READ TABLE gt_bkpf WITH KEY bukrs = gt_bseg-bukrs
              belnr = gt_bseg-belnr
              gjahr = gt_bseg-gjahr
              BINARY SEARCH.
    IF sy-subrc = 0.
      MOVE gt_bkpf-budat TO gt_final-budat.
      MOVE gt_bkpf-blart TO gt_final-blart.
      MOVE gt_bkpf-bldat TO gt_final-bldat.
    ENDIF.
    APPEND gt_final.
    CLEAR gt_final.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2009 07:34:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/highest-value-in-output/m-p/5485051#M1255491</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-17T07:34:09Z</dc:date>
    </item>
  </channel>
</rss>

