12-12-2007 7:31 AM
I have a report which needs to sum all the values of KONV-KBETR where KONV-kinak NE 'A'.
How do i write the code.
Can anyone help me in wrting the code..
This value i have to finally display in my internal table as one value.
i tried out with like this
LOOP AT it_konv INTO wa_konv WHERE knumv = wa_vbrk-knumv AND
kposn = wa_vbrp-posnr AND
kschl = wa_ztsd120_n-zlow
AND kinak NE 'A'.
l_kwert = wa_konv-kwert + l_kwert.( where DATA l_kwert LIKE wa_konv-kwert)
ENDLOOP.
wa_konv-kwert = l_kwert.
but its not working..
12-12-2007 7:41 AM
Hi,
Refer this code
*--Sort table by Personnel Number and Pay Scale Level
SORT it_final BY pernr endda begda.
LOOP AT it_final INTO wa_final.
lv_index = sy-tabix.
lv_index1 = lv_index - 1.
*--Clear
CLEAR : wa_final1.
READ TABLE it_final INTO wa_final1 INDEX lv_index1.
IF sy-subrc EQ 0 AND
wa_final1-pernr EQ wa_final-pernr.
wa_final-incre = wa_final-bet01 - wa_final1-bet01.
ENDIF.
MODIFY it_final FROM wa_final INDEX lv_index
TRANSPORTING incre.
*--Clear
CLEAR : wa_final,
wa_final1.
ENDLOOP.
Regards,
Prashant
12-12-2007 7:42 AM
hi Mona,
l_kwert = wa_konv-kwert + l_kwert.( where DATA l_kwert LIKE wa_konv-kwert)
replace witrh:
DATA l_kbetr LIKE wa_konv-kbetr
l_kbetr = wa_konv-kbetr + l_kbetr.
12-12-2007 7:55 AM
Hi Mona,
Why dont you use SUM(kbetr) in select statement it is vary easy with out write code for sum.
Plz Reward if useful,
Mahi.
12-12-2007 9:19 AM
Hi Prashant.
i was trying out your code and modified it like this.
data lv-index type sy-tabix.
data : wa_final1 like it_final.
loop at it_final into wa_final.
lv-index = sy-tabix.
lv-index = lv-index-1.
clear: wa_final1.
read table it_final into wa_final1 index lv-index1.
if sy-subrc = 0 and wa_final1-real = wa_final-real.
wa_final-real = wa_final-real + wa_final1-real.
endif.
modify it_final from wa_final index lv-index transporting real.
clear: wa_final, wa_final1.
endloop.
but i am getting an error saying " the data object lv-index has no structure and therefore no component called "1".
Can you help me further.
12-12-2007 9:22 AM
hi Mona,
with my solution would have been much easier, of course it is your decision...
here you have to change:
lv-index
replace with
lv<b>_</b>index
'-' is not allowed in name of variables, of course you have to make this for all variables which are defined with '-'
hope this helps
ec
12-12-2007 9:30 AM
hi,
to sum up the values write like this...it worked for me well
SELECT MATNR SUM( LSMNG ) SUM( WEMNG )
INTO (V_MAT, V_LSMNG, V_WEMNG)
FROM S012
WHERE MATNR = WA_MAT-MATNR
GROUP BY MATNR.
12-12-2007 10:38 AM
12-12-2007 10:47 AM
just revert to my first post in this thread, you only have to change one line in the coding (and the definition for the variable) it has to work.