ALV Grid Total Text (OOPS)

Hi All,
I have a simple ALV Grid Report(OOPS), I would like to give a Text for Total Row. In REUSE_ALV_GRID we have the option of giving this text, but i am not able to figure it out how to get the same in OOPS.
Regards
Anup

Hi Anup,
While using ALV with OOP methodology, you can create an extra row for giving the sum of any field.
In the field catalog, there is a component named 'DO_SUM', if set, will give the total value for the field.
In the method where you fill the field catalog , just add this component.
eg:
form catalog_fill changing p_field_catalog.
data ls_fcat type lvc_s_fcat .
ls_fcat-fieldname = 'CARRID' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Carrier ID' .
ls_fcat-web_field = 'carrid_handle'.
ls_fcat-edit = 'X'.
*ls_fcat-emphasize = 'C310'.   "needed for column coloring
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'FLDATE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'FLDATE' .
ls_fcat-outputlen = '20' .
<b>ls_fcat-do_sum = 'X'.</b>
ls_fcat-coltext = 'Flight Date' .
ls_fcat-web_field = 'fldate_handle'.
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'PRICE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'PRICE' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Airfare' .
append ls_fcat to field_catalog .
endform.
In this way, you can get the total of any field in ALV.
Regards,
SP.

Similar Messages

  • Problem in displaying Alv grid output  using oops........

    hi,
    i have two problems in displaying ALV grid output Using Oops.
    1) How to modify the fieldcatalog after we getting a field catalog using general FM.
    2) initialy it is displaying 13 fields but there are 63 fields .
       eventhough we chage the layout to 63 fields it is displaying only 13 fields , these 13 fields may be different based on our selection but count  of displayed fileds are same . how can display 63 fields at a time .

    Hi,
    You can chnage using below code:
    loop at gt_fieldcat.
    if <gt_fieldcat-field_name> = 'FIELDNAME'.
    endif.
    modify gt_fieldcat.
    clear gt_fieldcat.
    endloop.
    Make sure that all the field should not have no_out = 'X' and tech = 'X'.
    Thanks,
    Sriram Ponna.

  • ALV Sub total texts. displayed in list not in grid.

    Hi,
    I am displaying data using alv and sub-totals on a particular column.
    i am getting the sub-totals but i am not getting the sub-total texts when i am displaying data in a grid.
    'REUSE_ALV_GRID_DISPLAY'.
    i am getting subtotals and subtotal texts when i am diSplAying in list.
    'REUSE_ALV_LIST_DISPLAY'.
    but i want to get subtotal texts using alv grid, is it possible, if so please send me the code.
    Any help in this regard is highly appreciated.
    Thanks in advance for your help.

    Hi,
    Actually i have wriitten the same code, in the alv. I am using Function modules. for the same code the sub-total and total text is appearing in the list output. but not in the grid output.
    code.
      wa_layout-zebra          = 'X'.
      wa_layout-subtotals_text = 'Total'.
      wa_layout-totals_text    = 'Sum of Marks'.
    alv statement.
         is_layout = wa_layout
    Declaration.
    DATA : wa_layout type slis_layout_alv.
    for the same declarations (Above) list is showing the texts but not the grid.
    Any help in this regard is highly appreciated.

  • 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)

  • ALV grid total  or based on two key fields

    Hello experts,
    I have ALV grid with  vendor, g/l account and amount field.
    I want to have sum or total of each vendor, and if vendor having mutliple g/l accounts i want to have sum for each g/l account.
    ex:  vendor   g/l account    amount.
            10           aa                  100
            10           bb                  200
            11           cc                   300
    olp   :   10      aa   100
                10      bb   200
                11      cc   300
    ex2 :   vendor g/ account   amount
               10       aa                 100
                10       aa                200
                11        cc               300
    o/p       10   aa   300.
                11  cc    300.
    Could you please help me and any suggestions
    <<Text removed>>
    Thanks
    reddy.
    Edited by: Matt on Jul 27, 2011 9:21 AM

    Hello Reddy,
    Try using the sort functionality of ALV grid
        CALL METHOD grid1->set_table_for_first_display
          EXPORTING
            i_save                                           = 'A'
            is_layout                                      = lwa_layout
            it_toolbar_excluding                    = i_excl_func
            i_default                                      = c_x
          CHANGING
            it_outtab                                     = i_outtab[]
            it_fieldcatalog                             = i_fieldcat[]
            it_sort                                         = li_sort[]            "use this functionality as per your requirement
          EXCEPTIONS
            invalid_parameter_combination  = 1
            program_error                            = 2
            too_many_lines                          = 3
            OTHERS                                      = 4.
    Hope this may be helpful.
    Sharin

  • Alv grid total overflow

    hi all,
    I have an overflow error in alv total field.
    first i filled alv grid using et_table_for_first_display, again i changed itab data
    and use refresh_table_display to refresh data.
    the alv contains total fields in field catalog.... when i try to 'refresh_table_display '
    it comes an over flow error is coming and it comes every sort of records.. how can i trap this error ..??
    thanks and regards
    Jose

    Hi Anup,
    While using ALV with OOP methodology, you can create an extra row for giving the sum of any field.
    In the field catalog, there is a component named 'DO_SUM', if set, will give the total value for the field.
    In the method where you fill the field catalog , just add this component.
    eg:
    form catalog_fill changing p_field_catalog.
    data ls_fcat type lvc_s_fcat .
    ls_fcat-fieldname = 'CARRID' .
    ls_fcat-inttype = 'C' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Carrier ID' .
    ls_fcat-web_field = 'carrid_handle'.
    ls_fcat-edit = 'X'.
    *ls_fcat-emphasize = 'C310'.   "needed for column coloring
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'FLDATE' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'FLDATE' .
    ls_fcat-outputlen = '20' .
    <b>ls_fcat-do_sum = 'X'.</b>
    ls_fcat-coltext = 'Flight Date' .
    ls_fcat-web_field = 'fldate_handle'.
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'PRICE' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'PRICE' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Airfare' .
    append ls_fcat to field_catalog .
    endform.
    In this way, you can get the total of any field in ALV.
    Regards,
    SP.

  • ALV grid total line customizing

    Dear Masters,
    I need a solution for my problem. I need to modify sorting of subtotal and grand total based on currency which criteria i create  myself. The standard alv output sort total by currency based on alpahabetical order, e.g: AUD,  EUR, IDR, USD. I need to change the sorting into IDR, USD, AUD, EUR. How can i do it in alv grid?
    I also like to add new line after grand total line, which is grand total in Local Currency, in this case, in IDR, which rate given. I can get the figure of subtotal, but i don't know how to append new line after grand total line output in alv standard.
    Need your suggestion.
    Many thanks,
    Tiara

    Hi,
    I have used object oriented ALV. You can remove final total line and have sub total lines. Code below can help you.
    1) Fieldcatalog you can do sum for currency values
    2) Sort Build you can have sub totals.
    3) layout_init you can remove final total line.
    4) CALL METHOD grid->set_table_for_first_display you can pass above structure for excepted Result.
    fieldcatalog_init
    FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
                           value(field_name) value(field_type) value(field_text) value(field_key).
      DATA: ls_fieldcatalog TYPE lvc_s_fcat.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = field_name.
      ls_fieldcatalog-datatype  = field_type.
      ls_fieldcatalog-reptext   = field_text.
      ls_fieldcatalog-coltext   = field_text.
      ls_fieldcatalog-seltext   = field_text.
      ls_fieldcatalog-tooltip   = field_text.
      ls_fieldcatalog-key       = field_key.
      IF field_type = 'CURR'.
        ls_fieldcatalog-do_sum    = 'X'.
      ENDIF.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ENDFORM.                    "fieldcatalog_init
    sort_build
    FORM sort_build USING lt_sort TYPE lvc_t_sort.
      DATA: ls_sort TYPE lvc_s_sort.
      ls_sort-fieldname = 'BUKRS'. "Fieldname on which to sort
      ls_sort-subtot    = 'X'.
      ls_sort-up        = 'X'.     "Sort Ascending
      APPEND ls_sort TO lt_sort.
      IF p_comp <> 'X'.
        ls_sort-fieldname = 'LIFNR'. "Fieldname on which to sort
        ls_sort-subtot    = 'X'.
        ls_sort-up        = 'X'.     "Sort Ascending
        APPEND ls_sort TO lt_sort.
      ENDIF.
      ls_sort-fieldname = 'WAERS'. "Fieldname on which to sort
      ls_sort-subtot    = 'X'.
      ls_sort-up        = 'X'.     "Sort Ascending
      APPEND ls_sort TO lt_sort.
    ENDFORM.                    "sort_build
    layout_init
    FORM layout_init USING ls_layout TYPE lvc_s_layo.
      DATA lv_date(10) TYPE c.
      WRITE sy-datum TO lv_date.
      IF p_line = 'X'.
        CONCATENATE 'Line Item wise Report as on' lv_date INTO w_string2 SEPARATED BY space.
      ELSEIF p_vend = 'X'.
        CONCATENATE 'Vendor Summary Report as on' lv_date INTO w_string2 SEPARATED BY space.
      ELSEIF p_comp = 'X'.
        CONCATENATE 'Company Summary Report as on' lv_date INTO w_string2 SEPARATED BY space.
      ENDIF.
      ls_layout-zebra      = 'X'.
      ls_layout-grid_title =  w_string2.
      ls_layout-sel_mode   = 'A'.
    ls_layout-no_merging = 'X'.
      ls_layout-cwidth_opt = 'X'.
      ls_layout-no_totline = 'X'.
      IF p_line = 'X'.
        ls_layout-ctab_fname = 'COLINFO'.
      ENDIF.
    ENDFORM.                    "layout_init
          CALL METHOD grid->set_table_for_first_display
            EXPORTING
              is_layout       = gs_layout
              is_variant      = va_layout "&see below
              i_save          = 'A'     "&see below
              i_default       = ''
            CHANGING
              it_outtab       = it_apout[]
              it_fieldcatalog = gt_fieldcatalog
              it_sort         = gt_sort.
    Edited by: Himanshu Dave on May 11, 2009 2:33 PM

  • Web Dynpro ALV grid totals

    Hi,
    I have created an application that uses a web dynpro alv grid.  I want to display totals - is there a setting that can do this automatically - if so, can you please tell me how to do this?    Thanks,

    Hi
    You can take help of following code snippet to create totals for a particular column
    Data: lr_function_settings TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
            lr_column          TYPE REF TO cl_salv_wd_column,
            lt_column type salv_wd_t_column_ref,
            ls_column type salv_wd_s_column_ref.
    Data:  lr_field_amnt type REF TO CL_SALV_WD_FIELD.
    * get reference of ALV component
      lr_salv_wd_table = wd_this->wd_cpifc_OVERVIEW_EARNED_ALV( ).
      wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
    *  get function settings
      lr_function_settings ?= wd_this->alv_config_table.
    * display columns in correct order
      lr_column_settings ?= wd_this->alv_config_table.
      lt_column = lr_column_settings->get_columns( ).
      loop at lt_column into ls_column.
    CASE ls_column-id.
    when 'AMOUNT'
    * aggregate field
            CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD
              EXPORTING
                FIELDNAME = 'AMOUNT'
              RECEIVING
                VALUE     = lr_field_amnt.
    * create aggregate rule as total
            CALL METHOD LR_FIELD_AMNT->IF_SALV_WD_AGGR~CREATE_AGGR_RULE
              EXPORTING
                AGGREGATION_TYPE = IF_SALV_WD_C_AGGREGATION=>AGGRTYPE_TOTAL
              RECEIVING
                VALUE            = lv_aggr_rule.
    endcase.
    Regards
    Manas DUa

  • ALV Grid Report using OOPS

    Hi Friends,
    I have to develop the ALV Grid report using the Classes ie OOPS, as i am new to OOPS and know little bit of ALV,  so it will be little bit tough to develop the object so plz try to solve my query. I'm sending the Functional specs:
    The program should display the list of Purchase orders and Purchase requisitions created for specified materials. The output should be displayed in form of ALV grid. There should be separate ALV Grid for Purchase order and Purchase requisition list. The user should also have an option to save various ALV layouts and should be able to choose the ALV layout on the selection screen.The user should be able to navigate to the relevant document form the ALV grid. (Use hyperlink).
    The output must appear in the same screen.     
    Selection screen fields–
         Material Number
         Creation date (For both, PR and PO)
         Output fields –
              List one –
                  Po Number
                                        Po Item number
                                        Vendor
                                        Date
                                        Material Number
                                        Material Quantity
              List two –
                             PR Number
                                        Material Number
                                        Material Quantity
                                        Release status
                                        Date
                                        Reference
         Tables:  EKPO, EKKO, EBAN
         Transactions: ME23N
    HINT –      Use class - CL_GUI_ALV_GRID
    thnks in advance.....

    Hi,
    Check out these standard reports, they are enough to help you out .
    BCALV_GRID_01
    BCALV_GRID_02
    BCALV_GRID_03
    BCALV_GRID_04
    BCALV_GRID_05
    BCALV_GRID_06
    BCALV_GRID_07
    BCALV_GRID_08
    BCALV_GRID_09
    BCALV_GRID_10
    BCALV_GRID_11
    BCALV_GRID_AND_POPUP
    BCALV_GRID_DEMO
    Regards,
    Amit

  • ALV GRID Display using oops in sub screen in which sub screen is in tab

    Hi Mac,
    My requirement is to display an ALV Grid with data in a subscreen which is called in tab strip.
    Could you please help me the code of how actaully i can call th ALV in the tab.
    I want to display one field in editable and remaining 4 fields in display mode.
    Does any one had faced the same issue.This is standard program cloning object.
    Thanks
    Satish Raju

    what is the question? Callin grid in subscreen is the same as in other screen. Create PBO module for creating the grid, PAI to evaluate comands.
    Regards,
    Clemens

  • How to Expand ALV Grid Total Width

    I have to display 1476 characters in an ALV grid and then the users will use what they need when creating a layout.
    Problem is ALV stops after displaying 1375 (or so) characters) - any parm or action to do this (maybe in the catalog setup sent to the program?  Thanks!

    Hi Scott
    This may be a restriction ALV Grid puts. My recommendation will be that, split some fields and generate more than one rows with the same key (you should then add a new key field which will hold line numbers specific to one definite key). When you sort with ALV Grid's sort option the keys will vertically merged (if you do not turn off this feature via layout or field catalog settings). I know this is not so pretty but ALV is not intended to show that kind of stuff.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

  • ALV-GRID TOTAL

    Hi Experts,
    i have issue were in i need to show sum of the amount. like example...
    for Custmer 100 there are vendor number 10,20,30,40,50. so for all this vendor numbers..
    vendor-----  amount
    10 -
       100
    20----
    200
    30----
    300
    40----
    400
    50-------500
    so in the output i want it to be..
    customer--vendornumber--
    amount
       1000--10--
    1500
    20---
    30---
    40---
    50---
    .hope u experts have undestood. so how can i add the it and show it in the output....
    am  forwarding my code also..
    Corrects answers will be fully rewarded..
    REPORT  zrfi007 NO STANDARD PAGE HEADING LINE-SIZE 255 MESSAGE-ID z01.
    TYPE-POOLS: slis, abap.
    * TYPES Declaration
    TYPES: BEGIN OF ty_lfa1,
          lifnr TYPE lfa1-lifnr,
          name1 TYPE lfa1-name1,
          END OF ty_lfa1.
    TYPES:  BEGIN OF ty_bsik,
             bukrs  TYPE    bsik-bukrs,
             lifnr  TYPE    bsik-lifnr,
             belnr  TYPE    bsik-belnr,
             bldat  TYPE    bsik-bldat,
             waers  TYPE    bsik-waers,
             dmbtr  TYPE    bsik-dmbtr,
             wrbtr  TYPE    bsik-wrbtr,
              zfbdt TYPE    bsik-zfbdt,
             zbd1t  TYPE    bsik-zbd1t,
            zbd2t   TYPE    bsik-zbd2t,
            zbd3t   TYPE    bsik-zbd3t,
           END OF ty_bsik.
    TYPES: BEGIN OF ty_lfb1,
           lifnr TYPE lfb1-lifnr,
           bukrs TYPE lfb1-bukrs,
           END OF ty_lfb1.
    TYPES: BEGIN OF ty_final,
             bukrs  TYPE    bsik-bukrs,
             lifnr  TYPE    bsik-lifnr,
             belnr  TYPE    bsik-belnr,
             bldat  TYPE    bsik-bldat,
             days   TYPE    sy-datum,
             waers  TYPE    bsik-waers,
             dmbtr  TYPE    bsik-dmbtr,
    *         waers  type    bsik-waers,
             wrbtr  TYPE    bsik-wrbtr,
             zfbdt  TYPE    bsik-zfbdt,
             zbd1t  TYPE    bsik-zbd1t,
             zbd2t  TYPE    bsik-zbd2t,
             zbd3t  TYPE    bsik-zbd3t,
             name1  TYPE    lfa1-name1,
             current  TYPE    bsik-dmbtr,
            d30     TYPE    bsik-dmbtr,
            d60     TYPE    bsik-dmbtr,
            d90     TYPE    bsik-dmbtr,
            d120    TYPE    bsik-dmbtr,
            d180    TYPE    bsik-dmbtr,
            d240    TYPE    bsik-dmbtr,
            d360    TYPE    bsik-dmbtr,
            da365   TYPE    bsik-dmbtr,
    *        ct_date TYPE  sy-datum,
    *         date   TYPE datum,
    *         days  TYPE char8,
           END OF ty_final.
    * Data Declaration.
    DATA: gt_lfa1 TYPE STANDARD TABLE OF ty_lfa1,
          wa_lfa1 TYPE ty_lfa1.
    DATA: gt_final TYPE STANDARD TABLE OF ty_final,
          wa_final TYPE ty_final.
    DATA: gt_bsik TYPE STANDARD TABLE OF ty_bsik,
          wa_bsik TYPE ty_bsik.
    DATA: gt_lfb1 TYPE STANDARD TABLE OF ty_lfb1,
          wa_lfb1 TYPE ty_lfb1.
    DATA:   days        TYPE sy-datum.
    * ALV Components
    **** ALV Internal Table
    DATA : i_layout     TYPE slis_layout_alv OCCURS 0 WITH HEADER LINE,
           i_events     TYPE slis_t_event,
           i_fieldcat   TYPE slis_t_fieldcat_alv,
           i_print      TYPE slis_print_alv,
           i_list_top   TYPE slis_t_listheader,
           i_list_end   TYPE slis_t_listheader,
           i_sort       TYPE slis_t_sortinfo_alv.
    DATA:  wa_fieldcat  LIKE LINE OF i_fieldcat.
    * ALV Variable.
    DATA: v_top        TYPE slis_formname VALUE 'TOP_OF_PAGE',
          v_eop        TYPE slis_formname VALUE 'END_OF_PAGE',
          v_eol        TYPE slis_formname VALUE 'END_OF_LIST',
          v_tol        TYPE slis_formname VALUE 'TOP_OF_LIST'.
    **** ALV Variants
    DATA: i_variant      LIKE disvariant.
    * Selection screen
    DATA: v_bukrs TYPE bukrs,
          v_lifnr TYPE kunnr,
          pa_bldat TYPE bldat.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_bukrs FOR v_bukrs NO INTERVALS NO-EXTENSION OBLIGATORY,
                    s_lifnr FOR v_lifnr.
    *                bldat FOR v_bldat no-extension.
    PARAMETERS: p_bldat TYPE  bsik-bldat.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN SKIP 2.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS: p_detail RADIOBUTTON GROUP r1 DEFAULT 'X',
                p_sumry RADIOBUTTON GROUP r1.
    SELECTION-SCREEN END OF BLOCK b2.
    *  Top-Of-Page Declaration Header
    DATA: lwa_list_top LIKE LINE OF i_list_top.
    DATA: lv_header(70),
          lv_text(50),
          lv_text1(60),
          lv_text2(50),
          lv_text3(50) ,
          lv_text4(50),
          lv_date TYPE char10,
          lv_time TYPE char10.
    DATA: lv_butxt LIKE t001-butxt,
          lv_butxt1 LIKE lfa1-name1,
          lv_butxt2 LIKE lfb1-lifnr.
    INITIALIZATION.
    *TOP-OF-PAGE.
    * Validations for Selection screen
    AT SELECTION-SCREEN ON s_bukrs.
      IF NOT s_bukrs[] IS INITIAL.
        SELECT SINGLE bukrs FROM lfb1
         INTO s_bukrs
        WHERE bukrs IN s_bukrs.
      ENDIF.
      IF sy-subrc NE 0.
        MESSAGE e003.
      ENDIF.
    AT SELECTION-SCREEN ON s_lifnr.
      IF NOT s_lifnr[] IS INITIAL.
        SELECT SINGLE lifnr FROM lfa1
        INTO s_lifnr
        WHERE lifnr IN s_lifnr.
        IF sy-subrc NE 0.
          MESSAGE e005.
        ENDIF.
      ENDIF.
    AT SELECTION-SCREEN ON p_bldat.
      IF NOT p_bldat IS INITIAL.
        SELECT SINGLE bldat FROM bsid
        INTO p_bldat
        WHERE bldat = p_bldat.
        IF sy-subrc NE 0 .
          MESSAGE e004.
        ENDIF.
      ENDIF.
    * Selection For Top-of-page.
    ** Get company code description
      SELECT SINGLE butxt
        FROM t001 INTO lv_butxt
        WHERE bukrs IN s_bukrs.
    *  SELECT SINGLE lifnr  FROM lfb1
    *  INTO  lv_butxt2  WHERE bukrs IN s_bukrs.
    *  SELECT SINGLE name1 FROM lfa1
    *   INTO lv_butxt1 WHERE lifnr = lv_butxt2.
    START-OF-SELECTION.
      PERFORM data_retrival.
      PERFORM f_layout_init.
      PERFORM f_eventtab_build.
      i_variant-report = sy-repid.
      PERFORM f_print_control.
    *  PERFORM f_build_header_list.
    *  perform f_build_header_list1.
    *    PERFORM f_build_fieldcat.
      IF p_detail = 'X'.
        PERFORM f_build_sort.
        PERFORM fill_fieldcat.
        PERFORM f_build_header_list.
      ELSE.
        PERFORM f_build_sort1.
        PERFORM fill_fieldcat_sum.
        PERFORM f_build_header_list1.
      ENDIF.
      PERFORM f_list_display TABLES gt_final[].
    END-OF-SELECTION.
    *&      Form  data_retrival
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM data_retrival .
      SELECT   bukrs
               lifnr
               belnr
               bldat
               waers
               dmbtr
               wrbtr
               zfbdt
               zbd1t
               zbd2t
               zbd3t
               FROM bsik INTO TABLE gt_bsik
               WHERE bukrs IN s_bukrs
               AND   lifnr IN s_lifnr.
      SELECT lifnr
             name1
             FROM lfa1 INTO TABLE gt_lfa1
             FOR ALL ENTRIES IN gt_bsik
             WHERE lifnr = gt_bsik-lifnr.
      LOOP AT gt_bsik INTO wa_bsik.
        READ TABLE gt_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_bsik-lifnr.
        MOVE-CORRESPONDING wa_bsik TO wa_final.
        MOVE-CORRESPONDING wa_lfa1 TO wa_final.
        DATA: days TYPE char2,
              c4 TYPE char2.
        DATA: days1 TYPE sy-datum.
        DATA:duedate TYPE rfpos-faedt.
        CALL FUNCTION 'NET_DUE_DATE_GET'
          EXPORTING
            i_zfbdt       = wa_final-zfbdt
            i_zbd1t       = wa_final-zbd1t
            i_zbd2t       = wa_final-zbd2t
            i_zbd3t       = wa_final-zbd3t
            i_shkzg       = ' '
            i_rebzg       = ' '
    *   I_KOART       = 'D'
         IMPORTING
           e_faedt       = duedate.
        CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
          EXPORTING
            i_datum_bis                   = duedate
            i_datum_von                   = wa_final-bldat
    *   I_KZ_EXCL_VON                 = '0'
    *   I_KZ_INCL_BIS                 = '0'
    *   I_KZ_ULT_BIS                  = ' '
    *   I_KZ_ULT_VON                  = ' '
    *   I_STGMETH                     = '0'
    *   I_SZBMETH                     = '1'
         IMPORTING
           e_tage                        = days
         EXCEPTIONS
           days_method_not_defined       = 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.
        wa_final-days = duedate.
        DATA : wf_char TYPE char10.
        wf_char = days.
        IF wf_char+0(1) EQ '*' .
          SKIP.
        ELSE.
          IF days EQ 0.
            wa_final-current = wa_bsik-wrbtr.
          ELSEIF days LE 30 AND days GT 0.
            wa_final-d30 = wa_bsik-wrbtr.
          ELSEIF days LE 60 AND days GT 30 .
            wa_final-d60 = wa_bsik-wrbtr.
          ELSEIF days LE 90 AND days GT 60.
            wa_final-d90 = wa_bsik-wrbtr.
          ELSEIF days LE 120 AND days GT 90.
            wa_final-d120 = wa_bsik-wrbtr.
          ELSEIF days LE 180 AND days GT 120.
            wa_final-d180 = wa_bsik-wrbtr.
          ELSEIF days LE 240 AND days GT 180.
            wa_final-d240 = wa_bsik-wrbtr.
          ELSEIF days LE 360 AND days GT 240.
            wa_final-d360 = wa_bsik-wrbtr.
          ELSEIF days GT 365 .
            wa_final-da365 = wa_bsik-wrbtr.
          ENDIF.
        ENDIF.
        APPEND wa_final TO gt_final.
        CLEAR: wa_final,
               days,
               duedate,days1.
      ENDLOOP.
    ENDFORM.                    " data_retrival
    *&      Form  fill_fieldcat
    *       text
    FORM fill_fieldcat.
      PERFORM  fill_fields USING: 'Vendor Number' 'LIFNR',
                                  'Vendor Name' 'NAME1',
                                  'Document Number' 'BELNR',
                                  'Document Date' 'BLDAT',
                                  'Due Date' 'DAYS',
                                  'Total In Document Currency' 'WRBTR',
                                  'Currency' 'WAERS',
                                  'Total In Reporting Currency' 'DMBTR',
                                  'Current' 'CURRENT',
                                  '1-30 days' 'D30',
                                  '31-60 days' 'D60',
                                  '61-90 days' 'D90',
                                  '91-120 days' 'D120',
                                  '121-180 days' 'D180',
                                  '181-240 days' 'D240',
                                  '241-360 days'  'D360',
    *                              '181-365 days' 'D365',
                                  'Above 365 days' 'DA365'.
    ENDFORM.                    "fill_fieldcat
    *&      Form  fill_fieldcat_sum
    *       text
    FORM fill_fieldcat_sum.
      PERFORM  fill_fields USING: 'Vendor Number' 'LIFNR',
                                  'Vendor Name' 'NAME1',
                                  'Total In Reporting Currency' 'DMBTR',
                                  'Current' 'CURRENT',
                                  '1-30 days' 'D30',
                                  '31-60 days' 'D60',
                                  '61-90 days' 'D90',
                                  '91-120 days' 'D120',
                                  '121-180 days' 'D180',
                                  '181-240 days' 'D240',
                                  '241-360 days'  'D360',
                                  'Above 365 days' 'DA365'.
    ENDFORM.                    "fill_fieldcat_sum
    *&      Form  fill_fields
    *       text
    *      -->&01        text
    *      -->&02        text
    FORM fill_fields USING &01 &02 .
      wa_fieldcat-tabname = 'T_OUTPUT'.  "t_output_provgr
      wa_fieldcat-fieldname = &02.
      wa_fieldcat-seltext_m = &01.
    *  wa_fieldcat-ref_fieldname = fieldname.
    *  wa_fieldcat-ref_tabname = 'SFLIGHT'.
    *  w_fieldcat-do_sum = &03.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    ENDFORM.                    "fill_fields
    *&      Form  f_layout_init
    *       Set the layout
    FORM f_layout_init.
    *  P_layout-min_linesize       = 170.
    *  p_layout-max_linesize       = 170.
    *  P_layout-no_colhead         = abap_true.
    *  p_layout-detail_popup       = abap_true.
      i_layout-colwidth_optimize  = abap_true.
      i_layout-zebra              = abap_true.
    *  i_layout-subtotals_text     = 'SubTotal'.
    *  i_layout-totals_text        = 'Total'.
    ENDFORM.                    " f_layout_init
    *&      Form  f_eventtab_build
    *       Set the events
    FORM f_eventtab_build.
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = i_events.
      READ TABLE i_events WITH KEY name = slis_ev_top_of_page
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE v_top TO: ls_event-form,
                       ls_event-name.
        APPEND ls_event TO i_events.
      ENDIF.
      READ TABLE i_events WITH KEY name = slis_ev_end_of_page
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE v_eop TO: ls_event-form,
                       ls_event-name.
        APPEND ls_event TO i_events.
      ENDIF.
      READ TABLE i_events WITH KEY name = slis_ev_end_of_list
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE v_eol TO: ls_event-form,
                       ls_event-name.
        APPEND ls_event TO i_events.
      ENDIF.
      READ TABLE i_events WITH KEY name = slis_ev_top_of_list
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE v_tol TO: ls_event-form,
                       ls_event-name.
        APPEND ls_event TO i_events.
      ENDIF.
    ENDFORM.                    " f_eventtab_build
    *&      Form  f_print_control
    *       Set the print control
    FORM f_print_control .
    *  i_print-no_print_listinfos     = abap_true.
    *  i_print-no_print_selinfos      = abap_true.
    *  i_print-reserve_lines          = 2.
    *  i_print-no_change_print_params = abap_true.
    ENDFORM.                    " f_print_control
    *&      Form  f_build_header_list
    *       Build the header list (top of page)
    FORM f_build_header_list .
      lv_header = 'Vendor Open Item Analysis By Balance Of Overdue Items'(h01).
      lv_text   = 'Company Name:'(s01).
      lv_text1   = 'Open Item As Key Date:'(s02).
      lv_text2   = 'Company Code:'(s03).
      lv_text3   =  'Vendor Number:'(s04).
      lv_text4   =  'Vendor Name:'(s05).
    * Header
      CLEAR lwa_list_top.
      lwa_list_top-typ  = 'H'.
      lwa_list_top-info = lv_header.
      APPEND lwa_list_top TO i_list_top.
    * Run date Display
      lwa_list_top-typ  = 'S'.                " Item
      WRITE: sy-datum  TO lv_date MM/DD/YYYY.
      lwa_list_top-key = 'Date :'(025).
      lwa_list_top-info = lv_date.
      APPEND lwa_list_top TO i_list_top.
      CLEAR: lwa_list_top,
             lv_date.
    * Run time Display
      lwa_list_top-typ  = 'S'.                " Item
      WRITE: sy-uzeit  TO lv_time USING EDIT MASK '__:__:__'.
      lwa_list_top-key  = 'Time :'(026).
      lwa_list_top-info =  lv_time.
      APPEND lwa_list_top TO i_list_top.
      CLEAR: lwa_list_top,
             lv_time.
      CLEAR lwa_list_top.
    * Company Name
      lwa_list_top-typ  = 'S'.
      lwa_list_top-key  = lv_text.
      lwa_list_top-info = lv_butxt.
      APPEND lwa_list_top TO i_list_top.
      CLEAR lwa_list_top.
    *Open Item As Key Date
      lwa_list_top-typ  = 'S'.
      lwa_list_top-key  = lv_text1.
      lwa_list_top-info = p_bldat.
      APPEND lwa_list_top TO i_list_top.
      CLEAR lwa_list_top.
    * Company Code
      lwa_list_top-typ  = 'S'.
      lwa_list_top-key  = lv_text2.
      lwa_list_top-info = s_bukrs-low.
      APPEND lwa_list_top TO i_list_top.
      CLEAR lwa_list_top.
    ** Vendor Number
    *  lwa_list_top-typ  = 'S'.
    *  lwa_list_top-key  = lv_text3.
    *  lwa_list_top-info = lv_butxt2.
    *  APPEND lwa_list_top TO i_list_top.
    *  CLEAR lwa_list_top.
    **Vendor Name
    *  lwa_list_top-typ  = 'S'.
    *  lwa_list_top-key  = lv_text4.
    *  lwa_list_top-info = lv_butxt1.
    *  APPEND lwa_list_top TO i_list_top.
    ENDFORM.                    " f_build_header_list
    *&      Form  f_build_header_list1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_build_header_list1 .
      lv_header = 'Vendor Open Item Analysis By Balance Of Overdue Items'(h01).
      lv_text   = 'Company Name:'(s01).
      lv_text1   = 'Open Item As Key Date:'(s02).
      lv_text2   = 'Company Code:'(s03).
      lv_text3   =  'Vendor Number:'(s04).
      lv_text4   =  'Vendor Name:'(s05).
      lwa_list_top-typ  = 'H'.
      lwa_list_top-info = lv_header.
      APPEND lwa_list_top TO i_list_top.
    * Run date Display
      lwa_list_top-typ  = 'S'.                " Item
      WRITE: sy-datum  TO lv_date MM/DD/YYYY.
      lwa_list_top-key = 'Date :'(025).
      lwa_list_top-info = lv_date.
      APPEND lwa_list_top TO i_list_top.
      CLEAR: lwa_list_top,
             lv_date.
    * Run time Display
      lwa_list_top-typ  = 'S'.                " Item
      WRITE: sy-uzeit  TO lv_time USING EDIT MASK '__:__:__'.
      lwa_list_top-key  = 'Time :'(026).
      lwa_list_top-info =  lv_time.
      APPEND lwa_list_top TO i_list_top.
      CLEAR: lwa_list_top,
             lv_time.
      CLEAR lwa_list_top.
    * Company Name
      lwa_list_top-typ  = 'S'.
      lwa_list_top-key  = lv_text.
      lwa_list_top-info = lv_butxt.
      APPEND lwa_list_top TO i_list_top.
      CLEAR lwa_list_top.
    *Open Item As Key Date
      lwa_list_top-typ  = 'S'.
      lwa_list_top-key  = lv_text1.
      lwa_list_top-info = p_bldat.
      APPEND lwa_list_top TO i_list_top.
      CLEAR lwa_list_top.
    ENDFORM.                    " f_build_header_list1
    *&      Form  f_build_sort
    *       Set the sorting sequence
    FORM f_build_sort .
      DATA: l_sort TYPE slis_sortinfo_alv.
      l_sort-spos      =  '1'.
      l_sort-fieldname = 'LIFNR'.
      l_sort-up        = abap_true.
      l_sort-group     = '*'.
    *  l_sort-subtot    = 'X'.
      APPEND l_sort TO i_sort.
    *  l_sort-spos      =  '2'.
    *  l_sort-fieldname = 'NAME1'.
    *  l_sort-up        = abap_true.
    *  l_sort-group     = '*'.
    **  l_sort-subtot    = 'X'.
    *  APPEND l_sort TO i_sort.
    *  l_sort-spos      =  '2'.
    *  l_sort-fieldname = 'LIFNR'.
    *  l_sort-up        = abap_true.
    *  l_sort-subtot    = abap_true.
    *  APPEND l_sort TO i_sort.
    *  l_sort-spos      =  '1'.
    *  l_sort-fieldname = 'VBELN'.
    *  l_sort-up        = abap_true.
    *  l_sort-subtot    = abap_true.
    *  APPEND l_sort TO i_sort.
    *  l_sort-spos      =  '2'.
    *  l_sort-fieldname = 'POSNR'.
    *  l_sort-up        = abap_true.
    *  l_sort-subtot    = abap_true.
    *  APPEND l_sort TO i_sort.
    ENDFORM.                    " f_build_sort
    *&      Form  f_list_display
    *       Display the ALV list report
    *      -->PT_DATA    Internal table containing the data
    FORM f_list_display TABLES pt_data.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = i_variant-report
          is_layout          = i_layout
          it_fieldcat        = i_fieldcat[]
          it_sort            = i_sort
          i_default          = 'X'
          i_save             = 'A'
          is_variant         = i_variant
          it_events          = i_events[]
          is_print           = i_print
        TABLES
          t_outtab           = pt_data.
    ENDFORM.                    "f_list_display
    *&      Form  TOP_OF_PAGE
    *       TOP_OF_PAGE Event
    FORM top_of_page.                                           "#EC CALLED
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
    *      i_logo             = 'ZLOGO_BAB'
          it_list_commentary = i_list_top
          i_alv_form         = 'X'.
    *  PERFORM f_print_header USING SPACE SPACE SPACE.
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  END_OF_PAGE
    *       END_OF_PAGE Event
    FORM end_of_page.                                           "#EC CALLED
    *  DATA: l_pos(3) TYPE n VALUE 0,
    *        l_foot(30) VALUE '*** END OF PAGE ***'.
    *  l_pos = ( sy-linsz / 2 ) - ( STRLEN( l_foot ) / 2 ).
    *  ULINE.
    *  WRITE: /, AT l_pos l_foot.
    ENDFORM.                    "END_OF_PAGE
    *&      Form  END_OF_LIST
    *       END_OF_LIST Event
    FORM end_of_list.                                           "#EC CALLED
    *  DATA: l_pos(3) TYPE n VALUE 0,
    *        l_foot(30) VALUE '*** END OF REPORT ***'.
    *  l_pos = ( sy-linsz / 2 ) - ( STRLEN( l_foot ) / 2 ).
    *  ULINE.
    *  WRITE: /, AT l_pos l_foot.
    ENDFORM.                    "END_OF_LIST
    *&      Form  f_print_header
    *       Print the header (Top-Of-Page)
    *      -->P_P_TITLE1  Title text 1
    *      -->P_P_TITLE2  Title text 2
    *      -->P_P_TITLE3  Title text 3
    FORM f_print_header  USING    p_title1 LIKE sy-title
                                  p_title2 LIKE sy-title
                                  p_title3 LIKE sy-title.
      DATA: l_post1 TYPE i,
            l_post2 TYPE i,
            l_post3 TYPE i,
            l_posin TYPE i.
      l_post1 = ( sy-linsz / 2 ) - ( STRLEN( p_title1 ) / 2 ).
      l_post2 = ( sy-linsz / 2 ) - ( STRLEN( p_title2 ) / 2 ).
      l_post3 = ( sy-linsz / 2 ) - ( STRLEN( p_title3 ) / 2 ).
      l_posin = sy-linsz - 17.
      WRITE:  / 'Report  :', sy-cprog.
      WRITE AT  l_post1 p_title1.
      WRITE AT  l_posin 'Date :'.
      WRITE     sy-datum.
      WRITE:  / 'Cli/Sys :', sy-mandt, '/', sy-sysid.
      WRITE AT  l_post2 p_title2.
      WRITE AT: l_posin 'Time :'.
      WRITE     sy-uzeit.
      WRITE:  / 'UserID  :', sy-uname.
      WRITE AT  l_post3 p_title3.
      WRITE AT  l_posin 'Page :'.
      WRITE     sy-pagno NO-ZERO.
    ENDFORM.                    " f_print_header
    *&      Form  f_build_sort1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form f_build_sort1 .
    DATA: l_sort TYPE slis_sortinfo_alv.
      l_sort-spos      =  '1'.
      l_sort-fieldname = 'LIFNR'.
      l_sort-up        = abap_true.
      l_sort-group     = '*'.
    *  l_sort-subtot    = 'X'.
      APPEND l_sort TO i_sort.
    l_sort-spos      =  '2'.
      l_sort-fieldname = 'NAME1'.
      l_sort-up        = abap_true.
      l_sort-group     = '*'.
    *  l_sort-subtot    = 'X'.
      APPEND l_sort TO i_sort.
    *  l_sort-spos      =  '3'.
    *  l_sort-fieldname = 'DMBTR'.
    *  l_sort-up        = abap_true.
    *  l_sort-group     = '*'.
    *  l_sort-subtot    = 'X'.
    *  APPEND l_sort TO i_sort.
    endform.                    " f_build_sort1
    Regards
    Sunita.

    Hey,
    U can try out "SORTING THE VENDORS AND DO THE SUM in the NETWR"... try it out....see u sort the customers...rit?...keep it as usual and little mentoned above...
    hope dis help u out...
    Thanks.

  • ALV grid total andsub-total

    hi there...I know there´s a lot of posts about this subject but i didn't find what i´m looking for...
    I want to know if there´s some way to give a total and a sub-total of a field, but instead of the total and subtotal sums I just want a count of the number of rows for the field that I've sorted.
    FIELDCATALOG-FIELDNAME   = 'BUKRS'.
      FIELDCATALOG-SELTEXT_M   = 'BUKRS'.
      FIELDCATALOG-COL_POS     = 0.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'BUTXT'.
      FIELDCATALOG-SELTEXT_M   = 'BUTXT'.
      FIELDCATALOG-COL_POS     = 1.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'LIFNR'.
      FIELDCATALOG-SELTEXT_M   = 'LIFNR'.
      FIELDCATALOG-COL_POS     = 2.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'NAME1'.
      FIELDCATALOG-SELTEXT_M   = 'NAME1'.
      FIELDCATALOG-COL_POS     = 3.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'MBLNR'.
      FIELDCATALOG-SELTEXT_M   = 'MBLNR'.
      FIELDCATALOG-COL_POS     = 4.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'MJAHR'.
      FIELDCATALOG-SELTEXT_M   = 'MJAHR'.
      FIELDCATALOG-COL_POS     = 5.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'CPUDT'.
      FIELDCATALOG-SELTEXT_M   = 'CPUDT'.
      FIELDCATALOG-COL_POS     = 6.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'BUDAT'.
      FIELDCATALOG-SELTEXT_M   = 'BUDAT'.
      FIELDCATALOG-COL_POS     = 7.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'USNAM'.
      FIELDCATALOG-SELTEXT_M   = 'BUDAT'.
      FIELDCATALOG-COL_POS     = 8.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'MENGE'.
      FIELDCATALOG-SELTEXT_M   = 'MENGE'.
      FIELDCATALOG-COL_POS     = 9.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'DMBTR'.
      FIELDCATALOG-SELTEXT_M   = 'DMBTR'.
      FIELDCATALOG-COL_POS     = 10.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
    *          SORT
      WA_SORT-SPOS = 1.
      WA_SORT-FIELDNAME = 'BUKRS'.
      WA_SORT-TABNAME = 'ITAB'.
      WA_SORT-UP = 'X'.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
      WA_SORT-SPOS = 2.
      WA_SORT-FIELDNAME = 'LIFNR'.
      WA_SORT-TABNAME = 'ITAB'.
      WA_SORT-UP = 'X'.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
    in the alv i want to know the number of rows for each value of lifnr (sub-total) and in the end the total of the all values of lifnr
    thanks

    Hi,
    It is better to obtain this information not in ALV but working on the table. Using control level processing it is easy to achieve.
    data: begin of it_overview occurs 0
              lifnr type ..
              tot_item type i,     "number of lifnr withing subtotal
            end of it_overwiev.
    data: pos type i.   "to remember the position.
    "your output table
    Loop at it_ouptut.
       at new lifnr.
          pos = sy-tabix.    "remember first position of new LIFNR
       endat.
       at end of lifnr.
          it_overview-lifnr = it_output-lifnr.
          it_overview-tot_item = sy-tabix - pos.    "calculate how many within one LIFNR
          append it_overview.                             "store it in the table
           clear pos.
       endat.
    endloop.
    this way table IT_OVERVIEW stores LIFNRs and number of items forming their subtotals.
    To get total use:
    DESCRIEBE TABLE it_output.
    it_output-lifnr = 'TOTAL_ITEMS'.    "total items within all LIFNRs
    it_output-tot_item = sy-tfill.            "is equal to total lines in the table
    append it_output.
    Regards
    Marcin

  • ALV Grid Totals Issue

    Hi,
    We are using REUSE_ALV_GRID_DISPLAY for diaplying grid . we want the totals to be displayed for some fields.
    but for percentage fields we want to calculate the values. How do we do this?

    Hi Asharaghu,
    FOR TOTAL:
    there is a property of fieldcatalog, that is do_sum.
    USE COED LIKE:
    PERFORM fieldcat USING:
    '1' 'KUNNR' 'I_MARD' 'CUSTOMER NO' ,
    '2' 'DMBTR' 'I_MARD' 'CURRENCY' ,
    FORM fieldcat USING value(p_0029)
    value(p_0030)
    value(p_0031)
    value(p_0032)
    wa_fieldcat-col_pos = p_0029.
    wa_fieldcat-fieldname = p_0030.
    wa_fieldcat-tabname = p_0031.
    wa_fieldcat-reptext = p_0032.
    wa_fieldcat-do_sum = 'X'.
    APPEND wa_fieldcat TO i_fieldcat.
    ENDFORM. " FIELDCAT
    Then pass i_fieldcat through REUSE_ALV_GRID_DISPLAY.
    in final output you will get the total of currency field.
    Hope this can solve your problems.
    Regards,
    Tutun

  • Need to display grand total text in OOPS ABAP ALV report

    Hi
    I am using OOPS for alv display and need to display grand "total text" in any column in th eoutput display.
    I know the procedure to display in ALV display. but dont have idea in OOPS. Please help.
    Thanks
    Amminesh.

    hi,
    follow this link for alv's with oop's oncept.
    http://abapreports.blogspot.com/2008/06/alv-grid-display-with-oops.html
    for calculating total  to the specific field.....
    while creating the fieldcatalog pass the value 'X' to field do_sum of lvc_t_fcat( field catalog).
    data: fcat type lvc_t_fcat.
    fcat-fieldname = <field-name>.
    fcat-ref_table = <ref-tablename>.
    fcat-ref_field = <ref-fieldname>.
    fcat-do_sum = 'X'.
    regards,
    Ashok

Maybe you are looking for

  • How to get name of table cell ? Also, how to set name and label property on table itself?

    I am trying to use below API: PMString tableName = "myTable"; ErrorCode error = Utils<Facade::IPageItemNameFacade>()->SetUserAssignedPageItemName(tableUIDRef, tableName); But this is not setting up the table name, also I am getting error = 1. Also, I

  • I7 iMac Arrives With Cracked Glass. Apple Customer Service Acts Suspect.

    So the i7 iMac arrives. Excited and scared - because I've heard all the stories about "bad iMacs" being delivered. I unpack it and place it on the top to admire it's girth and beauty. It truly is glorious! I remove the static sleeve and begin to remo

  • No access to S_ALV_LAYO, can still change a layout

    End user is executing transaction ME2S and is able to change layout.  When I checked he does have access to authorization object S_ALV_LAYO. I did a system trace and the authorization object is checked, gets a return code of 12. This authrization obj

  • Javascript Date & Time Picker

    Hi, I would like to create an event on a text field, when you click on it it's calling a javascript function to popup a date & time picker. Is anyone can help me ? Eric . Thanks

  • Protocol maintenance -OAA3

    Hi All, I am integrating a 3rd party content server with SAP. I have done following steps: OAC0 u2013 customizing Content Repositories OAC2 u2013 SAP AL Documenttypes global OAC3 u2013 SAP AL Link Table I have created links in the SAP table TOA01. Lo