Multiple subtotals/totals in ALV
Hi guys,
my requirement in ALV(oops) is, I need to get the ALV in the below format .
I have done the report which brings subtotal and grand total. my requirement has changed a little.
I need an intermediate total (ie. sub_4 mentioned below).
mat1 100 110 usd
mat2 200 220 usd
Sub_1 300 330 usd
lab1 120 222 usd
lab2 111 112 usd
sub_2 230 333 usd
Tot 530 663 usd (sub_1 + sub_2) = sub_4
set1 313 311 USD
set2 131 131 USD
sub_3 444 442 usd
Tot 974 1105 usd (sub_4 + sub_3)
any thoughts appreciated .
Hi guys,
my requirement in ALV(oops) is, I need to get the ALV in the below format .
I have done the report which brings subtotal and grand total. my requirement has changed a little.
I need an intermediate total (ie. sub_4 mentioned below).
mat1 100 110 usd
mat2 200 220 usd
Sub_1 300 330 usd
lab1 120 222 usd
lab2 111 112 usd
sub_2 230 333 usd
Tot 530 663 usd (sub_1 + sub_2) = sub_4
set1 313 311 USD
set2 131 131 USD
sub_3 444 442 usd
Tot 974 1105 usd (sub_4 + sub_3)
any thoughts appreciated .
Similar Messages
-
Reg: passing totals /subtotals of a ALV to a smartform
I have a editable ALV report which has a button to call a smartform . Once the user edits some fields I need to pass the refreshed total to the smartform. I want to know - in what structure the totals/subtotals of the ALV report are stored.
Banu,
Even if you figure out how to get the subtotals / totals from a ALV, I would still suggest you to use the features of SMART Forms to calculate the same again in the form.
http://help.sap.com/saphelp_nw04/helpdata/en/55/610e2db57911d4b62c006094192fe3/content.htm
So, that way if your form is triggered even without doing the subtotalling done by the user you are on the safer side as the form will still display what you have designed it for.
Regards,
Ravi
Note :Please mark all the helpful answers -
Hi All,
I want subtotals text in ALV GRID. For this iam seeing a standard program 'BCALV_TEST_FULLSCREEN'.Iam giving subtotal text on selection screen,but its not displayed in output.How to view the text.
When i executed another program BCALV_TEST_LIST, iam able to get the subtotal text in output, what ever i give the text on the selction screen.
Regards,
Kiran IHi,
Chk out this:
*& Form BUILD_LAYOUT
Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
Best Regards,
Anjali -
Sub total in ALV GRID using oops concept
Hi,
If Plant (VBAP-WERKS) is not the same for all items on a Sales Order (VBAK-VBELN is the same for al items) then create a separate line on the report for each different plant specified in the line items. Copy all fields from the original order line except for plant and Net Value. Net Value should be the total of item Net Values for all items with the same plant in the order.
Example:
Data:
Order---- Item- Plant- Net Value---
123---- 010- 3467- 100.00---
123---- 020- 7865- 50.00---
123---- 030- 3467- 80.50---
Report:
Order- Plant- Net Value---
123- 3467- 180.50---
123- 7865- 50.00----
I need to dispaly the Report format in ALV Grid using oops concept...
no need of calling any function modules.
Regards,
NithyaHi
Here is example code
This is the method to be called:
get_subtotals
Use
Returns the current subtotals of the ALV Grid Control. Having created totals for at least one column, users can calculate at most nine subtotals. The list is sorted by the values of one or several columns (called the subtotals column). If a value is changed in the subtotals column, the subtotal is displayed (this is also referred to as control level change).
Integration
Before you access the subtotals value, you use the method get_sort_criteria to get the sort table . One row of this table describes properties of a column in the output table.
If the field SUBTOT is set for a column in this table, the column is a subtotals column.
The field SPOS then indicates at which level (see below) the subtotal has been calculated.
The field FIELDNAME contains the name of the subtotals column in the output table.
Based on this information, you specifically access the values of the tables passed (using reference variables COLLECT01 to COLLECT09).
Features
CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->get_subtotals
IMPORTING
EP_COLLECT00 = <reference variable of type REF TO DATA>
EP_COLLECT01 = <reference variable of type REF TO DATA>
EP_COLLECT02 = <reference variable of type REF TO DATA>
EP_COLLECT03 = <reference variable of type REF TO DATA>
EP_COLLECT04 = <reference variable of type REF TO DATA>
EP_COLLECT05 = <reference variable of type REF TO DATA>
EP_COLLECT06 = <reference variable of type REF TO DATA>
EP_COLLECT07 = <reference variable of type REF TO DATA>
EP_COLLECT08 = <reference variable of type REF TO DATA>
EP_COLLECT09 = <reference variable of type REF TO DATA>
ET_GROUPLEVELS = <ínternal table of type LVC_T_GRPL>.
In order to access the values of EP_COLLECT00 to EP_COLLECT09, you use ASSIGN to dereference the relevant reference variable in a field symbol of your output table type (see below).
Parameters
Meaning
EP_COLLECT00
Points to the totals line. Since there is only one totals line which, in addition, has a unique totalling area, no further information is available for this table in table ET_GROUPLEVELS.
get_subtotals
EP_COLLECT01 to EP_COLLECT09
Point to the subtotals line. For each subtotals level, there is one reference variable. Each of these variables points to an internal table that has the type of the output table. EP_COLLECT01 points to the subtotal at the hightest level, while EP_COLLECT02 points to the subtotal at the second highest level, and so on. The levels are derived from the sort priority (field SPOS in the sort table ). The column by which the data was sorted first, is the highest subtotals level.
ET_GROUPLEVELS
Manages all indexes for the individual control levels. The fields of the table have the following meaning:
INDEX_FROM, INDEX_TO: Rows of the output table for which the subtotal was created
LEVEL: Subtotals level (see above)
COUNTER: Number of rows for which the subtotal was created
COMPRESS: For this subtotals line, the user has hidden the associated rows.
COLLECT: Indicates the subtotals table (01-09) in which the values are stored
For an overview, see Methods of Class CL_GUI_ALV_GRID
Activities -
How to display total in ALV Header
How to display total in ALV Header?
Hi Venkey,
As far as your issue is concerned I would like to quote my perception.
Create a header internal table with title and number of records.
At the later part of your program you should have found the total number of records ,now assign it to the header internal table and print it.
For further clarification you can go check this link:
http://wiki.sdn.sap.com/wiki/display/ABAP/AddHeadertoALVreport
Thanks
P.Srikanth -
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 -
I have data like currency and amounts and i want to display that amount as a total in alv display..
i used do_sum = x whle building fieldcat but itsdisplaying it currencywise like sub total...instead i want to total for all currencies and display it..
please guideSee the following example in this example WAERS is CUKY type
DATA: BEGIN OF ITAB OCCURS 0,
BELNR LIKE BSEG-BELNR,
GJAHR TYPE I,
WRBTR TYPE I,
WAERS LIKE BKPF-WAERS,
TOTAL TYPE P,
END OF ITAB.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_EVENTS TYPE SLIS_T_EVENT,
FCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
REC_FCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
START-OF-SELECTION.
FCAT-COL_POS = 1.
FCAT-FIELDNAME = 'BELNR'.
FCAT-TABNAME = 'ITAB'.
FCAT-REF_FIELDNAME = 'BELNR'.
FCAT-REF_TABNAME = 'BSEG'.
APPEND FCAT.
FCAT-COL_POS = 2.
FCAT-FIELDNAME = 'GJAHR'.
FCAT-TABNAME = 'ITAB'.
FCAT-REF_FIELDNAME = 'GJAHR'.
FCAT-DATATYPE = 'INT4'.
FCAT-INTTYPE = 'I'.
FCAT-DO_SUM = 'X'.
APPEND FCAT.
FCAT-COL_POS = 3.
FCAT-FIELDNAME = 'WRBTR'.
FCAT-TABNAME = 'ITAB'.
FCAT-DATATYPE = 'INT4'.
FCAT-INTTYPE = 'I'.
FCAT-DO_SUM = 'X'.
APPEND FCAT.
FCAT-COL_POS = 4.
FCAT-FIELDNAME = 'TOTAL'.
FCAT-TABNAME = 'ITAB'.
* FCAT-DATATYPE = 'INT4'.
FCAT-INTTYPE = 'P'.
FCAT-DO_SUM = 'X'.
APPEND FCAT.
DO 10 TIMES.
ITAB-WRBTR = SY-INDEX.
ITAB-GJAHR = SY-INDEX + 1.
ITAB-TOTAL = ITAB-WRBTR / ITAB-GJAHR.
APPEND ITAB.
ENDDO.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = 'Z_TOT_ALV'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT[]
I_TABNAME = 'ITAB'
IT_EVENTS = IT_EVENTS[]
TABLES
T_OUTTAB = ITAB[].
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
Edited by: kk.adhvaryu on Apr 5, 2010 9:23 AM -
Totals and Sub-Totals in ALV GRID
Could anyone advice, how to display sub-totals and totals in ALV Grid(using FM).
Ex: value1 value2
100 50
200 50
subtotal 300 100
total 400
Thanks in advance...Refer below demo code and see perform Sort_list..
it wil serve ur purpose.
REPORT ZGILL_ALV message-id rp .
type-pools slis.
tables: zgill_main,zgill_details.
data z_fieldcat type slis_t_fieldcat_alv.
data begin of itab occurs 0.
DATA ICON TYPE ICON-ID.
include structure zgill_main.
data salary like zgill_details-salary.
data end of itab.
*data itab1 like table of itab with header line.
data : WA_SORT TYPE SLIS_SORTINFO_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
PARAMETERS: p_list radiobutton group A1,
P_GRID RADIOBUTTON GROUP A1.
SELECT-OPTIONS: S_PERNR FOR ZGILL_MAIN-PERNR.
start-of-selection.
perform fill_itab.
perform sort_list.
**************Start of scenario without container******************************************
*********Method 1***********
perform fill_fieldcat. " Manuallly Preparing Fiedl Catalog
*********Method 2***********
*perform fill_fieldcat1 changing z_fieldcat. "Preparing field catalog with merge function
perform display_alv.
*****************end of scenario without container*****************************************
*& Form fill_itab
text
--> p1 text
<-- p2 text
form fill_itab .
*select * from zgill_main up to 20 rows INTO CORRESPONDING FIELDS OF TABLE itab.
*ITAB1[] = ITAB[].
select apernr aname aorg adob b~salary INTO CORRESPONDING FIELDS OF TABLE itab
from zgill_main as a join zgill_details as b on apernr = bpernr
WHERE A~PERNR IN S_PERNR.
LOOP AT ITAB.
IF ITAB-PERNR < 1111.
ITAB-ICON = '@08@'.
ELSEIF ITAB-PERNR > 1111 AND ITAB-PERNR < 11111111.
ITAB-ICON = '@09@'.
ELSEIF ITAB-PERNR GE 11111111.
ITAB-ICON = '@0A@'.
ENDIF.
MODIFY ITAB INDEX SY-TABIX.
ENDLOOP.
endform. " fill_itab
*& Form display_alv
text
--> p1 text
<-- p2 text
form display_alv .
data repid like sy-repid.
REPID = SY-REPID.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
WA_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL'.
WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
IF P_GRID = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
IT_FIELDCAT = IT_FIELDTAB
IT_SORT = IT_SORT
IS_LAYOUT = WA_LAYOUT
TABLES
t_outtab = itab[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
message e016 with 'Error in Display'.
ENDIF.
ELSEIF P_LIST = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
IT_FIELDCAT = IT_FIELDTAB
IT_SORT = IT_SORT
IS_LAYOUT = WA_LAYOUT
TABLES
t_outtab = itab[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
message e016 with 'Error in Display'.
ENDIF.
ENDIF.
endform. " display_alv
*& Form fill_fieldcat1
text
--> p1 text
<-- p2 text
form fill_fieldcat1 changing d_fcat type slis_t_fieldcat_alv.
data repid like sy-repid.
data d_fcat1 type slis_t_fieldcat_alv with header line.
REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = repid
I_INTERNAL_TABNAME = 'ITAB'
I_STRUCTURE_NAME = 'ZGILL_MAIN'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = d_fcat[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF sy-subrc <> 0.
message e016 with 'Error in preparing fiedl catalog'.
ENDIF.
loop at d_fcat into d_fcat1.
case d_fcat1-fieldname.
when 'NAME'.
d_fcat1-reptext_ddic = 'Emp Name'.
MODIFY D_FCAT FROM D_FCAT1.
WHEN 'PERNR'.
d_fcat1-reptext_ddic = 'Emp Num'.
MODIFY D_FCAT FROM D_FCAT1.
WHEN 'ORG'.
d_fcat1-reptext_ddic = 'Org Unit'.
MODIFY D_FCAT FROM D_FCAT1.
endcase.
clear d_fcat1.
endloop.
endform. " fill_fieldcat1
*& Form sort_list
text
--> p1 text
<-- p2 text
form sort_list .
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'DOB'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'NAME'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
endform. " sort_list
*& Form fill_fieldcat
text
--> p1 text
<-- p2 text
form fill_fieldcat .
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'ICON'.
WA_FIELDCAT-SELTEXT_L = 'TRAFFIC'.
WA_FIELDCAT-ICON = 'X'.
WA_FIELDCAT-ddictxt = 'l'.
WA_FIELDCAT-COL_POS = 1.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'PERNR'.
WA_FIELDCAT-SELTEXT_L = 'EMP NUMBER'.
WA_FIELDCAT-ddictxt = 'l'.
WA_FIELDCAT-COL_POS = 2.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
when 'maktx'.
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'NAME'.
WA_FIELDCAT-SELTEXT_L = 'EMP NAME'.
WA_FIELDCAT-ddictxt = 'l'.
WA_FIELDCAT-COL_POS = 3.
WA_FIELDCAT-OUTPUTLEN = 15.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'ORG'.
WA_FIELDCAT-SELTEXT_L = 'ORG UNIT'.
WA_FIELDCAT-COL_POS = 4.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'DOB'.
WA_FIELDCAT-SELTEXT_L = 'BIRTH DATE'.
WA_FIELDCAT-COL_POS = 5.
WA_FIELDCAT-OUTPUTLEN = 12.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'SALARY'.
WA_FIELDCAT-SELTEXT_L = 'SALARY'.
WA_FIELDCAT-COL_POS = 6.
WA_FIELDCAT-OUTPUTLEN = 25.
WA_FIELDCAT-do_sum = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
endform. " fill_fieldcat -
How to create Multiple Selection Screen in ALV
Hi,
Can anybody tell me how to create the Multiple Selection screen in ALV reports.
Plse give me code sample if possible.
Thanks in advance
KPHi Rich,
thanks for the reply.
I am creating a report. in that for one field, i need to create a multiple selection screen. i mean in the output screen , i need to get the multiple selection screen for that field. in that i should be able to select multiple values, or single values or range of values.
eg: if i take the field kunnr, i should be able to select the multiple kunnar values in the output screen.
Hope my problem is understood.
Thanks
KP -
Currency wise grand totals IN ALV
Hi friends,
I have problem in alv report, my requirement is want to display the
currency wise grand totals in ALV Report.if any having this idea please
address the solution.
yours
ramakrishna.Yif i am not wrong then ithink you are talking about subtotal as per currency .
then you have to use sort fnality..
you have to write your fieldcat for currency value field
wfieldcat-do_sum = 'X'.
data : isort type slis_t_sortinfo_alv,
wsort type slis_sortinfo_alv.
wsort-spos = 1.
wsort-up = 'X'.
wsort-fieldname = ' YOUR CURRency key field in caps'.
wsort-group = 'UL'.
append wsort to isort.
you have to pass that to reuse alv fm it_sort = isort.
regards
shiba dutta -
Suppressing some subtotals in an ALV grid
Hi,
Does anyone know if it is possible to suppress some of the subtotals in an ALV grid? In some cases I have redundant subtotals, and I would like to suppress one of them. I am using the event SUBTOTAL_TEXT, and this is not something I can control with the sort order.
Thanks,
Margaret Brooker.Hi Margaret,
You might want to take a look at the Development Class (Package) in the Object Navigator (SE80) called SLIS.
There you will find excellent ALV demo programs that illustrate many possible customizations to the Alv grid.
Although there is not an exact supress subtotal example, you could probably create your own pushbuttons or events to embed your own logic.
It is possible to create a local class and implement a double click event, which could delete a duplicate line or any other preferred logic that you code.
cheers,
Marilyn -
hi,
i am making report in alv in which i have to display the sub totals and den full total.
is it possible to display sub total in ALV acccording to material type wise or itemid wise.
plzz help me with some example.
If find useful he or she will definately rewarded.........Hi,
The following example for sub totall for ALV report..
u have to pass do_sum = 'X'. for perticuler fileds.
if it is use full answer reward me a points..
*& Report ZDEL_ALV1
*Description: This ALV interactive report is display Delivary
status
REPORT zdel_alv1 NO STANDARD PAGE HEADING LINE-SIZE 255 LINE-COUNT 60.
*TABLE DECLARATION
TABLES : likp, "Delivery Header Data
lips, "Delivery item Data
vbup. "sales document item status
TYPE-POOLS : slis.
*SRUCTURE DECLARATION
*THIS TABLE FOR HEADER DETAILS
TYPES : BEGIN OF t_likp ,
vbeln LIKE likp-vbeln, "Delivery number
kosta like vbup-kosta,
kunnr LIKE likp-kunnr, "Customer number
wadat LIKE likp-wadat, "Planned goods movement date
ernam LIKE likp-ernam, "Name of person
vkorg LIKE likp-vkorg, "Sales organization
lfart LIKE likp-lfart, "DELIVERY TYPE
ntgew LIKE likp-ntgew, "NET WEIGHT
END OF t_likp.
*THIS TABLE FOR ITEM DETAILS
TYPES : BEGIN OF t_lips ,
vbeln LIKE lips-vbeln, "Delivery number
posnr LIKE lips-posnr, "delivery item
matnr LIKE lips-matnr, "Material number
lfimg LIKE lips-lfimg, "Actual quantity delivered
ntgew LIKE lips-ntgew, "Net weight
exbwr LIKE lips-exbwr, "Externally entered posting amount
arktx LIKE lips-arktx, "Short text SO Item
END OF t_lips.
*THIS IS FOR FINAL OUTPUT
TYPES : BEGIN OF t_vbup ,
vbeln LIKE likp-vbeln, "Delivery number
kosta LIKE vbup-kosta, "Picking status/Putaway status
posnr LIKE vbup-posnr, "delivery item
matnr LIKE lips-matnr, "Material number
lfimg LIKE lips-lfimg, "Actual quantity delivered
ntgew LIKE lips-ntgew, "Net weight
exbwr LIKE lips-exbwr, "Externally entered posting amount
arktx LIKE lips-arktx, "SHORT text SO Item
description(20), "for display text
END OF t_vbup.
*INTERNAL TABLES
DATA : i_likp TYPE STANDARD TABLE OF t_likp.
DATA : i_lips TYPE STANDARD TABLE OF t_lips.
DATA : i_vbup TYPE STANDARD TABLE OF t_vbup.
DATA : repid LIKE sy-repid.
DATA : delivar1(10) TYPE c.
*WORK AREA
DATA : wa_likp TYPE t_likp.
DATA : wa_lips TYPE t_lips.
DATA : wa_vbup TYPE t_vbup.
DATA: i_vbup1 LIKE wa_vbup OCCURS 0 WITH HEADER LINE.
*SLIS TABLE DECLARATIONS
DATA: i_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
i_events TYPE slis_t_event,
w_events TYPE slis_alv_event,
i_fieldcat1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
i_layout TYPE slis_layout_alv.
*SELECTING RANGE OF VALUES
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_vbeln FOR likp-vbeln,
s_kunnr FOR likp-kunnr,
s_wadat FOR likp-wadat.
SELECTION-SCREEN END OF BLOCK b1 .
*CHOOSE ONE CHECK BOX FOR DISPLAYING THE DELIVARY STATUS
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS : cb_kostc AS CHECKBOX,"DEFAULT 'X',
cb_kosta AS CHECKBOX,
cb_kostb AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b2.
*INTIALIZATION CHECK
INITIALIZATION.
repid = sy-repid.
*START-OF-SELECTION
START-OF-SELECTION.
PERFORM get_data.
PERFORM get_field.
PERFORM GET_EVENTS.
PERFORM display.
*END-OF-SELECTION
END-OF-SELECTION.
*& Form RUCOMM
This form getting details from lips table for displaying
the item details and all select statements for delivary status
-->R_UCOMM text
-->RS_SELFIELDtext
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
slis_selfield.
IF rs_selfield-fieldname = 'VBELN'.
delivar1 = rs_selfield-value.
ENDIF.
IF cb_kostc = 'X'.
SELECT VBELN KOSTA FROM VBUP
INTO TABLE I_VBUP
WHERE VBELN IN DELIVAR
AND KOSTA = 'C'.
SELECT VBELN MATNR LFIMG EXBWR INTO TABLE I_LIPS FROM LIPS
WHERE VBELN EQ DELIVAR1.
REFRESH i_vbup1[].
CLEAR i_vbup1.
SELECT avbeln akosta bposnr bmatnr blfimg bntgew b~exbwr
b~arktx
INTO TABLE i_vbup
FROM vbup AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~vbeln EQ delivar1
AND kosta = 'C'.
ELSEIF cb_kosta = 'X'.
SELECT VBELN KOSTA FROM VBUP
INTO TABLE I_VBUP
WHERE VBELN IN DELIVAR
AND KOSTA = 'A'.
SELECT avbeln akosta bposnr bmatnr blfimg bntgew b~exbwr
b~arktx
INTO TABLE i_vbup
FROM vbup AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~vbeln EQ delivar1
AND kosta = 'A'.
ELSEIF cb_kostb = 'X'.
SELECT VBELN KOSTA FROM VBUP
INTO TABLE I_VBUP
WHERE VBELN IN DELIVAR
AND KOSTA = 'B'.
SELECT avbeln akosta bposnr bmatnr blfimg bntgew b~exbwr
b~arktx
INTO TABLE i_vbup
FROM vbup AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~vbeln EQ delivar1
AND kosta = 'B'.
ENDIF.
CLEAR i_vbup1.
LOOP AT i_vbup INTO wa_vbup.
i_vbup1-vbeln = wa_vbup-vbeln.
i_vbup1-kosta = wa_vbup-kosta.
IF wa_vbup-kosta = 'C'.
i_vbup1-description = 'COMPLETELY PROCESSED'.
ELSEIF wa_vbup-kosta = 'B'.
i_vbup1-description = 'PARTIALLY PROCESSED'.
ELSEIF wa_vbup-kosta = 'A'.
i_vbup1-description = 'NOT YET PROCESSED'.
ENDIF.
i_vbup1-posnr = wa_vbup-posnr.
i_vbup1-matnr = wa_vbup-matnr.
i_vbup1-lfimg = wa_vbup-lfimg.
i_vbup1-ntgew = wa_vbup-ntgew.
i_vbup1-exbwr = wa_vbup-exbwr.
i_vbup1-arktx = wa_vbup-arktx.
APPEND i_vbup1 .
ENDLOOP.
SORT i_vbup1 BY vbeln matnr lfimg.
DELETE ADJACENT DUPLICATES FROM i_vbup1 COMPARING vbeln matnr lfimg.
SELECT VBELN MATNR LFIMG EXBWR INTO TABLE I_LIPS FROM LIPS
WHERE VBELN EQ DELIVAR1.
*This function module for displaying the item details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
it_fieldcat = i_fieldcat1[]
i_callback_top_of_page = 'TOP_OF_PAGE'
i_callback_user_command = 'USER_COMMAND1'
it_events = i_events
TABLES
t_outtab = i_vbup1
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.
CLEAR i_vbup1.
ENDFORM. "RUCOMM
*& Form USER_COMMAND1
text
-->R_UCOMM1 text
-->RS_SELFIELDtext
FORM user_command1 USING r_ucomm1 LIKE sy-ucomm rs_selfield1 TYPE
slis_selfield.
DATA: deliv(10) TYPE c.
IF rs_selfield1 = 'VBELN'.
deliv = rs_selfield1-value.
ENDIF.
SET PARAMETER ID 'VL' FIELD delivar1.
CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
ENDFORM. "USER_COMMAND1
*& Form GET_DATA
This form for getting the data from likp table
--> p1 text
<-- p2 text
FORM get_data .
SELECT VBELN KUNNR WADAT FROM LIKP INTO TABLE I_LIKP
WHERE VBELN IN S_VBELN
AND KUNNR IN S_KUNNR
AND WADAT IN S_WADAT.
REFRESH i_likp[].
CLEAR i_likp.
IF cb_kostc = 'X' AND cb_kosta = ' ' AND cb_kostb = ''.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND a~kosta = 'C'.
ELSEIF cb_kosta = 'X' AND cb_kostb = ' ' AND cb_kostc = ''.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND a~kosta = 'A'.
ELSEIF cb_kostb = 'X' AND cb_kosta = '' AND cb_kostc = ''.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND kosta = 'B'.
ELSEIF cb_kostc = 'X' AND cb_kosta = 'X' AND cb_kostb = 'X'.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND kosta NE ' '.
ENDIF.
DELETE ADJACENT DUPLICATES FROM i_likp.
ENDFORM. " GET_DATA
*& Form GET_FIELD
This form for defining the every fields from likp & lips tables
FORM get_field .
*This fields are retrieving from header table(likp)
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'VBELN'.
i_fieldcat-seltext_m = 'SALES ORDER NO'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'KUNNR'.
i_fieldcat-seltext_m = 'CUSTOMER NO'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'WADAT'.
i_fieldcat-seltext_m = 'DATE'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'ERNAM'.
i_fieldcat-seltext_m = 'NAME OF PERSON'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'VKORG'.
i_fieldcat-seltext_m = 'SALES ORGANIZATION'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'LFART'.
i_fieldcat-seltext_m = 'DELIVERY TYPE'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'NTGEW'.
i_fieldcat-seltext_m = 'NET WEIGHT'.
i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
*This fields are retrieving from item table(lips)
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'VBELN'.
i_fieldcat1-seltext_m = 'DELIVAR NO'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'POSNR'.
i_fieldcat1-seltext_m = 'DELIVERY ITEM'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'MATNR'.
i_fieldcat1-seltext_m = 'MATERIAL NO'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'LFIMG'.
i_fieldcat1-seltext_m = 'ACTUAL QUANTITY'.
i_fieldcat1-do_sum = 'X'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'NTGEW'.
i_fieldcat1-seltext_m = 'NET WEIGHT'.
i_fieldcat1-do_sum = 'X'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'EXBWR'.
i_fieldcat1-seltext_m = 'AMOUNT'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'ARKTX'.
i_fieldcat1-seltext_m = 'SHORT TEXT FOR so ITEM'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'DESCRIPTION'.
i_fieldcat1-seltext_m = 'PICKING STATUS'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
ENDFORM. " GET_FIELD
*& Form GET_EVENTS
This form defining the events
*FORM GET_EVENTS .
CLEAR W_EVENTS.
W_EVENTS-NAME = 'USER_COMMAND'.
W_EVENTS-FORM = 'RUCOMM'.
APPEND W_EVENTS TO I_EVENTS.
*ENDFORM. " GET_EVENTS
*& Form DISPLAY
This form is going to display header details from likp table
FORM display .
*This function module for displaying the header details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = i_fieldcat[]
i_save = 'X'
it_events = i_events
TABLES
t_outtab = i_likp
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
This form is going to display top-of-page header text
FORM top-of-page.
DATA: i_list_comments TYPE slis_t_listheader.
DATA: w_list_comments TYPE slis_listheader.
CLEAR: i_list_comments[].
w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action
w_list_comments-info = 'DELIVERY ORDER DETAILS'.
APPEND w_list_comments TO i_list_comments.
w_list_comments-typ = 'A'. " H = Header, S = Selection, A = Action
w_list_comments-info = 'Basic list'.
APPEND w_list_comments TO i_list_comments.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'enjoy'
it_list_commentary = i_list_comments.
ENDFORM. "TOP-OF-PAGE
*& Form TOP_OF_PAGE
This form is going to display top-of-page item text
FORM top_of_page.
DATA: i_list_comments TYPE slis_t_listheader.
DATA: w_list_comments TYPE slis_listheader.
DATA : i_line LIKE w_list_comments-info.
CONCATENATE 'DELIVERY ITEM DETAILS :' delivar1 INTO i_line .
SEPARATED BY SPACE.
CLEAR: i_list_comments[].
w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action
w_list_comments-info = i_line.
APPEND w_list_comments TO i_list_comments.
w_list_comments-typ = 'A'. " H = Header, S = Selection, A = Action
w_list_comments-info = 'Secondary list'.
APPEND w_list_comments TO i_list_comments.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'enjoy'
it_list_commentary = i_list_comments.
ENDFORM. "TOP_OF_PAGE -
Multiple checkbox selection in ALV and updating internal table
Dear Expert,
Can anyone tell me how to handle the multiple checkbox selection in ALV Grid report and then updating the internal table.
I tried the option but it works only when i select only 1 row in ALV.
DO L_LINES TIMES.
read table icoas index rs_selfield-tabindex.
if sy-subrc = 0.
ICOAS-NOCHK = 'X'.
modify ICOAS INDEX rs_selfield-tabindex TRANSPORTING NOCHK.
ENDIF.
ENDDO.
Requires help....
Regards & Thanx,
Bhupathi.Hi,
Use this method to capture the check box event. Write this once you create your grid using CREATE OBJECT grid1.
DATA: GRID1 TYPE REF TO CL_GUI_ALV_GRID,
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
EXCEPTIONS
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.
LOOP AT T_GRIDDETAILS INTO WA_GRIDDETAILS.
IF WA_GRIDDETAILS-CHECKBOX = 'X'.
"Do your operation
ENDIF.
CLEAR WA_GRIDDETAILS.
ENDLOOP. -
Total in ALV List (own calculation)
Hi All,
do you know how to display total in ALV List which calculated by me ?
Previously I am using Before Line Output event ?
I dont know why it's not working now (see the code below)? Now it is always overrided by standard sum calculation. Please help me.
Thank you in advance.
Sandi
FORM ALV_BEFORE_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO.
IF RS_LINEINFO-endsum = 'X'.
I_DATA-PERFORMANCE = L_AVG.
"MODIFY I_DATA INDEX RS_LINEINFO-SUMINDEX.
ENDIF.
ENDFORM.Hi All,
do you know how to display total in ALV List which calculated by me ?
Previously I am using Before Line Output event ?
I dont know why it's not working now (see the code below)? Now it is always overrided by standard sum calculation. Please help me.
Thank you in advance.
Sandi
FORM ALV_BEFORE_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO.
IF RS_LINEINFO-endsum = 'X'.
I_DATA-PERFORMANCE = L_AVG.
"MODIFY I_DATA INDEX RS_LINEINFO-SUMINDEX.
ENDIF.
ENDFORM. -
Hi All.
I am trying to set multiple selection on in ALV using the method SET_SELECTION_MODE of IF_WD_SELECT_OPTIONS. (if_salv_wd_table_settings)
But it is always resulting in a dump saying that :
Selection type Multi is not allowed in combination with the selection Single of the data node
Now how can we change the context of the ALV?
What am i doing wrong here?
Thanks.Hi this works fine here:
data: lr_table_settings type ref to if_salv_wd_table_settings.
lr_table_settings->set_read_only( abap_false ).
lr_table_settings->set_enabled( abap_true ).
lr_table_settings->set_selection_mode( CL_WD_TABLE=>e_selection_mode-multi ).
The node i bound to the ALV has selection 0..n.
Cheers,
Sascha
Maybe you are looking for
-
Crystal report addon prompt database login screen
I'm trying to run a crystal report using crystal report add-on 1.0 from SAP, however, I always see the screen that prompts for database login when trying to generate the report.
-
I have a turnkey desktop computer dedicated for photography and video use only. Below is a listing of tech points about the computer. I operate with Adobe Creative Suite 6 Master Collection. Also installed is Lightroom 4. I played around with the
-
[Solved - KDE 4.6] No desktop effects, but still have 3D render
I have an nvidia graphics card, with the nvidia binary driver installed, and everything worked smoothly, until I updated to Kde4.6 just now. After a few seconds where everything looked normal (desktop effects enabled just as before), the screen went
-
How do i get my library from one computer to another?
My iTunes library is on an older PC that I don't use anymore. I want to move the files to my newer computer. The older computer will NOT connect to the internet... The two computers are close to each other. I'm wondering if I can set up a network wit
-
Text messages and calls not received???
ever since i updated my phone to iOS 4, i've experienced "late" smses, where i receive messages 2 to 3 hours after my friends sent them, and even receiving the messages only after i restart the phone. also, just yesterday, my friends couldn't reach m