Calculating Totals for a column in ALV Grid Display
Hi All,
I frustrated with the problem of simple calculating total for a column. I wrote the following code:
LW_CATALOG-TABNAME = P_GV_STRUCT.
LW_CATALOG-FIELDNAME = 'ZSUMMS'.
LW_CATALOG-DO_SUM = GC_X.
APPEND LW_CATALOG TO G_FIELDCAT_TAB.
CLEAR LW_CATALOG.
It is not working. Could you please suggest the solution?
It would be great help to me.
Advanced Thanks,
Phani Kumar
Phani,
Did u try playing around with any of these layout fields ?
no_sumchoice(1), " no choice for summing up
no_totalline(1), " no total line
no_subchoice(1), " no choice for subtotals
no_subtotals(1), " no subtotals possible
no_unit_splitting " no sep. tot.lines by inh.units
totals_before_items, " diplay totals before the items
totals_only(1), " show only totals
totals_text(60) , " text for 1st col. in total line
subtotals_text(60) , " text for 1st col. in subtotals
b. Addtionally... not a solution.. but u know...
just try the same code iwth reuse_alv_list_display and see if the total gets displayed properly ?
Similar Messages
-
Want to display more than 300 charcters in a column using ALV grid display
Hi Guru's,
I am trying to display more than 500 charcters in a column using alv grid display but it in the output it is showing only 128 characters. Can you help me to display all the characters in particular column Or is there any limitation in maximum of no of charcters for a column?
Thanks,
Radha.Hi Paurl,
Define a work area say
wa_layout type slis_layout_alv.
then fill this work area as
wa_layout-zebra = X
wa_layout-colwidth_optimize = X.
wa_layout-max_linesize = 300.
Then in FM 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = wa_layout
etc.
you provided this for the field which is displayed in alv grid will have more than 128 characters.
from this code i want,how it refers to particular field.
when i mentioned field catalog-OUTPUTLEN = '300'.
it is not displayed the field morethan 128 characters.
it only displays 128 characters.
please provide me clear and breif information with suitable code.
i am trying what your sending but it is not displayed more than 128 characters.
if you don't mind please spend for me some time for this and
give me clear and breif information with suitable code.
Thanks & Regards,
Radhakrishna. -
How to change a color for a row in ALV grid display
Hi,
how to change a color for a row in ALV grid display based on a condition.Any sample code plzHello Ramya,
Did you check in [SCN|How to color a row of alv grid]
Thanks! -
Maximum number of character we can print in a column uing ALV grid display
Hi frnds,
My requirment is to print 500 charcter data in a column using ALV grid display.
Could any body tell me is it possible and the maximum character it can i print in a column using ALV grid dispaly.
Regards,
SandipanHi Sandipan,
refer notes 857823, 910300 and 959775. All these say there is a limitation of 128 characters.
857823 - ALV grid: Strings with a maximum of 128 characters
Symptom
Entries in cells of the type CHAR or string are truncated after 128
characters in the SAP GUI.
also refer,
ALV Grid Control (cl_gui_alv_grid), function module (Full-screen) Grid
(Reuse_alv_grid_display, SAPLSLVC_FULLSCREEN), SAPGUI, back end, front end
Cause and Prerequisites
The data table that is sent to the front end only allows character values
with the length 128.
Solution
This is the standard system behavior and cannot be changed. -
How to insert the checkbox as a separate column in alv grid display
Hi
How to insert the checkboxes as a separate column in alv grid display with using the reuse_alv_fieldcatlog_mege.
example
matnr maktx ersda checkbox
10 books 28/03/2009 checkbox
Thanks
chinnuHi,
Check the following code.
TYPE-POOLS: slis.
TYPES:
BEGIN OF ty_output,
chk TYPE c,
number TYPE i,
name(20) TYPE c,
END OF ty_output.
DATA: gt_output TYPE STANDARD TABLE OF ty_output,
gs_output TYPE ty_output.
DATA: wa_layout TYPE slis_layout_alv.
DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
After you populate the data, build the field catlog like shown below.
wa_fieldcatalog TYPE slis_fieldcat_alv.
wa_fieldcatalog-fieldname = 'CHK'.
wa_fieldcatalog-outputlen = '3'.
wa_fieldcatalog-col_pos = '1'.
wa_fieldcatalog-seltext_m = 'CHK'.
wa_fieldcatalog-checkbox = 'X'.
wa_fieldcatalog-edit = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
wa_fieldcatalog-fieldname = 'NUMBER'.
wa_fieldcatalog-outputlen = '10'.
wa_fieldcatalog-col_pos = '2'.
wa_fieldcatalog-seltext_m = 'NUMBER'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'NAME'.
wa_fieldcatalog-outputlen = '10'.
wa_fieldcatalog-col_pos = '3'.
wa_fieldcatalog-seltext_m = 'NAME'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_layout-box_fieldname = 'CHK' .
wa_layout-box_tabname = 'GT_OUTPUT' .
Now call the FM
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'USER_COMMAND_GRID'
* I_CALLBACK_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 = it_fieldcatalog
* 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
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_output
* 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. -
Sub columns in alv grid display
hi everyone,
can anyone tell me the way in which we can include sub-column headings in alv grid display. i.e., for example as shown below.
column1 column2 column3
scol1 scol2 scol3 scol4 scol5 scol6........................
thanks in advance. Here we are generating the column headings by using fm field catalog merge.
regards,
rajsekhar.kcheck this thread, check the sample code in my post
Re: multiple headers in ALV. -
Folder for multiple details in ALV GRID DISPLAY
Hi All,
I am developing one ALV GRID DISPLAY report. Here I am displaying the material and production order details in the report. If we have the multiple production order details for one material , then in that case , we have to place one folder at the first material level, in that folder I need to show all the multiple production order details.
I am using FUNCTION MODULE to develope the report, not using any Objects to develope this.
Thanks in advance.
Ramesh.Here is a simple example of such an ALV.
report zrich_0001.
type-pools: slis.
data: begin of head occurs 0,
matnr type afpo-matnr,
maktx type makt-maktx,
EXPAND type c,
end of head.
data: begin of detail occurs 0,
aufnr type afpo-aufnr,
matnr type afpo-matnr,
werks type aufk-werks,
pwerk type afpo-pwerk,
psmng type afpo-psmng,
end of detail.
start-of-selection.
select * into corresponding fields of table detail
from afpo
inner join aufk
on afpo~aufnr = aufk~aufnr
inner join afko
on afpo~aufnr = afko~aufnr
up to 500 rows
where aufk~auart = 'PP01'.
if not detail[] is initial.
sort detail ascending by matnr.
select distinct * into corresponding fields of table head
from makt
for all entries in detail
where matnr = detail-matnr
and spras = sy-langu.
endif.
perform call_alv.
* FORM call_alv *
form call_alv.
data: gt_fieldcat type slis_t_fieldcat_alv,
gs_keyinfo type slis_keyinfo_alv,
gs_layout type slis_layout_alv.
data: ls_fieldcat type slis_fieldcat_alv.
clear gs_keyinfo.
gs_keyinfo-header01 = 'MATNR'.
gs_keyinfo-item01 = 'MATNR'.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-reptext_ddic = 'Material'.
ls_fieldcat-tabname = 'HEAD'.
ls_fieldcat-outputlen = 18.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MAKTX'.
ls_fieldcat-reptext_ddic = 'Description'.
ls_fieldcat-tabname = 'HEAD'.
ls_fieldcat-outputlen = 40.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'AUFNR'.
ls_fieldcat-reptext_ddic = 'Production Order'.
ls_fieldcat-tabname = 'DETAIL'.
ls_fieldcat-outputlen = 12.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-reptext_ddic = 'Production Plant'.
ls_fieldcat-tabname = 'DETAIL'.
ls_fieldcat-outputlen = 4.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'PWERK'.
ls_fieldcat-reptext_ddic = 'Planning Plant'.
ls_fieldcat-tabname = 'DETAIL'.
ls_fieldcat-outputlen = 4.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'PSMNG'.
ls_fieldcat-reptext_ddic = 'Quantity'.
ls_fieldcat-tabname = 'DETAIL'.
ls_fieldcat-outputlen = 20.
append ls_fieldcat to gt_fieldcat.
gs_layout-expand_fieldname = 'EXPAND'.
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
it_fieldcat = gt_fieldcat[]
is_layout = gs_layout
i_tabname_header = 'HEAD'
i_tabname_item = 'DETAIL'
is_keyinfo = gs_keyinfo
tables
t_outtab_header = head
t_outtab_item = detail.
endform.
Regard,s
RIch Heilman -
Max number of columns in Alv grid display.
Is there any limitation on number of fields that can be displayed using alv grid display.
Please tell how i can display 199 fields using ALV.
Thanks in advance.I am not sure of the maximum of columns possible.
If you see the col_pos field in the field catalog table it can have only 2 digits. so i would assume it would be only 99 columns, but not sure.
Would get you more information soon.
Thanks,
Balaji -
Add Total for a Column in Data Grid Screen Based on Query
Hi Guys , I have query based on table Payments in which I search By Start Date , End Date and tenant person [ from drop down List ].
How to display sum of Payments.[Amount] column in the query screen , which off-course varies for selected person.
OmarThe data grid doesn't support calculating aggregate functions on columns automatically, but you can write a little bit of code to show the total of the payments right beneath the data grid.
Add a screen member called PaymentsTotal that is the same type as the column that you want to sum.
Drag out the screen member to be underneath the data grid. You can change the sizing settings (e.g. Horizontal Alignment) so that it aligns with the data grid how you want it.
Select the Payments collection and select Payments_Changed from the Write Code drop down.
In the generated method, write the following code:
partial void Payments_Changed(NotifyCollectionChangedEventArgs e)
// Total is the name of the property in my Payment entity that I want to sum
this.PaymentsTotal = this.Payments.Sum(p => p.Total);
When you run the screen, the PaymentsTotal property will show the total of all of the payments that are shown in the data grid.
Justin Anderson, LightSwitch Development Team -
Display one or more rows for a particular column in alv grid display
Hi,
My requirement in the report is to display users for a particular workitem id.If a workitem is in the inbox of one or more users(approvers) i have to display all the user names in one field in alv grid output (output-approver id).There are other fields which display details of the workitem also.
Is there a way to populate multiple rows for a single column or creating one more internal table for users in the alv output table.
Please suggest.
regards,
Sravanthi ChilalALV only can show flat internal table data.
you should set a sort on the field which you want to show only once.
Then on the output of the ALV, the field with the same value will show only once. -
Grand total (of all columns) in ALV grid
Hi Experts,
I have developed one custom ALV report in GRID format. Now Report output is displaying like below.
COL1 | COL2 | COL3 | COL4 |
TYPE1 | 10 | 44 | 05 |
TYPE2 | 01 | 20 | 35 |
TYPE3 | 05 | 10 | 20 |
=============================
sum | 16 | 74 | 50 |
But I need Grand Total for COL2 and COL3 and COL4 (i.e 16 + 74 + 50 )
This grand total line should be at the end of the internal table -- 140 .
The report output should be like below.....
COL1 | COL2 | COL3 | COL4 |
TYPE1 | 10 | 44 | 05 |
TYPE2 | 01 | 20 | 35 |
TYPE3 | 05 | 10 | 20 |
=============================
sum | 16 | 74 | 50 | ====> this sum will displayed when user select sum button on the Grid toolbar.
=============================
Grand Total 140 |
Suppose when I press sum button on the COL2. it should not change grand total. I mean Grand total should be like footer always.
Please advise
Thanks in advance.
RaghuHi
For your requirment ,you have to fill the field catalog for each field for which
you have to create the the grand total and check the option DO_SUM.
If you neeed the sub total ,in the sort table you can check the option- fs_sort-subtot = 'X'.
Just try the belo code .
It will solve your problem.
REPORT ztest.
* INTERNAL TABLE DECLARATION.
DATA:
t_sflight TYPE TABLE OF sflight,
fs_sflight TYPE sflight.
*OBJECTS FOR CONTAINER AND GRID.
DATA:
r_container1 TYPE REF TO cl_gui_custom_container,
r_grid1 TYPE REF TO cl_gui_alv_grid.
*FIELD CATALOG
DATA:
t_fcat TYPE lvc_t_fcat,
fs_fcat TYPE lvc_s_fcat.
fs_fcat-fieldname = 'SEATSMAX'.
fs_fcat-do_sum = 'X'.
APPEND fs_fcat TO t_fcat.
CLEAR fs_fcat.
fs_fcat-fieldname = 'PRICE'.
fs_fcat-do_sum = 'X'.
APPEND fs_fcat TO t_fcat.
CLEAR fs_fcat.
* SORT TABLE
DATA:
t_sort TYPE lvc_t_sort,
fs_sort TYPE lvc_s_sort.
* LAYOUT TABLE
DATA:
fs_layo TYPE lvc_s_layo.
*FS_LAYO-SGL_CLK_HD = 'X'.
fs_layo-zebra = 'X'.
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
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN1'.
SET TITLEBAR 'TITLE1'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. "user_command_0100 INPUT
**& Module HANDLER OUTPUT
** text
MODULE header OUTPUT.
CREATE OBJECT r_container1
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT r_grid1
EXPORTING
i_parent = r_container1.
CALL METHOD r_grid1->set_table_for_first_display
EXPORTING
is_layout = fs_layo
i_structure_name = 'SFLIGHT'
CHANGING
it_fieldcatalog = t_fcat
it_outtab = t_sflight
it_sort = t_sort.
ENDMODULE. "Header OUTPUT
Regards
Hareesh. -
Headings for Synamic Columns in ALV Grid ?
Dear All,
I have a fieldsymbol which is of type table and has a dynamic content in it.
Eg. Say my Field Symbol when displayed in the Output has the following Output >
Object Table Name 2002 2003 2004 2002 2003 2004
" 2002,2003,2004 are the dynamic columns --> for the number of entries in that year.
' The 2nd time 2002,2003,2004 is --> for the Size of entries in that Year.
Since I can't show the User with the same heading for both
a. Number of Entries and
b. Size
I want a heading for both of these values like for the first 2002,2003,2004 set I want a heading saying Total number of Records
and for the next set of years 2002,2003,2004 Iwant a heading saying Total Size.
Is it possible ?
If so how ?
Hope I'm clear in explaining my scenario !
Thanks & regards,
Deepu.KCheck on this forum on ALV OO and fieldcatalog.
In the fieldcatalog you can define dynamically the columns to be displayed including their heading.
regards
Hans -
Split columns in ALV Grid Display.
Hi
Currently we are displaying the output as below :
currently :
Docid | Created | Posted |
| | |
Needed :
Docid | Created | Posted |
|X1 |X2 |X3 |X4 |
| | | | |
now some columns have to be splitted as above like Created is splitted into X1 and X2, Posted into X3 and X4 .I am using Set_table for_first_display method to display the current result, so is there any option in the method that can split the columns into two .
Edited by: Varun on Jan 27, 2011 7:30 PM
Edited by: Varun on Jan 29, 2011 2:25 PMI am not sure of the maximum of columns possible.
If you see the col_pos field in the field catalog table it can have only 2 digits. so i would assume it would be only 99 columns, but not sure.
Would get you more information soon.
Thanks,
Balaji -
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 -
ALV GRID Display Column Width problem when filtering
Hello All,
When i displaying ALV Grid Display ,i selected one column and set filter for that.
the problem is column width at display is 12 charecters but in filter it is allowing only 10 charecters to enter which is wrong. i am unable to set filter.please give solution.
Thanks
Sandeep.Ghello i am calling perform, ineed to set OUTPUTLEN according to field length how can i do that.
FORM fill_fieldcat USING p_field TYPE slis_fieldcat_alv-fieldname
p_text TYPE slis_fieldcat_alv-seltext_l
p_flag TYPE c.
wa_fieldcat-fieldname = p_field.
wa_fieldcat-seltext_l = p_text.
wa_fieldcat-no_out = p_flag.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Maybe you are looking for
-
Preview in Browser and Adobe Browser Lab show website differently? Please help
Hi...working on my first website and I have a question about the differences in viewing the site through choosing file...preview in browser.... from within Dreamweaver, and using the Adobe Browser Lab to view the website. There seems to be a very sig
-
How can I get iTunes to locate my music?
Alright, a couple days ago I found myself with a problem. iTunes could not locate my music. I went on the internet looking up solutions and loe and behold... they didn't work. Then, just today, I found one that put myself in another mess. It had me g
-
Cross company sales / Inter company sales ( STO ) in Is- retail
Hi All, I need your help in understanding how sales occur between two different company codes in Is-retail. As far as retail is concern the sales doc OR is created automatically based on the POS inbound data. Please provide me input to understand how
-
I have had verizon for years, through shared lines with kids, hubby...pay..pay..pay. The last couple of years the kids have left, hubby has a phone from work so I am left paying a fortune for a single phone. 2 years ago I finally upgraded to the che
-
Hello, I would like to have the message the can be found at: http://forums.oracle.com/forums/thread.jsp?forum=75&thread=278931&message=853986#853986 deleted The reason is because it contains some personal information Thank You Douglas McGillivray