‎2009 Jul 29 1:46 AM
selection screen has 2 options
detail
summary
already one internal table is getting the detailed values.
now i have write code for summary
when summary is clicked
the output shoul be sorted by matnr and all the similar
matnr should be consolidated .ie all the qunatity
and price values should be totalled for similar matnr.
please let me knwo ur suggestions for logic of this
FORM SUMMARY_REPORT .
sort tbl_output by matnr.
loop at tbl_output.
MOVE-CORRESPONDING tbl_output TO tbl_output1.
append tbl_output1.
ENDLOOP.
sort tbl_output1 by matnr.
loop at tbl_output1.
at end of matnr.
sum.
endat.
endloop.
‎2009 Jul 29 1:55 AM
Hi Revanth,
try this way:
" sort tbl_output by matnr. -> you dont need, unsell you want for output
LOOP AT tbl_output.
tbl_output1-matnr = tbl_output-matnr.
tbl_output1-value_field = tbl_output-value_field.
" next velues fileds
collect tbl_output1.
ENDLOOP.
Collect will sum all value fields comparing all non-numeric fields.
So, using move-corresponding won't work, unless you have just matnr field as non-numerica.
Regards,
Frisoni
‎2009 Jul 29 1:55 AM
Hi Revanth,
try this way:
" sort tbl_output by matnr. -> you dont need, unsell you want for output
LOOP AT tbl_output.
tbl_output1-matnr = tbl_output-matnr.
tbl_output1-value_field = tbl_output-value_field.
" next velues fileds
collect tbl_output1.
ENDLOOP.
Collect will sum all value fields comparing all non-numeric fields.
So, using move-corresponding won't work, unless you have just matnr field as non-numerica.
Regards,
Frisoni
‎2009 Jul 29 2:13 AM
hi thanks for your info but i want to do it with alv functions
i can use do_sum = x for the fields to be consolidated.
but what option should i use for consolidating based on matnr??
ie at similar matnr the consolidation should take place in alv
‎2009 Jul 29 2:31 AM
So you should set do_sum = 'X' in your fieldcatalog, for each field you want do sum.
Then you have to sort by matnr and set SUBTOT = 'X' for this field.
Frisoni
‎2009 Jul 29 2:45 AM
hi i have put teh do_sum = x
but where should i sort matnr and put subtot = x??
PERFORM write_fieldcat1 USING 'WERKS' 'TBL_OUTPUT' 'AUFK' 'X' 1 ' ' ' '.
PERFORM write_fieldcat1 USING 'AUFNR' 'TBL_OUTPUT' 'AUFK' ' ' 2 ' ' ' '.
PERFORM write_fieldcat1 USING 'MATNR' 'TBL_OUTPUT' 'AFPO' ' ' 3 ' ' ' '.
if p_sum = 'X'.
PERFORM write_fieldcat1 USING 'WKG010' 'TBL_OUTPUT' ' ' ' ' 4 'PV Alum' 'X'.
PERFORM write_fieldcat1 USING 'WKG0102' 'TBL_OUTPUT' ' ' ' ' 5 'PV Cemt' 'X'.
PERFORM write_fieldcat1 USING 'WKG0103' 'TBL_OUTPUT' ' ' ' ' 6 'PV Ceno' 'X'.
PERFORM write_fieldcat1 USING 'WKG0104' 'TBL_OUTPUT' ' ' ' ' 7 'PV Pulp' 'X'.
PERFORM write_fieldcat1 USING 'WKG0105' 'TBL_OUTPUT' ' ' ' ' 8 'PV Silica' 'X'.
PERFORM write_fieldcat1 USING 'WKG0106' 'TBL_OUTPUT' ' ' ' ' 9 'PV MACDO' 'X'.
PERFORM write_fieldcat1 USING 'WKG0107' 'TBL_OUTPUT' ' ' ' ' 10 'PV NonFM' 'X'.
endif.
FORM WRITE_FIELDCAT1 USING name tab st key pos desc sum.
st_fieldcat-fieldname = name.
st_fieldcat-tabname = tab.
st_fieldcat-ref_tabname = st.
st_fieldcat-key = key.
st_fieldcat-col_pos = pos.
st_fieldcat-seltext_m = desc.
st_fieldcat-do_sum = sum.
APPEND st_fieldcat TO tbl_fieldcat.
CLEAR st_fieldcat.
ENDFORM. " WRITE_FIELDCAT1
‎2009 Jul 29 2:58 AM
You have to set your SORT order in SORT table for ALV.
Take a look here:
Frisoni