Subtotal in alv grid
hi friends..
how to maintain subtotal (group of fields) in alv gird display. we have two fields in our report. filed2 is editable mode. see the below the example..
eg:
field1 field2
abc 100.00
abc 200.00
abc 300.00
bcd 100.00
bcd 250.00
cde 250.00
cde 100.00
here we want sub total1.
pqr 100.00
pqr 200.00
qrs 250.00
rsu 210.00
here we want subtotal2
xyz 100.00
xyz 200.00
yza 100.00
here we want subtotal3.
angin we want subtotal1 + subtotal2
angin we want subtotal2 + subtotal3
angin we want subtotal1 + subtotal3
finally we wnat grand total.
whenever enduser edit the field2 value to effected all subtotal & grand totals.
in our report have this type of calcucation is there.
plese help me ..
thanks & regrads....
DATA: struct_gridsort TYPE lvc_t_sort WITH HEADER LINE,
i_sort_fcat TYPE lvc_t_sort.
IN PBO,
PERFORM sort_outtable CHANGING i_sort_fcat.
FORM sort_outtable CHANGING p_i_sort_fcat.
struct_gridsort-fieldname = 'YEAR'.
<b>struct_gridsort-up = 'X'.</b> (for sorting)
APPEND struct_gridsort TO i_sort_fcat.
CLEAR struct_gridsort.
struct_gridsort-fieldname = 'MONTH'.
struct_gridsort-up = 'X'.
<b> struct_gridsort-subtot = 'X'</b>.(SubTotal)
APPEND struct_gridsort TO i_sort_fcat.
CLEAR struct_gridsort.
ENDFORM. " sort_outtable
Hope this helps.
Kindly reward points and close the thread if ur problem got solved or kindly get back.
Similar Messages
-
Subtotal in ALV grid for a particular type and Grand total in ALV
Hi,
I need to have sub total for a particular type(eg: goods, services).. and grand total at end in ALV grid..
ALV output required as below:
Type VAT registration number Country Total Gross Amounts Total Tax Amounts Total Amount, ex-tax
Goods ATU12345678 AT 222.42 0 222.42
Goods NL123456789B02 NL 3,417.00 0 3,417.00
Goods Total 3,639.42 - 3,639.42
Services ATU12345678 AT 2,342.34 0 2,342.34
Services NL123456789B02 NL 223.33 0 223.33
Services Total 2,565.67 - 2,565.67
Grand Total 6,205.09 - 6,205.09
Let me as to how to achieve the above type in ALV grid...
Regards
Shivacheck this link..
Grand Totals in ALV grid disply function module
or do like this..
REPORT ZALVTESTFORSUBTOTAL.
tables:pa0008.
type-pools:slis.
types:begin of ty_pa0008,
pernr like pa0008-pernr,
begda like pa0008-begda,
endda like pa0008-endda,
ansal like pa0008-ansal,
lga01 like pa0008-lga01,
bet01 like pa0008-bet01,
end of ty_pa0008.
data:it_pa0008 type standard table of ty_pa0008 with header line.
data:it_fieldcat type SLIS_T_FIELDCAT_ALV,
wa_fieldcat type slis_fieldcat_alv,
it_layout type slis_layout_alv,
WA_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
select-options:s_pernr for pa0008-pernr.
start-of-selection.
perform getD_data.
perform disp_alv.
*& Form getD_data
text
--> p1 text
<-- p2 text
form getD_data .
select pernr
begda
endda
ansal
lga01
bet01
from pa0008
into table it_pa0008
where pernr in s_pernr.
sort it_pa0008 by pernr begda descending.
endform. " getD_data
*& Form disp_alv
text
--> p1 text
<-- p2 text
form disp_alv .
wa_fieldcat-fieldname = 'PERNR'.
wa_FIELDCAT-REPTEXT_DDIC = 'Personnel no'.
*WA_FIELDCAT-no_subtotals = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BEGDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'Start date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENDDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'End date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ANSAL'.
wa_FIELDCAT-REPTEXT_DDIC = 'Annula salary'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'LGA01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Wage Type'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BET01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Amount for wagetype'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
DATA: sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv.
sort-fieldname = 'PERNR'.
sort-subtot = 'X'.
SORT-UP = 'X'.
APPEND sort TO it_sort.
*sort-fieldname = 'BEGDA'.
*SORT-NO_SUBTOTS = 'X'.
*APPEND sort TO it_sort.
IT_layout-totals_text = 'total text'.
IT_layout-subtotals_text = 'Subtotal text'.
*WA_EVENTS-NAME = 'SUBTOTAL TEXT'.
*WA_EVENTS-FORM = 'SUBTOTAL TEXT'.
*APPEND WA_EVENTS TO IT_EVENTS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = it_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_sort = it_sort
it_events = it_events
TABLES
t_outtab = it_pa0008 .
endform. " disp_alv -
Percentage Total/Subtotal in ALV Grid
Dear All,
I have to display an ALV report with percentage feilds. Everything is fine but the problem arises when the standard ALV sum functionality is used. It simply adds up all the percentage columns. Making do_sum = 'C' wont help either as it would simple give an average of all the percentage. My requirement is to show them through calculation. I have searched the web and saw some solutions with SUBTOTAL_TEXT nad some with OOP programming but i am not able to get this. Can anybody please help.
<REMOVED BY MODERATOR>
Thanks
MV
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 4:24 PMhi manish,
try this program.
ALV Grid List with sub-totals
REPORT z_demo_alv_sort.
* This program lists orders (VBAK) with sort and sub-total for *
* 'sold-to-party' (KUNNR) and 'Sales organization' (VKORG) *
TABLES : vbak.
TYPE-POOLS: slis. " ALV Global types
SELECT-OPTIONS :
s_vkorg FOR vbak-vkorg, " Sales organization
s_kunnr FOR vbak-kunnr, " Sold-to party
s_vbeln FOR vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
DATA:
BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg, " Sales organization
kunnr LIKE vbak-kunnr, " Sold-to party
vbeln LIKE vbak-vbeln, " Sales document
netwr LIKE vbak-netwr, " Net Value of the Sales Order
waerk LIKE vbak-waerk, " Document currency
END OF gt_vbak.
INITIALIZATION.
v_1 = 'Maximum of records to read'.
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
* Form f_read_data
FORM f_read_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
FROM vbak
UP TO p_max ROWS
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg.
ENDFORM. " F_READ_DATA
* Form f_display_data
FORM f_display_data.
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'VBAK'.
ls_fieldcat-do_sum = &2.
ls_fieldcat-cfieldname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'NETWR' 'X' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal
m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal
m_sort 'VBELN' ''. " Sort by vbeln
ls_layout-cell_merge = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA
***************** END OF PROGRAM Z_DEMO_ALV_SORT **********************
thanks
karthik
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 4:50 PM -
Subtotal in alv grid output.
hi experts,
i want to display subtotal in the alv output using control break statement, without using alv functionality and layout.
my code is given below, how can i add subtotal field and display them in alv ,
*& Report Y_VARUNSHARMA
REPORT Y_VARUNSHARMA.
TABLES: VBAK.
TYPE-POOLS: SLIS.
TYPES: BEGIN OF T_ITAB,
VBELN LIKE VBAK-VBELN,
ERDAT LIKE VBAK-ERDAT,
ERNAM LIKE VBAK-ERNAM,
ANGDT LIKE VBAK-ANGDT,
BNDDT LIKE VBAK-BNDDT,
AUART LIKE VBAK-AUART,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
CHARG LIKE VBAP-CHARG,
MAKTX LIKE MAKT-MAKTX,
NETPR LIKE VBAP-NETPR,
VGBEL LIKE VBAK-VGBEL,
MEINS LIKE VBAP-MEINS,
SMENG LIKE VBAP-SMENG,
END OF T_ITAB.
DATA: G_REPID LIKE SY-REPID.
DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: I_ITAB TYPE T_ITAB OCCURS 0,
WA_ITAB TYPE T_ITAB.
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV ,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: I_LISTHEADER TYPE SLIS_T_LISTHEADER,
WA_LISTHEADER TYPE SLIS_LISTHEADER.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: DOCNO FOR VBAK-VBELN.
PARAMETER DOCTYPE LIKE VBAK-AUART.
SELECT-OPTIONS: DATE FOR SY-DATUM.
SELECTION-SCREEN SKIP 2.
PARAMETER P_CHECK AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK B1.
INITIALIZATION.
G_REPID = SY-REPID.
PERFORM BUILD_CATALOGE.
PERFORM LIST_HEADER.
PERFORM SET_LAYOUT.
AT SELECTION-SCREEN.
IF DOCNO-LOW = '' .
MESSAGE E000(ZVARUN) .
elseif DOCNO-HIGH = '' .
MESSAGE E001(ZVARUN) .
ENDIF.
START-OF-SELECTION.
PERFORM GET_DATA.
*PERFORM DISPLAY.
END-OF-SELECTION.
IF P_CHECK = 'X'.
PERFORM DOWNLOAD_EXCEL.
ELSE.
PERFORM DISPLAY.
ENDIF.
FORM DOWNLOAD_EXCEL.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:\FILE.XLS'
FILETYPE = 'XLS'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = I_ITAB
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM BUILD_CATALOGE.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'SALES DOC'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'ERDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'ERNAM'.
WA_FIELDCAT-SELTEXT_M = 'NAME'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'ANGDT'.
WA_FIELDCAT-SELTEXT_M = 'VALID FR'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'BNDDT'.
WA_FIELDCAT-SELTEXT_M = 'VALID TO'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'AUART'.
WA_FIELDCAT-SELTEXT_M = 'DOC TYPE'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-SELTEXT_M = 'DOC ITEM'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'CHARG'.
WA_FIELDCAT-SELTEXT_M = 'BATCH NO'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'MAKTX'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL DESC'.
WA_FIELDCAT-EDIT = 'X'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'UNIT PRICE'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'VGBEL'.
WA_FIELDCAT-SELTEXT_M = 'RFR DOC NO'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UNIT'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'SMENG'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
*WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM.
FORM LIST_HEADER.
WA_LISTHEADER-TYP = 'H'.
WA_LISTHEADER-INFO = 'RJT COMPUSOLUTIONS'.
APPEND WA_LISTHEADER TO I_LISTHEADER.
CLEAR WA_LISTHEADER.
ENDFORM.
FORM SET_LAYOUT.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM.
FORM DISPLAY.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = I_ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = I_LISTHEADER
I_LOGO = 'RJT'
I_END_OF_LIST_GRID =
I_ALV_FORM =
ENDFORM.
FORM GET_DATA.
SELECT AVBELN AERDAT AERNAM AANGDT ABNDDT AAUART AVGBEL BPOSNR BMATNR BCHARG BMEINS BSMENG BNETPR CMAKTX INTO CORRESPONDING FIELDS OF TABLE I_ITAB FROM ( ( VBAK AS A INNER JOIN VBAP AS B
ON AVBELN = BVBELN ) INNER JOIN MAKT AS C ON BMATNR = CMATNR ) WHERE AVBELN IN DOCNO AND AAUART = DOCTYPE .
ENDFORM.
FORM USER_COMMAND USING L_UCOMM LIKE SY-UCOMM L_SELFIELD TYPE SLIS_SELFIELD.
CASE L_UCOMM.
WHEN '&IC1'.
IF L_SELFIELD-FIELDNAME = 'VBELN'.
CALL TRANSACTION 'VA02'.
ELSEIF
L_SELFIELD-FIELDNAME = 'MATNR'.
CALL TRANSACTION 'MM02'.
ENDIF.
ENDCASE.
ENDFORM.Hi,
That I guess is difficult. Only way is to append a new line with your subtotal to the output table with the subtotal filled in appro. field.
Santhosh -
ALV Grid Control - Modifiy data in total and subtotal lines
Hello all,
I´am creating a report using ALV Grid Control. This report calculates (using delivered and returned materials) for each vendor/material-combination the return quote.
Using the totals and subtotals function for different characteristics I want to calculate the return quote for the selected characteristic. Example:
Material delivered returned quote
..4711 . . . 500 . . . 5 . . . . 1 (=returned*100/delivered)
..4711 . . . 400 . . . 10 . . . . 2,5
. SUM . . . 900 . . . 15 . . . . 3,5 <-- 3,5 is the sum but I want display the calculated value 1,667
Is there a possibility to modify data in the total and subtotal lines.
Thank you for your answer
Best regards
Thomasyou said instead of 3.5 you want to show 1,667 ..
how is it possible...
3,5 become 1,667
i thought you are doing any conversions...
vijay -
Regarding user interface in subtotal line of ALV grid, ensure points
Hi,
I have 3 fields,
A= vendor , B = freight , C = Cost PMT
When the vendor get changed, My Grid is showing subtotal of B i.e freight.
Now my requirement is, in the same subtotal line, I want average of C (Cost PMT) field.
So how we can interact with the subtotal line of the ALV grid.
Pleas reply!!!! & have ur points.
cheersRead the documentation of FM ICON_CREATE, the purpose of the Function module is entirely different from what you are using it for.
To print Icons in ALV (Using FMs ) all you need to do is to send the Icon name in the field.
Also parameters TEXT and INFO of FM ICON_CREATE seem to be flags, that are appended to the icon name so that when you set it on the screen the appropriate info or Text is shown. -
How to display a row after a subtotal field in ALV Grid
Hi All,
My requirement is to print a extra row with values and constant text after printing subtotal values in ALV Grid.
e.g. TOTAL 12.23 ---> Subtotal field
Tax 5.2 ---> extra row after subtotal field.
Please help me....
Thanks in advance.
Regards
AjayHi
You can try using INSERT <WA> OR INSERT INITIAL LINE .
fill the wa with tax value.
INSERT <wa> into table < internal table >
A row will be inserted into internal table with the values.
Try this and let me know.
Thanks
Hariharan -
Subtotal Text in ALV Grid and hiding empty row
Hello,
ive got a ALV-Grid with a few fields .. Total on one field subtotal on VKORG, category or some other fields .
after subtotal of one of the 2 named fields i'm reading the literal to the given fields and writing them in the table which is displayed and do a refresh.
i can show the field literal in the alv by adding it into the field cat but than its displayed even if its not filled.
i just want to display that column after filling it - the subtotal of the 2 columns.
and i want to add the text of the literal to the subtotal line. so if the alv grid is closed to display the totals. i want to see what the subtotal is for.
for displaying i use
CALL METHOD lcl_alv_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = gs_variant
it_toolbar_excluding = gt_exclude
i_save = x_save
i_default = 'X'
CHANGING
it_outtab = it_alvlist[]
it_fieldcatalog = gt_field_cat.
for refresh
lv_lvc_s_stbl-row = 'X'.
lv_lvc_s_stbl-col = 'X'.
lv_soft_refresh = 'X'.
CALL METHOD lcl_alv_grid->refresh_table_display
EXPORTING
is_stable = lv_lvc_s_stbl
i_soft_refresh = lv_soft_refresh
EXCEPTIONS
finished = 1
OTHERS = 2.
get the selected column to read literal
CALL METHOD lcl_alv_grid->get_selected_columns
IMPORTING
et_index_columns = it_col_tab
EXCEPTIONS
OTHERS = 1.
Hope you can help me and understand my problemHi,
Use the No_out from Reusable types of fieldcat..For example.
IF it_final-field is initial.
READ TABLE IT_FIELDCAT5 WITH KEY FIELDNAME = 'BCD'.
IF SY-SUBRC EQ 0.
IT_FIELDCAT5-NO_OUT = 'X'.
MODIFY IT_FIELDCAT5 INDEX SY-TABIX TRANSPORTING NO_OUT.
ENDIF.
else.
READ TABLE IT_FIELDCAT5 WITH KEY FIELDNAME = 'BCD'.
IF SY-SUBRC EQ 0.
IT_FIELDCAT5-NO_OUT = ' '.
MODIFY IT_FIELDCAT5 INDEX SY-TABIX TRANSPORTING NO_OUT.
ENDIF.
ENDIf.
Cheers,
Syed Maheboob. -
ALV grid display the subtotal not getting for one column at the output
Hi,
I am working one report ALV grid display and subtotal is not getting for one paricular coulumn.
Eventhough that column has some values.
So can anyone give the proper solution.
Waiting quick response.
Best Regards,
BansiHi
see this link .
https://wiki.sdn.sap.com/wiki/display/ABAP/SUBTOTALinALV
or try this program.
REPORT zalv.
DATA:
t_sflight TYPE TABLE OF sflight,
fs_sflight TYPE sflight.
DATA:
r_container TYPE REF TO cl_gui_custom_container,
r_grid TYPE REF TO cl_gui_alv_grid.
*FIELD CATALOG
DATA:
t_fcat TYPE lvc_t_fcat,
fs_fcat TYPE lvc_s_fcat.
*SORTING THE BASIC LIST
DATA:
t_sort TYPE lvc_t_sort,
fs_sort TYPE lvc_s_sort.
fs_fcat-fieldname = 'PRICE'.
fs_fcat-do_sum = 'X'.
APPEND fs_fcat TO t_fcat.
fs_sort-spos ='1'.
fs_sort-fieldname = 'CARRID'.
fs_sort-down = 'X'.
fs_sort-group = '*'.
fs_sort-subtot = 'X'.
APPEND fs_sort TO t_sort.
SELECT * FROM sflight INTO TABLE t_sflight.
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN1'.
SET TITLEBAR 'TITLE1'.ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
**& Module HANDLER OUTPUT
MODULE list OUTPUT.
CREATE OBJECT r_container
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT r_grid
EXPORTING
i_parent = r_container.
CALL METHOD r_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_fieldcatalog = t_fcat
it_outtab = t_sflight
it_sort = t_sort.
ENDMODULE. "list OUTPUT
Regards
Hareesh Menon -
Total, Subtotal of a hidden column in an ALV grid
I have a requirement for an ALV grid where I have to use a custom formula for a column's total and subtotal.
This value is a function of another column which is hidden (No_out = 'X').
I am unable to access the total and subtotal of this hidden column . I am able to access this only when I unhide the column in the field catalog.
THis is how I access the total and subtotal of the GRID. I use oops ALV of the class CL_GUI_ALV_GIRD.
call method o_grid->get_subtotals
importing
ep_collect00 = total
ep_collect01 = subto.
assign total->* to <ftotal>.
assign subto->* to <fsubto>.
I thought I would manipulate <ftotal>-mycolumn and <fsubto>-mycolumn . But both these are functions of a hidden column
and <ftotal>-hiddencolumn and <fsubto>-hiddencolumn is always empty unless I unhide them. I cannot display these columns to users as they are just logical columns of a dynamic internal table I have built. :-sHI,i have the same issue, how did you solve it?
Regards. -
Total/Subtotal Icon in ALV GRID
Hi;
i have an ALV GRID that is already sorted and data is shown ordered in the grid:
Sort Documento
wa_sort-spos = '1' .
wa_sort-fieldname = 'MBLNR'.
wa_sort-tabname = 'ITAB'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
But, i need to subtotal by a column and i do this:
gt_fieldcat-seltext_l = 'Cant_entregada'.
gt_fieldcat-fieldname = 'MENGE'.
gt_fieldcat-ref_tabname = 'itab'.
gt_fieldcat-outputlen = 14.
gt_fieldcat-do_sum = 'X'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
Menge is data type Integer because the Key User doesn´t want decimal places.
And ,
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_sort = i_sort
i_default = 'X'
i_save = 'A'
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2
So data in the grid is ordered by Document number, but the total/subtotal button is not displayed.
i've been lookin other posts about the same, but i don´t see any difference with my code.
Any help.
David Fúnez
Tegucigalpa, Hondurasi found the answer..jus added this line : gt_fieldcat-datatype = 'INT4'.
gt_fieldcat-seltext_l = 'Cant_entregada'.
gt_fieldcat-fieldname = 'MENGE'.
gt_fieldcat-ref_tabname = 'itab'.
gt_fieldcat-outputlen = 14.
gt_fieldcat-do_sum = 'X'.
gt_fieldcat-datatype = 'INT4'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
Now buttons are displayed... -
ALV GRID: How to change Subtotal and Main total values in standard row
Hi Experts,
By using SORT-SUBTOT = 'X' and FIELDCATALOG-DO_SUM = 'X', I will get subtotal and Main total.
My requiremnt is I need be calculate values manually and pass the calculated values to subtotal and maintotal.
is it possible in ALV GRID?
By adding extra row we will do this but I am looking standard subtotal and maintotal row change.
Thanks in advance,
MaheHi,
With function REUSE_ALV_GRID_DISPLAY you cannot do this.
It´s possible if you create a class inherited from cl_gui_alv_grid and rewrite the method set_data_table, you can do this. Like:
CLASS xgrid DEFINITION INHERITING FROM cl_gui_alv_grid.
PROTECTED SECTION.
METHODS: set_data_table REDEFINITION.
ENDCLASS. "xgrid DEFINITION
CLASS xgrid IMPLEMENTATION.
METHOD set_data_table.
* ....MODIFY data_table ...
CALL METHOD super->set_data_table
CHANGING
data_table = data_table.
ENDMETHOD. "set_data_table
ENDCLASS. "xgrid IMPLEMENTATION
DATA: grid TYPE REF TO xgrid.
CREATE OBJECT custom_container EXPORTING container_name = mycontainer.
CREATE OBJECT grid EXPORTING i_parent = custom_container.
CALL METHOD grid1->set_table_for_first_display ...
Best regards,
Leandro Mengue -
ALV Grid Subtotal text and Total text display
Hello ABAPGuru's
I want to display the subtotal and Total texts. alv grid program runing on background.
Regards
Sweety(Sri)Hello Neil,
Here I have attached my routines.anyway my confusion. I have wrote the routine subtotal_text .but i am not passing ALV GRID FM.
*& Form eventtab_build
&---- This is used to get the list of events
---- <--RI_EVENTS Internal table
FORM eventtab_build CHANGING ri_events TYPE slis_t_event.
Structure for event handling.
DATA: rs_event TYPE slis_alv_event.
Returns table of possible events for a list type.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = ri_events. " Table of events to perform
Read the internal table with the TOP_OF_PAGE and move the
form name to the internal table
READ TABLE ri_events
WITH KEY name = slis_ev_top_of_page INTO rs_event.
IF sy-subrc = 0.
MOVE c_formname TO rs_event-form. " Form name
MODIFY ri_events FROM rs_event
INDEX sy-tabix. " Top of page event
ENDIF.
READ TABLE ri_events
WITH KEY name = slis_ev_end_of_page INTO rs_event.
IF sy-subrc = 0.
MOVE c_form_eop_name TO rs_event-form. " Form name
MODIFY ri_events FROM rs_event
INDEX sy-tabix. " Top of page event
ENDIF.
READ TABLE ri_events
WITH KEY name = slis_ev_subtotal_text INTO rs_event.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO rs_event-form. " Formname
MODIFY ri_events FROM rs_event
INDEX sy-tabix. " Top of page event
ENDIF.
*&-- Delete all unneeded events:
DELETE ri_events WHERE form IS INITIAL.
ENDFORM. " eventtab_build
*& Form SUBTOTAL_TEXT
text
--> p1 text
<-- p2 text
FORM SUBTOTAL_TEXT USING ep_subtot_line TYPE type_data
e_event_data TYPE slis_subtot_text.
IF NOT e_event_data-criteria IS INITIAL.
E_EVENT_DATA-DISPLAY_TEXT_FOR_SUBTOTAL = 'Account Total'.
ENDIF.
ENDFORM. "SUBTOTAL_TEXT
*& Form initialise_layout
Initialise Layout
FORM initialise_layout .
i_layout-colwidth_optimize = c_x.
i_layout-group_change_edit = c_x.
*i_layout-subtotals_text = ' a'.
i_layout-detail_popup = c_x.
i_layout-zebra = c_x.
i_layout-no_vline = 'X'.
i_layout-no_hline = 'X'.
i_layout-totals_text = 'Account Total'.
ENDFORM. " initialise_layout
Call the function module to display the report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_program
i_callback_top_of_page = 'TOP_OF_PAGE' "Top Of Page
is_layout = i_layout
it_fieldcat = i_fieldtab
it_sort = i_sort
it_events = i_events " Events
is_print = i_print
i_default = c_x
i_save = c_save
is_variant = v_variant
TABLES
t_outtab = i_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards
Sweety (Sri) -
Change the total and subtotal dynamically in ALV GRID
Hi guys,
I need to change the total and subtotal of field "AMOUNT" dynamically.I am using ALV GRID CONTROL(oops concept).I need to override the standard functionality.I need to show my own subtotal and total line instead of standard one .Hi
I've understood it, I wanted to use OO Grid too, but I had to use the ALV list in order to write my total.
If you need to use OO grid u can try to exclude all funcitonalities for the total, subtotal and sorting and insert in the output table the lines with your totals.
Max -
HI ALL,
could any one send me how to display the subtotal Text in ALV grid output with code sample.
with thanks.
kannanhi,
means u want to print some text instead of star ( coming in subtotal) ?
If so than try like,
*& Report ZALV_LIST
REPORT zalv_list.
TABLES : mseg.
TYPE-POOLS : slis.
DATA : BEGIN OF itab OCCURS 0,
mblnr LIKE mseg-mblnr,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
menge LIKE mseg-menge,
line_color(4) TYPE c,
END OF itab.
DATA : BEGIN OF itab1 OCCURS 0,
mblnr LIKE mseg-mblnr,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
menge LIKE mseg-menge,
line_color(4) TYPE c,
END OF itab1.
DATA : t_fcat TYPE slis_t_fieldcat_alv,
t_eve TYPE slis_t_event,
t_subtot TYPE slis_t_sortinfo_alv,
subtot LIKE LINE OF t_subtot,
wa_fcat LIKE LINE OF t_fcat,
gd_layout TYPE slis_layout_alv.
DATA : gt_menge LIKE mseg-menge,
st_menge LIKE mseg-menge.
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : doc FOR mseg-mblnr.
SELECTION-SCREEN : END OF BLOCK blk1.
INITIALIZATION.
PERFORM build_cat USING t_fcat.
PERFORM build_eve.
PERFORM build_layout.
START-OF-SELECTION.
PERFORM get_data.
PERFORM display.
*& Form build_cat
text
-->TEMP_FCAT text
FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MBLNR'.
wa_fcat-seltext_m = 'Material Doc.'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-seltext_m = 'Material'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-seltext_m = 'Plant'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MENGE'.
wa_fcat-seltext_m = 'Quantity'.
wa_fcat-do_sum = 'Y'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
subtot-spos = 1.
subtot-fieldname = 'MBLNR'.
subtot-tabname = 'ITAB'.
subtot-up = 'X'.
subtot-group = 'X'.
subtot-subtot = 'X'.
subtot-expa = 'X'.
APPEND subtot TO t_subtot.
ENDFORM. "build_cat
*& Form build_eve
text
FORM build_eve.
DATA : wa_eve TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = t_eve
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE t_eve WITH KEY name = slis_ev_top_of_page
INTO wa_eve.
IF sy-subrc = 0.
MOVE 'TOP_OF_PAGE' TO wa_eve-form.
APPEND wa_eve TO t_eve.
ENDIF.
ENDFORM. "build_eve
*& Form build_layout
text
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-info_fieldname = 'LINE_COLOR'.
gd_layout-subtotals_text = 'Sub Total'.
ENDFORM. " BUILD_LAYOUT
*& Form get_data
text
FORM get_data.
SELECT mblnr matnr werks menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab
WHERE mblnr IN doc.
SORT itab BY mblnr.
LOOP AT itab.
AT NEW mblnr.
LOOP AT itab WHERE mblnr = itab-mblnr.
st_menge = st_menge + itab-menge.
itab1-mblnr = itab-mblnr.
itab1-matnr = itab-matnr.
itab1-werks = itab-werks.
itab1-menge = itab-menge.
APPEND itab1.
ENDLOOP.
itab1-mblnr = 'Sub_Total'.
itab1-matnr = ''.
itab1-werks = ''.
itab1-menge = st_menge.
itab1-line_color = 'C710'.
APPEND itab1.
itab1-line_color = ''.
CLEAR st_menge.
ENDAT.
ENDLOOP.
LOOP AT itab.
gt_menge = gt_menge + itab-menge.
ENDLOOP.
itab1-mblnr = 'Total'.
itab1-matnr = ''.
itab1-werks = ''.
itab1-menge = gt_menge.
itab1-line_color = 'C310'.
APPEND itab1.
ENDFORM. "get_data
*& Form display
text
FORM display.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZALV_LIST'
is_layout = gd_layout
it_fieldcat = t_fcat
it_sort = t_subtot
it_events = t_eve
TABLES
t_outtab = itab1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "display
*& Form top_of_page
text
FORM top_of_page.
WRITE:/ 'Data'.
ENDFORM. "top_of_page
reward if useful....
Edited by: Dhwani shah on Dec 20, 2007 1:20 PM
Maybe you are looking for
-
ITunes 10 (Mac) no longer sees my iPhone 4
iTunes no longer thought it was installed on my computer. I installed it, I re-associated my music, and then I tried to sync my phone, but because I manage music manually, I was getting an error message. I called Applecare to see what the error mess
-
Custom work centers are not visible in the production tenant UI after solution is deployed
Hi Experts, We have deployed the solution into the production tenant. The solution is deployed successfully. But the custom business option(BAC) element which we have created is not part of proejct scoping. We have created a new change project in pro
-
Problem with the program Wine.
Well, I'm trying to install this program called Wine, a program that allows you to run Windows programs on a Mac legally, and currently I followed these steps: 1. Download Mac Ports and install it. 2. Enter: echo export PATH=\$PATH:/opt/local/bin:/op
-
Performance Management Appraisal Reporting
Hi Experts, I have a business requirement to report on Final Performance Ratings via Org. Units. Standard SAP Reporting for Performance Management appears to be very limited with phap_search_pa... I want to be able to report on Org. Units and their
-
Do I gee a copy of submitted forms with the free account?
Do I gee a copy of submitted forms with the free account?