Skip to Content
0
Former Member
Jan 28, 2009 at 07:38 PM

Not summing up -internal table entries

48 Views

Hi,

Below is the code I am trying to get respective totals of cost elements.

but i am getting output as.

51000 120

51000 300

54000 700

54000 100

54000 400

I need following output

51000 420

54000 1200

REPORT  YY.

tables: prps.

data: t_prps like prps occurs 0 with header line.
data: t_final like zjob occurs 0 with header line.

types: t_coep type coep.


data: it_coep TYPE STANDARD TABLE OF t_coep.
DATA : wa_coep TYPE t_coep.
DATA : wa1_coep TYPE t_coep.

select-options:

s_pspid for prps-psphi.

select * from PRPS  into corresponding fields of table t_prps
where psphi in s_pspid.

***Actual Costs
select * from coep into corresponding fields of table it_coep
for all entries in t_prps
where objnr = t_prps-objnr.



sort it_coep by kstar.

loop at it_coep into wa1_coep.

  wa1_coep-wtgbtr = wa1_coep-wtgbtr   + wa_coep-wtgbtr .

  AT END OF kstar.
    ULINE.
    WRITE: / wa1_coep-wtgbtr , 30 wa1_coep-kstar  .
    move wa1_coep-wtgbtr to t_final-CJTDAT.
    move wa1_coep-kstar to t_final-kstar.

    append t_final.
    CLEAR wa1_coep.
    SKIP.
  ENDAT.

endloop.


loop at t_final.

  write:/10 t_final-kstar, 40 t_final-cjtdat.

endloop.

What am i doing wrong?

rgds

vara