ALV GRID TEXT in grand Total

Hi friends,
    In ALV GRID I need to display text in total like grand Total not in subtotal.
Please let me know the solution .
Thanks in advance
Rajendran

Hi,
R U using FM or Class.
If you are using FM, Grand total cannot be produced. Only using classes we can display Grand Totals.
Its my own experience.
thanks

Similar Messages

  • ALV GRID - Text for Grand Total

    Hi guys,
    In ALV Grid, i need to display the Text 'GRAND TOTAL' at the left side of the row(Yellow line).
    I have tried searching in the forum but didn't get the answer.
    Please advice.
    Thanks
    Chintu

    Hi
    <br><br>
    IF you copy and past this might not work but this is the sample code<br><br>
    <pre>
    REPORT  Y_DOWN_TIME_ENTRYSRA.
    TABLES : YDOWNTIME1.
    TYPE-POOLS : SLIS.
    *INTERNAL TABLE DECLARTION
    data : l_layout type slis_layout_alv,
           x_events type slis_alv_event,
           it_events type slis_t_event.
    DATA :ITAB LIKE YDOWNTIME1 OCCURS 0 WITH HEADER LINE .
    data :  GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          wa_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    **********************SELECTION PARAMETERS ************************
    PARAMETERS: CB1 RADIOBUTTON GROUP G1 ,
                CB2 RADIOBUTTON GROUP G1 ,
                cb3 RADIOBUTTON GROUP G1 ,
                CB4 RADIOBUTTON GROUP G1 ,
                CB5 RADIOBUTTON GROUP G1 ,
                CB6 RADIOBUTTON GROUP G1 ,
                CB7 RADIOBUTTON GROUP G1 ,
                CB8 RADIOBUTTON GROUP G1 ,
                CB9 RADIOBUTTON GROUP G1 .
               CB10 RADIOBUTTON GROUP G1,
               CB11 RADIOBUTTON GROUP G1.
    DATA : A TYPE C.
    SELECTION-SCREEN BEGIN OF BLOCK BK1 WITH FRAME TITLE TEXT-001.
      SELECT-OPTIONS :S_EQUNR         FOR  YDOWNTIME1-EQUNR ,
                      S_ERDop        FOR  YDOWNTIME1-ERDAT,
                      S_MFSTT         FOR  YDOWNTIME1-MFSTART.
      PARAMETERS :    P_SHIFT         TYPE YDOWNTIME1-SHIFT,
                      P_CHARG         TYPE YDOWNTIME1-CHARG,
                      p_COGRU         TYPE YDOWNTIME1-QMGRP,
                      P_CODE          TYPE YDOWNTIME1-COde,
                     p_name          type ydowntime1-OPNAME,
                      p_sup           TYPE YDOWNTIME1-SUPERVISOR,
                      P_MANG           TYPE YDOWNTIME1-MANG.
    SELECTION-SCREEN END OF BLOCK BK1 .
    AT SELECTION-SCREEN.
      IF CB1 EQ 'X'.
        select  * from YDOWNTIME1
             INTO  CORRESPONDING FIELDS OF TABLE   ITAB
                   where erdat in S_ERDop  .
      ELSEIF CB2 EQ 'X' .
         select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where erdat in S_ERDop and  charg eq p_charg .
      ELSEIF CB3 EQ 'X' .
         select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where erdat in S_ERDop and charg  eq p_charg and shift eq P_SHIFT .
      ELSEIF  CB4 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where  code eq p_code and  erdat in S_ERDop.
      ELSEIF  CB5 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where  erdat in S_ERDop and EQUNR in S_EQUNR and QMGRP eq p_COGRU.
      ELSEIF  CB6 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where  OPNAME eq p_name and  erdat in S_ERDop.
      ELSEIF   CB7 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where SUPERVISOR eq p_sup and  erdat in S_ERDop.
      ELSEIF   CB8 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where MANG eq p_MANG and  erdat in S_ERDop.
      ELSEIF   CB9 EQ 'X'.
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where erdat in S_ERDop and EQUNR in S_EQUNR.
      endif.
    loop at itab.
    if itab-schno > 1.
      A = '  '.
      move A to itab-DCOR .
      move A to itab-DCCR .
      move A to itab-DCNR .
      modify itab.
    endif.
    endloop.
    perform create_fieldcat.
    data: sort type slis_sortinfo_alv,
          it_sort type  SLIS_T_SORTINFO_ALV.
    sort-fieldname = 'EQUNR'.
    sort-up = 'X'.
    sort-subtot = 'X'.
    APPEND sort to it_sort.
    sort-fieldname = 'SHIFT'.
    sort-up = 'X'.
    *sort-subtot = 'X'.
    APPEND sort to it_sort.
    l_layout-TOTALS_TEXT = 'TOTAL'.
    l_layout-SUBTOTALS_TEXT = 'SUBTOTAL'.
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
        i_callback_program       = sy-repid
        is_layout                = l_layout
        it_fieldcat              = gt_fieldcat
        it_events                = it_events
        it_sort                  = it_sort
      TABLES
        T_OUTTAB                       = ITAB
    EXCEPTIONS
       PROGRAM_ERROR                  = 1
       OTHERS                         = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *&      Form  CREATE_FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM CREATE_FIELDCAT .
      DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '1'.
      LS_FIELDCAT-FIELDNAME   = 'ERDAT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '12'.
    ls_fieldcat-do_sum       = 'X'.
      LS_FIELDCAT-SELTEXT_L =  'Date'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
      clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '2'.
      LS_FIELDCAT-FIELDNAME   = 'UZEIT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '8'.
      LS_FIELDCAT-SELTEXT_L =  'Time'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '2'.
      LS_FIELDCAT-FIELDNAME   = 'EQUNR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '8'.
      LS_FIELDCAT-SELTEXT_L =  'Equipment'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '2'.
      LS_FIELDCAT-FIELDNAME   = 'CODE'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '12'.
      LS_FIELDCAT-SELTEXT_L =  'CODE'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '3'.
      LS_FIELDCAT-FIELDNAME   = 'QMGRP'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Code Group'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '3'.
      LS_FIELDCAT-FIELDNAME   = 'KURZTEXT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '40'.
      LS_FIELDCAT-SELTEXT_L =  'Code Text'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '7'.
      LS_FIELDCAT-FIELDNAME   = 'DCOR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '14'.
      LS_FIELDCAT-SELTEXT_L =  'Opening Dips'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
        CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '8'.
      LS_FIELDCAT-FIELDNAME   = 'DCCR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '14'.
      LS_FIELDCAT-SELTEXT_L =  'Closing Dips'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'DCNR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      ls_fieldcat-do_sum       = 'X'.
      LS_FIELDCAT-SELTEXT_L =  'Net Dips'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    CLEAR LS_FIELDCAT.
    LS_FIELDCAT-ROW_POS     = '1'.
    LS_FIELDCAT-COL_POS     = '9'.
    LS_FIELDCAT-FIELDNAME   = 'PRO'.
    LS_FIELDCAT-KEY         = ''.
    LS_FIELDCAT-OUTPUTLEN   = '10'.
    ls_fieldcat-do_sum       = 'X'.
    LS_FIELDCAT-SELTEXT_L =  'PROD IN LAC'.
    APPEND LS_FIELDCAT TO GT_FIELDCAT.
       clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '4'.
      LS_FIELDCAT-FIELDNAME   = 'CHARG'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '12'.
      ls_fieldcat-do_sum       = 'X'.
      LS_FIELDCAT-SELTEXT_L =  'Batch Number'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '6'.
      LS_FIELDCAT-FIELDNAME   = 'OPNAME'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Operators Name'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '6'.
      LS_FIELDCAT-FIELDNAME   = 'SUPERVISOR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Supervisor Name'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
         CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '6'.
      LS_FIELDCAT-FIELDNAME   = 'MANG'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Manager'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '6'.
      LS_FIELDCAT-FIELDNAME   = 'SHIFT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Shift'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'MFSTART'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      LS_FIELDCAT-SELTEXT_L =  'Start Time'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'MFEND'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      LS_FIELDCAT-SELTEXT_L =  'End Time'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'DURATION'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      ls_fieldcat-do_sum       = 'X'.
      LS_FIELDCAT-SELTEXT_L =  'DURATION'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
        CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'ZUNIT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      LS_FIELDCAT-SELTEXT_L =  'UNIT'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    ENDFORM.                    " CREATE_FIELDCAT
    </pre>
    Edited by: Matt on Sep 3, 2009 12:06 PM

  • Downloads from ALV GRID-Text conversion to dates in EXCEL

    When downloading table displays of data from ALV-GRID for excel spreadsheet, we end of with files that have a header and various line ifnromation.  IF we manually clear up the display, then we can have the individicual column headers used and force them to text but if we just call the file up as an EXCEL spreadsheet, some part numbers such 12-3465 appear in Excel as Dec-65.
    The following is an example of the record (but it is word wrapped within this display limit).  In actuality, the verbage enclosed with the <b> represent the start of the  lines that have actual display data running out about 90 characters.
    Suggestions on how to make the download immediately correct in Excel direct from SAP ALV-GRID without cleaning out the heading lines and manually forcing the affected columns to TEXT format?
    thanks
    <b>03/02/2007</b>                                                                    Dynamic List Display                                                                                1
    <b>Materials-Inforecord Details Report</b>
    <b>Purchasing Org: ILMO</b>
                        <b>Report Run Date:03/02/2007</b>                    <b>Report Time:14:31:16</b>
         <b>Plnt     Mat Grp     Vendor     Name 1     Material     Material</b> description     Vendor Cat     Mfr     MPN     PC     Item Chg.     OUn      Eq to     BUn     Net price     Per     OPUn     Inforecord     PGr     Mv Avg        per     ValCl
         <b>0042     04     106070     BURROWS COMPANY</b>     184110     Glv Exam Ltx Non Ster     02-5001     TILLOTSON     02-5001               CA     2,000     EA        93.40      1     CA     5300006999     999     93.40     2,000     6438

    there are different options to export to excel which all behave differently, if you go for the menu ->export it differs from the export button from the alv buttonbar.
    try the different export to excel options perhaps there is one that behaves the way you want
    kind regards
    arthur de smidt

  • ALV Grid throwing dump in total function

    Hi,
      My ALV grid program, is working fine in development server, for the total and subtotal function. However, the same program is throwing a short dump in Quality server when we try to get the total.Please help!
    Regards,
    Anita Jeyan

    Hi ,
    Please go to ST22 and check what is the reason for error.
    Let me know the error.
    The reason might be due to some less data size or some data type mismatch.
    Regards,
    Uma
    Edited by: UmaDave on Jun 9, 2010 12:10 PM
    Edited by: UmaDave on Jun 9, 2010 12:10 PM

  • ALV Report - Average and Grand total.

    Hi,
    Could you tell me in ALV, how i can calculate the average of a particular field and display it in the grand total row?
    What is the property to display the grand total alone, without the subtotal?

    To force a grand total line, first you need to have a field in your internal table that can be totaled, when defining that field in your field catalog, you must set the flag for DO_SUM = 'X',  you may also need to set the DATATYPE = 'QUAN'.  Then the grand total line will show automatically.
    Regards,
    RIch Heilman

  • ALV Grid Header Problem.

    Hi All,
    I want to display the header of the ALV Grid as:
    Material                          111/11823
    Plant/Usage/Alt               2845/3/5
    Description                      ABI CAB
    Base Qty.                        23.000
    The values are to be taken from variables
    Please suggest how to do this.
    Thanks

    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report with grand total                *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKKO table.                                         *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    perform top-of-page.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you  more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
                  I.e. Field type may be required in-order for
                       the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      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
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = it_ekko
           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_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    Form  TOP-OF-PAGE                                                 *
    ALV Report Header                                                 *
    Form top-of-page.
    *ALV Header declarations
    data: t_header type slis_t_listheader,
          wa_header type slis_listheader,
          t_line like wa_header-info,
          ld_lines type i,
          ld_linesc(10) type c.
    Title
      wa_header-typ  = 'H'.
      wa_header-info = 'EKKO Table Report'.
      append wa_header to t_header.
      clear wa_header.
    Date
      wa_header-typ  = 'S'.
      wa_header-key = 'Date: '.
      CONCATENATE  sy-datum+6(2) '.'
                   sy-datum+4(2) '.'
                   sy-datum(4) INTO wa_header-info.   "todays date
      append wa_header to t_header.
      clear: wa_header.
    Total No. of Records Selected
      describe table it_ekko lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'Total No. of Records Selected: ' ld_linesc
                        into t_line separated by space.
      wa_header-typ  = 'A'.
      wa_header-info = t_line.
      append wa_header to t_header.
      clear: wa_header, t_line.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
                it_list_commentary = t_header.
               i_logo             = 'ideas'.
    endform.

  • Grand total (of all columns) in ALV grid

    Hi Experts,
    I have developed one custom ALV report in GRID format. Now Report output is displaying like below.
    COL1 |   COL2  |    COL3  |  COL4 |
    TYPE1  |   10   |           44  |          05 |
    TYPE2  |    01  |           20  |          35 |
    TYPE3  |   05   |          10   |         20  |
    =============================
       sum  |     16  |          74   |  50  |
    But I need Grand Total for COL2 and COL3 and COL4 (i.e 16 + 74 + 50 )
    This grand total line should be at the end of the internal table -- 140 .
    The report output should be like below.....
    COL1 |   COL2  |    COL3  |  COL4 |
    TYPE1  |   10   |           44  |          05 |
    TYPE2  |    01  |           20  |          35 |
    TYPE3  |   05   |          10   |         20  |
    =============================
       sum  |     16  |          74   |  50  |           ====> this sum will displayed when user select sum button on the Grid toolbar.
    =============================
    Grand Total   140 |
    Suppose when I press sum button on the COL2. it should not change grand total. I mean Grand total should be like footer always.
    Please advise
    Thanks in advance.
    Raghu

    Hi
    For your requirment ,you have to fill the field catalog for each field for which
    you have to create the the grand total and check the option DO_SUM.
    If you neeed the sub total ,in the sort table you can check the option- fs_sort-subtot = 'X'.
    Just try the belo code .
    It will solve your problem.
    REPORT ztest.
    * INTERNAL TABLE DECLARATION.
    DATA:
    t_sflight TYPE TABLE OF sflight,
    fs_sflight TYPE sflight.
    *OBJECTS FOR CONTAINER AND GRID.
    DATA:
    r_container1 TYPE REF TO cl_gui_custom_container,
    r_grid1 TYPE REF TO cl_gui_alv_grid.
    *FIELD CATALOG
    DATA:
    t_fcat TYPE lvc_t_fcat,
    fs_fcat TYPE lvc_s_fcat.
    fs_fcat-fieldname = 'SEATSMAX'.
    fs_fcat-do_sum = 'X'.
    APPEND fs_fcat TO t_fcat.
    CLEAR fs_fcat.
    fs_fcat-fieldname = 'PRICE'.
    fs_fcat-do_sum = 'X'.
    APPEND fs_fcat TO t_fcat.
    CLEAR fs_fcat.
    * SORT TABLE
    DATA:
    t_sort TYPE lvc_t_sort,
    fs_sort TYPE lvc_s_sort.
    * LAYOUT TABLE
    DATA:
    fs_layo TYPE lvc_s_layo.
    *FS_LAYO-SGL_CLK_HD = 'X'.
    fs_layo-zebra = 'X'.
    fs_sort-spos ='1'.
    fs_sort-fieldname = 'CARRID'.
    fs_sort-down = 'X'.
    fs_sort-group = '*'.
    *fs_sort-subtot = 'X'.
    APPEND fs_sort TO t_sort.
    SELECT * FROM sflight INTO TABLE t_sflight.
    CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'SCREEN1'.
      SET TITLEBAR 'TITLE1'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                    "user_command_0100 INPUT
    **&      Module  HANDLER  OUTPUT
    **       text
    MODULE  header  OUTPUT.
      CREATE OBJECT r_container1
        EXPORTING
          container_name = 'CONTAINER'.
      CREATE OBJECT r_grid1
        EXPORTING
          i_parent = r_container1.
      CALL METHOD r_grid1->set_table_for_first_display
        EXPORTING
          is_layout        = fs_layo
          i_structure_name = 'SFLIGHT'
        CHANGING
          it_fieldcatalog  = t_fcat
          it_outtab        = t_sflight
          it_sort          = t_sort.
    ENDMODULE.                    "Header OUTPUT
    Regards
    Hareesh.

  • Total at end of alv grid

    hiiiiiiiiiiii
    i write one alv grid program
    i wnat total at last of output for the field *DMBTR*
    plz see the code and give me solution
    type-pools: slis.
    tables: BSID, KNA1.
    data : begin of it_BSID occurs 0,
          BUKRS TYPE BSID-BUKRS,   "COMPANY CODE
          KUNNR TYPE BSID-KUNNR,   "Customer no
          NAME1 TYPE KNA1-NAME1,   "Customer name
          XBLNR TYPE BSID-XBLNR,   "REFERANCE
          BLART TYPE BSID-BLART,   "Document Type
          BUDAT TYPE BSID-BUDAT,   "Posting Date in the Document
          SHKZG TYPE BSID-SHKZG,   "Debit/Credit Indicator
          BELNR TYPE BSID-BELNR,   "Accounting Doc no
          DMBTR TYPE BSID-DMBTR,   "Amount in Local Currency
          SGTXT TYPE BSID-SGTXT,   "Item text
           end of it_BSID.
    data : begin of itab occurs 0,
          BUKRS TYPE BSID-BUKRS,   "COMPANY CODE
          KUNNR TYPE BSID-KUNNR,   "Customer no
          NAME1 TYPE KNA1-NAME1,   "Customer name
          XBLNR TYPE BSID-XBLNR,   "REFERANCE
          BLART TYPE BSID-BLART,   "Document Type
          BUDAT TYPE BSID-BUDAT,   "Posting Date in the Document
          SHKZG TYPE BSID-SHKZG,   "Debit/Credit Indicator
          BELNR TYPE BSID-BELNR,   "Accounting Doc no
          DMBTR TYPE BSID-DMBTR,   "Amount in Local Currency
          SGTXT TYPE BSID-SGTXT,   "Item text
          end of itab.
    *********ALV Declaration************************************************
    data: it_fieldcatalog type  slis_t_fieldcat_alv with header line,
          wa_fieldcatalog like line of it_fieldcatalog,
          wa_layout type slis_layout_alv,
          it_rec type table of itab,
          it_rec1 type table of itab,
          wa_rec like line of itab,
          wa_itab like line of itab.
    data : it_sort type slis_t_sortinfo_alv,
           wa_sort type slis_sortinfo_alv.
    *********ALV Declaration************************************************
    selection-screen : begin of block b with frame title text-100.
    select-options:
                    COMPANY for BSID-BUKRS ,
                    CUSTOMER for BSID-KUNNR,
                    DATE FOR BSID-BUDAT.
    selection-screen  end of block b .
    start-of-selection.
      select BUKRS KUNNR XBLNR BLART BUDAT
          SHKZG BELNR DMBTR SGTXT
           from BSID into corresponding fields of table it_BSID
         where
           BUKRS IN COMPANY AND
           KUNNR IN CUSTOMER AND
           BUDAT IN DATE .
      sort it_BSID by BUDAT KUNNR.
    end-of-selection.
      loop at it_BSID.
    IF it_BSID-SHKZG EQ 'H'.
          MULTIPLY it_BSID-DMBTR BY -1.
        ENDIF.
        move: IT_BSID-BUKRS TO ITAB-BUKRS,   "COMPANY CODE
              IT_BSID-KUNNR TO ITAB-KUNNR,   "Customer no
              IT_BSID-XBLNR TO ITAB-XBLNR,   "REFERANCE
              IT_BSID-BLART TO ITAB-BLART,   "Document Type
              IT_BSID-BUDAT TO ITAB-BUDAT,   "Posting Date in the Document
              IT_BSID-SHKZG TO ITAB-SHKZG,   "Debit/Credit Indicator
              IT_BSID-BELNR TO ITAB-BELNR,   "Accounting Doc no
              IT_BSID-DMBTR TO ITAB-DMBTR,   "Amount in Local Currency
              IT_BSID-SGTXT TO ITAB-SGTXT.   "Item text
        select single NAME1 from KNA1 into (itab-NAME1) where KUNNR = itab-KUNNR.
    APPEND ITAB.
      endloop.
    loop at itab .
    at end of itab-dmbtr.
    sum.
    endat.
    endloop.
      if not itab[] is initial.
        perform populate_field_catalog.
        perform fill_layout.
        perform display_alv.
      else.
        write: ' NO DATA'.
      endif.
    *&      Form  populate_field_catalog
    *       text
    form populate_field_catalog .
      wa_fieldcatalog-fieldname = 'BUKRS'.
      wa_fieldcatalog-seltext_m  = 'COMPANY'.
      append wa_fieldcatalog to it_fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-fieldname =  'KUNNR'.
      wa_fieldcatalog-seltext_m  = 'CUSTOMER CODE.'.
      wa_fieldcatalog-no_zero      = 'X'.
      append wa_fieldcatalog to it_fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-fieldname =  'NAME1'.
      wa_fieldcatalog-seltext_m  = 'NAME'.
      append wa_fieldcatalog to it_fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-fieldname =  'BLART'.
      wa_fieldcatalog-seltext_m  = 'DOC. TYPE '.
      append wa_fieldcatalog to it_fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-fieldname = 'BUDAT'.
      wa_fieldcatalog-seltext_m  = 'POSTING DATE'.
      append wa_fieldcatalog to it_fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-fieldname = 'BELNR'.
      wa_fieldcatalog-seltext_m  = 'DOCUMENT NO.'.
      append wa_fieldcatalog to it_fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-fieldname = 'DMBTR'.
      wa_fieldcatalog-seltext_m  = 'AMOUNT'.
       wa_fieldcatalog-DO_SUM = 'X'.
      append wa_fieldcatalog to it_fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-fieldname = 'SGTXT'.
      wa_fieldcatalog-seltext_m  = 'TEXT'.
      append wa_fieldcatalog to it_fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-fieldname = 'XBLNR'.
      wa_fieldcatalog-seltext_m  = 'REFERANCE'.
      append wa_fieldcatalog to it_fieldcatalog.
      clear wa_fieldcatalog.
    endform.                    " populate_field_catalog
    *&      Form  fill_layout
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form fill_layout .
      wa_layout-no_input = 'X'.
      wa_layout-colwidth_optimize = 'X'.
      wa_layout-zebra = 'X'.
    endform.                    " fill_layout
    *&      Form  display_alv
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form display_alv .
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = sy-repid
          i_callback_user_command = 'USER_COMMAND'
          is_layout               = wa_layout
          it_fieldcat             = it_fieldcatalog[]
          i_default               = 'X'
          i_save                  = 'A'
        tables
          t_outtab                = itAB
        exceptions
          program_error           = 1
          others                  = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number
    sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " display_alv
    Edited by: pranay panchbhai on Mar 15, 2010 3:18 PM

    Hi
    Give this code for field DMBTR in fielcatalog.
    wa_fieldcatalog-FIELDNAME = 'DMBTR'.
    wa_fieldcatalog-INTTYPE = 'C'.
    wa_fieldcatalogT-DO_SUM = 'X'.                     
    APPEND wa_fieldcatalog TO it_fieldcatalog.
    CLEAR wa_fieldcatalog.
    It will work definitely.
    If you still have doubts then revert back.
    Thanks & Regards
    Khushboo

  • Percentage Total/Subtotal in ALV Grid

    Dear All,
    I have to display an ALV report with percentage feilds. Everything is fine but the problem arises when the standard ALV sum functionality is used. It simply adds up all the percentage columns. Making do_sum = 'C' wont help either as it would simple give an average of all the percentage. My requirement is to show them through calculation. I have searched the web and saw some solutions with SUBTOTAL_TEXT nad some with OOP programming but i am not able to get this. Can anybody please help.
    <REMOVED BY MODERATOR>
    Thanks
    MV
    Edited by: Alvaro Tejada Galindo on Apr 21, 2008 4:24 PM

    hi manish,
    try this program.
    ALV Grid List with sub-totals
    REPORT z_demo_alv_sort.
    * This program lists orders (VBAK) with sort and sub-total for        *
    * 'sold-to-party' (KUNNR) and 'Sales organization' (VKORG)            *
    TABLES : vbak.
    TYPE-POOLS: slis.                      " ALV Global types
    SELECT-OPTIONS :
      s_vkorg FOR vbak-vkorg,              " Sales organization
      s_kunnr FOR vbak-kunnr,              " Sold-to party
      s_vbeln FOR vbak-vbeln.              " Sales document
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
    PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    DATA:
      BEGIN OF gt_vbak OCCURS 0,
        vkorg LIKE vbak-vkorg,             " Sales organization
        kunnr LIKE vbak-kunnr,             " Sold-to party
        vbeln LIKE vbak-vbeln,             " Sales document
        netwr LIKE vbak-netwr,             " Net Value of the Sales Order
        waerk LIKE vbak-waerk,             " Document currency
      END OF gt_vbak.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
    *      Form  f_read_data
    FORM f_read_data.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
               FROM vbak
                 UP TO p_max ROWS
              WHERE kunnr IN s_kunnr
                AND vbeln IN s_vbeln
                AND vkorg IN s_vkorg.
    ENDFORM.                               " F_READ_DATA
    *      Form  f_display_data
    FORM f_display_data.
      DEFINE m_fieldcat.
        add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname   = &1.
        ls_fieldcat-ref_tabname = 'VBAK'.
        ls_fieldcat-do_sum      = &2.
        ls_fieldcat-cfieldname  = &3.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        ls_sort-subtot    = &2.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,
        lt_sort     TYPE slis_t_sortinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        ls_layout   TYPE slis_layout_alv.
      m_fieldcat 'VKORG' ''  ''.
      m_fieldcat 'KUNNR' ''  ''.
      m_fieldcat 'VBELN' ''  ''.
      m_fieldcat 'NETWR' 'X' 'WAERK'.
      m_fieldcat 'WAERK' ''  ''.
      m_sort 'VKORG' 'X'.                  " Sort by vkorg and subtotal
      m_sort 'KUNNR' 'X'.                  " Sort by kunnr and subtotal
      m_sort 'VBELN' ''.                   " Sort by vbeln
      ls_layout-cell_merge = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           TABLES
                t_outtab    = gt_vbak.
    ENDFORM.                               " F_DISPLAY_DATA
    ***************** END OF PROGRAM Z_DEMO_ALV_SORT **********************
    thanks
    karthik
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 21, 2008 4:50 PM

  • Split Totals on ALV Grid

    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,
    Randy

    Hi
      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 display a row after a subtotal field in ALV Grid

    Hi All,
    My requirement is to print a extra row with values and constant text after printing subtotal values in ALV Grid.
    e.g.      TOTAL      12.23       ---> Subtotal field
                 Tax            5.2         ---> extra row after subtotal field.
    Please help me....
    Thanks in advance.
    Regards
    Ajay

    Hi
    You can try using INSERT <WA> OR INSERT INITIAL LINE .
    fill the wa with tax value.
    INSERT  <wa> into table < internal table > 
    A row will be inserted into internal table with the values.
    Try this  and let me know.
    Thanks
    Hariharan

  • Regarding subtotals and new page in ALV Grid

    Hi All,
    I have 5 employees in my internal table and each employee having five records.
    Now iam displaying total employees in ALV grid and calculating their totals at the end of the hole records.
    But i need to display the sub totals for each employee and i need new page for each employee.
    means  1) New page for each employye
                2) sub totals for each employee
                3) grand total for all employees
    How can i proceed for this requirement in ALV grid?

    For subtotals first you need to set the do_sum = 'X' in the fieldcatalog for the columns you want totals.
    fieldcat-fieldname = 'ABC'.
    fieldcat-do_sum = 'X'.
    Append fieldcat to it_fieldcat,
    for subtotals you need to populate the SORT table.
    sort-fieldname = 'EMPLOYEE'.
    sort-up = 'X'.
    sort-group = '*'.  "<----- this is for new page
    "you can view new page in preview / print /
    "if you are using the list function
    sort-subtot = 'X'.
    append sort to it_sort.
    pass this it_sort to it_sort of the alv function.

  • Field Catolgue in alv grid display

    Hi Abapers,
    I need to display the percentage rows with decimals and other rows without decimal . Is their any option in field catalog to do like this. Or tell me any other alternative to achieve this.
    sno  total     col1      col2      col3
    1      220       100        20       100
    2      320      120         50        150
    tot    540       220        70         250
    per               40.74     1.87  and so on
    or ,
    I have two different internal tables how can i put it in one field catalog to pass it to alv grid display.
    Regards,
    Priya

    Don't   do  total  by your  self  in the Pogram.
    in the   Fieldcatalog  there is an Attribute which will do total  &  Average .
    Enable it so that  from one  internal  table   data   it self it will do  good.
    example program
    Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
    display it using the basic ALV grid functionality(including column total). The example details the main
    sections of coding required to implement the ALV grid functionality:
                             Data declaration
                             Data retrieval
                             Build fieldcatalog
                             Build layout setup
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15. 
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      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
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = it_ekko
           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_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    gowri
    Message was edited by:
            Gowri Krishna

  • Printing Grand Totals in Footer along with page total

    Hi
    I have a report which prints PO Header and PO Lines. For each page while iterating thru PO Lines I print page total in the footer.
    Once all PO Lines are printed with page totals in the footer of each page, I want to print Grand total in the last page in the footer along with last page total. Currently my XML data has pre-computed grand total in the PO Header block.
    The problem
    I have wrapped header and lines inside <?start:body?> and <?end:body?> which allows me to print page totals outside the <?end:body?> tag.
    I print page totals and "Continue" next to it in the footer. But
    Finally when grand total comes into picture in the outer loop I want to replace "Continue" text with grand total value in the last page and print it as footer.
    I tried to use xdoxlt:set_variable() function to flag a variable value to 1 when iteration happens in HEADER block and set it to 2 in inner loop of lines block. But the scope of the variable is confined between <?start:body?> and < ?end:body? and is not visible outside the <?end:body?> tag.
    The logic I want to accomplish is
    if var = 1 then
    print page total and "Continue"
    elsif var = 2 then
    print page total and Grand Total.
    end if
    This logic doest work as the value of var is not visible outside the body tag.
    I want to use this variable value to print footer which lies outside <?end:body?> tag with grand totalor page total
    Please suggest if there is any other way I can accomplish this functionality. Can we use parameter and update it. Syntax for update parameter value is not clear in user guide.
    Any help would be appreciated.
    thanks
    sukarna

    thanks for the info, i was trying to avoid this but had already reached the same conclusion.
    everything else seems to be very time consuming and may not work correctly in the end.
    we're on Oracle Applications : 11.5.10.2 which has just been converted to utf-8 and is an Oracle On-Demand installation.
    do you know if 5.6.3 of the publisher is supported and any ideas on how difficult it is to get it installed?
    cheers
    ellen

  • 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 to force lang level 7.0 (diamond op.) for classes generated by JAXB xjc

    I tried various JAXB maven plugins in the respective latest version and none uses the diamond operator in the generated code. <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>1.5</version> <groupId>org.jvnet.j

  • Cursor Pointer in Mail

    my cursor is not changing into a pointer when i have written an email in my mail programm, only when i touch the adress bars. does anybody know how to solve this?

  • Settings of audit_syslog_level

    Hello, I have a technical question concerning the setting of parameter audit_syslog_level: we are recommended to audit events err, crit, alert and emerg. But in parameter audit_syslog_level I can only define one combination, for example: audit_syslog

  • How to restart WTC without restarting WL

    We are running WL 6.0 sp2rp2 on Win2K. Almost daily the WTC exits ####<Apr 17, 2002 4:27:44 PM CDT> <Debug> <WTC> <TESTWEBLOGIC1> <OptiSoftAppServer> <Thread-9> <> <1387:6157dda167644992> <180056> <[/tBexec/showTuxMsg/> ####<Apr 17, 2002 4:27:44 PM C

  • Forms Don't Connect

    Dear Sirs, When I want to connect forms to the database using Scott/tiger I receive the following message Ora-12203 TNS-unable to connect to destination What should I do? Thanks