Total at end of alv grid
hiiiiiiiiiiii
i write one alv grid program
i wnat total at last of output for the field *DMBTR*
plz see the code and give me solution
type-pools: slis.
tables: BSID, KNA1.
data : begin of it_BSID occurs 0,
BUKRS TYPE BSID-BUKRS, "COMPANY CODE
KUNNR TYPE BSID-KUNNR, "Customer no
NAME1 TYPE KNA1-NAME1, "Customer name
XBLNR TYPE BSID-XBLNR, "REFERANCE
BLART TYPE BSID-BLART, "Document Type
BUDAT TYPE BSID-BUDAT, "Posting Date in the Document
SHKZG TYPE BSID-SHKZG, "Debit/Credit Indicator
BELNR TYPE BSID-BELNR, "Accounting Doc no
DMBTR TYPE BSID-DMBTR, "Amount in Local Currency
SGTXT TYPE BSID-SGTXT, "Item text
end of it_BSID.
data : begin of itab occurs 0,
BUKRS TYPE BSID-BUKRS, "COMPANY CODE
KUNNR TYPE BSID-KUNNR, "Customer no
NAME1 TYPE KNA1-NAME1, "Customer name
XBLNR TYPE BSID-XBLNR, "REFERANCE
BLART TYPE BSID-BLART, "Document Type
BUDAT TYPE BSID-BUDAT, "Posting Date in the Document
SHKZG TYPE BSID-SHKZG, "Debit/Credit Indicator
BELNR TYPE BSID-BELNR, "Accounting Doc no
DMBTR TYPE BSID-DMBTR, "Amount in Local Currency
SGTXT TYPE BSID-SGTXT, "Item text
end of itab.
*********ALV Declaration************************************************
data: it_fieldcatalog type slis_t_fieldcat_alv with header line,
wa_fieldcatalog like line of it_fieldcatalog,
wa_layout type slis_layout_alv,
it_rec type table of itab,
it_rec1 type table of itab,
wa_rec like line of itab,
wa_itab like line of itab.
data : it_sort type slis_t_sortinfo_alv,
wa_sort type slis_sortinfo_alv.
*********ALV Declaration************************************************
selection-screen : begin of block b with frame title text-100.
select-options:
COMPANY for BSID-BUKRS ,
CUSTOMER for BSID-KUNNR,
DATE FOR BSID-BUDAT.
selection-screen end of block b .
start-of-selection.
select BUKRS KUNNR XBLNR BLART BUDAT
SHKZG BELNR DMBTR SGTXT
from BSID into corresponding fields of table it_BSID
where
BUKRS IN COMPANY AND
KUNNR IN CUSTOMER AND
BUDAT IN DATE .
sort it_BSID by BUDAT KUNNR.
end-of-selection.
loop at it_BSID.
IF it_BSID-SHKZG EQ 'H'.
MULTIPLY it_BSID-DMBTR BY -1.
ENDIF.
move: IT_BSID-BUKRS TO ITAB-BUKRS, "COMPANY CODE
IT_BSID-KUNNR TO ITAB-KUNNR, "Customer no
IT_BSID-XBLNR TO ITAB-XBLNR, "REFERANCE
IT_BSID-BLART TO ITAB-BLART, "Document Type
IT_BSID-BUDAT TO ITAB-BUDAT, "Posting Date in the Document
IT_BSID-SHKZG TO ITAB-SHKZG, "Debit/Credit Indicator
IT_BSID-BELNR TO ITAB-BELNR, "Accounting Doc no
IT_BSID-DMBTR TO ITAB-DMBTR, "Amount in Local Currency
IT_BSID-SGTXT TO ITAB-SGTXT. "Item text
select single NAME1 from KNA1 into (itab-NAME1) where KUNNR = itab-KUNNR.
APPEND ITAB.
endloop.
loop at itab .
at end of itab-dmbtr.
sum.
endat.
endloop.
if not itab[] is initial.
perform populate_field_catalog.
perform fill_layout.
perform display_alv.
else.
write: ' NO DATA'.
endif.
*& Form populate_field_catalog
* text
form populate_field_catalog .
wa_fieldcatalog-fieldname = 'BUKRS'.
wa_fieldcatalog-seltext_m = 'COMPANY'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'KUNNR'.
wa_fieldcatalog-seltext_m = 'CUSTOMER CODE.'.
wa_fieldcatalog-no_zero = 'X'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'NAME1'.
wa_fieldcatalog-seltext_m = 'NAME'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BLART'.
wa_fieldcatalog-seltext_m = 'DOC. TYPE '.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BUDAT'.
wa_fieldcatalog-seltext_m = 'POSTING DATE'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BELNR'.
wa_fieldcatalog-seltext_m = 'DOCUMENT NO.'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'DMBTR'.
wa_fieldcatalog-seltext_m = 'AMOUNT'.
wa_fieldcatalog-DO_SUM = 'X'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'SGTXT'.
wa_fieldcatalog-seltext_m = 'TEXT'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'XBLNR'.
wa_fieldcatalog-seltext_m = 'REFERANCE'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
endform. " populate_field_catalog
*& Form fill_layout
* text
* --> p1 text
* <-- p2 text
form fill_layout .
wa_layout-no_input = 'X'.
wa_layout-colwidth_optimize = 'X'.
wa_layout-zebra = 'X'.
endform. " fill_layout
*& Form display_alv
* text
* --> p1 text
* <-- p2 text
form display_alv .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
is_layout = wa_layout
it_fieldcat = it_fieldcatalog[]
i_default = 'X'
i_save = 'A'
tables
t_outtab = 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. " display_alv
Edited by: pranay panchbhai on Mar 15, 2010 3:18 PM
Hi
Give this code for field DMBTR in fielcatalog.
wa_fieldcatalog-FIELDNAME = 'DMBTR'.
wa_fieldcatalog-INTTYPE = 'C'.
wa_fieldcatalogT-DO_SUM = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
It will work definitely.
If you still have doubts then revert back.
Thanks & Regards
Khushboo
Similar Messages
-
Displaying Total Text in an ALV Grid
Hi Experts,
Please suggest me how to display the Total text in the alv grid using CL_SALV_FACTORY method.
Example Output:
Field1 Field2 Field3
a b 100
b c 100
Total 200
Regards,
Sunil KumarHi Avinash,
It will not work since am using cl_salv_factory method. whatever links you have sent are using reuse_alv_grid_display or set_first_table_display.
Regards,
Sunil Kumar -
'TOTAL' text display in ALV GRID output
Hi,
My requirement is to display 'TOTAL' text at the end of the ALV report alongwith Totals for the respective columns.
I've used Classical method(i.e. used ALV GRID FM) to display the report.
For Totals I've used 'DO_SUM', option and for text populated 'TOTALS_TEXT' field, but still its not showing the desired text.
I've tried most of the solutions provided on SDN, and they are not working.
So, plssss help me to find out correct solution.
Thanks in Advance!!!!!!
Thanks & regards,
Amithi,
i hope this code will exactli fulfil ur requirement.
type-poolS: slis.
TYPES: BEGIN OF S_TAB,
F1 TYPE CHAR5,
F2 TYPE I,
F3 TYPE I,
END OF S_TAB.
TYPES: BEGIN OF sf_TAB,
f0 type char10,
F1 TYPE CHAR5,
F2 TYPE I,
F3 TYPE I,
END OF Sf_TAB.
DATA: IT_TAB TYPE TABLE OF S_TAB,
WA_TAB TYPE S_TAB,
IT_FIN TYPE TABLE OF Sf_TAB,
WA_FIN TYPE Sf_TAB.
data: fcat type slis_t_fieldcat_alv,
wa_fcat type slis_fieldcat_alv,
layout type slis_layout_alv,
it_sort type SLIS_T_SORTINFO_ALV,
wa_sort type SLIS_SORTINFO_ALV.
FREE IT_TAB. CLEAR WA_TAB.
WA_TAB-F1 = 'A1'.
WA_TAB-F2 = '10'.
WA_TAB-F3 = '20'.
APPEND WA_TAB TO IT_TAB.
CLEAR WA_TAB.
WA_TAB-F1 = 'A1'.
WA_TAB-F2 = '10'.
WA_TAB-F3 = '20'.
APPEND WA_TAB TO IT_TAB.
CLEAR WA_TAB.
WA_TAB-F1 = 'A2'.
WA_TAB-F2 = '15'.
WA_TAB-F3 = '30'.
APPEND WA_TAB TO IT_TAB.
CLEAR WA_TAB.
WA_TAB-F1 = 'A3'.
WA_TAB-F2 = '15'.
WA_TAB-F3 = '40'.
APPEND WA_TAB TO IT_TAB.
CLEAR WA_TAB.
WA_TAB-F1 = 'A3'.
WA_TAB-F2 = '20'.
WA_TAB-F3 = '60'.
APPEND WA_TAB TO IT_TAB.
CLEAR WA_TAB.
LOOP AT IT_TAB INTO WA_TAB.
wa_fin-f0 = 'Total'.
wa_fin-f1 = wa_tab-f1.
wa_fin-f2 = wa_tab-f2.
wa_fin-f3 = wa_tab-f3.
append wa_fin to it_fin.
clear wa_fin.
ENDLOOP.
Define Imacro.
wa_fcat-fieldname = &1.
wa_fcat-tabname = &2.
wa_fcat-reptext_ddic = &3.
wa_fcat-col_pos = &4.
WA_FCAT-DO_SUM = &5.
WA_FCAT-NO_OUT = &6.
append wa_fcat to fcat .
clear wa_fcat.
end-of-definition.
imacro 'F0' 'it_fin' '' '1' '' 'X'.
imacro 'F1' 'it_fin' 'PO Document' '2' '' ''.
imacro 'F2' 'it_fin' 'TOTAL' '3' 'X' ''.
imacro 'F3' 'it_fin' 'Space' '4' '' ''.
****************DEFINE LAYOUT
layout-zebra = 'X'.
layout-colwidth_optimize = 'X'.
layout-no_totAlLine = 'X'.
WA_SORT-SPOS = 1.
WA_SORT-fieldname = 'F0'.
wa_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_GRID_TITLE = 'SALES ORDER DETAILS'
IS_LAYOUT = layout
IT_FIELDCAT = fcat
IT_SORT = IT_SORT
TABLES
T_OUTTAB = IT_FIN
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Cheers,
Rudhir -
Color the sub-total row in an alv-grid
Hi all.
I work on SAP 4.7 WAS6.20 and output a table with the cl_gui_alv_grid. I´m able to color special rows (or columns) in the alv grid. But I want to color individually the sub-total lines (like the lines before) and don´t want the yellow color for all of the sub-total lines.
Do you know how to color the sub-total-lines?
Thanks a lot.
MichaelHi,
U can color an individula row see the link below
Color a line
The steps for coloring a line i the grid is much the same as making a traffic light.
* To color a line the structure of the table must include a Char 4 field for color properties
TYPES: BEGIN OF st_sflight.
INCLUDE STRUCTURE zsflight.
* Field for line color
types: line_color(4) type c.
TYPES: END OF st_sflight.
TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
DATA: gi_sflight TYPE tt_sflight.
* Loop trough the table to set the color properties of each line. The color properties field is
* Char 4 and the characters is set as follows:
* Char 1 = C = This is a color property
* Char 2 = 6 = Color code (1 - 7)
* Char 3 = Intensified on/of = 1 = on
* Char 4 = Inverse display = 0 = of
LOOP AT gi_sflight INTO g_wa_sflight.
IF g_wa_sflight-paymentsum < 100000.
g_wa_sflight-line_color = 'C610'.
ENDIF.
MODIFY gi_sflight FROM g_wa_sflight.
ENDLOOP.
* Name of the color field
gs_layout-info_fname = 'LINE_COLOR'.
* Grid setup for first display
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING it_outtab = gi_sflight
see the link
http://www.sapgenie.com/abap/controls/alvgrid.htm -
Total problem in Exporting ALV GRID to Excel
Hi all,
I have manipulated the Total of ALV Grid by using GET_SUBTOTALS and REFRESH method of CL_GUI_ALV_GRID. The ALV Output is also correct. When i export to Excel,only the Original total is displaying not the calculated one. How to download the exact output which is displaying in the ALV Grid to Excel.
Please help me out to solve this.
Thanks,
RameshDEAR,
AS U WANT UPLOAD WITH THE SUB TOTAL YOU TRY THIS.
FIRST to get subtotal in ALV output you select at least one column of total and then press ctrl + F6 . u will see the sub total .
and now how to download it so press ctrl + shift + F9 .
now screen appears and select second option ie spreadsheet and press enter
now a screen appear in wich u have to give file name.
so double click on search button of file name . click on desktop give ur file name as u want suppose zreport u have given.
and save type = excel file.
now save it and then generate it your output bytes will be transmitted .
now u can see in your desktop in your file name . ur output with subtotal.
regards
navin -
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... -
Position button at the end of ALV grid
Hi,
I have a requirement to place position button (like in OB52 or any table/view maintenance ) to search and position the record on the top of list. I have placed the position pushbutton with function code and have called TABLE_GET_KEY_TO_SET_CUR_ROW for the input . My alv grid doesn't show the toolbar till the records cross one page. can you please suggest 1- how to make the scrollbar visible always ? 2- How to make the position button work as in tables for ALV grid?
Regards,
GarimaI have created the pushbutton in the same screen as container and assigned a function code. I have put this logic in user-command for this button and refreshed display. But it doesn't work, moreover the scrollbar is not visible if the records are less than one page.
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN '&BACK&'.
LEAVE TO SCREEN 0.
WHEN '&EXIT&'.
LEAVE PROGRAM.
WHEN '&POSI&'.
DATA: LV_EBELN(15) TYPE C,
IT_EXCL TYPE VIMEXCLFLD OCCURS 0,
WA_EXCL TYPE VIMEXCLFLD,
LV_PO TYPE EKKO-EBELN.
DATA: LT_CELL1 TYPE TABLE OF LVC_S_ROID,
LS_ROW_ID TYPE LVC_S_ROID,
LS_COL_ID TYPE LVC_S_COL.
DATA: LWA_CELL1 LIKE LINE OF LT_CELL1.
WA_EXCL-FIELDNAME = 'MANDT'.
APPEND WA_EXCL TO IT_EXCL.
CALL FUNCTION 'TABLE_GET_KEY_TO_SET_CUR_ROW'
EXPORTING
TABLE = 'EKKO'
IMPORTING
TABLE_KEY = LV_EBELN
TABLES
EXCLUDE_FIELDS = IT_EXCL
EXCEPTIONS
CANCELLED_BY_USER = 1
TABLE_NOT_FOUND = 2
OTHERS = 3.
IF SY-SUBRC EQ 0.
SHIFT LV_EBELN LEFT DELETING LEADING SPACE.
MOVE LV_EBELN+0(10) TO LV_PO.
READ TABLE GT_FINAL INTO WA_FINAL WITH KEY EBELN = LV_PO.
CALL METHOD R_GRID->GET_SCROLL_INFO_VIA_ID
iMPORTING
ES_ROW_NO = LS_ROW_ID
ES_COL_INFO = LS_COL_ID.
LS_ROW_ID-ROW_ID = sy-tabix.
LS_COL_ID-FIELDNAME = 'EKGRP'.
data: ls_row type LVC_S_ROW,
ls_col type LVC_S_COL.
ls_row-index = 2.
CALL METHOD r_grid->set_scroll_info_via_id
EXPORTING
IS_ROW_INFO = ls_row
is_col_info = ls_col.
ENDIF.
**Row and column of the alv are refreshed after changing values
STABLE-ROW = 'X'.
STABLE-COL = 'X'.
*REfreshed ALV display with the changed values
*This ALV is non editable and contains new values
CALL METHOD R_GRID->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = STABLE
EXCEPTIONS
FINISHED = 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.
Please help!! -
Totalling the columns in ALV Grid
Hello All,
I have a output with amount and currencies. The problem i am facing is, the amount is in USD and in GBP and it is giving me single value. It is not splitting the USD amount from the GBP amount.
Also, I am doing a subtotal based on material. This is the most important requirement.
Can anybody help me out in this.
Thanks,
Salil
I am giving the below piece of code if you want to refer it.
DATA: gr_alv TYPE REF TO cl_salv_table,
lr_display TYPE REF TO cl_salv_display_settings,
lr_columns TYPE REF TO cl_salv_columns_table,
lr_column TYPE REF TO cl_salv_column_table,
lr_functions TYPE REF TO cl_salv_functions_list,
lr_sorts TYPE REF TO cl_salv_sorts,
lr_print TYPE REF TO cl_salv_print,
lr_column_f TYPE REF TO cl_salv_columns,
gr_error TYPE REF TO cx_salv_not_found ,
lr_layout TYPE REF TO cl_salv_layout.
DATA: key TYPE salv_s_layout_key,
gr_msg TYPE string.
IF NOT lt_output[] IS INITIAL.
TRY.
* Create ALV instance - use CALL METHOD since this is a static method
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = lt_output.
lr_display = gr_alv->get_display_settings( ).
lr_display->set_list_header( text-ttl ).
* Get functions object and then set all the functions to be allowed
lr_functions = gr_alv->get_functions( ).
lr_functions->set_all( ).
DATA: lv_field TYPE lvc_fname.
* Get column settings object and then optimize the column widths to the
* data
lr_columns = gr_alv->get_columns( ).
lr_columns->set_optimize( ).
*--- set column header for custom field Difference in Qty
TRY.
lr_column ?= lr_columns->get_column( 'BUCHM2' ).
lr_column->set_output_length('12').
lr_column->set_long_text( 'Diff Qty' ).
lr_column->set_short_text( 'Diff Qty' ).
lr_column->set_medium_text( 'Diff Qty' ).
CATCH cx_salv_not_found INTO gr_error.
gr_msg = gr_error->get_text( ).
MESSAGE gr_msg TYPE 'I'.
ENDTRY.
*--- set column header for custom field Difference in Qty Abs
TRY.
lr_column ?= lr_columns->get_column( 'BUCHM3' ).
lr_column->set_output_length('13').
lr_column->set_long_text( 'Diff Qty(Abs)' ).
lr_column->set_medium_text( 'Diff Qty(Abs)' ).
* lr_column->set_short_text( 'Diff Qty(Abs)' ).
CATCH cx_salv_not_found INTO gr_error.
gr_msg = gr_error->get_text( ).
MESSAGE gr_msg TYPE 'I'.
ENDTRY.
*--- set column header for custom field Difference in Value
TRY.
lr_column ?= lr_columns->get_column( 'VALUE' ).
lr_column->set_output_length('15').
lr_column->set_long_text( 'Value Diff' ).
lr_column->set_medium_text( 'Value Diff' ).
lr_column->set_short_text( 'Value Diff' ).
CATCH cx_salv_not_found INTO gr_error.
gr_msg = gr_error->get_text( ).
MESSAGE gr_msg TYPE 'I'.
ENDTRY.
*--- set column header for custom field Difference in Value Abs
TRY.
lr_column ?= lr_columns->get_column( 'VALUE_ABS' ).
lr_column->set_output_length('15').
lr_column->set_long_text( 'Value Diff(Abs)' ).
lr_column->set_medium_text( 'Value Diff(Abs)' ).
CATCH cx_salv_not_found INTO gr_error.
gr_msg = gr_error->get_text( ).
MESSAGE gr_msg TYPE 'I'.
ENDTRY.
*--- set column header for custom field Status
TRY.
lr_column ?= lr_columns->get_column( 'STATUS' ).
lr_column->set_output_length('15').
lr_column->set_long_text( 'PI Item Status' ).
lr_column->set_medium_text( 'PI Item Status' ).
CATCH cx_salv_not_found INTO gr_error.
gr_msg = gr_error->get_text( ).
MESSAGE gr_msg TYPE 'I'.
ENDTRY.
*--- set column header for custom field Status
TRY.
lr_column ?= lr_columns->get_column( 'TOTAL' ).
lr_column->set_output_length('15').
lr_column->set_long_text( 'Total Value Diff' ).
lr_column->set_medium_text( 'Total Value Diff' ).
CATCH cx_salv_not_found INTO gr_error.
gr_msg = gr_error->get_text( ).
MESSAGE gr_msg TYPE 'I'.
ENDTRY.
* Optimize the column widths for printing.
lr_print = gr_alv->get_print( ).
lr_print->set_print_parameters_enabled( value = 'X' ).
lr_print->set_column_optimization( value = 'X' ).
*--- This code is to get the layout,save the layout and display the
* layout
lr_layout = gr_alv->get_layout( ).
lr_layout->set_default( cl_salv_layout=>true ). " allow default
key-report = sy-repid.
lr_layout->set_key( key ).
lr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
DATA: init_layout TYPE slis_vari.
init_layout = p_layout.
lr_layout->set_initial_layout( init_layout ).
*--- display report
gr_alv->display( ).
CATCH cx_salv_msg.
WRITE: 'Error displaying grid! - cx_salv_msg'.
CATCH cx_salv_not_found.
WRITE: 'Error displaying grid! - cx_salv_not_found'.
CATCH cx_salv_data_error.
WRITE: 'Error displaying grid! - cx_salv_data_error'.
CATCH cx_salv_existing.
WRITE: 'Error displaying grid! - cx_salv_existing'.
ENDTRY.
ELSE.
MESSAGE s004.
ENDIF.Can you use something like function module CONVERT_CURRENCY_BY_RATE to convert one set of currencies so all amounts are in the same currency before you display them in the ALV?
- April King -
Data from Front end to Back end of ALV Grid
Hi Experts,
I developed interactive ALV for maintaining master data for some BW Objects. I also included custom F4 for all fields.
Problem:
When entered new record or modified a record by using F4 help of fields, it doesn't work properly. For collecting front end data i wrote below specified code.
for new record insert.
METHOD handle_data_changed.
DATA: mod_cell TYPE lvc_s_modi,
del_row TYPE lvc_s_moce,
del_index TYPE i,
new_index TYPE sy-tabix.
DATA: l_assum TYPE /bic/pzassum-/bic/zassum,
l_assum_modl TYPE /bic/pzassum-/bic/zass_mdl,
l_assum_typ TYPE /bic/pzassum-/bic/zass_typ,
l_drv_assum TYPE /bic/pzassum-/bic/zdriver,
l_infl_assum TYPE /bic/pzassum-/bic/zinflate,
l_sht_text TYPE /bic/tzassum-txtsh,
l_mdm_text TYPE /bic/tzassum-txtmd.
CLEAR error_record.
IF e_onf4 IS INITIAL.
******Get Inserted Data from Frontend
CALL FUNCTION 'MESSAGES_INITIALIZE'.
IF er_data_changed->mt_inserted_rows IS NOT INITIAL.
IF er_data_changed->mt_mod_cells IS NOT INITIAL.
REFRESH : gt_inserted_data,gt_inserted_text.
LOOP AT er_data_changed->mt_mod_cells INTO mod_cell.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZASSUM'
IMPORTING
e_value = l_assum.
wa_changed_data-/bic/zassum = l_assum.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZASS_MDL'
IMPORTING
e_value = l_assum_modl.
wa_changed_data-/bic/zass_mdl = l_assum_modl.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZASS_TYP'
IMPORTING
e_value = l_assum_typ.
wa_changed_data-/bic/zass_typ = l_assum_typ.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZDRIVER'
IMPORTING
e_value = l_drv_assum.
IF sy-subrc = 0.
wa_changed_data-/bic/zdriver = l_drv_assum.
ENDIF.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZINFLATE'
IMPORTING
e_value = l_infl_assum.
IF sy-subrc = 0.
wa_changed_data-/bic/zinflate = l_infl_assum.
ENDIF.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = 'TXTSH'
IMPORTING
e_value = l_sht_text.
IF sy-subrc = 0.
wa_changed_text-txtsh = l_sht_text.
ENDIF.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = 'TXTMD'
IMPORTING
e_value = l_mdm_text.
wa_changed_text-txtmd = l_mdm_text.
APPEND wa_changed_data TO gt_inserted_data.
wa_changed_text-/bic/zassum = wa_changed_data-/bic/zassum.
APPEND wa_changed_text TO gt_inserted_text.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM gt_inserted_data.
DELETE ADJACENT DUPLICATES FROM gt_inserted_text.
ENDIF.
For Modified Record
IF er_data_changed->mt_mod_cells IS NOT INITIAL AND
er_data_changed->mt_inserted_rows IS INITIAL.
REFRESH : gt_modified_text,gt_modified_data.
REFRESH : gt_valid_text,gt_modified_text.
LOOP AT er_data_changed->mt_mod_cells INTO mod_cell.
row_index = mod_cell-row_id.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZASSUM'
IMPORTING
e_value = l_assum.
wa_changed_data-/bic/zassum = l_assum.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZASS_MDL'
IMPORTING
e_value = l_assum_modl.
wa_changed_data-/bic/zass_mdl = l_assum_modl.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZASS_TYP'
IMPORTING
e_value = l_assum_typ.
wa_changed_data-/bic/zass_typ = l_assum_typ.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZDRIVER'
IMPORTING
e_value = l_drv_assum.
IF sy-subrc = 0.
wa_changed_data-/bic/zdriver = l_drv_assum.
ENDIF.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = '/BIC/ZINFLATE'
IMPORTING
e_value = l_infl_assum.
IF sy-subrc = 0.
wa_changed_data-/bic/zinflate = l_infl_assum.
ENDIF.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = 'TXTSH'
IMPORTING
e_value = l_sht_text.
IF sy-subrc = 0.
wa_changed_text-txtsh = l_sht_text.
ENDIF.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = mod_cell-row_id
i_fieldname = 'TXTMD'
IMPORTING
e_value = l_mdm_text.
wa_changed_text-txtmd = l_mdm_text..
APPEND wa_changed_data TO gt_modified_data.
wa_changed_text-/bic/zassum = wa_changed_data-/bic/zassum.
APPEND wa_changed_text TO gt_modified_text.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM gt_modified_data.
DELETE ADJACENT DUPLICATES FROM gt_modified_text.
ENDIF.
Custom F4 is working properly.
Below i am specifing one test case which is my program failed.
i entered 2 new records by choosing F4 help. The 2nd record only inserted in data base.
Please help me....
Thanks in AdvanceHello Siva
Some people like to do extensive coding in the event handler method for DATA_CHANGED.
I do NOT belong to these people.
My recommendation is (almost) always the same:
- If required store values in (static) attributes of your event handler class / instance
- Trigger PAI (using method CL_GUI_CFW=>SET_NEW_OK_CODE)
At PAI of your screen you can now easily work with your OUTTAB itab used for the ALV list.
Regards
Uwe -
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 -
Total and non-total lines in ALV grid
Hi all,
Does anyone know if there is any standard SAP functionality for retrieving the non-total/raw item lines that lies beneath a total line in an ALV grid (after the user has selected the total line)?
All helpful answers will be rewarded!
Best regards,
MVTry the ALV event AFTER-LINE-OUTPUT may be it can help u to achieve ur requirement.
Append AFTER-LINE-OUTPUT event to the internal table T_EVENT.
CLEAR W_EVENT.
W_EVENT-FORM = SLIS_EV_AFTER_LINE_OUTPUT.
W_EVENT-NAME = SLIS_EV_AFTER_LINE_OUTPUT.u201CAFTER_LINE_OUTPUT event
APPEND W_EVENT TO T_EVENT.
FORM AFTER_LINE_OUTPUT
USING P_RS_LINEINFO TYPE SLIS_LINEINFO.
Here you have to write the logic to retrieve the 'total' line
ENDFROM.
Now call the alv FM
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = L_REPID "Program Name
IS_LAYOUT = W_LAYOUT "Layout of the Report
IT_FIELDCAT = T_FIELDCAT "Field Catalog for Report
IT_EVENTS = T_EVENT "For setting the events
TABLES
T_OUTTAB = T_OUTPUT "Report data Internal Table
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2. -
Hi,
Can I use a total line in an ALV grid and hide part of the columns, so that only the total line will be presented for some of the columns ?Hi,
Yes u can use a total column in the ALV Grid.
Check the code below:
AT LAST.
WA_ALV_CAT1-FIELDNAME = 'TOTAL'(004).
WA_ALV_CAT1-COL_POS = L_I.
WA_ALV_CAT1-COLTEXT = 'TOTAL'(004).
WA_ALV_CAT1-JUST = C_CENTER. " 'C'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR WA_ALV_CAT1.
ENDAT.
Regards
Kannaiah -
Totals text and currency sign in alv grid
Hi!
How to display totals text and currency sign in the totals part of the alv grid??
Ex.
5 6
4 9
5 2
Totals: $14 $17Hi,
For Currency :
https://forums.sdn.sap.com/click.jspa?searchID=11871008&messageID=3564279
https://forums.sdn.sap.com/click.jspa?searchID=11871008&messageID=1019294
For Total_text
Maybe you will find something in examples SALV_OBJECTS.
it's a package in the systems above 6.4 with new ALV. There are nice examples. Main package is SALV.
https://forums.sdn.sap.com/click.jspa?searchID=11871273&messageID=3935361
Regards,
Shiva Kumar -
Automatically update totals in an ALV-grid
Hi there,
Is there a possibility to automatically update a totals-field in an ALV-grid?
At the moment the totals-field is only updated when the ALV-grid is refreshed (PBO). I want an immediate update when the user enters a value in the ALV.
Who can help me?
AngeloHi,
Subramanian has taken his time and effort to help you. if you wish to reward his effort SDN has got a way for that. Since you are new to SDN may i introduce you to the points system at SDN.
You assign points to the replies that you have found to be useful. It's a way to say "thanks" for the effort in the replies.
See: /people/mark.finnern/blog/2004/08/10/spread-the-love for directions.
Click on the Yellow Star icon in each reply.
You can give:
1 - 10 pointer (marks it as a solved problem)
2 - 6 pointers (very helpful)
Lots of 2 pointers (helpful)
Raja -
Identify selection of sub-total line in ALV grid
Hi folks,
Is there a way to identify in the report if the user has selected any sub-total line in an ALV grid? Both for REUSE_ALV_GRID_DISPLAY and CL_GUI_ALV_GRID.
Thanks
SagarSagar,
1. I don't think its good design, if you want to process those three lines, you should ask the user to select those 3 rows and process them.
2. If you have no choice, tyr these methods, these might give you some info
GET_SORT_CRITERIA
GET_SUBTOTALS
These methods might give you the info you are looking for. Try it out.
regards,
Ravi
Maybe you are looking for
-
Installing on more than 1 computer
I have Lightroom 3.6 installed on my home PC and my laptop which I use when travelling. I am about to take delivery of a new home Pc on which I want to install Lightroom. Question: Do I need to uninstall from my old PC first before installing on the
-
I need a french person for my problem please
Alors voila j'ai fait la dernière mise a jour et l'écran de mon iPhone 4 reste bloquer, la jauge d'installation reste a moitié remplie, elle ne veut pas se remplir, aidez moi s'il vous plait.
-
Formatted search as such G/L Account name to be shown
Dear All, I have added in Udf in the row level of marketing document like U_Sales A/C Name, U_Cogs A/C Name, U_Inventory Account Name. Stock is maintained Warehouse Wise. Now I want that in the row level for any item e.g warehouse 001 I want a format
-
Iphoto does not use the proper display profile
Hello. I just bought a 20' Apple Cinema display and connected it to my Macbook. I have noticed a very strange behavior of iPhoto and Preview. I will first describe the expected (right behaviour). When I drag an image opened in Adobe LG or Aperture fr
-
Dynamic Title for Interactive Report?
I have an interactive report where I am passing in interative report filters. This is great becase it allows me to reuse a single interactive report in different ways. However, one drawback I am running into is the report title. I'd really like to be