2007 Jun 01 7:27 AM
Hi experts,
In ALV report how to hide the total amount for a particular column.
Scenario is :
waerks netvalue in USD
EUR 1 1.3
2 2.6
3 3.9
INR 1 37
1 37
2 74
5 77.9
In th last line i dont want toal for netvalue. Because there is no meaning for totaling different currencis.
pls help me to do.
Thanks.
Message was edited by:
Murugan Arumugam
2007 Jun 01 7:28 AM
2007 Jun 01 7:34 AM
hi Chandrasekar,
If i do like your idea , then there is no subtoal. i need subtotals. i dont need the last line of the ALV that sums all the sub total.
2007 Jun 01 7:42 AM
hi Murugan,
for sutotal , you need to build the sort table
it_sort-fieldname = 'FIELD1'.
it_sort-up = 'X'.
it_sort-subtotal = 'X'.
append it_sort.
and pass IT_SORT to REUSE_ALV_GRID_DISPLAY
2007 Jun 01 7:50 AM
i did that also. Pls. see my code.
DEFINE M_FIELDCAT.
ADD 1 TO X_FIELDCAT-COL_POS.
X_FIELDCAT-FIELDNAME = &1.
X_FIELDCAT-DO_SUM = &2.
X_FIELDCAT-SELTEXT_L = &3.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_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.
CLEAR LS_SORT.
END-OF-DEFINITION.
M_FIELDCAT 'WAERK' '' 'Document curr.'. / this is for document currency
M_FIELDCAT 'NVAL_KONV' ' ' 'Net value'. / this is for net value
M_FIELDCAT 'CURR_NETWR' 'X' 'In USD'. / this is for net value in USD
2007 Jun 01 9:49 AM
hello murugan
in ur code wht is da val of &2 ?
if u want total at the end of the column the do_sum val shld b set to 'X' otherwise it shl b spcae.
same for sub total the sub_tot vale shld b...
in ur code both sub_tot n do_sum are havin val as &2 so chk the dat n set it accordingly
2007 Jun 01 9:56 AM
hello ashwinee mali
This is the value
M_FIELDCAT 'WAERK' ' X ' 'Document curr.'. / this is for document currency
M_FIELDCAT 'NVAL_KONV' ' ' 'Net value'. / this is for net value
M_FIELDCAT 'CURR_NETWR' 'X' 'In USD'. / this is for net value in USD
2007 Jun 01 10:01 AM
ok so c u r settin do_sum val as X plz set it to blank
thatis <fieldcat>-do_sum = ''
and u want sub total so assign X to sub_tot
i.e. <fieldcat>-sub_tot = 'X'.
so instead of passing &2 val set values as i hav suggested...
n let me knw ....
ur code shl look like this
DEFINE M_FIELDCAT.
ADD 1 TO X_FIELDCAT-COL_POS.
X_FIELDCAT-FIELDNAME = &1.
X_FIELDCAT-DO_SUM = ''. ( u can even comment thhis line)
X_FIELDCAT-SELTEXT_L = &3.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
END-OF-DEFINITION.
DEFINE M_SORT.
ADD 1 TO LS_SORT-SPOS.
LS_SORT-FIELDNAME = &1.
LS_SORT-UP = 'X'.
LS_SORT-SUBTOT = 'X'.
APPEND LS_SORT TO LT_SORT.
CLEAR LS_SORT.
END-OF-DEFINITION.
do_sum is used to give u the total at teh end of the column
and sub_tot is used for giving sub total.
if ur prob is resolve then update this thread accordiongly n reward pnts if ans were helpufl..
Message was edited by:
ashwinee mali
2007 Jun 01 7:40 AM
Hi Murugan
If ur doubt is about subtotals then follow this
<b>LS_FIELDCAT-DO_SUM = 'X'.</b>
<u><b>U have to use this statement for detailed concept
follow this code it may help u</b></u>
REPORT ZALV.
TYPE-POOLS: SLIS.
DATA: G_REPID LIKE SY-REPID,
GS_PRINT TYPE SLIS_PRINT_ALV,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GT_EVENTS TYPE SLIS_T_EVENT,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
COL_POS TYPE I.
DATA: BEGIN OF ITAB,
FIELD1(5) TYPE C,
FIELD2(5) TYPE C,
FIELD3(5) TYPE P DECIMALS 2,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0.
INCLUDE STRUCTURE ITAB.
DATA: END OF ITAB1.
DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
INCLUDE STRUCTURE ITAB.
DATA: END OF ITAB_FIELDCAT.
* Print Parameters
PARAMETERS:
P_PRINT AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
P_RESERV TYPE I. "NO OF FOOTER LINE
INITIALIZATION.
G_REPID = SY-REPID.
PERFORM PRINT_BUILD USING GS_PRINT. "Print PARAMETERS
START-OF-SELECTION.
* TEST DATA
MOVE 'TEST1' TO ITAB1-FIELD1.
MOVE 'TEST1' TO ITAB1-FIELD2.
MOVE '10.00' TO ITAB1-FIELD3.
APPEND ITAB1.
MOVE 'TEST2' TO ITAB1-FIELD1.
MOVE 'TEST2' TO ITAB1-FIELD2.
MOVE '20.00' TO ITAB1-FIELD3.
APPEND ITAB1.
DO 50 TIMES.
APPEND ITAB1.
ENDDO.
END-OF-SELECTION.
PERFORM BUILD.
PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
PERFORM COMMENT_BUILD CHANGING GT_LIST_TOP_OF_PAGE.
PERFORM CALL_ALV.
FORM BUILD.
* DATA FIELD CATALOG
* Explain Field Description to ALV
DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD1'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
*FIELDCAT_LN-NO_OUT = 'X'. "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
FIELDCAT_LN-KEY = ' '. "SUBTOTAL KEY
FIELDCAT_LN-NO_OUT = ' '.
FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD2'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
FIELDCAT_LN-NO_OUT = 'X'.
FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD3'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
FIELDCAT_LN-REF_TABNAME = 'MSEG'. "<- REF TABLE IN THE DICTIONNARY
FIELDCAT_LN-NO_OUT = ' '.
FIELDCAT_LN-DO_SUM = 'X'. "SUM UPON DISPLAY
APPEND FIELDCAT_LN TO GT_FIELDCAT.
* DATA SORTING AND SUBTOTAL
DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD1'.
GS_SORT-SPOS = 1.
GS_SORT-UP = 'X'.
GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD2'.
GS_SORT-SPOS = 2.
GS_SORT-UP = 'X'.
*GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
ENDFORM.
FORM CALL_ALV.
* ABAP List Viewer
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = G_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'ITAB1'
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = GT_SORT[]
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
IT_EVENTS = GT_EVENTS[]
* IT_EVENT_EXIT =
IS_PRINT = GS_PRINT
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
* HEADER FORM
FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
*GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = LT_EVENTS.
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO LT_EVENTS.
ENDIF.
* define END_OF_PAGE event
* READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
* INTO LS_EVENT.
* IF SY-SUBRC = 0.
* MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
* APPEND LS_EVENT TO LT_EVENTS.
* ENDIF.
ENDFORM.
FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: GS_LINE TYPE SLIS_LISTHEADER.
CLEAR GS_LINE.
GS_LINE-TYP = 'H'.
GS_LINE-INFO = 'HEADER 1'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
CLEAR GS_LINE.
GS_LINE-TYP = 'S'.
GS_LINE-KEY = 'STATUS 1'.
GS_LINE-INFO = 'INFO 1'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
GS_LINE-KEY = 'STATUS 2'.
GS_LINE-INFO = 'INFO 2'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
* CLEAR GS_LINE.
* GS_LINE-TYP = 'A'.
*
* GS_LINE-INFO = 'ACTION'.
* APPEND GS_LINE TO GT_TOP_OF_PAGE.
ENDFORM.
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
ENDFORM.
FORM END_OF_PAGE.
WRITE at (sy-linsz) sy-pagno CENTERED.
ENDFORM.
* PRINT SETTINGS
FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
LS_PRINT-PRINT = P_PRINT. "PRINT IMMEDIATE
LS_PRINT-NO_PRINT_SELINFOS = P_NOSINF. "NO SELECTION INFO
LS_PRINT-NO_COVERPAGE = P_NOCOVE. "NO COVER PAGE
LS_PRINT-NO_NEW_PAGE = P_NONEWP.
LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
LS_PRINT-RESERVE_LINES = P_RESERV.
ENDFORM.
*END OF ZALV PROGRAM
Follow this link
for detailes concept
http://help.sap.com/saphelp_sm32/helpdata/en/ee/b99d37e188a049e10000009b38f8cf/content.htm
<b>And if ur doubt is about is about hide then follow this</b>
<b><u>IT_TOOLBAR_EXCLUDING</u></b>
This table contains function codes of the toolbar that you want to hide for the lifetime of the ALV Grid Control. The function codes are constant attributes and are prefixed with MC_FC_.
<b>KEY</b>
<u>If this field is set, the ALV Grid Control color-codes the column as a key field and fixes this column during horizontal scrolling. The order of the key columns in the ALV Grid Control can be modified interactively. In contrast to the SAP List Viewer, the ALV Grid Control allows you to directly hide key columns with NO_OUT then use the key word</u>
<b>NO_OUT</b>
<u>If you set this field, you hide the relevant column in the list. Nevertheless, the column is available in the field selection and can be interactively selected by the user as a display field. The ALV displays the contents of hidden fields on the detail screen for a row in the grid control.</u>
To hide the entire toolbar, you can set the field NO_TOOLBAR of the layout structure to X.
Reward if helpfull
Regards
Pavan
2007 Jun 01 8:24 AM
hi,
while declaring fieldcatalog.
d_fieldcat_wa-matnr = 'CURRENCY'.
d_fieldcat_wa-seltext_l = 'currency'.
d_fieldcat_wa-do_sum = ' '.
d_fieldcat_wa-col_pos = 2.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
call function reuse_grid_display_alv.
exporting
programname = gd_repid
fieldcat = d_fieldcat
importing.
t_outtab = itab_final.
excepions.
Reward with points if helpful.
2007 Jun 01 10:01 AM
Hi,
Use this it will not hide subtotal but will show subtotal for that ciurrency,
basically u have to pass currency field before do sum.
1) while your building field catalog do like this for the field you want to do
Pass wa_fieldcat-cfieldname = 'WAERK'currency field as passed below
DATA : wa_fieldcat TYPE slis_fieldcat_alv,
P_it_fieldcat TYPE slis_t_fieldcat_alv,
l_col_pos TYPE i.
l_col_pos = l_col_pos + 1.
Wa_fieldcat-col_pos = l_col_pos.
Wa_fieldcat-fieldname = 'NETWR'. Field name as u have declared
Wa_fieldcat-ref_fieldname = 'NETWR'. Field name in table
Wa_fieldcat-ref_tabname = 'VBRP'. table from which u r taking the field
Wa_fieldcat-cfieldname = 'WAERK'. currency field
Wa_fieldcat-do_sum = 'X'. for doing sum
Wa_fieldcat-seltext_l = 'Net Sales Value'. text u want to display
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
l_col_pos = l_col_pos + 1.
Wa_fieldcat-col_pos = l_col_pos. the currency field refer to above
Wa_fieldcat-fieldname = 'WAERK'.
Wa_fieldcat-ref_fieldname = 'WAERK'.
Wa_fieldcat-ref_tabname = 'VBRK'.
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
2) Now do the subtotal for that field here Iam doing for VBELN(netsales value)
DATA: it_sortinfo TYPE slis_t_sortinfo_alv,
Wa_sortinfo TYPE slis_sortinfo_alv.
wa_sortinfo-fieldname = 'VBELN'.
wa_sortinfo-tabname = 'VBAK'.
wa_sortinfo-up = 'X'.
wa_sortinfo-subtot = 'X'.
APPEND wa_sortinfo TO p_it_sortinfo.
regards,
Sudha,
2007 Jun 05 7:19 AM
Hi,
Is it working fine now?
the attaachment u sent me is not opening
regards
sudha
2007 Jun 05 7:48 AM
hey sudha.yadav,
it it not working. if i remove 'x' from do_sum then it never calculate sub total. i need subtotal. i dont need the main total which is in last line. once again i will send the screen shot. .
thanks.
2009 Sep 29 8:10 AM
hi
in layout check for no_totline
ie., ls_layout-no_totline = 'X'.
with this you wont get the total in the last and you can get only the subtotal.