Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

summing problem

hi experts

i have an interanl table:

DATA: BEGIN OF i_data OCCURS 0,

lifnr LIKE mseg-lifnr,

grund LIKE mseg-grund,

matnr LIKE mseg-matnr,

ebeln LIKE mseg-ebeln,

erfmg LIKE mseg-erfmg,

erfme LIKE mseg-erfme,

shkzg LIKE mseg-shkzg,

grtxt LIKE t157e-grtxt,

kvgr1 LIKE knvv-kvgr1,

bezei LIKE tvv1t-bezei,

name1 LIKE lfa1-name1,

stras LIKE lfa1-stras,

ort01 LIKE lfa1-ort01,

telf1 LIKE lfa1-telf1,

kunnr LIKE lfa1-kunnr,

ktabg LIKE vbka-ktabg,

preis LIKE eipa-preis,

bwaer LIKE eipa-bwaer,

peinh LIKE eipa-peinh,

bprme LIKE eipa-bprme,

END OF i_data.

which is sorted according to fields lifnr and grund

i want to take from this table every row with the same lifnr and grund and to sum the field erfmg of all rows

with the same two fields to a variable or another table.

how can i do this

thanks

amit

Edited by: amit walden on Sep 17, 2008 10:39 AM

Tags:
replied

Hi Amit,

Do like the following,

Consider itab1 contains number of records.

copy itab1 values to itab2,

itab2[] = itab1[].

sort itab2 by fld1 fld2.

delete adjacent duplicate from itab2 comparing fld1 fld2.

loop at itab2.

loop at itab1 where fld1 eq itab2-fld1 and fld2 eq itab2-fld2.

itab2-fld3 = itab1-fld3 + itab2-fld3.

endloop.

endloop.

loop at itab2.

write : / itab2-fld1, itab2-fld2, itab2-fld3.

endloop.

I hope the above coding will help you to solve your problem.

Regards,

Harish

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question