Skip to Content
author's profile photo Former Member
Former Member

How to add field values?

Hi gurus can any one help me out in doing the total for a field in my report, example weight in Kgs i am having ten weights for which i have to do total for that 10 weights and display the total weight.

Thank in Advance

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2008 at 01:10 PM

    Hi,

    you can define a variabe in your print program and pass it to the SAPScript.

    LIKE:

    Define L_SUM in the Global data.

    DATA: L_SUM TYPE BSEG-DMBTR.
    
    LOOP AT ITAB.
    L_SUM = L_SUM + ITAB-AMOUNT.
    ENDLOOP.
    
    CALL FUNCTION 'WRITE_FORM'
    WINDOW = 'MAIN'
    ELEMENT = 'TOTAL'.
    

    Now, in your SAPScript, create a text element in MAIN window

    For more info checkout the below link

    http://sap-img.com/sapscripts/sapscript-how-to-calculate-totals-and-subtotals.htm

    Regards,

    Chandru

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2008 at 01:11 PM

    Can you give more detail about this question, please?

    is it that you have 10 different weights in an ALV report and you want to sum up them?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2008 at 01:13 PM

    hi Venkat,

    try this.

    For total.

    While building the fieldcatalog you have use do_sum = 'X' for the column which you need the summation.

    For subtotal use below code :

    data :gt_sort TYPE slis_t_sortinfo_alv,

    DATA: ls_sort TYPE slis_sortinfo_alv.

    CLEAR ls_sort.

    ls_sort-fieldname = 'Fieldname'.

    ls_sort-up = 'X'.

    ls_sort-subtot = 'X'.

    APPEND ls_sort TO gt_sort.

    And pass gt_sort to grid display export parameter I_sort.

    hope this helps,

    cheers,

    Hema.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 19, 2008 at 02:09 PM

    Hi venkateshwar,

    Describe table it_wght lines v_line.

    Loop at it_wght into wa_wght.

    V_i = V_i + 1.

    *Use write stmts to print each 10 weights.

    V_wght = V_wght + wa_wght-weight.

    if V_i eq V_line.

    • Use write stmts to print the total weight

    endif.

    Get back to me if you need more details.

    Plz award points if helpful.

    Thanks,

    Karthik

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.