Total in ALV Grid
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 guide
See 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
Similar Messages
-
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 -
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 -
Hi all,
When displaying totals in a column of an ALV Grid (objects methodology) my totals are split. For example, if I have 5 rows with values in the column being summed of 100, 20, 300, 40 and 500; I end up with 3 total lines at the end of the list of 120, 300 and 540. The column being summed is a QUAN field (EKPO-MENGE). I have tried the NO_UTSPLIT parameter in the layout, and have tried referencing the UoM in the fieldcatalog for the field being summed with no success. Any ideas?
Regards,
RandyHi
As amit said, sum of the field is triggered at other fields, you can change in the output of this ALV list,
if have the GUI status as STANDARD or MAIN,
you will get the following in the menu bar, prerequest before,
1. u should have a sum field in the outlist.
2. u should have subtotal.
Now follow the steps in the menu,
1. Go to setting --> Choose Summary level --> Define drildown.
Now u can change the sub total level based on the sort conditions.
Regards,
prabhu rajesh. -
How to divide 2 columns totals in ALv grid
Hi All,
i developed alv report & displayed totals. now i need to divide those totals and display as another column total.
anyone please suggest.
col1 col2 col3
tot1 tot2 tot3
tot3 = tot2 / tot1.
thanks,Hi,
For this, in HTML_TOP_OF_PAGE or TOP_OF_PAGE first you need to get global reference variable for GRID
for getting reference call FM GET_GLOBALS_FROM_SLVC_FULLSCR.
By using this reference call method GET_SUBTOTALS it will get the all total into Internal Table .
Using Field Symbols u can calculate. Still u have any problem i will help u further .
Regards,
Ravindra. -
Insert a new total line - ALV GRID
Hi Experts!
I need to insert a new total line in a ALV. I'm using the class CL_GUI_ALV_GRID. The total's line "normal" is displayed right, but I want to insert a new total line and that line will receive the total entries number.
Can u help me, please?
I'll reward points!
Best Regards,
Caíque Escaler
Edited by: Caíque Escaler on Feb 8, 2008 6:07 PMPlease check program BCALV_GRID_VERIFY
May this will help you out.
a® -
Totas and sub totals in ALV grid display
Hi all,
how can I get the total for an integer field in internal table. I am using the following code, but unable to display the total. Can anyone give the reason for the same.
Thank you,
Usha
REPORT ZTEST_SUB .
TABLES : vbak.
TYPE-POOLS: slis.
SELECT-OPTIONS : s_vkorg FOR vbak-vkorg,
s_kunnr FOR vbak-kunnr,
s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN : SKIP,
BEGIN OF LINE,
COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '2' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
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.
DATA: BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg,
kunnr LIKE vbak-kunnr,
vbeln LIKE vbak-vbeln,
test type I,
END OF gt_vbak.
START-OF-SELECTION.
PERFORM f_read_data.
loop at gt_vbak.
gt_vbak-test = 1.
modify gt_vbak.
endloop.
PERFORM f_display_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.
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-ref_FIELDname = &2.
ls_fieldcat-do_sum = &3.
ls_fieldcat-cfieldname = &4.
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.
ls_sort-group = '*'.
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' 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' '' ''.
m_fieldcat 'VBELN' '' '' ''.
m_fieldcat 'TEST' '' 'X' ''.
m_sort 'VKORG' ''.
m_sort 'KUNNR' ''.
m_sort 'VBELN' ''.
m_sort 'TEST' 'X'.
ls_layout-cell_merge = 'X'.
LS_LAYOUT-WINDOW_TITLEBAR = 'test window'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = ls_layout
IT_FIELDCAT = lt_fieldcat
IT_SORT = lt_sort
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = gt_vbak
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.hi
REPORT ZTEST_SUB .
TABLES : vbak.
TYPE-POOLS: slis.
SELECT-OPTIONS : s_vkorg FOR vbak-vkorg,
s_kunnr FOR vbak-kunnr,
s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN : SKIP,
BEGIN OF LINE,
COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '2' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
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.
DATA: BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg,
kunnr LIKE vbak-kunnr,
vbeln LIKE vbak-vbeln,
test type I,
END OF gt_vbak.
START-OF-SELECTION.
PERFORM f_read_data.
loop at gt_vbak.
gt_vbak-test = 1.
modify gt_vbak.
endloop.
PERFORM f_display_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.
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-ref_FIELDname = &2.
ls_fieldcat-do_sum = &3.
ls_fieldcat-cfieldname = &4.
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.
ls_sort-group = '*'.
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' 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' '' ''.
m_fieldcat 'VBELN' '' '' ''.
m_fieldcat 'TEST' '' 'X' ''.
m_sort 'VKORG' ''.
m_sort 'KUNNR' ''.
<b> m_sort 'VBELN' 'X'.</b>
*m_sort 'TEST' 'X'.
ls_layout-cell_merge = 'X'.
LS_LAYOUT-WINDOW_TITLEBAR = 'test window'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = ls_layout
IT_FIELDCAT = lt_fieldcat
IT_SORT = lt_sort
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = gt_vbak
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.
Message was edited by: Ashok Parupalli -
Subtotal in ALV grid for a particular type and Grand total in ALV
Hi,
I need to have sub total for a particular type(eg: goods, services).. and grand total at end in ALV grid..
ALV output required as below:
Type VAT registration number Country Total Gross Amounts Total Tax Amounts Total Amount, ex-tax
Goods ATU12345678 AT 222.42 0 222.42
Goods NL123456789B02 NL 3,417.00 0 3,417.00
Goods Total 3,639.42 - 3,639.42
Services ATU12345678 AT 2,342.34 0 2,342.34
Services NL123456789B02 NL 223.33 0 223.33
Services Total 2,565.67 - 2,565.67
Grand Total 6,205.09 - 6,205.09
Let me as to how to achieve the above type in ALV grid...
Regards
Shivacheck this link..
Grand Totals in ALV grid disply function module
or do like this..
REPORT ZALVTESTFORSUBTOTAL.
tables:pa0008.
type-pools:slis.
types:begin of ty_pa0008,
pernr like pa0008-pernr,
begda like pa0008-begda,
endda like pa0008-endda,
ansal like pa0008-ansal,
lga01 like pa0008-lga01,
bet01 like pa0008-bet01,
end of ty_pa0008.
data:it_pa0008 type standard table of ty_pa0008 with header line.
data:it_fieldcat type SLIS_T_FIELDCAT_ALV,
wa_fieldcat type slis_fieldcat_alv,
it_layout type slis_layout_alv,
WA_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
select-options:s_pernr for pa0008-pernr.
start-of-selection.
perform getD_data.
perform disp_alv.
*& Form getD_data
text
--> p1 text
<-- p2 text
form getD_data .
select pernr
begda
endda
ansal
lga01
bet01
from pa0008
into table it_pa0008
where pernr in s_pernr.
sort it_pa0008 by pernr begda descending.
endform. " getD_data
*& Form disp_alv
text
--> p1 text
<-- p2 text
form disp_alv .
wa_fieldcat-fieldname = 'PERNR'.
wa_FIELDCAT-REPTEXT_DDIC = 'Personnel no'.
*WA_FIELDCAT-no_subtotals = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BEGDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'Start date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENDDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'End date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ANSAL'.
wa_FIELDCAT-REPTEXT_DDIC = 'Annula salary'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'LGA01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Wage Type'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BET01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Amount for wagetype'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
DATA: sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv.
sort-fieldname = 'PERNR'.
sort-subtot = 'X'.
SORT-UP = 'X'.
APPEND sort TO it_sort.
*sort-fieldname = 'BEGDA'.
*SORT-NO_SUBTOTS = 'X'.
*APPEND sort TO it_sort.
IT_layout-totals_text = 'total text'.
IT_layout-subtotals_text = 'Subtotal text'.
*WA_EVENTS-NAME = 'SUBTOTAL TEXT'.
*WA_EVENTS-FORM = 'SUBTOTAL TEXT'.
*APPEND WA_EVENTS TO IT_EVENTS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = it_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_sort = it_sort
it_events = it_events
TABLES
t_outtab = it_pa0008 .
endform. " disp_alv -
Total problem in Exporting ALV GRID to Excel
Hi all,
I have manipulated the Total of ALV Grid by using GET_SUBTOTALS and REFRESH method of CL_GUI_ALV_GRID. The ALV Output is also correct. When i export to Excel,only the Original total is displaying not the calculated one. How to download the exact output which is displaying in the ALV Grid to Excel.
Please help me out to solve this.
Thanks,
RameshDEAR,
AS U WANT UPLOAD WITH THE SUB TOTAL YOU TRY THIS.
FIRST to get subtotal in ALV output you select at least one column of total and then press ctrl + F6 . u will see the sub total .
and now how to download it so press ctrl + shift + F9 .
now screen appears and select second option ie spreadsheet and press enter
now a screen appear in wich u have to give file name.
so double click on search button of file name . click on desktop give ur file name as u want suppose zreport u have given.
and save type = excel file.
now save it and then generate it your output bytes will be transmitted .
now u can see in your desktop in your file name . ur output with subtotal.
regards
navin -
ALV Grid Subtotal text and Total text display
Hello ABAPGuru's
I want to display the subtotal and Total texts. alv grid program runing on background.
Regards
Sweety(Sri)Hello Neil,
Here I have attached my routines.anyway my confusion. I have wrote the routine subtotal_text .but i am not passing ALV GRID FM.
*& Form eventtab_build
&---- This is used to get the list of events
---- <--RI_EVENTS Internal table
FORM eventtab_build CHANGING ri_events TYPE slis_t_event.
Structure for event handling.
DATA: rs_event TYPE slis_alv_event.
Returns table of possible events for a list type.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = ri_events. " Table of events to perform
Read the internal table with the TOP_OF_PAGE and move the
form name to the internal table
READ TABLE ri_events
WITH KEY name = slis_ev_top_of_page INTO rs_event.
IF sy-subrc = 0.
MOVE c_formname TO rs_event-form. " Form name
MODIFY ri_events FROM rs_event
INDEX sy-tabix. " Top of page event
ENDIF.
READ TABLE ri_events
WITH KEY name = slis_ev_end_of_page INTO rs_event.
IF sy-subrc = 0.
MOVE c_form_eop_name TO rs_event-form. " Form name
MODIFY ri_events FROM rs_event
INDEX sy-tabix. " Top of page event
ENDIF.
READ TABLE ri_events
WITH KEY name = slis_ev_subtotal_text INTO rs_event.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO rs_event-form. " Formname
MODIFY ri_events FROM rs_event
INDEX sy-tabix. " Top of page event
ENDIF.
*&-- Delete all unneeded events:
DELETE ri_events WHERE form IS INITIAL.
ENDFORM. " eventtab_build
*& Form SUBTOTAL_TEXT
text
--> p1 text
<-- p2 text
FORM SUBTOTAL_TEXT USING ep_subtot_line TYPE type_data
e_event_data TYPE slis_subtot_text.
IF NOT e_event_data-criteria IS INITIAL.
E_EVENT_DATA-DISPLAY_TEXT_FOR_SUBTOTAL = 'Account Total'.
ENDIF.
ENDFORM. "SUBTOTAL_TEXT
*& Form initialise_layout
Initialise Layout
FORM initialise_layout .
i_layout-colwidth_optimize = c_x.
i_layout-group_change_edit = c_x.
*i_layout-subtotals_text = ' a'.
i_layout-detail_popup = c_x.
i_layout-zebra = c_x.
i_layout-no_vline = 'X'.
i_layout-no_hline = 'X'.
i_layout-totals_text = 'Account Total'.
ENDFORM. " initialise_layout
Call the function module to display the report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_program
i_callback_top_of_page = 'TOP_OF_PAGE' "Top Of Page
is_layout = i_layout
it_fieldcat = i_fieldtab
it_sort = i_sort
it_events = i_events " Events
is_print = i_print
i_default = c_x
i_save = c_save
is_variant = v_variant
TABLES
t_outtab = i_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards
Sweety (Sri) -
Mix AVG and Total for the same column in ALV grid
Hi,
We are using CL_GUI_ALV_GRID=>SET_TABLE_FOR_FIRST_DISPLAY, and I'd like to know if the following situation is possible.
Let's say we have a column which contains a number of hours, and we set it up to subtotal by period, but as an average rather than a total (DO_SUM = "C"). This is not a problem so far.
The problem is that we'd like for the "Grand Total" at the bottom of the ALV grid to total all of the subtotal averages, instead of calculating an average.
Ex:
Period Hours
2010/01 6.0
2010/02 7.0
2010/03 2.0
5.0 (This is an average... 6.0 + 7.0 + 2.0 / 3)
2011/01 12.0
2011/02 5.0
2011/03 4.0
7.0 (This is an average... 12.0 + 5.0 + 4.0 / 3)
12.0 (We want this to be a total of 5.0 + 7.0)
So we want the "grand total" line to be 12.0 which is the sum, but it currently comes out as an average.
Therefore we're looking to average at the sub total level, but we want a total of the subtotal levels at the grand total level for the same column.
Thanks,
DenisRefer to the suggestion given by Naimesh here Can we modify a sub-total in ALV making use of function GET_GLOBALS_FROM_SLVC_FULLSCR and the method GET_SUBTOTALS. You can see the parameter ep_collect01 refered in case of subtotals. Can you please check ep_collect00 for grand total in your case.
As said about EP_COLLECT00,here goes a classic example Modify grand total in ALV GRID
BR
Keshav
Edited by: Keshav.T on Sep 21, 2011 9:39 AM -
ALV Grid Control - Modifiy data in total and subtotal lines
Hello all,
I´am creating a report using ALV Grid Control. This report calculates (using delivered and returned materials) for each vendor/material-combination the return quote.
Using the totals and subtotals function for different characteristics I want to calculate the return quote for the selected characteristic. Example:
Material delivered returned quote
..4711 . . . 500 . . . 5 . . . . 1 (=returned*100/delivered)
..4711 . . . 400 . . . 10 . . . . 2,5
. SUM . . . 900 . . . 15 . . . . 3,5 <-- 3,5 is the sum but I want display the calculated value 1,667
Is there a possibility to modify data in the total and subtotal lines.
Thank you for your answer
Best regards
Thomasyou said instead of 3.5 you want to show 1,667 ..
how is it possible...
3,5 become 1,667
i thought you are doing any conversions...
vijay -
Can i change the values in total column in ALV Grid program. I had made one report with 3 hirerchy level and for first hirerchy i need different total values just for one column as total values are misleading the users. is it possible to change the value total field in ALV?
hi
make the fields for which u r displaying total as editable.
so when ever u make changes in the column,
see the sample code, i have done a similar program
FORM DATA_CHANGED_MATRIX USING P_ER_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL P_ONF4 type C E_UCOMM TYPE SY-UCOMM.
DATA: VALUE LIKE YRECORDINGD_QDMS-SCORE.
CLEAR VALUE.
data: begin of wa_tot,
TOTAL_SCORE like yrecordingd_qdms-score,
end of wa_tot.
DATA: BEGIN OF WA_DATA,
SRNO type i,
LOCATION LIKE YCONCERNS_QDMS-LOCATION,
LOC_DESC LIKE YLOCATION_QDMST-LOC_DESC,
TOTAL_SCORE LIKE YRECORDINGD_QDMS-SCORE,
END OF WA_DATA.
FIELD-SYMBOLS: <LS_VALUE1> TYPE ANY,
<LS_VALUE2> TYPE ANY.
DATA: L_VALUE TYPE LVC_VALUE,
ls_mod_cell type lvc_s_modi.
SORT P_ER_DATA_CHANGED->MT_MOD_CELLS BY ROW_ID.
LOOP AT P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
EXPORTING
I_ROW_ID = LS_MOD_CELL-row_id
I_FIELDNAME = LS_MOD_CELL-fieldname
IMPORTING
E_VALUE = L_VALUE.
VALUE = L_VALUE.
IF VALUE < 100.
READ TABLE <TEMP_TAB> INTO <TEMP_WA> INDEX LS_MOD_CELL-ROW_ID.
MOVE-CORRESPONDING <TEMP_WA> TO WA_TOT.
WA_TOT-TOTAL_SCORE = WA_TOT-TOTAL_SCORE + VALUE.
MOVE-CORRESPONDING WA_TOT TO <TEMP_WA>.
MODIFY <TEMP_TAB> FROM <TEMP_WA> INDEX LS_MOD_CELL-ROW_ID.
CALL METHOD GO_GRID->REFRESH_TABLE_DISPLAY.
ELSE.
CLEAR WA_DATA.
ENDIF.
CLEAR:WA_TOT,VALUE.
ENDLOOP.
ENDFORM. -
Total for a Numeric field in ALV Grid display
Hi all,
I am not getting the Total for a Numeric field in ALV Grid output. What might be the problem.
Regards,
Balavardhan.KCheck this code for subtotals and totals..
REPORT ZYFI_REPT007
NO STANDARD PAGE HEADING
LINE-SIZE 300
LINE-COUNT 50
MESSAGE-ID ZYFI.
TABLES : COOI, " Commitments Management: Line Items
LFA1, " Vendor master (general section)
VBEP,
RKPLN.
TABLE TYPES AND INTERNAL TABLES *
DATA : BEGIN OF TYP_COOI ,
OBJNR LIKE COOI-OBJNR,
SAKTO LIKE COOI-SAKTO,
MEGBTR LIKE COOI-MEGBTR,
MEINH LIKE COOI-MEINH,
WKGBTR LIKE COOI-WKGBTR,
REFBN LIKE COOI-REFBN,
RFPOS LIKE COOI-RFPOS,
SGTXT LIKE COOI-SGTXT,
BUDAT LIKE COOI-BUDAT,
LIFNR LIKE COOI-LIFNR,
END OF TYP_COOI.
DATA : BEGIN OF TYP_LFA1 ,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF TYP_LFA1.
DATA : BEGIN OF IT_OUTTAB OCCURS 0,
OBJNR LIKE COOI-OBJNR,
SAKTO LIKE COOI-SAKTO,
MEGBTR LIKE COOI-MEGBTR,
MEINH LIKE COOI-MEINH,
WKGBTR LIKE COOI-WKGBTR,
REFBN LIKE COOI-REFBN,
RFPOS LIKE COOI-RFPOS,
SGTXT LIKE COOI-SGTXT,
BUDAT LIKE COOI-BUDAT,
LIFNR LIKE COOI-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF IT_OUTTAB.
DATA : IT_COOI LIKE TYP_COOI OCCURS 0 WITH HEADER LINE,
IT_LFA1 LIKE TYP_LFA1 OCCURS 0 WITH HEADER LINE.
*-- ALV Declarations
TYPE-POOLS SLIS.
DATA: IT_EVENTS TYPE SLIS_T_EVENT,
GS_EVENT TYPE SLIS_ALV_EVENT,
wa_fldcat type slis_fieldcat_alv.
DATA: S_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_PRINT TYPE SLIS_PRINT_ALV.
DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: IT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: V_REPID LIKE SY-REPID.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_KOKRS FOR COOI-KOKRS NO-EXTENSION NO INTERVALS,
" Controlling Area
S_BUKRS FOR COOI-BUKRS NO-EXTENSION NO INTERVALS,
" Company code
S_GJAHR FOR COOI-GJAHR NO-EXTENSION NO INTERVALS,
" Fiscal Year
S_OBJNR FOR RKPLN-AUFNR MATCHCODE OBJECT ORDE,
" Internal order
S_SAKTO FOR COOI-SAKTO MATCHCODE OBJECT KART,
" Cost Element
S_BUDAT FOR COOI-BUDAT, " Debit Date
S_LIFNR FOR COOI-LIFNR. " Vendor
SELECTION-SCREEN END OF BLOCK B1.
S T A R T O F S E L E C T I O N *
START-OF-SELECTION.
*-- Read data
PERFORM GET_DATA.
E N D O F S E L E C T I O N *
END-OF-SELECTION.
*-- Process the data and prepare the output data
PERFORM CALCULATE_FINAL_INFO.
*--Display Report output
PERFORM DISPLAY_REPORT.
FORM CALCULATE_FINAL_INFO *
Process the data and prepare final internal table *
FORM CALCULATE_FINAL_INFO.
DATA : L_OBJNR LIKE COOI-OBJNR.
SORT IT_LFA1 BY LIFNR.
DELETE ADJACENT DUPLICATES FROM IT_LFA1 COMPARING LIFNR.
LOOP AT IT_COOI.
L_OBJNR = IT_COOI-OBJNR+2(20).
SHIFT L_OBJNR LEFT DELETING LEADING '0'.
IF L_OBJNR IN S_OBJNR.
READ TABLE IT_LFA1 WITH KEY LIFNR = IT_COOI-LIFNR.
IF SY-SUBRC EQ 0.
IT_OUTTAB-NAME1 = IT_LFA1-NAME1.
ENDIF.
MOVE-CORRESPONDING IT_COOI TO IT_OUTTAB.
CLEAR IT_OUTTAB-OBJNR.
IT_OUTTAB-OBJNR = L_OBJNR.
APPEND IT_OUTTAB.
CLEAR IT_OUTTAB.
CLEAR IT_LFA1.
CLEAR L_OBJNR.
ENDIF.
ENDLOOP.
ENDFORM.
*& Form GET_DATA
Fetch the Data from the table COOI and LFA1
FORM GET_DATA.
SELECT OBJNR
SAKTO
MEGBTR
MEINH
WKGBTR
REFBN
RFPOS
SGTXT
BUDAT
LIFNR
FROM COOI
INTO TABLE IT_COOI
WHERE BUDAT IN S_BUDAT
AND LIFNR IN S_LIFNR
AND KOKRS IN S_KOKRS
AND BUKRS IN S_BUKRS
AND GJAHR IN S_GJAHR
AND SAKTO IN S_SAKTO.
IF SY-SUBRC EQ 0 .
Get the Vendor name from LFA1
SELECT LIFNR
NAME1
FROM LFA1
INTO TABLE IT_LFA1
FOR ALL ENTRIES IN IT_COOI
WHERE LIFNR EQ IT_COOI-LIFNR.
ELSE.
MESSAGE I999 WITH TEXT-013.
ENDIF.
ENDFORM. " GET_DATA
*& Form DISPLAY_REPORT
Display the output
FORM DISPLAY_REPORT.
PERFORM BUILD_CATALOG.
PERFORM FRM_PREPARE_EVENT_LIST TABLES IT_EVENTS.
IF NOT IT_OUTTAB[] IS INITIAL.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FLDCAT
IT_SORT = IT_SORT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = IT_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ELSE.
MESSAGE I999 WITH TEXT-013.
ENDIF.
ENDFORM. " DISPLAY_REPORT
*& Form BUILD_CATALOG
Build the Field catalog for the ALV Report
FORM BUILD_CATALOG.
DATA: V_INDEX LIKE SY-TABIX.
V_REPID = SY-REPID.
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_OUTTAB'
I_INCLNAME = V_REPID
CHANGING
CT_FIELDCAT = IT_FLDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
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 IT_FLDCAT WITH KEY FIELDNAME = 'WKGBTR'
TABNAME = 'IT_OUTTAB' INTO WA_FLDCAT.
IF SY-SUBRC EQ 0.
WA_FLDCAT-DO_SUM = 'X'.
MODIFY IT_FLDCAT FROM WA_FLDCAT INDEX SY-TABIX.
ENDIF.
READ TABLE IT_FLDCAT WITH KEY FIELDNAME = 'OBJNR'
TABNAME = 'IT_OUTTAB' INTO WA_FLDCAT.
IF SY-SUBRC EQ 0.
WA_FLDCAT-SELTEXT_L = 'Order'.
WA_FLDCAT-COL_POS = 1.
WA_FLDCAT-DDICTXT = 'L'.
MODIFY IT_FLDCAT FROM WA_FLDCAT INDEX SY-TABIX.
ENDIF.
LS_SORT-FIELDNAME = 'OBJNR'.
LS_SORT-SPOS = 1.
LS_SORT-UP = 'X'.
LS_SORT-SUBTOT = 'X'.
APPEND LS_SORT TO IT_SORT.
ENDFORM. " BUILD_CATALOG
*& Form FRM_PREPARE_EVENT_LIST
Build the Events
FORM FRM_PREPARE_EVENT_LIST TABLES IT_EVENTS TYPE SLIS_T_EVENT.
CLEAR GS_EVENT.
GS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
GS_EVENT-FORM = 'TOP_OF_PAGE_REPORT'.
APPEND GS_EVENT TO IT_EVENTS.
ENDFORM. " FRM_PREPARE_EVENT_LIST
TOP OF PAGE
FORM TOP_OF_PAGE_REPORT.
CALL FUNCTION 'Z_YREPORT_HEADER'
EXPORTING
DL_TITLE = SY-TITLE
DL_REPID = SY-CPROG
DL_LINSZ = SY-LINSZ
EXCEPTIONS
OTHERS = 1.
ENDFORM. " FRM_TOP_OF_PAGE_REPORT
*& Form USER_COMMAND
Drill Down Functionality to Call the Transaction ME23
FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM
P_SELFIELD TYPE SLIS_SELFIELD.
DATA : L_INDEX LIKE SY-INDEX,
L_REFBN LIKE COOI-REFBN.
L_INDEX = P_SELFIELD-TABINDEX. " holds the selected table index
CLEAR L_REFBN.
CASE P_UCOMM.
*-- On Double Click
WHEN '&IC1'.
CLEAR L_REFBN.
*-- Read the Current Line
READ TABLE IT_OUTTAB INDEX L_INDEX.
IF SY-SUBRC EQ 0.
L_REFBN = IT_OUTTAB-REFBN.
IF NOT L_REFBN IS INITIAL.
*-- Set the BES Paramater Id to the Current line Purchase Order Number
SET PARAMETER ID 'BES' FIELD L_REFBN.
*-- Call the Transaction Purchase Order Display with the above PO Number
CALL TRANSACTION 'ME23' AND SKIP FIRST SCREEN.
ENDIF.
ELSE.
MESSAGE E999 WITH TEXT-014.
ENDIF.
ENDCASE.
ENDFORM. " USER_COMMAND -
How to get Grand Total Text in ALV GRID
Hi Folks,
I am able to get the SUBTOTAL TEXT .....But i need...
How to get Grand Total Text in ALV GRID Display...
Can any one give a Solution for this...Hi Surendar,
Check out this code.. this is showing Total Text in Toal line in the very first column.
REPORT zsales_ord_det_1 .
TABLES: ztable_10.
TYPE-POOLS: slis.
DATA: BEGIN OF it OCCURS 0,
srno(6) type c,
name LIKE ztable_10-name,
age LIKE ztable_10-age,
END OF it.
DATA : BEGIN OF it_temp OCCURS 0,
name LIKE ztable_10-name,
age LIKE ztable_10-age,
END OF it_temp.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA: v_repid LIKE sy-repid,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
gs_layout TYPE slis_layout_alv,
gd_layout TYPE slis_layout_alv,
i_sort TYPE STANDARD TABLE OF slis_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
START-OF-SELECTION.
v_repid = sy-repid.
SELECT * FROM ztable_10 INTO TABLE it_temp.
LOOP AT it_temp .
it-srno = 'Total'.
it-name = it_temp-name.
it-age = it_temp-age.
APPEND it.
ENDLOOP.
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_internal_tabname = 'IT'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = i_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'SRNO'.
wa_fieldcat-tabname = it.
append wa_fieldcat to i_fieldcat.
LOOP AT i_fieldcat INTO wa_fieldcat.
IF wa_fieldcat-fieldname = 'AGE'.
wa_fieldcat-do_sum = 'X'.
MODIFY i_fieldcat FROM wa_fieldcat.
ENDIF.
IF wa_fieldcat-fieldname = 'SRNO'.
Hide this field so that it can display it's content i.e.
Total text in Subtotal level
wa_fieldcat-tech = 'X'.
wa_fieldcat-no_out = 'X'.
MODIFY i_fieldcat FROM wa_fieldcat TRANSPORTING tech no_out.
ENDIF.
ENDLOOP.
wa_sort-spos = 1.
wa_sort-fieldname = 'SRNO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort.
gd_layout-no_totalline = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND'
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 = gd_layout
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = i_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 = it
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.
Regards,
Seema
Maybe you are looking for
-
How can I get the "music" box visible on the iTunes Store settings?
I am trying to sync my music from my Mac Book pro to my iMac, (all updated and running with the latest software, this also includes iTunes) Support metions that in the iTunes store settings, there are three boxes that should be ticked off. Music, App
-
Error in document number while posting the material
Dear experts while posting the stock MB1C for the material the error is " incorrect doc number $ 1 .select doc number between 800000100 and 800000199. how to correct this error. where to check this number ranges of document. Thanks &
-
Collect funding at sales order item level
Hi all, Is there a FM or BAPI that will allow me to feed in a WBS element to retrieve a list of all sales orders and associated line items. I have a need to sum the funding at the sales order item level. Thanks, Mat
-
Process order scheduling based on in-house production time.
Hello! I have following problem. My SAP system is configured in that way that process oedrs are schedulled based on times saved in master recipies. When I input data to in-house production time in master data for materials and make new process order,
-
Hello, a customer of us, want to use one OIM as production and quality environment. From my point of view a big mistake. I recommened to build a separate environment. Are there any best practices documentation from oracle, where is described to seper