Skip to Content
avatar image
Former Member

sum help

HI

i have a FM and i buield stuctre in se 11 with fields like h1,h2...see below, and i wont to add to this structre anoter line with sum of the field that above

how can i do that in my program .

example

h1-h2-h3-h4-h5-h6<--


fields name

10-20-30-40-50---60

<b>10-30-60-100150210 <----Add this to structre with the sum os the field above</b>

Regards

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Aug 20, 2007 at 05:47 AM

    Hi,

    try this

    data: begin of itab occurs 0,

    field type i,

    field1 type i,

    field2 type i,

    end of itab.

    data: wa like itab.

    data: m type i.

    itab-field = '10'.

    itab-field1 = '20'.

    itab-field2 = '30'.

    append itab.

    clear: itab.

    loop at itab .

    write:/ itab-field, itab-field1, itab-field2.

    wa-field = itab-field.

    wa-field1 = wa-field + itab-field1.

    wa-field2 = wa-field1 + itab-field2.

    append wa to itab.

    write:/ wa-field, wa-field1, wa-field2.

    exit.

    endloop.

    thanks & regards,

    Venkatesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2007 at 06:33 AM

    plz any one

    i need help i do it like that and its <b>work</b> but there is beeter way to do that

    LOOP AT planned_hours ASSIGNING <wa_p_h>.

    ADD <wa_p_h>-zhly TO l_sum.

    MOVE l_sum TO wa_tmp-zhly. <----first field

    ADD <wa_p_h>-h1 TO l_sum.

    MOVE l_sum TO wa_tmp-h1. <----second field

    ADD <wa_p_h>-h2 TO l_sum.

    MOVE l_sum TO wa_tmp-h2. <-----so on

    ADD <wa_p_h>-h3 TO l_sum.

    MOVE l_sum TO wa_tmp-h3.

    ADD <wa_p_h>-h4 TO l_sum.

    MOVE l_sum TO wa_tmp-h4.

    ADD <wa_p_h>-h5 TO l_sum.

    MOVE l_sum TO wa_tmp-h5.

    endloop

    APPEND wa_tmp TO planned_hours.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2007 at 06:42 AM

    hi snaya

    try wit collect

    regards

    Add comment
    10|10000 characters needed characters exceeded