Skip to Content

Sub total to be included in alv?

Hi friends, I need total field to be added for all similar vendor's & should be displayed.

from this image you can see that i'm getting subtotal for every line eventhough we have same vendor. So my requirement is that I need to display all the same vendors sorted then display subtotal & then other vendors followed by the subtotal.

Plz help me out with this issue.

Capture.PNG (22.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 18, 2014 at 04:32 AM

    hi Bharath,

    Please go through the code and do changes as per your requirement.

    *&---------------------------------------------------------------------*
    *& Form subtotal_text
    *&---------------------------------------------------------------------*
    * Build subtotal text
    *----------------------------------------------------------------------*
    * P_total Total
    * p_subtot_text Subtotal text info
    *----------------------------------------------------------------------*
    FORM subtotal_text CHANGING
    p_total TYPE any
    p_subtot_text TYPE slis_subtot_text.

    * Material level sub total
    IF p_subtot_text-criteria = 'MATNR'.
    p_subtot_text-display_text_for_subtotal
    = 'Material level total'(009).
    ENDIF.
    * Plant level sub total
    IF p_subtot_text-criteria = 'WERKS'.
    p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
    ENDIF.
    ENDFORM. "subtotal_text
    Add comment
    10|10000 characters needed characters exceeded

  • Sep 17, 2014 at 12:48 PM

    You can do this in your ALV variant. First sort by vendor, then select the column you want the subtotals for and click the SUM sign. Now you have a total for all vendors.

    Now select the vendor column (in my screen shot this is AMNT_TYP) and click the subtotals button that has appeared after you did the SUM.


    Subtotals.png (13.1 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Peter,
      Thanks for your reply,
      I want to directly get the alv diplay as required(changes to be made in the code).
      Could you help me if you know any similar fields like do_sum Or subtot that can be used ?

  • avatar image
    Former Member
    Sep 17, 2014 at 12:47 PM

    Can u paste your code so that i can give you the correct solution ....

    or else

    sort by vendor in alv fieldcatalog using keyfield for vendor.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 18, 2014 at 06:39 AM

    Hi Bharath,

    Paste your code so that we can find where code need to be corrected..

    chech this thread. it would be helpful for your issue.

    http://scn.sap.com/thread/978043

    Thanks

    Raju C D

    Add comment
    10|10000 characters needed characters exceeded