2007 Sep 01 7:29 PM
HALLOW
i have a table and i wont to add the tables line to one line , to do sum
if date appear more then one time like in example.
i give example
date----
hours
01.01.2002 6.5
01.01.2002 2.5
02.01.2002 5
03.01.2002 3
03.01.2002 3
04.01.2002 4
06.01.2002 5
i wont to move it to table like this
date----
hours
01.01.2002 9 ->sum houres of date 01.01.2002
02.01.2002
03.01.2002 6 ->sum houres of date 03.01.2002
04.01.2002 4
06.01.2002 5
Regards
i reward
2007 Sep 01 9:41 PM
You can get same functionality if you use Internal table events .
See the simple example :
&----
*& Report ZTEST_IEVENTS
*&
&----
*&
*&
&----
REPORT ZTEST_IEVENTS no standard page heading
line-count 40(2).
tables : vbap.
data : begin of i_vbap occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
kwmeng like vbap-kwmeng,
netpr like vbap-netpr,
end of i_vbap.
data wa_vbap like line of i_vbap.
data v_flag type c.
select-options s_vbeln for vbap-vbeln obligatory.
start-of-selection.
select vbeln
posnr
matnr
kwmeng
netpr from vbap
into table i_vbap
where vbeln in s_vbeln.
sort i_vbap by vbeln posnr.
end-of-selection.
loop at i_vbap.
move i_vbap to wa_vbap.
at first.
write:/2 'Order #',15 'Item #',28 'Material #',50 'Qty', 70 'Net value'.
skip 1.
endat.
at new vbeln.
write:/2 wa_vbap-vbeln,15 wa_vbap-posnr,28 wa_vbap-matnr,
47 wa_vbap-kwmeng,65 wa_vbap-netpr.
v_flag = 'X'.
endat.
if v_flag ne 'X'.
write:/15 wa_vbap-posnr,28 wa_vbap-matnr,
47 wa_vbap-kwmeng,65 wa_vbap-netpr.
endif.
at end of vbeln.
sum.
skip 1.
write:/5 'Sub totals', 47 i_vbap-kwmeng,65 i_vbap-netpr.
skip 1.
endat.
at last .
skip 1.
sum.
write:/5 'Grand Totals',47 i_vbap-kwmeng,65 i_vbap-netpr.
skip 1.
write:/ 'end of page', 'Footer'.
endat.
clear v_flag.
endloop.
Good luck
Thanks
Seshu
HALLOW
i have a table and i wont to add the tables line to one line , to do sum
if date appear more then one time like in example.
i give example
date----
hours
01.01.2002 6.5
01.01.2002 2.5
02.01.2002 5
03.01.2002 3
03.01.2002 3
04.01.2002 4
06.01.2002 5
i wont to move it to table like this
date----
hours
01.01.2002 9 ->sum houres of date 01.01.2002
02.01.2002
03.01.2002 6 ->sum houres of date 03.01.2002
04.01.2002 4
06.01.2002 5
Regards
i reward
2007 Sep 01 7:32 PM
Hi Tals,
U can do it by simply changing the "type" (data type) of the field you want to add to type N or P and do a COLLECT on the internal table.
Regards,
K
2007 Sep 01 7:33 PM
Hi,
Code like this.
LOOP AT itab.
itab2-date = tab-date.
itab2-hours = tab-hours.
COLLECT itab2.
ENDLOOP.
itab2 being of same structure as tab.
Thanks and Best Regards,
Vikas Bittera.
2007 Sep 01 9:41 PM
You can get same functionality if you use Internal table events .
See the simple example :
&----
*& Report ZTEST_IEVENTS
*&
&----
*&
*&
&----
REPORT ZTEST_IEVENTS no standard page heading
line-count 40(2).
tables : vbap.
data : begin of i_vbap occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
kwmeng like vbap-kwmeng,
netpr like vbap-netpr,
end of i_vbap.
data wa_vbap like line of i_vbap.
data v_flag type c.
select-options s_vbeln for vbap-vbeln obligatory.
start-of-selection.
select vbeln
posnr
matnr
kwmeng
netpr from vbap
into table i_vbap
where vbeln in s_vbeln.
sort i_vbap by vbeln posnr.
end-of-selection.
loop at i_vbap.
move i_vbap to wa_vbap.
at first.
write:/2 'Order #',15 'Item #',28 'Material #',50 'Qty', 70 'Net value'.
skip 1.
endat.
at new vbeln.
write:/2 wa_vbap-vbeln,15 wa_vbap-posnr,28 wa_vbap-matnr,
47 wa_vbap-kwmeng,65 wa_vbap-netpr.
v_flag = 'X'.
endat.
if v_flag ne 'X'.
write:/15 wa_vbap-posnr,28 wa_vbap-matnr,
47 wa_vbap-kwmeng,65 wa_vbap-netpr.
endif.
at end of vbeln.
sum.
skip 1.
write:/5 'Sub totals', 47 i_vbap-kwmeng,65 i_vbap-netpr.
skip 1.
endat.
at last .
skip 1.
sum.
write:/5 'Grand Totals',47 i_vbap-kwmeng,65 i_vbap-netpr.
skip 1.
write:/ 'end of page', 'Footer'.
endat.
clear v_flag.
endloop.
Good luck
Thanks
Seshu
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |