10-10-2007 3:05 PM
Hi Friends,
I need to display only the subtotals and total but not the line items in ALV list. There is a field in the structure layout TOTALS_ONLY for showing only total. But it is not working. Please tell me is needed anything to be passed along with that or tell me other possible ways to this problem.
Thanks in advance.
10-10-2007 3:07 PM
You could try using these options.
Fieldname - NO_TOTLINE
If this field is set, only subtotals, but no totals, are displayed.
Value range - SPACE, 'X'
**********************************8
Fieldname - NUMC_TOTAL
If this field is set, the user can calculate totals for fields of datatype NUMC (normally, users are not allowed to do this).
Value range - SPACE, 'X'
**************************************
Fieldname - TOTALS_BEF
If this field is set, the ALV displays totals calculated as the first rows in the grid control. Subtotals are displayed before a new value of the subtotals criterion.
Value range - SPACE, 'X'
*************************************
while mentioning the fieldcatalog for field specify do_sum .
X_FIELDCAT-SCRTEXT_M = 'quantity'.
X_FIELDCAT-FIELDNAME = 'MENGE'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
<b> X_FIELDCAT-DO_SUM = 'X'.</b>
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
10-10-2007 3:18 PM
Hi,
1. Simply doing this won't work.
2. We have to do SOME EXTRA thing also.
3. <b>srtwa-expa = 'X'.</b>
4. Just check out this program (copy paste in new program)
IT WILL SHOW ONLY TOTALS
(NOT DETAIL LINES)
IMPORTANT THING IS : srtwa-expa = 'X'.
5.Check this Sample Code,
REPORT abc.
*----
NECESSARY / MUST
TYPE-POOLS : slis.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : fcwa TYPE slis_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
DATA : alvsrt TYPE slis_t_sortinfo_alv.
DATA : srtwa TYPE slis_sortinfo_alv.
DATA : BEGIN OF itab OCCURS 0,
f1(3) TYPE c,
f2(25) TYPE c,
f3 TYPE i,
END OF itab.
*----
itab-f1 = '10c'.
itab-f2 = 'Description1'.
itab-f3 = 24.
APPEND itab.
itab-f1 = '10c'.
itab-f2 = 'Description1'.
itab-f3 = 34.
APPEND itab.
itab-f1 = '10c'.
itab-f2 = 'Description1'.
itab-f3 = 12.
APPEND itab.
*----
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
IMPORTANT
LOOP AT alvfc INTO fcwa.
IF fcwa-fieldname = 'F3'.
fcwa-do_sum = 'X'.
ENDIF.
MODIFY alvfc FROM fcwa.
ENDLOOP.
*----
IMPORTANT
srtwa-fieldname = 'F1'.
srtwa-expa = 'X'.
srtwa-spos = 1.
*SRTWA-GROUP = 'X'.
APPEND srtwa TO alvsrt.
srtwa-fieldname = 'F2'.
srtwa-subtot = 'X'.
srtwa-spos = 2.
APPEND srtwa TO alvsrt.
*alvly-totals_only = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid
is_layout = alvly
it_sort = alvsrt
i_save = 'A'
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
<b>Reward If Helpful.</b>
Regards,
Padmam.
10-11-2007 12:05 PM
Thanks.
This will work, if in list output we have only one subtotal and one or more then one totals. but in case of more then two subtotals fields, it is showing only one subotal field(Depends on the 'SPOS') with totals fields.
i want to show both subtotal fields.
Please Help me..
Thanks.
10-11-2007 12:34 PM
Hi ..
You have to add both the Fields for SORT table. then it works..
DATA: WA_SORT TYPE SLIS_SORTINFO_ALV.
*
WA_SORT-SPOS = 1.
WA_SORT-FIELDNAME = 'GRP01'.
WA_SORT-UP = ' '.
WA_SORT-DOWN = 'X'.
WA_SORT-EXPA = 'X'.
WA_SORT-GROUP = 'UL'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO SORT.
clear wa_sort.
WA_SORT-SPOS = 2.
WA_SORT-FIELDNAME = 'GRP02'.
WA_SORT-UP = ' '.
WA_SORT-DOWN = 'X'.
WA_SORT-EXPA = 'X'.
WA_SORT-GROUP = 'UL'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO SORT.
REWARD IF HELPFUL.
10-10-2007 3:45 PM
Hi,
try this in ALV-SORT:
DATA: WA_SORT TYPE SLIS_SORTINFO_ALV.
*
WA_SORT-SPOS = 1.
WA_SORT-FIELDNAME = 'GRP01'.
WA_SORT-UP = ' '.
WA_SORT-DOWN = 'X'.
<b> WA_SORT-EXPA = 'X'.</b>
WA_SORT-GROUP = 'UL'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO SORT.
*
10-11-2007 12:06 PM
Thanks.
This will work, if in list output we have only one subtotal and one or more then one totals. but in case of more then two subtotals fields, it is showing only one subotal field(Depends on the 'SPOS') with totals fields.
i want to show both subtotal fields.
Please Help me..
Thanks.
10-11-2007 12:11 PM
HI
You have to use in alv function as ls_fieldcat-do_sum = 'X'.
Check this sample report
&----
*& Report ZALVTOTAL *
*& *
&----
*& *
*& *
&----
REPORT ZALVTOTAL .
TYPES :
BEGIN OF ty_vbak,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
netwr TYPE vbak-netwr, " Net Value of the Sales Order
waerk TYPE vbak-waerk, " Document currency
END OF ty_vbak.
DATA:
vbak TYPE vbak,
gt_vbak TYPE TABLE OF ty_vbak.
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.
----
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 vkorg kunnr vbeln netwr waerk
UP TO p_max ROWS
INTO TABLE gt_vbak
FROM vbak
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.
TYPE-POOLS: slis. " ALV Global types
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
<b>Reward if usefull</b>
10-11-2007 12:23 PM
Hi Siva,
Just follow these simple steps.
1. Define SORT table and FIELDCATALOG table .
DATA IT_FCAT TYPE slis_T_fieldcat_alv.
DATA WA_FCAT LIKE LINE OF IT_FCAT.
DATA IT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA WA_SORT LIKE LINE OF IT_SORT.
"Others data
DATA I_REPID LIKE SY-REPID.
2. Create Grand Total.
While creating fieldcatalog, we have to set DO_SUM = 'X' for quantity field .
clear WA_FCAT.
WA_FCAT-fieldname = 'ANZHL'. " Your Quantity Field
WA_FCAT-tabname = 'IT_CUTI'. " Your Internal Table
WA_FCAT-DO_SUM = 'X'.
append WA_FCAT TO IT_FCAT.
3. Create Subtotal
Whenever BEGDA [Start Date] is changed Subtotal is displayed ( Set Subtot = 'X' ) .
Build our sort table .
Clear: WA_SORT.
WA_SORT-spos = 1.
WA_SORT-fieldname = 'BEGDA'. "
WA_SORT-up = 'X'.
WA_SORT-subtot = 'X'.
append WA_SORT TO IT_SORT.
4.Pass this IT_SORT table thrugh REUSE_ALV_LIST_DISPLAY function module.
I_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = I_REPID
I_INTERNAL_TABNAME = 'IT_CUTI' "capital letters = Your Internal Table
I_INCLNAME = I_REPID
CHANGING
CT_FIELDCAT = IT_FCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = I_REPID
IT_FIELDCAT = IT_FCAT
I_SAVE = 'A'
IT_SORT = IT_SORT
TABLES
T_OUTTAB = IT_CUTI " Your Internal Table
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
Reward if Useful.
Regards,
Chitra
07-13-2016 2:00 PM