2006 Oct 24 3:28 PM
My display is like this
Monday ( Text)
planned (Text )
matnr
quantity
matnr
quantity
......
.....
....
......
sum :
______
I need to sum only the quantitiy here.....
How can i do it.
My display is like this
Monday ( Text)
planned (Text )
matnr
quantity
matnr
quantity
......
.....
....
......
sum :
______
I need to sum only the quantitiy here.....
How can i do it.
2006 Oct 24 3:49 PM
Johnn, here is a sample program using the iT_SORT parameter. This program sorts and subtotals by MATKL, this should show you what you need to do in your program. Just cut and paste this example you in system, the alv grid is implemented in a docking container on the selection screen, so no need to create a screen for the ALV Grid.
report zrich_0001 .
data: begin of i_alv occurs 0,
matnr type mara-matnr,
mtart type mara-mtart,
matkl type mara-matkl,
groes type mara-groes,
brgew type mara-brgew,
end of i_alv.
data: alv_container type ref to cl_gui_docking_container.
data: alv_grid type ref to cl_gui_alv_grid.
<b>data: sort type lvc_t_sort.</b>
data: fieldcat type lvc_t_fcat.
data: repid type sy-repid.
parameters: p_check.
initialization.
repid = sy-repid.
perform get_data.
at selection-screen output.
check alv_container is initial.
create object alv_container
exporting repid = repid
dynnr = sy-dynnr
side = alv_container->dock_at_left
extension = 1500.
create object alv_grid
exporting
i_parent = alv_container.
* Populate Field Catalog
perform get_fieldcatalog.
<b> perform get_sort.</b>
call method alv_grid->set_table_for_first_display
exporting
i_structure_name = 'I_ALV'
changing
it_outtab = i_alv[]
<b> it_sort = sort[]</b>
it_fieldcatalog = fieldcat[].
start-of-selection.
************************************************************************
* FORM GET_DATA
************************************************************************
form get_data.
select * into corresponding fields of table i_alv
from mara
up to 100 rows.
sort i_alv ascending by matnr.
endform.
************************************************************************
* Form Get_Fieldcatalog - Set Up Columns/Headers
************************************************************************
form get_fieldcatalog.
data: ls_fcat type lvc_s_fcat.
refresh: fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '18'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '1'.
append ls_fcat to fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Type'.
ls_fcat-fieldname = 'MTART'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '10'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '2'.
append ls_fcat to fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Group'.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '12'.
ls_fcat-col_pos = '3'.
append ls_fcat to fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Size'.
ls_fcat-fieldname = 'GROES'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '30'.
ls_fcat-col_pos = '4'.
append ls_fcat to fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Weight'.
ls_fcat-fieldname = 'BRGEW'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '15'.
ls_fcat-col_pos = '5'.
<b> ls_fcat-do_sum = 'X'.
ls_fcat-datatype = 'QUAN'.</b>
append ls_fcat to fieldcat.
endform.
************************************************************************
* Form sort
************************************************************************
form get_sort.
<b> data: ls_sort type lvc_s_sort.
refresh sort.
ls_sort-fieldname = 'MATKL'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
append ls_sort to sort.</b>
endform.
Regards,
Rich Heilman
2006 Oct 24 4:54 PM
Hello Rich,
I am trying to do this way, But automatically all the text get sorted.
so i think i should hardcode to find the sum of the quantity for every day.
How to do it ?