Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

help in sum

Former Member
0 Likes
748

HI

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

how can i do that in my program .

example

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

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

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

how could i do that

HI

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

how can i do that in my program .

example

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

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

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

how could i do that

5 REPLIES 5
Read only

Former Member
0 Likes
732

hi Shnya,

you can define two internal table:

i_table1 type table of your_structure.

i_table2 type table of your_structure.

*select to i_table1

i_table2 = i_table1. "copy values from table 1 to table 2

collect i_table2. " sum all numeric fields

insert lines of table i_table2 into table i_table1. "in the end you should have a sum

best,

wojciech

Read only

0 Likes
732

hi

i try like u tell but its not working

APPEND LINES OF planned_hours to planned_hours_tmp .

COLLECT planned_hours_tmp.

APPEND LINES OF planned_hours_tmp to planned_hours .

regards

Read only

0 Likes
732

Maybe that will wor:

i_table1 type table of your_structure.

i_table2 type table of your_structure.

w_area type your_structure.

*select to i_table1

loop at i_table1 into w_area.
collect w_area into i_table2. " sum all numeric fields
endloop.

append lines of table i_table2 into table i_table1. "in the end you should have a sum

Read only

Former Member
0 Likes
732

Hi Shnya,

You can achieve this using DO....VARYING FROM statement.

DATA V_TOTAL TYPE H1.

LOOP AT ITAB INTO WA.

DO 6 TIMES VARYING V_H FROM WA-H1 NEXT WA-H6.

V_TOTAL = V_TOTAL + V_H.

WRITE:/ V_TOTAL.

ENDDO.

ENDLOOP.

Thanks,

Vinay

Read only

0 Likes
732

hi

i try like u tell but i have dump

DATA: V_TOTAL TYPE char10 , V_H type char10.

LOOP AT planned_hours ASSIGNING <wa_p_h>.

DO 12 TIMES VARYING V_H FROM <wa_p_h>-H1 NEXT <wa_p_h>-H12.

V_TOTAL = V_TOTAL + V_H.

ENDDO.

ENDLOOP.

this is the error

The program terminated while the 3 loop pass was being executed.

If you cannot solve the problem yourself and yo

an error message to SAP, include the following

1. A printout of the problem description (short

To obtain this, select in the current displa

Save->Local File (unconverted)".

2. A suitable printout of the system log

To obtain this, call the system log through

Limit the time interval to 10 minutes before

after the short dump. In the display, then s

"System->List->Save->Local File (unconverted

3. If the programs are your own programs or mod

supply the source code.

To do this, select the Editor function "Furt

Upload/Download->Download".

4. Details regarding the conditions under which

or which actions and input led to the error.

thankes