Subtotal in alv after sort
i have six fields,
based upon the sorting of all 5 fields, i should get the subtotal for sixth field in the alv list report(i have used func module alv_list_display').
How can I set the sorting sequence in IT_SORT?
and display the sub-total.
Hai
Go through the following Example Code
Refer to this similar thread.
alv Display :Total and subtotal
for sub totals you have to use
sort table.
sort-fieldname = 'VBELN'.
sort-tabname = 'ITAB'.
sort-up = 'X'.
sort-subtot = 'X'.
append sort to it_sort.
Or
Define SORT table and FIELDCATALOG table .
Data :i_field type slis_t_fieldcat_alv,
w_field like line of i_field,
i_sort type slis_t_sortinfo_alv,
w_sort like line of i_sort.
2.Grand Total
While buildingfieldcatalog,We have to set DO_SUM = 'X' for quantity field .
ex.
w_field-fieldname = 'MENGE'.
w_field-tabname = 'I_TAB'.
w_field-DO_SUM = 'X'.
append w_field to i_field.
clear w_field.
3.Subtotal
Whenever WERKS is changed Subtotal is displayed .
Build sort table .
Clear: w_sort,i_sort[].
w_sort-spos = 1.
w_sort-fieldname = 'WERKS'.
w_sort-up = 'X'.
w_sort-subtot = 'X'.
append w_sort to i_sort.
clear w_sort.
4.
Pass this I_SORT table thru REUSE_ALV_LIST_DISPLAY function module ..like fieldcatalog table.
Or
For sub totals you need to sort and pass the sort table to FM.
But for total you need to pass to field catalog like below
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
Thanks & regards
Sreeni
Similar Messages
-
ALV after sorting modifying problem
Hi all,
I use ALV with function.On ALV output when i sort output for some field ITAB was not modify new index key. Forexample,
Record before sorting index key 10, then after sorting it was same 10. How can i solve this problem?
Best regards,
MunurHi Munur,
if you want to see the same thing after sorting on the grid, save it in a layout.
or else before displaying the grid , sort the itab contents and push them on to alv.
Thanks & regards,
Sasi Kanth. -
Subtotal in ALV without sort technique to maintain heirarchy of records.
Hello Abappers,
In my functionality, i want to perform subtotals of the expenditures of a particular SBU. So in the ALV under each Business Unit, there are various Expense types and under them various SBU's
Heirachy is as follows :
BU - > Expense Type - > SBU
So when i display all this in ALV,
column A is BU
column B is expense types under one BU
column C is SBU's under one expense type
column D is the amount expenditure of SBU
I want a subtotal of amounts spend under one expense type. i.e sum of all SBU expenditure and then total of all expenditure. Total i can get by do_sum in fieldcatalog.
But for the subtotal, i need to use sort criteria, but if i sort entire thing gets sorted and the heirarchy is lost.
Is there any other way of performing subtotal without sorting?
Regards.hi.
i think before showing the itab in alv , u should also calculate the subtotals in it.and then sort it out and send to alv. -
Hi all,
I have a Alv grid display.After the ouput is shown
suppose i have it ascending or descending.Now i want to get the sorted alv into my internal table .Bcoz when i double click a particular row it goes to the next screen with the contents of that particular line.Does any one know how to do that here i am using OOPS Alv.
regards
AhasanHi,
You cannot directly get the SORTED table, but you get the SORT info and do the SORTING yourself, so that the internal table will be the same as that of the display.
The method get_frontend_layout will give you the layout info and the method <b> GET_SORT_CRITERIA </b>, will give you the sort criteria applied by the user.
The table parameter ET_SORT will have the name of the fields sorted. Then what you can do is
SORT itab BY (FIELDNAME). FIELDNAME is from the ET_SORT table.
Regards,
Ravi
Note : Please mark the helpful answers. -
Field should not display in the subtotal row in ALV report after sorting .
we have a requirement, after sorting and subtotaling, the output in ALV is -
vbeln amount1 amount2 amount3
123 11 12 13
123 12 13 14
123 23 25 27
133 11 12 13
133 12 13 14
133 23 25 27
Now the customer wants the ALV outpput in this fashion -
123 11 12 13
123 12 13 14
23 25 27 --->123 (vbeln) should not come in subtotaling row
133 11 12 13
133 12 13 14
23 25 27--->133(vbeln) should not come in subtotaling rowHi,
if it helps you could create a hierachy. In this way you can define the field catalog for the lines and for the subtotal columns. The only thing is that you would always show the subtotal rows.
You have references of hierachy alvs in
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c060fcb4-2c62-2b10-d2b2-f32407a5cc6f
ALV Hierarchy
alv hierarchy
In this case it also sorts
Sorting for ALV hierarchy
I hope it helps.
Edited by: Oscar Pecharroman on Aug 2, 2010 1:13 PM -
Adding row after subtotal in ALV
Hi Guys,
can we add one row after the subtotal in ALV.
Like the below...
field1 field2 field3 field4
Sub total. 120 121 125 130
Test 150
can you help me about the above...
Thanks,
LingeshHi
If you use GROUPLEVEL_CHANGE you have to creare a form like this:
FORM GROUPLEVEL_CHANGE
USING P_LINEINFO TYPE SLIS_LINEINFO
LS_GROUPS TYPE KKBLO_GROUPLEVELS.
ENDFORM. "GROUPLEVEL_CHANGE
In the P_LINEINFO you have details of row and in the LS_GROUPS details of level of sorting.
For example I used it to re-write subtotal:
FORM GROUPLEVEL_CHANGE USING P_LINEINFO TYPE SLIS_LINEINFO
LS_GROUPS TYPE KKBLO_GROUPLEVELS.
PERFORM WRITE_SUB_TOTAL USING LS_GROUPS.
ENDFORM. "GROUPLEVEL_CHANGE
FORM WRITE_SUB_TOTAL USING P_GROUPS TYPE KKBLO_GROUPLEVELS.
DATA: TOT_SALDO_A LIKE BSID-DMBTR,
TOT_FATTURATO_A LIKE BSID-DMBTR,
TOT_DSO_A LIKE BSID-DMBTR.
DATA: WA_GROUP TYPE KKBLO_GROUPLEVELS.
DATA: RUN_LEVEL TYPE I.
DATA: BEGIN OF T_LEVEL OCCURS 1,
LEVEL TYPE I,
INDEX_FROM TYPE I,
INDEX_TO TYPE I,
END OF T_LEVEL.
T_LEVEL-LEVEL = P_GROUPS-LEVEL.
T_LEVEL-INDEX_FROM = P_GROUPS-INDEX_FROM.
T_LEVEL-INDEX_TO = P_GROUPS-INDEX_TO.
APPEND T_LEVEL.
Check livel:
CALL FUNCTION 'ALV_GROUPLEVELS_GET'
IMPORTING
ET_GROUPS = GT_GROUP
TABLES
T_OUTTAB = <FS_OUTPUT>.
RUN_LEVEL = P_GROUPS-LEVEL + 1.
IF RUN_LEVEL <= LEVEL.
DO.
LOOP AT GT_GROUP INTO WA_GROUP
WHERE INDEX_FROM => P_GROUPS-INDEX_FROM
AND INDEX_TO <= P_GROUPS-INDEX_TO
AND LEVEL = RUN_LEVEL.
T_LEVEL-LEVEL = RUN_LEVEL.
T_LEVEL-INDEX_FROM = WA_GROUP-INDEX_FROM.
T_LEVEL-INDEX_TO = WA_GROUP-INDEX_TO.
ENDLOOP.
IF SY-SUBRC = 0.
APPEND T_LEVEL.
ENDIF.
RUN_LEVEL = RUN_LEVEL + 1.
IF RUN_LEVEL > LEVEL. EXIT. ENDIF.
ENDDO.
ENDIF.
SORT T_LEVEL BY LEVEL DESCENDING.
LOOP AT T_LEVEL.
TOT_SALDO_A = TOT_FATTURATO_A = 0.
LOOP AT <FS_OUTPUT> INTO <FS_WA_OUT>
FROM T_LEVEL-INDEX_FROM
TO T_LEVEL-INDEX_TO.
ASSIGN COMPONENT 'ZSALDO'
OF STRUCTURE <FS_WA_OUT> TO <FS_SALDO>.
ASSIGN COMPONENT 'ZFATTURATO'
OF STRUCTURE <FS_WA_OUT> TO <FS_FATTURATO>.
TOT_SALDO_A = TOT_SALDO_A + <FS_SALDO>.
TOT_FATTURATO_A = TOT_FATTURATO_A + <FS_FATTURATO>.
ENDLOOP.
TOT_SALDO = TOT_SALDO + TOT_SALDO_A .
TOT_FATTURATO = TOT_FATTURATO + TOT_FATTURATO_A.
PERFORM CALCULATE_DSO USING TOT_FATTURATO_A
TOT_SALDO_A TOT_DSO_A.
PERFORM WRITE_TOT_DSO
USING TOT_SALDO_A
TOT_FATTURATO_A TOT_DSO_A
T_LEVEL-LEVEL T_LEVEL-INDEX_FROM.
ENDLOOP.
ENDFORM. " WRITE_SUB_TOTAL
Max -
ALV - Editing a Row after Sorting - REAL HEADACHE.....
Hi,
I have a ALV table with a DropDown in one of the columns. The user can enter a value in the dropdown boxes.
Now the proble is, lets say I have SORTED the table by another column. Now the user enters a value in one of the rows of the dropdown and clicks the SAVE Button.
How do i find out, which Row the User Has entered the value ?
I tried using the table it_modified_cells in the event handler for ON_DATA_CHECK . However it gives wrong row indexes, that is if, the row number '10' is Row number '1', after sorting, and if this row is modified, then it_modified_cells table gives Row '1' as modified rather than Row '10'.
So ina nut shell, after sorting , if a row is edited, How to find out which is this row...... ?Nithya,
Look at this thread of mine....
Re: ALV - Lead Selection of Node When FILTERS ACTIVE
I had this issue when after filtering in ALV Table, th e bound Node wtill held original records......
So is it something likeSORTING Updates the context,,,,,FILTERING does not ?
Thanks
Anand -
hello freinds,
I am facing problem of subtotal in alv report.
I am explaining my problem.....................
In my report there are 8 columns...
in first colum there is <b>'Acount Number'</b> field. I have to sort out it.and I have done it succesfully. Now in my seventh and eighth column there are fields 'PAYMENT GROSS AMOUNT' and ' IVA AMOUNT' respectively.
Now I have to do subtotal of these two columns (7th & 8th) according to first column value i.e Acount Number.
Please send me solution.
Thanks in Advance........Hi,
try this code ,hope usefull to u, please reward point if usefull to u.
*& Report ZALV_SUBTOTAL
This program lists orders (VBAK) with sort and sub-total for *
'sold-to-party' (KUNNR) and 'Sales organization' (VKORG) *
REPORT ZALV_SUBTOTAL.
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 **********************
Regards
fareedas -
How to find out the total, subtotal in alv report
hi dears,
how to find out the total, subtotal in alv report?
pls tell me logic ,
i will be waiting for eply
regards
eswarHi,
<b>ALV Grid List with sub-totals</b>
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 **********************
Regards
Sudheer -
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 -
Hi Experts,
I wanted to do the subtotal in ALV report. For subtotal which data type we need to take. Is it really affect with data type??
My problem is: I wanted to do the subtotal based on Purchase order number. I need to do the subtotal of field LV_VAR based on purchase order number. The field LV_VAR having TYPE packed decimal.
Do I need to change the data type of field LV_VAR for getting subtotal?
For implementing the Subtotal functionality in my alv report, I did following changes
1. Declared one sort catalog as
gs_sort-fieldname = 'EBELN'.
gs_sort-up = 'X'.
gs-sort-subtot = 'X'.
append gs_sort to gt_sort.
2. In fieldcatalog of field LV_VAR
i_fieldcatalog-fieldname = 'LV_VAR'.
i_fieldcatalog-tabname = 'ITAB'.
i_fieldcatalog-do_sum = 'X'.
append i_fieldcatalog.
Then in FM REUSE_ALV_GRID_DISPLAY, I had passed sort catalog as
it_sort = gt_sort[]
But I did not get the subtotal functionality.
Any suggestion pls?Hi ,
I will give you one sample code which has a functionality of subtotal and grand total also .
And this code will help you in many aspects also.
*& Report ZSAND_SUBTOTAL *
REPORT ZSAND_SUBTOTAL LINE-COUNT 65 .
*& 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: it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort like line of it_sortcat.
DATA: it_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.
data: var1(1).
DATA var2.
data:mytabix like sy-tabix.
data:wtab1 like line of itab,
wtab2 like line of itab.
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.
data:it_extab type SLIS_t_EXTAB,
wa_extab like line of it_extab.
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : doc FOR mseg-mblnr.
SELECTION-SCREEN : END OF BLOCK blk1.
START-OF-SELECTION.
PERFORM build_cat USING t_fcat.
PERFORM build_layout.
PERFORM build_eve.
perform fill_sort.
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.
ENDFORM. "build_cat
*& Form build_eve
*text
FORM build_eve.
DATA : wa_eve TYPE slis_alv_event.
data:mytabix type sy-tabix.
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 into wa_eve WITH KEY name = slis_ev_top_of_page.
*INTO wa_eve.
IF sy-subrc = 0.
mytabix = sy-tabix.
MOVE 'TOP_OF_PAGE' TO wa_eve-form.
append wa_eve to t_eve.
*modify t_eve from wa_eve index mytabix transporting form.
ENDIF.
READ TABLE t_eve into wa_eve WITH KEY name = slis_ev_end_of_page.
*INTO wa_eve.
IF sy-subrc = 0.
mytabix = sy-tabix.
MOVE 'END_OF_PAGE' TO wa_eve-form.
append wa_eve to t_eve.
*modify t_eve from wa_eve index mytabix transporting form.
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 = 'SUBTOTAL'.
*gd_layout-totals_text = 'TOTAL'.
gd_layout-EDIT = 'X'.
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.
sort itab by mblnr matnr.
read table itab into wtab1 index 1.
mytabix = 1.
loop at itab into wtab2 from 2.
if wtab1-mblnr = wtab2-mblnr and wtab1-matnr = wtab2-matnr.
wtab1-menge = wtab1-menge + wtab2-menge.
modify itab from wtab1 index mytabix.
else.
modify itab from wtab1 index mytabix.
clear wtab1.
mytabix = sy-tabix.
move wtab2 to wtab1.
endif.
clear wtab2.
endloop.
delete ADJACENT DUPLICATES from itab comparing mblnr matnr.
ENDFORM. "get_data
*& Form display
*text
FORM display.
wa_extab-fcode = '&ETA'.
append wa_extab to it_extab.
wa_header-typ = 'H'.
wa_header-info = 'SANDY is Great'.
append wa_header to it_header.
clear wa_header.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'ZSAND_SUBTOTAL'
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USERCOMMAND'
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 = gd_layout
IT_FIELDCAT = t_fcat
IT_EXCLUDING = it_extab
IT_SPECIAL_GROUPS =
IT_SORT = it_sortcat
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = t_eve[]
IT_EVENT_EXIT = 'BUILD_EVE'
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 = 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
***& Form top_of_page
*text
FORM top_of_page.
if var1 is initial.
wa_header-typ = 'H'.
wa_header-info = 'SANDY is Great'.
append wa_header to it_header.
clear wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = it_header
I_LOGO = 'HR_LOGO'
I_END_OF_LIST_GRID =
var1 = 'X'.
endif.
ENDFORM. "top_of_page
FORM end_of_page.
if var2 is initial.
wa_header-typ = 'H'.
wa_header-info = 'SANDY is Great'.
append wa_header to it_header.
clear wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = it_header
I_LOGO = 'HR_LOGO'
I_END_OF_LIST_GRID =
var2 = 'X'.
endif.
ENDFORM. "top_of_page
*& Form fill_sort
text
--> p1 text
<-- p2 text
form fill_sort .
wa_sort-spos = 1.
wa_sort-fieldname = 'MBLNR'.
wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field
gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.
wa_sort-spos = 2.
wa_sort-fieldname = 'MATNR'.
gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.
endform. " fill_sort
FORM status USING rt_extab TYPE slis_t_extab.
set pf-status 'ZSTANDARD'.
endform.
form USERCOMMAND USING R_UCOMM type sy-ucomm
rselfield type slis_selfield .
set parameter id 'MAT' field rselfield-value .
call transaction 'MM03' and skip first screen.
endform.
I hope this program will help you out.
Help children of U.N World Food Program by rewarding points and encourage others to answer your queries. -
How to use subtotal in ALV report
hi all,
I need to find subtotal say for Event_ID(type numc) and this should come in the ALV grid intial screen itself.
I have coded like
gs_sort1-spos = '1'.
gs_sort1-fieldname = 'EVENT_ID'.
gs_sort1-up = 'X'.
gs_sort1-subtot = 'X'.
APPEND gs_sort1 TO gt_sort1.
and declare gt_sort1 in FM' REUSE_ALV_GRID_DISPLAY'.. but I am not getting the subtotal in the ALV screen
points will be rewarded
thanks in advance
it is urgentHi Jayasree,
Plerase check this program
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
Hope this helps...
Best regards,
raam -
How to do subtotal in alv?
Hi,
I have a problem to do the subtotal in alv.
The outlook of alv now is as following:
Specimen Adversary Amount
ZZZ 300100089 1050
ZZZ 300100089 -1050
90256243 300100000 193410
90256242 300100000 173250
90256241 300100000 173250
90256240 300100000 173250
90256239 300100000 173250
90256238 300100000 173250
90256237 300100000 173250
What I need to do it to sum up the amount for same "ADVERSARY"
The out-come image should be
Specimen Adversary Amount
ZZZ 300100089 1050
ZZZ 300100089 -1050
subtotal 0
90256243 300100000 193410
90256242 300100000 173250
90256241 300100000 173250
90256240 300100000 173250
90256239 300100000 173250
90256238 300100000 173250
90256237 300100000 173250
subtotal 1232910
Question:
How can I add the subtotal in alv?
Please help!!
The following is the original coding:
END-OF-SELECTION.
SORT t.
LOOP AT t.
AT NEW bukrs.
CLEAR anz_dl.
CLEAR htext-anzahl.
CLEAR htext-datei.
htext-text1 = ' records writen in file '.
CLEAR p_pfad.
CONCATENATE
i_pfad
'CU_CC'
t-bukrs
sy-datum+6(2)
sy-datum+4(2)
sy-datum(4)
sy-uzeit
'.txt'
INTO p_pfad.
CLEAR outtab.
REFRESH outtab.
REFRESH: gt_outalv. "INS MG020207
ENDAT.
IF t-shkzg = 'H'.
h_betrg = t-wrbtr * -1.
ELSE.
h_betrg = t-wrbtr.
h_dmbtr = t-dmbtr.
ENDIF.
s-filler1 = s-filler2 = s-filler3 = s-filler4 = s-filler5 = ';'.
s-filler6 = s-filler7 = s-filler8 = ';'.
s-filler9 = s-filler10 = s-filler11 = s-filler12 = s-filler13 = ';'.
s-filler14 = ';'.
s-belnr = t-belnr.
IF t-xblnr NE space. "WD041005a
s-xblnr = t-xblnr. "WD041005a
ELSE. "WD041005a
s-xblnr = t-belnr. "WD041005a
ENDIF. "WD041005a
WHILE s-xblnr(1) EQ '0'. "INS MG130606
SHIFT s-xblnr LEFT. "INS MG130606
ENDWHILE. "INS MG130606
WRITE t-kunnr TO s-kunnr NO-ZERO.
s-lifn2 = s-kunnr.
shift s-lifn2 RIGHT.
s-lifn2(1) = 'R'.
S-KUNNR = T-KUNNR+5(5).
s-bldat+2(1) = '/'.
s-bldat+5(1) = '/'.
s-bldat0(2) = t-bldat4(2).
s-bldat3(2) = t-bldat6(2).
s-bldat6(4) = t-bldat0(4).
s-budat+2(1) = '/'.
s-budat+5(1) = '/'.
s-budat0(2) = t-budat4(2).
s-budat3(2) = t-budat6(2).
s-budat6(4) = t-budat0(4).
s-netdt+2(1) = '/'.
s-netdt+5(1) = '/'.
s-netdt0(2) = t-netdt4(2).
s-netdt3(2) = t-netdt6(2).
s-netdt6(4) = t-netdt0(4).
s-waers = t-waers.
s-dmbtr = t-dmbtr.
s-sgtxt = t-sgtxt.
CLEAR s-twaer.
SELECT SINGLE waers INTO s-twaer
FROM t001
WHERE bukrs = t-bukrs.
IF h_betrg < 0.
hs_betrg+0(1) = '-'.
ELSE.
hs_betrg+0(1) = ' '.
ENDIF.
WRITE h_betrg CURRENCY t-waers TO hs_betrg+1 NO-GROUPING
NO-SIGN
LEFT-JUSTIFIED.
REPLACE ',' WITH '.' INTO hs_betrg.
WRITE hs_betrg TO s-betrg.
IF h_dmbtr < 0.
hs_betrg+0(1) = '-'.
ELSE.
hs_betrg+0(1) = ' '.
ENDIF.
WRITE h_dmbtr CURRENCY t-waers TO hs_betrg+1 NO-GROUPING
NO-SIGN
LEFT-JUSTIFIED.
REPLACE ',' WITH '.' INTO hs_betrg.
WRITE hs_betrg TO s-dmbtr.
s-compcode = t-bukrs. "fw070905
IF p_downl = 'X'.
MOVE s TO outtab-s.
APPEND outtab.
ADD 1 TO anz_dl.
ENDIF.
gs_outalv-belnr = s-belnr. "INS MG020207
*<<<< CR01 START ADD as_outalv-zuonr
gs_outalv-zuonr = s-zuonr. "CR01
*>>>> CR01 EDD ADD as_outalv-zuonr
gs_outalv-kunnr = s-kunnr. "INS MG020207
gs_outalv-bldat = s-bldat. "INS MG020207
gs_outalv-netdt = s-netdt. "INS MG020207
gs_outalv-betrg = s-betrg. "INS MG020207
gs_outalv-waers = s-waers. "INS MG020207
gs_outalv-compcode = s-compcode. "INS MG020207
gs_outalv-budat = s-budat. "INS MG020207
gs_outalv-sgtxt = s-sgtxt.
gs_outalv-kmmnt = s-kmmnt.
gs_outalv-vbeln = s-vbeln.
gs_outalv-xblnr = s-xblnr.
gs_outalv-lifn2 = s-lifn2.
gs_outalv-dmbtr = s-dmbtr.
gs_outalv-twaer = s-twaer.
APPEND gs_outalv TO gt_outalv. "INS MG020207
AT END OF bukrs.
WRITE anz_dl TO htext-anzahl.
WRITE p_pfad TO htext-datei.
CONDENSE htext.
IF p_downl = 'X'.
SKIP 2.
WRITE: / htext.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = p_pfad
filetype = 'ASC'
TABLES
data_tab = outtab
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.
write: / 'Error creating File:', P_Pfad, sy-subrc.
MESSAGE e405 WITH text-002 p_pfad.
ENDIF.
ENDIF.
*<<<<< INS MG020207
IF p_alvd EQ 'X'.
PERFORM build_layout_data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = 'GT_OUTALV'
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
i_callback_top_of_page = 'TOP-OF-PAGE'
TABLES
t_outtab = gt_outalv.
ENDIF.
*>>>>> INS MG020207
ENDAT.
ENDLOOP.Check this code....it will help you...reward if useful.
REPORT ZPP473_VEHICLE_REVERSAL_REP NO STANDARD PAGE HEADING
MESSAGE-ID ZPP.
TABLES:ZPP18_RT_CORR.
TYPE-POOLS:SLIS.
DATA:BEGIN OF WA_VEH_REV,
VEHNO TYPE ZPP18_RT_CORR-VEHNO,
MATNR TYPE ZPP18_RT_CORR-MATNR,
WERKS TYPE ZPP18_RT_CORR-WERKS,
MDV01 TYPE ZPP18_RT_CORR-MDV01,
ENGNO TYPE ZPP18_RT_CORR-ENGNO,
FRMNO TYPE ZPP18_RT_CORR-FRMNO,
ERFMG TYPE ZPP18_RT_CORR-ERFMG,
SHIFT TYPE ZPP18_RT_CORR-SHIFT,
ZUNAME TYPE ZPP18_RT_CORR-ZUNAME,
ZDATE TYPE ZPP18_RT_CORR-ZDATE,
MAKTX TYPE MAKT-MAKTX,
ZREASON_DES TYPE ZPP17_REASON_COD-ZREASON_DES,
*VTEXT TYPE T179T-VTEXT,
END OF WA_VEH_REV.
DATA:IT_VEH_REV LIKE STANDARD TABLE OF WA_VEH_REV.
DATA: ALVFLD TYPE SLIS_FIELDCAT_ALV,
FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: WK_LAYOUT TYPE SLIS_LAYOUT_ALV,
I_SORT TYPE SLIS_T_SORTINFO_ALV,
W_SORT LIKE LINE OF I_SORT.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
SO_ZDATE FOR ZPP18_RT_CORR-ZDATE OBLIGATORY,
SO_WERKS FOR ZPP18_RT_CORR-WERKS,
SO_SHIFT FOR ZPP18_RT_CORR-SHIFT,
SO_MDV01 FOR ZPP18_RT_CORR-MDV01,
SO_MATNR FOR ZPP18_RT_CORR-MATNR,
SO_VEHNO FOR ZPP18_RT_CORR-VEHNO,
SO_ENGNO FOR ZPP18_RT_CORR-ENGNO,
SO_FRMNO FOR ZPP18_RT_CORR-FRMNO,
SO_UNAME FOR ZPP18_RT_CORR-ZUNAME.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
**GET REVERSAL,MATERIAL DESCRIPTIONS, REASON DESCRIPTIONS
SELECT ZPP18_RT_CORR~VEHNO
ZPP18_RT_CORR~MATNR
ZPP18_RT_CORR~WERKS
ZPP18_RT_CORR~MDV01
ZPP18_RT_CORR~ENGNO
ZPP18_RT_CORR~FRMNO
ZPP18_RT_CORR~ERFMG
ZPP18_RT_CORR~SHIFT
ZPP18_RT_CORR~ZUNAME
ZPP18_RT_CORR~ZDATE
MAKT~MAKTX
ZPP17_REASON_COD~ZREASON_DES
INTO TABLE IT_VEH_REV FROM
ZPP18_RT_CORR INNER JOIN MAKT
ON ( ZPP18_RT_CORRMANDT = MAKTMANDT AND
ZPP18_RT_CORRMATNR = MAKTMATNR )
INNER JOIN ZPP17_REASON_COD
ON ( ZPP18_RT_CORRMANDT = ZPP17_REASON_CODMANDT AND
ZPP18_RT_CORRZREASON = ZPP17_REASON_CODZREASON )
CLIENT SPECIFIED
WHERE ZPP18_RT_CORR~MANDT = SY-MANDT
AND ZPP18_RT_CORR~ZDATE IN SO_ZDATE
AND ZPP18_RT_CORR~WERKS IN SO_WERKS
AND ZPP18_RT_CORR~SHIFT IN SO_SHIFT
AND ZPP18_RT_CORR~MATNR IN SO_MATNR
AND ZPP18_RT_CORR~MDV01 IN SO_MDV01
AND ZPP18_RT_CORR~VEHNO IN SO_VEHNO
AND ZPP18_RT_CORR~ENGNO IN SO_ENGNO
AND ZPP18_RT_CORR~FRMNO IN SO_FRMNO
AND ZPP18_RT_CORR~ZUNAME IN SO_UNAME
AND MAKT~SPRAS = SY-LANGU.
IF SY-SUBRC = 0.
SORT IT_VEH_REV ASCENDING BY ZDATE SHIFT WERKS MDV01 MATNR.
ELSE.
MESSAGE I961 WITH 'No Data Found...Try Again !!!'.
STOP.
ENDIF.
**BUILD ALV DISPLAY.
DEFINE ALV_MACRO.
ALVFLD-FIELDNAME = &1.
ALVFLD-SELTEXT_M = &2.
ALVFLD-COL_POS = &3.
IF &1 = 'ERFMG'.
ALVFLD-DO_SUM = 'X'.
ENDIF.
APPEND ALVFLD TO FIELDCAT.
CLEAR ALVFLD.
END-OF-DEFINITION.
REFRESH FIELDCAT.
WK_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
ALV_MACRO 'ZDATE' 'Rev.Date' '1'.
ALV_MACRO 'SHIFT' 'Shift' '2'.
ALV_MACRO 'WERKS' 'Plant' '3'.
ALV_MACRO 'MDV01' 'Conveyor' '4'.
ALV_MACRO 'MATNR' 'Material.No' '5'.
ALV_MACRO 'MAKTX' 'Description' '6'.
ALV_MACRO 'VEHNO' 'Veh.No' '7'.
ALV_MACRO 'ENGNO' 'Eng.No' '8'.
ALV_MACRO 'FRMNO' 'Frame.No' '9'.
ALV_MACRO 'ERFMG' 'Qty' '10'. <----Do Sum Here
ALV_MACRO 'ZREASON_DES' 'Reason' '11'.
ALV_MACRO 'ZUNAME' 'User.Reversed' '12'.
REFRESH I_SORT.
W_SORT-SPOS = 1.
W_SORT-FIELDNAME = 'ZDATE'.
W_SORT-UP = 'X'.
APPEND W_SORT TO I_SORT.
CLEAR W_SORT.
W_SORT-SPOS = 6.
W_SORT-FIELDNAME = 'MAKTX'.
W_SORT-UP = 'X'.
W_SORT-SUBTOT = 'X'.
APPEND W_SORT TO I_SORT.
CLEAR W_SORT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_GRID_TITLE = 'Vehicle Reversal Report'
IS_LAYOUT = WK_LAYOUT
IT_FIELDCAT = FIELDCAT[]
IT_SORT = I_SORT[]
TABLES
T_OUTTAB = IT_VEH_REV[]
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.
END-OF-SELECTION. -
Subtotaling in ALV(urgent)
Hi experts,
can anyone tell how to achieve the subtotaling in ALV'S.any pseudo code .points will be awarded.
Regards,
nagarajHello Nagaraj,
In the sort table use:
REFRESH IT_SORT.
CLEAR: G_S_SORT,G_S_SORT.
G_S_SORT-SPOS = 1.
G_S_SORT-FIELDNAME = 'EBELN'.
G_S_SORT-UP = 'X'.
G_S_SORT-DOWN = ' '.
<b> G_S_SORT-SUBTOT = 'X'.</b>
G_S_SORT-EXPA = ' '.
APPEND G_S_SORT TO IT_SORT.
If useful reward.
Vasanth -
Hi Experts,
I Want to tead The ALV after appliying a filter. that means.. if my alv contains 50 rows. after filter suppose it reduce to 10 lines. i want to read those 10 lines into an itab.
Please suggest asap
Regards
Sarath SatheesanHi Sarath,
Try this code:
DATA: lr_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
l_VALUE type If_Salv_Wd_Table=>S_Type_Param_Get_Ui_Info.
try.
lr_INTERFACECONTROLLER = wd_This->wd_CpIfc_alv_invoice( ).
catch CX_WDR_RT_EXCEPTION.
endtry.
if not lr_INTERFACECONTROLLER is initial.
l_VALUE = lr_INTERFACECONTROLLER->Get_Ui_Info(
endif.
Regards,
Shemim
Maybe you are looking for
-
Can you watch movies you buy on the itouch?
I bought and downloaded a movie from itunes.It shows up on my itunes and i can watch it on the computer..but i want to watch it on my itouch.Can you watch movies you buy from itunes on the itouch..(i thought you could) but the movie wont sync to my
-
NO SERVICE BEING PROVIDED IN REEDS, MO
Thanks for your reply John. However, you are in error in many areas.. since you have obviously checked my usage of my phone lets review shall we?? As you can see, my calls (made) have drastically gone down since moving to Missouri. "It is your right
-
The link for latest patchset for 11.2.0.3.0 windows 64 bit
Hi Platform: windows 64 bit Oracle database 11.2.0.3 I successfully upgraded my database from oracle 11.2.0.1.0 to 11.2.0.3.0 and the upgrade worked fine. I installed the 11.2.0.3.0 in a new oracle home. Now my task is to install the latest patchset
-
Beginning a brand new comp...using solid black layer and camera...apply Trapcode Form to solid layer. It appears. When I try to blow the comp up (just scrolling in with the mouse wheel to make it bigger), it disappears. No setting other than default.
-
Hi: Can someone give me a QOS example config for my scenario below: I have read the config guide and is confused. Let's say I have a router leg on e1/1 of N5K1. I want to limit on the outbound( N5K1 to router) http 25%, icmp 10K and remaining goes t