11-01-2012 7:15 AM
Hi,
I am generating an ALV and want to do calculation at the end of rows, my code is below please guide me which is best way to do calculation
FORM DISPLAY_SM .
DATA: HEADER1(100) TYPE C.
HEADER1 = 'Department Report Orgnizational Unit Wise'.
PERFORM fill_fieldcat USING 'ORGEH' 10 'Organization Unit' 'TAB'.
PERFORM fill_fieldcat USING 'PERNR' 20 'Personnel Number' 'TAB'.
PERFORM fill_fieldcat USING 'ENAME' 22 ' EmpName' 'TAB'.
PERFORM fill_fieldcat USING 'PERSG' 6 'EE. Group' 'TAB'.
PERFORM fill_fieldcat USING 'PERSK' 18 'EE. Subgroup' 'TAB'.
PERFORM fill_fieldcat USING 'BASIC' 12 'Basic Salary' 'TAB'.
PERFORM fill_fieldcat USING 'TRANSPORT' 10 'Transportation' 'TAB'.
PERFORM fill_fieldcat USING 'HOUSING' 10 'Housing' 'TAB'.
PERFORM fill_fieldcat USING 'FOOD' 11 'Food ' 'TAB'.
PERFORM fill_fieldcat USING 'OTHERS' 11 'Others' 'TAB'.
PERFORM fill_fieldcat USING 'OVERTIME' 10 'Over Time' 'TAB'.
PERFORM fill_fieldcat USING 'BONUS' 11 'Bonus' 'TAB'.
PERFORM fill_fieldcat USING 'GROSS' 11 'Gross Salary' 'TAB'.
PERFORM fill_fieldcat USING 'GOSI' 11 'Gosi' 'TAB'.
PERFORM fill_fieldcat USING 'OTHER_DED' 11 'Other Deduct' 'TAB'.
PERFORM fill_fieldcat USING 'LOAN' 11 'Loan' 'TAB'.
PERFORM fill_fieldcat USING 'PLAC_FEE' 11 'Placement Fee' 'TAB'.
PERFORM fill_fieldcat USING 'SEC_DEP' 11 'Security Deposit' 'TAB'.
PERFORM fill_fieldcat USING 'ABSENT' 11 'Absent' 'TAB'.
PERFORM fill_fieldcat USING 'PLENTY' 11 'Plenty' 'TAB'.
PERFORM fill_fieldcat USING 'LATE' 11 'Late Attendance' 'TAB'.
PERFORM fill_fieldcat USING 'NET' 11 'Net Income' 'TAB'.
PERFORM add_heading_alv USING c_alv_head_header '' HEADER1.
* PERFORM add_heading_alv USING c_alv_head_selection '' HEADER1.
PERFORM display_alv USING TAB[].
endform.
DO I NEED TO MAKE FIELD LIKE THIS
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
REGARDS
11-01-2012 9:21 AM
Hello Sarosh,
Do you want to perform sum of column values and display in ALV in the end.
If so then use do_sum = 'X' in fieldcatalog for that field.
If you want to perform calculation at the end of internal table and display value in ALV output then use AT END OF statement for calculation.
Regards,
Deepti
11-01-2012 9:46 AM
yes, you have to do do like this. assign like this :
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, "internal table
WA_FCAT TYPE slis_fieldcat_alv. "work area
WA_FCAT-ROW_POS = 1.
WA_FCAT-col_pos = 1.
WA_Fcat-fieldname = 'PRUEFLOS'.
WA_Fcat-seltext_l = 'INSPECTION_LOT_NUMBER.'.
WA_Fcat-just ='L'.
WA_Fcat-lzero = ''.
WA_Fcat-outputlen = '15'."(output length)
APPEND WA_Fcat TO IT_FCAT.
CLEAR WA_Fcat.
use :
do_sum in your field catalog to sum.
11-02-2012 5:12 PM
Hi,
If you want to do the summation of one field based on other field, you can use I_SORT parameter in ALV function module.
Regards,
Vasu.