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

help in doing sum fields from tables

HALLOW

i have a table and i wont to add the tables line to one line , to do sum

if date appear more then one time like in example.

i give example

date----


hours

01.01.2002 6.5

01.01.2002 2.5

02.01.2002 5

03.01.2002 3

03.01.2002 3

04.01.2002 4

06.01.2002 5

i wont to move it to table like this

date----


hours

01.01.2002 9 ->sum houres of date 01.01.2002

02.01.2002

03.01.2002 6 ->sum houres of date 03.01.2002

04.01.2002 4

06.01.2002 5

Regards

i reward

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 01, 2007 at 08:41 PM

    You can get same functionality if you use Internal table events .

    See the simple example :

    &----


    *& Report ZTEST_IEVENTS

    *&

    &----


    *&

    *&

    &----


    REPORT ZTEST_IEVENTS no standard page heading

    line-count 40(2).

    tables : vbap.

    data : begin of i_vbap occurs 0,

    vbeln like vbap-vbeln,

    posnr like vbap-posnr,

    matnr like vbap-matnr,

    kwmeng like vbap-kwmeng,

    netpr like vbap-netpr,

    end of i_vbap.

    data wa_vbap like line of i_vbap.

    data v_flag type c.

    select-options s_vbeln for vbap-vbeln obligatory.

    start-of-selection.

    select vbeln

    posnr

    matnr

    kwmeng

    netpr from vbap

    into table i_vbap

    where vbeln in s_vbeln.

    sort i_vbap by vbeln posnr.

    end-of-selection.

    loop at i_vbap.

    move i_vbap to wa_vbap.

    at first.

    write:/2 'Order #',15 'Item #',28 'Material #',50 'Qty', 70 'Net value'.

    skip 1.

    endat.

    at new vbeln.

    write:/2 wa_vbap-vbeln,15 wa_vbap-posnr,28 wa_vbap-matnr,

    47 wa_vbap-kwmeng,65 wa_vbap-netpr.

    v_flag = 'X'.

    endat.

    if v_flag ne 'X'.

    write:/15 wa_vbap-posnr,28 wa_vbap-matnr,

    47 wa_vbap-kwmeng,65 wa_vbap-netpr.

    endif.

    at end of vbeln.

    sum.

    skip 1.

    write:/5 'Sub totals', 47 i_vbap-kwmeng,65 i_vbap-netpr.

    skip 1.

    endat.

    at last .

    skip 1.

    sum.

    write:/5 'Grand Totals',47 i_vbap-kwmeng,65 i_vbap-netpr.

    skip 1.

    write:/ 'end of page', 'Footer'.

    endat.

    clear v_flag.

    endloop.

    Good luck

    Thanks

    Seshu

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 01, 2007 at 06:32 PM

    Hi Tals,

    U can do it by simply changing the "type" (data type) of the field you want to add to type N or P and do a COLLECT on the internal table.

    Regards,

    K

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 01, 2007 at 06:33 PM

    Hi,

    Code like this.

    LOOP AT itab.

    itab2-date = tab-date.

    itab2-hours = tab-hours.

    COLLECT itab2.

    ENDLOOP.

    • itab2 being of same structure as tab.

    Thanks and Best Regards,

    Vikas Bittera.

    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.