How to get Subtotal text in ALV using OOPS

hi,
Can any one pls help me out getting  <b>subtotals text</b> in ALV using OOPS concepts....Pls provide me if any of u have  sample code for that......
my code:
data:gr_grid_d0100 type ref to cl_gui_alv_grid.
data : gr_events_d0100   type ref to lcl_events_d0100.
classes**********
class lcl_events_d0100 definition.
  public section.
    methods:
subtotal_text for event subtotal_text
                    of cl_gui_alv_grid
                    importing es_subtottxt_info
                    ep_subtot_line
                    e_event_data.
endclass.
class lcl_events_d0100 implementation.
method subtotal_text.
    perform d0100_event_subtotal_text using       es_subtottxt_info
ep_subtot_line
e_event_data.
  endmethod.                    "subtotal_text
endclass.
data : gr_event_handler type ref to lcl_events_d0100.
SET HANDLER gr_event_handler->subtotal_text FOR wcl_alv_grid_request
FORM d0100_event_subtotal_text USING
      es_subtottxt_info TYPE LVC_S_STXT
      ep_subtot_line TYPE REF TO data
      e_event_data TYPE REF TO cl_alv_event_data.
  DATA: l_text TYPE string.
  l_text = es_subtottxt_info.
  FIELD-SYMBOLS: <fs> TYPE ANY.
  ASSIGN e_event_data->m_data->* TO <fs>.
                        <fs> = text-007.

hi vijay
check this code
if you want to use field symbols.
data: total type ref to data,
subtotal1 type ref to data.
field-symbols <total> like gt_sflight.
field-symbols <subtotal1> like gt_sflight.
call method grid1->get_subtotals
importing
ep_collect00 = total
ep_collect01 = subtotal1.
assign total->* to <total>.
assign subtotal1->* to <subtotal1>.
or u can use
U have to do the subtotal column wise.In the field catalog specify the following in addition to the corresponding field name(i.e. Column)
DATA ls_fcat TYPE lvc_s_fcat.
ls_fcat-do_sum = 'X'.
Hope this helps u out.
Thanks & Regards,
naveen

Similar Messages

  • Subtotal text in ALV using OO ALV

    HI All,
    How to display subtotal text in ALV using OO ALV?
    My output of ALV should be as follows
    COL1    COL2   COL3
    ABC      900       M1
    PQR      100       M1
    M1 Subtotal 1000
    XYZ      2100    M2    
    M2 Subtotal 2100
    I could put the subtotal, but couldnu2019t add subtotal text.
    My code
      TRY.
          CALL METHOD cl_salv_table=>factory
            IMPORTING
              r_salv_table   = g_alv
            CHANGING
              t_table        = gt_report
        CATCH cx_salv_msg .
      ENDTRY.
    u2026u2026
    *Display the table.
      g_alv->display( ).

    Hi
    REPORT  z_alv_demo_total_text.
    Type declaration for final table to display the output
    TYPES: BEGIN OF ty_mara,
            srno TYPE char40, " Storing the total text
            matnr TYPE matnr, " Material
            ersda TYPE ersda, " Creation date
            ernam TYPE ernam, " Created by
            laeda TYPE laeda, " Last change date
            aenam TYPE aenam, " Last change by
            vpsta TYPE vpsta, " Maintenance status
            brgew TYPE brgew, " Gross weight
            ntgew TYPE ntgew, " Net weight
            gewei TYPE gewei, " Weight Unit
           END OF ty_mara.
    Type declaration for table storing temp. data
    TYPES: BEGIN OF ty_mara_tmp,
            matnr TYPE matnr, " Material
            ersda TYPE ersda, " Creation date
            ernam TYPE ernam, " Created by
            laeda TYPE laeda, " Last change date
            aenam TYPE aenam, " Last change by
            vpsta TYPE vpsta, " Maintenance status
            brgew TYPE brgew, " Gross weight
            ntgew TYPE ntgew, " Net weight
            gewei TYPE gewei, " Weight Unit
          END OF ty_mara_tmp.
    Internal table for storing final data
    DATA: i_mara TYPE STANDARD TABLE OF ty_mara INITIAL SIZE 0.
    Work area for final table
    DATA: w_mara TYPE ty_mara.
    Internal table for storing temp. data
    DATA: i_mara_tmp TYPE STANDARD TABLE OF ty_mara_tmp INITIAL SIZE 0.
    Work area for temp. table
    DATA: w_mara_tmp TYPE ty_mara_tmp.
    Object variable for ALV grid
    DATA: oref1 TYPE REF TO cl_gui_alv_grid.
    Field catalog table for ALV grid
    DATA: fieldcat TYPE  lvc_t_fcat.
    Workarea for field catalog table
    DATA: w_field TYPE lvc_s_fcat.
    Internal table for storing info. for ALV grid
    data: i_sort2 TYPE STANDARD TABLE OF lvc_s_sort INITIAL SIZE 0.
    Workarea for sort table
    DATA: wa_sort2      TYPE  lvc_s_sort.
    Workarea for ALV layout
    data: wa_layout     TYPE  lvc_s_layo.
    START-OF-SELECTION.
    Fetch data
    SELECT  matnr   " Material
            ersda   " Creation date
            ernam   " Created by
            laeda   " Last change date
            aenam   " Last change by
            vpsta   " Maintenance status
            brgew   " Gross weight
            ntgew   " Net weight
            gewei   " Weight Unit
      FROM mara
      INTO TABLE i_mara_tmp
      UP TO 100 ROWS.
      CHECK sy-subrc = 0.
    Populate final table
      LOOP AT i_mara_tmp INTO w_mara_tmp.
      Storing the Total text need to be displayed in
      ALV
        w_mara-srno = 'Total weight (Gross & Net)'.
        w_mara-matnr = w_mara_tmp-matnr.
        w_mara-ersda = w_mara_tmp-ersda.
        w_mara-ernam  = w_mara_tmp-ernam .
        w_mara-laeda = w_mara_tmp-laeda.
        w_mara-aenam = w_mara_tmp-aenam.
        w_mara-vpsta = w_mara_tmp-vpsta.
        w_mara-brgew = w_mara_tmp-brgew.
        w_mara-ntgew = w_mara_tmp-ntgew.
        w_mara-gewei = w_mara_tmp-gewei.
        APPEND w_mara TO i_mara.
      ENDLOOP.
    Calling the screen to display ALV
      CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
          Display ALV report
    MODULE status_0100 OUTPUT.
      IF oref1 IS INITIAL.
      Create ALV grid object
      In this case we have not created any custom container in the screen,
      Instead of that dummy container name is passed
      ADVANTAGE: we can run this report in background without any problem
        CREATE OBJECT oref1
          EXPORTING
            i_parent          = cl_gui_custom_container=>screen0
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5
        CHECK sy-subrc = 0.
      Preparing the field catalog
      ZDEMO: Defined in DDIC, it's structure is same as TYPE ty_mara
      defined in the program
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_structure_name       = 'ZDEMO'
          CHANGING
            ct_fieldcat            = fieldcat
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc = 0.
          LOOP AT fieldcat INTO w_field.
            IF w_field-fieldname = 'BRGEW' OR
              w_field-fieldname = 'NTGEW'.
            Summation for Gross & Net weight
              w_field-do_sum = 'X'.
              MODIFY fieldcat FROM w_field TRANSPORTING do_sum.
            ENDIF.
            IF w_field-fieldname = 'SRNO'.
            Hide this field so that it can display it's content i.e.
            Total text in Subtotal level
              w_field-tech = 'X'.
              w_field-no_out = 'X'.
              MODIFY fieldcat FROM w_field TRANSPORTING tech no_out.
            ENDIF.
            CLEAR w_field.
          ENDLOOP.
        ENDIF.
      Populate Sort table with SRNO field so that we can display the total
      text in it's subtotal level
        wa_sort2-spos = 1.
        wa_sort2-fieldname = 'SRNO'.
        wa_sort2-up = 'X'.
        wa_sort2-subtot = 'X'.
        APPEND wa_sort2 TO i_sort2.
      Hide the total line
        wa_layout-no_totline = 'X'.
      Display the ALV grid
        CALL METHOD oref1->set_table_for_first_display
          EXPORTING
            is_layout                     = wa_layout
          CHANGING
            it_outtab                     = i_mara[]
            it_fieldcatalog               = fieldcat
            it_sort                       = i_sort2
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
        IF sy-subrc <> 0.
        ENDIF.
      Set the focus on the grid
        CALL METHOD cl_gui_alv_grid=>set_focus
          EXPORTING
            control           = oref1
          EXCEPTIONS
            cntl_error        = 1
            cntl_system_error = 2
            OTHERS            = 3.
        IF sy-subrc <> 0.
        ENDIF.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    These will defintely help  in u displaying subtotal text check it
    thanks

  • Displaying subtotal text in alv using the fm reuse_alv_grid_display

    Hi,
    Can someone help me with this, I am having some problem in displaying the subtotal text in subtotal field in alv. I tried populating the layout of the alv with the text that will be displayed on the output but nothing happens. Is is possible to display the subtotal text in alv using the fm reuse_alv_grid_display? If so, what are the things that I must consider to display the subtotal text in alv output.
    Please help me with this. I promise to give you points if you resolve this problem.
    Thanks,
    Gie

    Hi ,
         Make it use in your code and let me know if u have any concerns...
        Use "Subtotal_text" in events table.
    here GTOTAL is field in itab on which we sortindf data, and use your own field on which field u want to sort...
    refresh gt_event.
    clear gw_event.
    call function 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type = 0
       IMPORTING
         et_events   = gt_event.
    Subtotal
    read table gt_event with key name = slis_ev_subtotal_text into gw_event.
    if sy-subrc = 0.
       move 'SUBTOTAL_TEXT' to gw_event-form.
       append gw_event to gt_event.
    endif.
         form subtotal_text using uw_subtot_line type ty_main
                    uv_subtottxt type slis_subtot_text.  "#EC CALLED
    if uv_subtottxt-criteria = 'GTOTAL'.
       uv_subtottxt-display_text_for_subtotal = 'TOTAL'.
    endif.
         *FORM build_sort .
    refresh gt_sort.
    gw_sort-spos      = 1.
    gw_sort-fieldname = 'GTOTAL'.
    gw_sort-tabname   = 'GT_MAIN'.
    gw_sort-up        = 'X'.
    gw_sort-subtot    = 'X'.
    APPEND gw_sort TO gt_sort.
    CLEAR gw_sort.
    Reward points once its useful..

  • How to get subtotal value in ALV list display

    Hi all,
    How to give condition on the value of subtotal line in ALV list display,
    i.e.if value of subtotal of plan quantity = actual quantity (in red oval) it should show the message
    'ON TIME DELIVERY' else it should not show messagee.In my case(shown in red oval) its
    showing for each subtotal value. I know how to change the subtotal text but i want to change
    with respect to value of the subtotal.(plz refer attachment)
    Any input regard to this will be achieved great.
    Many thanks in advance.
    samadhan shinde.

    Hi Samadhan,
    I am awaiting for solution for this problem.....but as i think dynamically displaying sub total based on
    matching actual quantity and planned quantity is bit complicated.
    My idea is to display matched quantities in one block and unmatched  quantities in another. I mean using blocked list.
    awaiting suggestions.
    regards,

  • How to Get Subtotal Text

    Hi all,
    iam able to display subtotals for grid alv using class cl_gui_alv_grid
    but not able to display text for subtotals
    please let me known how to achive this.
    Thanks.

    Hi RK,
    Please check the forms before asking
    Create one dummy field in the final table and hide that field.
    check the bits of below code.
    TYPES: BEGIN OF TY_VBAP,
           VBELN1 TYPE VBAP-VBELN,       
           VBELN  TYPE VBAP-VBELN,         " Dummy field
           NETWR  TYPE VBAP-NETWR,
           END OF TY_VBAP.
      GT_FCAT-FIELDNAME = 'VBELN'.
      GT_FCAT-REF_TABLE = 'VBAP'.
      GT_FCAT-TECH = 'X'.
      GT_FCAT-NO_OUT = 'X'.
      APPEND GT_FCAT.
      CLEAR GT_FCAT.
    FORM SUB_TEXT USING ES_SUBTOTTXT_INFO TYPE LVC_S_STXT
                        E_EVENT_DATA      TYPE REF TO CL_ALV_EVENT_DATA
                        EP_SUBTOT_LINE    TYPE REF TO DATA.
      DATA LS_VBAP LIKE VBAP.
      FIELD-SYMBOLS: <FS1> LIKE GT_VBAP ,
                     <FS2>.
      IF ES_SUBTOTTXT_INFO-CRITERIA = 'VBELN'.
        ASSIGN EP_SUBTOT_LINE->* TO <FS1>.
        ASSIGN E_EVENT_DATA->M_DATA->* TO <FS2>.
       CONCATENATE 'Subtotal' ':'
        <FS1>-VBELN INTO <FS2> SEPARATED BY SPACE.
      ENDIF.
    Regards,
    Kumar M

  • Cannot get subtotal text in ALV

    Hi all,
    I cannot get the text for my subtotal. Anyone have any idea?
    & Report  ABC&
    REPORT  ABC.
    after getting data*
      SORT lt_manpower by gsber landx50 bukrs.
      PERFORM set_header.
      PERFORM set_fieldcatalog USING alv_fieldcat.
      alv_layout-colwidth_optimize = 'X'.
      alv_layout-zebra = 'X'.
    alv_layout-cell_merge = 'X'.
    alv_layout-get_selinfos = 'X'.
      alv_layout-no_totalline = 'X'.
      PERFORM data_sort USING alv_sort.
      PERFORM data_get_events.
      PERFORM data_subtotal_text USING ls_manpower
                                          alv_subtot_text .
      PERFORM set_alv.
    *&      Form  data_get_events
          text
    FORM data_get_events.
      CONSTANTS: lc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
      CONSTANTS: c_formname_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.
      DATA ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE     = 0
        IMPORTING
          ET_EVENTS       = lt_event
        EXCEPTIONS
          LIST_TYPE_WRONG = 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.
    Subtotal
      READ TABLE lt_event INTO ls_event WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text to ls_event-form.
        MODIFY lt_event FROM ls_event INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    "data_get_events
    *&      Form  data_subtotal_text
          text
         -->VALUE(LT_MANPOWER)  text
         -->LS_SUBTOT_TEXT      text
    FORM data_subtotal_text USING lt_total TYPE ty_manpower_struct
                            ls_subtot_text TYPE slis_subtot_text.
    Division total
      IF ls_subtot_text-criteria = 'GSBER'.
        ls_subtot_text-display_text_for_subtotal = 'Division total'.
      ENDIF.
    Country total
      IF ls_subtot_text-criteria = 'LANDX50'.
        ls_subtot_text-display_text_for_subtotal = 'Country total'.
      ENDIF.
    Company Code total
      IF ls_subtot_text-criteria = 'BUKRS'.
        ls_subtot_text-display_text_for_subtotal = 'Company Code total'.
      ENDIF.
    ls_subtot_text-display_text_for_subtotal = 'Sub total text'.
    ENDFORM.                    "data_subtotal_text
    *&      Form  set_alv
          text
    FORM set_alv.
      DATA lv_repid TYPE syrepid.
      lv_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program     = lv_repid
          i_callback_top_of_page = 'ALV_TOP_OF_PAGE'
               is_layout              = alv_layout
          it_fieldcat            = alv_fieldcat
          it_sort                = alv_sort
          it_events              = lt_event
         i_default              = 'X'
         i_save                 = 'A'
        TABLES
          t_outtab               = lt_manpower
        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.                    "set_alv
    *&      Form  alv_top_of_page
          text
    FORM alv_top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = alv_top_of_page.
    ENDFORM.                    "alv_top_of_page
    Edited by: Siong Chao on Oct 18, 2011 9:39 AM
    Edited by: Siong Chao on Oct 18, 2011 9:40 AM

    Hi Keshav,
    The following is my set_fieldcatalog.
    FORM set_fieldcatalog using alv_fieldcat TYPE slis_t_fieldcat_alv. As you can see, the 3 fields I wanted to display the subtotal, I did set the do_sum = 'X'. Anything else I am missing?
      DATA ls_fieldcat TYPE slis_fieldcat_alv.
    employee number
      ls_fieldcat-fieldname     = 'PERNR'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'PERNR'.
      ls_fieldcat-ref_tabname   = 'P0000'.
      ls_fieldcat-key           = 'X'.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    employee name
      ls_fieldcat-fieldname     = 'CNAME'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'CNAME'.
      ls_fieldcat-ref_tabname   = 'P0002'.
      ls_fieldcat-key           = ''.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    gender
      ls_fieldcat-fieldname     = 'GESCH'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'GESCH'.
      ls_fieldcat-ref_tabname   = 'P0002'.
      ls_fieldcat-key           = ''.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    employee status
      ls_fieldcat-fieldname     = 'STAT2'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'STAT2'.
      ls_fieldcat-ref_tabname   = 'P0000'.
      ls_fieldcat-key           = ''.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    division
      ls_fieldcat-fieldname     = 'GSBER'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'GSBER'.
      ls_fieldcat-ref_tabname   = 'P0001'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-do_sum        = 'X'.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    country
      ls_fieldcat-reptext_ddic   = 'Country'.
      ls_fieldcat-fieldname     = 'LANDX50'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-key           = ''.
      ls_fieldcat-do_sum        = 'X'.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    company code
      ls_fieldcat-fieldname     = 'BUKRS'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'BUKRS'.
      ls_fieldcat-ref_tabname   = 'P0001'.
      ls_fieldcat-key           = ''.
      ls_fieldcat-do_sum        = 'X'.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    personnel area
      ls_fieldcat-fieldname     = 'WERKS'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'WERKS'.
      ls_fieldcat-ref_tabname   = 'P0001'.
      ls_fieldcat-key           = ''.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    employee group
      ls_fieldcat-fieldname     = 'PERSG'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'PERSG'.
      ls_fieldcat-ref_tabname   = 'P0001'.
      ls_fieldcat-key           = ''.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    job title
      ls_fieldcat-fieldname     = 'PLANS'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'PLANS'.
      ls_fieldcat-ref_tabname   = 'P0001'.
      ls_fieldcat-key           = ''.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    action type
      ls_fieldcat-fieldname     = 'MASSN'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'MASSN'.
      ls_fieldcat-ref_tabname   = 'P0000'.
      ls_fieldcat-key           = ''.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    action date
      ls_fieldcat-fieldname     = 'BEGDA'.
      ls_fieldcat-tabname       = 'LT_MANPOWER'.
      ls_fieldcat-ref_fieldname = 'BEGDA'.
      ls_fieldcat-ref_tabname   = 'P0000'.
      ls_fieldcat-key           = ''.
      APPEND ls_fieldcat TO alv_fieldcat.
      CLEAR ls_fieldcat.
    ENDFORM.                    "set_fieldcatalog

  • How to display subtotal text in alv report for particular group of values

    Hi,
    if material number falls 1 to 10 then i considered be calculate and display subtotal qty amount with subtotal text " Total of the mat1" and if material number falls 11 to 20 then again i need to be claculate and display subtotal qty amount with subtotal text "total of the mat2". if material number falls 21 to 30 then i don't want to display any subtotal and At last grand total also is not required.
    Please help me asap

    just check the thread...
    Can we modify a sub-total in ALV

  • How to get check box in alv output

    hi gurus
    can anyone explian me how to get check box in alv output
    it should not be a pop up window
    i want to get in output itself
    tahnk you
    regards
    kals.

    Hi
    by using rs_selfield
    ty to call dynamic subroutine..
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield. "#EC CALLED
    read table rs-selfield with key cond = 'X'
    endform.
    see the below example
    REPORT Z_GET_REFRESH no standard page heading.
    type-pools : slis.
    tables : makt,
    mara.
    data : i_fieldcat type slis_t_fieldcat_alv.
    CONSTANTS :
    gc_refresh TYPE syucomm VALUE '&REFRESH'.
    data : begin of i_makt occurs 0,
    matnr like makt-matnr,
    maktx like makt-maktx,
    end of i_makt.
    data : v_repid like sy-repid,
    g_user_command type slis_formname value 'USER_COMMAND',
    g_status_set type slis_formname value 'SET_PF_STATUS',
    lt_event_exit TYPE slis_t_event_exit,
    ls_event_exit TYPE slis_event_exit.
    DATA:LC_GLAY TYPE LVC_S_GLAY.
    select-options s_matnr for mara-matnr .
    start-of-selection.
    select matnr maktx from makt into table i_makt
    where matnr in s_matnr.
    end-of-selection.
    Fill the fieldcatlog
    perform fill_field.
    Call the FM
    perform call_fm.
    *& Form fill_field
    text
    --> p1 text
    <-- p2 text
    FORM fill_field.
    data wa_fieldcat type slis_fieldcat_alv.
    clear : wa_fieldcat.
    wa_fieldcat-tabname = 'I_MAKT'.
    wa_fieldcat-fieldname = 'MATNR'.
    wa_fieldcat-outputlen = '18'.
    wa_fieldcat-seltext_l = 'Material #'.
    wa_fieldcat-col_pos = '1'.
    append wa_fieldcat to i_fieldcat.
    clear : wa_fieldcat.
    wa_fieldcat-tabname = 'I_MAKT'.
    wa_fieldcat-fieldname = 'MAKTX'.
    wa_fieldcat-outputlen = '40'.
    wa_fieldcat-seltext_l = 'Material Desc'.
    wa_fieldcat-col_pos = '2'.
    append wa_fieldcat to i_fieldcat.
    ENDFORM. " fill_field
    *& Form call_fm
    text
    --> p1 text
    <-- p2 text
    FORM call_fm.
    v_repid = sy-repid.
    LC_GLAY-EDT_CLL_CB = 'X'.
    CLEAR ls_event_exit.
    ls_event_exit-ucomm = gc_refresh. " Refresh
    ls_event_exit-after = 'X'.
    APPEND ls_event_exit TO lt_event_exit.
    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 = g_status_set
    I_CALLBACK_USER_COMMAND = g_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 = LC_GLAY
    IS_LAYOUT =
    IT_FIELDCAT = i_fieldcat
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT = lt_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_ADD_FIELDCAT =
    IT_HYPERLINK =
    I_HTML_HEIGHT_TOP =
    I_HTML_HEIGHT_END =
    IT_EXCEPT_QINFO =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = i_makt
    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. " call_fm
    FORM USER_COMMAND *
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield. "#EC CALLED
    data i_RSPARAMS like RSPARAMS occurs 0.
    CASE R_UCOMM.
    WHEN '&IC1'.
    read table i_makt index rs_selfield-tabindex.
    SET PARAMETER ID 'MAT' FIELD i_makt-matnr.
    if not i_makt-matnr is initial.
    call transaction 'MM02' and skip first screen.
    endif.
    when '&REFRESH'.
    CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
    EXPORTING
    CURR_REPORT = v_repid
    IMPORTING
    SP =
    TABLES
    SELECTION_TABLE = i_RSPARAMS
    EXCEPTIONS
    NOT_FOUND = 1
    NO_REPORT = 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.
    submit z_get_refresh with selection-table i_RSPARAMS.
    rs_selfield-refresh = 'X'.
    ENDCASE.
    MOVE '&REFRESH' TO r_ucomm.
    ENDFORM.
    FORM set_pf_status *
    FORM SET_PF_STATUS USING rt_extab TYPE slis_t_extab.
    DELETE Rt_extab WHERE fcode = gc_refresh.
    SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'
    EXCLUDING Rt_extab.
    *SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.
    SET TITLEBAR sy-tcode.
    ENDFORM.

  • How to get check box in alv grid list output

    hi gurus,
    can anyone inform me
    how to get check box in alv output it should not be a pop up window
    thank you
    regards
    kals.

    or
    hi go through the fallowing code.
    code*&----
    *& Report YGS_ALV_BOM *
    REPORT YGS_ALV_BOM .
    TABLES : MAST,STKO,STPO.
    TYPE-POOLS: SLIS.
    TYPES : BEGIN OF TY_MAST,
    CHECK_BOX,
    MATNR TYPE MAST-MATNR,
    WERKS TYPE MAST-WERKS,
    STLAN TYPE MAST-STLAN,
    STLNR TYPE MAST-STLNR,
    STLAL TYPE MAST-STLAL,
    END OF TY_MAST.
    TYPES : BEGIN OF TY_STKO,
    STLTY TYPE STKO-STLTY,
    STLNR TYPE STKO-STLNR,
    STLAL TYPE STKO-STLAL,
    STKOZ TYPE STKO-STKOZ,
    BMENG TYPE STKO-BMENG,
    BMEIN TYPE STKO-BMEIN,
    END OF TY_STKO.
    TYPES : BEGIN OF TY_STPO,
    LIGHTS,
    STLTY TYPE STPO-STLTY,
    STLNR TYPE STPO-STLNR,
    STLKN TYPE STPO-STLKN,
    STPOZ TYPE STPO-STPOZ,
    IDNRK TYPE STPO-IDNRK,
    MENGE TYPE STPO-MENGE,
    MEINS TYPE STPO-MEINS,
    END OF TY_STPO.
    DATA : IT_MAST TYPE TABLE OF TY_MAST,
    WA_MAST TYPE TY_MAST,
    IT_STKO TYPE TABLE OF TY_STKO,
    WA_STKO TYPE TY_STKO,
    IT_STPO TYPE TABLE OF TY_STPO,
    WA_STPO TYPE TY_STPO.
    DATA : lt_fieldcat TYPE slis_t_fieldcat_alv,
    ls_layout TYPE slis_layout_alv,
    ls_event TYPE slis_alv_event,
    lt_event TYPE slis_t_event,
    it_sortinfo type slis_t_sortinfo_alv,
    ls_header TYPE slis_listheader,
    lt_header TYPE slis_t_listHEADER.
    DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    SELECT-OPTIONS : S_MATNR FOR MAST-MATNR.
    START-OF-SELECTION.
    PERFORM GET_DATA.
    PERFORM BUILD_FIELDCAT USING LT_FIELDCAT.
    PERFORM BUILD_LAYOUT.
    END-OF-SELECTION.
    PERFORM DISPLAY_DATA.
    *& Form GET_DATA
    text
    --> p1 text
    <-- p2 text
    form GET_DATA .
    REFRESH : IT_MAST.
    SELECT MATNR
    WERKS
    STLAN
    STLNR
    FROM MAST
    INTO CORRESPONDING FIELDS OF TABLE IT_MAST
    WHERE MATNR IN S_MATNR.
    endform. " GET_DATA
    *& Form BUILD_FIELDCAT
    text
    --> p1 text
    <-- p2 text
    form BUILD_FIELDCAT USING LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA : L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    REFRESH : LT_FIELDCAT.
    L_FIELDCAT-COL_POS = 1.
    L_FIELDCAT-FIELDNAME = 'MATNR'.
    L_FIELDCAT-TABNAME = 'IT_MAST'.
    L_FIELDCAT-REF_FIELDNAME = 'MATNR'.
    L_FIELDCAT-REF_TABNAME = 'MAST'.
    APPEND L_FIELDCAT TO LT_FIELDCAT.
    L_FIELDCAT-COL_POS = 2.
    L_FIELDCAT-FIELDNAME = 'WERKS'.
    L_FIELDCAT-TABNAME = 'IT_MAST'.
    L_FIELDCAT-REF_FIELDNAME = 'WERKS'.
    L_FIELDCAT-REF_TABNAME = 'MAST'.
    APPEND L_FIELDCAT TO LT_FIELDCAT.
    L_FIELDCAT-COL_POS = 3.
    L_FIELDCAT-FIELDNAME = 'STLNR'.
    L_FIELDCAT-TABNAME = 'IT_MAST'.
    L_FIELDCAT-REF_FIELDNAME = 'STLNR'.
    L_FIELDCAT-REF_TABNAME = 'MAST'.
    APPEND L_FIELDCAT TO LT_FIELDCAT.
    endform. " BUILD_FIELDCAT
    *& Form BUILD_LAYOUT
    text
    --> p1 text
    <-- p2 text
    form BUILD_LAYOUT .
    CLEAR LS_LAYOUT.
    LS_LAYOUT-BOX_FIELDNAME = 'CHECK_BOX'.
    LS_LAYOUT-BOX_TABNAME = 'IT_MAST'.
    endform. " BUILD_LAYOUT
    *& Form DISPLAY_DATA
    text
    --> p1 text
    <-- p2 text
    form DISPLAY_DATA .
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = SY-REPID
    I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    I_STRUCTURE_NAME =
    IS_LAYOUT = LS_LAYOUT
    IT_FIELDCAT = LT_FIELDCAT
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_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
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    t_outtab = IT_MAST
    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_DATA
    FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
    SET PF-STATUS 'YSTATUS' OF PROGRAM SY-REPID
    EXCLUDING RT_EXTAB.
    ENDFORM.
    FORM USER_COMMAND USING RF_UCOMM TYPE SY-UCOMM
    SELFIELD TYPE SLIS_SELFIELD.
    CASE RF_UCOMM.
    WHEN '&NEXT'.
    PERFORM GET_DATA_BOM .
    PERFORM BUILD_FIELDCAT_BOM USING LT_FIELDCAT.
    PERFORM BUILD_LAYOUT_BOM.
    PERFORM DISPLAY_DATA_BOM.
    ENDCASE.
    ENDFORM.
    *& Form GET_DATA_BOM
    text
    --> p1 text
    <-- p2 text
    form GET_DATA_BOM .
    CLEAR : WA_STPO,
    WA_MAST.
    REFRESH : IT_STPO.
    DATA : IT_CHECK TYPE TABLE OF TY_MAST.
    LOOP AT IT_MAST INTO WA_MAST.
    IF WA_MAST-CHECK_BOX EQ 'X'.
    APPEND WA_MAST TO IT_CHECK.
    ENDIF.
    ENDLOOP.
    SELECT STLTY
    STLNR
    STLKN
    VGKNT
    IDNRK
    MENGE
    MEINS
    FROM STPO
    INTO CORRESPONDING FIELDS OF TABLE IT_STPO
    FOR ALL ENTRIES IN IT_CHECK
    WHERE IDNRK EQ IT_CHECK-MATNR.
    CLEAR WA_STPO.
    LOOP AT IT_STPO INTO WA_STPO.
    SELECT SINGLE * FROM MAST WHERE MATNR EQ WA_STPO-IDNRK.
    IF SY-SUBRC = 0.
    WA_STPO-LIGHTS = '2'.
    ELSE.
    WA_STPO-LIGHTS = '1'.
    ENDIF.
    MODIFY IT_STPO FROM WA_STPO.
    ENDLOOP.
    endform. " GET_DATA_BOM
    *& Form BUILD_FIELDCAT_BOM
    text
    --> p1 text
    <-- p2 text
    form BUILD_FIELDCAT_BOM USING LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA : L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    REFRESH : LT_FIELDCAT.
    L_FIELDCAT-COL_POS = 1.
    L_FIELDCAT-FIELDNAME = 'STLTY'.
    L_FIELDCAT-TABNAME = 'IT_STPO'.
    L_FIELDCAT-REF_FIELDNAME = 'STLTY'.
    L_FIELDCAT-REF_TABNAME = 'STPO'.
    APPEND L_FIELDCAT TO LT_FIELDCAT.
    L_FIELDCAT-COL_POS = 2.
    L_FIELDCAT-FIELDNAME = 'STLNR'.
    L_FIELDCAT-TABNAME = 'IT_STPO'.
    L_FIELDCAT-REF_FIELDNAME = 'STLNR'.
    L_FIELDCAT-REF_TABNAME = 'STPO'.
    APPEND L_FIELDCAT TO LT_FIELDCAT.
    L_FIELDCAT-COL_POS = 3.
    L_FIELDCAT-FIELDNAME = 'STLKN'.
    L_FIELDCAT-TABNAME = 'IT_STPO'.
    L_FIELDCAT-REF_FIELDNAME = 'STLKN'.
    L_FIELDCAT-REF_TABNAME = 'STPO'.
    APPEND L_FIELDCAT TO LT_FIELDCAT.
    L_FIELDCAT-COL_POS = 4.
    L_FIELDCAT-FIELDNAME = 'IDNRK'.
    L_FIELDCAT-TABNAME = 'IT_STPO'.
    L_FIELDCAT-REF_FIELDNAME = 'IDNRK'.
    L_FIELDCAT-REF_TABNAME = 'STPO'.
    APPEND L_FIELDCAT TO LT_FIELDCAT.
    L_FIELDCAT-COL_POS = 5.
    L_FIELDCAT-FIELDNAME = 'MENGE'.
    L_FIELDCAT-TABNAME = 'IT_STPO'.
    L_FIELDCAT-REF_FIELDNAME = 'MENGE'.
    L_FIELDCAT-REF_TABNAME = 'STPO'.
    APPEND L_FIELDCAT TO LT_FIELDCAT.
    endform. " BUILD_FIELDCAT_BOM
    *& Form BUILD_LAYOUT_BOM
    text
    --> p1 text
    *<-- p2 text
    form BUILD_LAYOUT_BOM .
    CLEAR : LS_LAYOUT.
    LS_LAYOUT-LIGHTS_FIELDNAME = 'LIGHTS'.
    LS_LAYOUT-LIGHTS_TABNAME = 'IT_STPO'.
    endform. " BUILD_LAYOUT_BOM
    *& Form DISPLAY_DATA_BOM
    text
    --> p1 text
    <-- p2 text
    form DISPLAY_DATA_BOM .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = SY-REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND_BOM'
    I_CALLBACK_TOP_OF_PAGE = 'TOP9'
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = 'ALV_BACKGROUND'
    I_GRID_TITLE =
    I_GRID_SETTINGS =
    IS_LAYOUT = LS_LAYOUT
    IT_FIELDCAT = LT_FIELDCAT
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_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_STPO
    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_DATA_BOM
    FORM TOP9 .
    CLEAR LS_HEADER.
    REFRESH LT_HEADER.
    LS_HEADER-TYP = 'H'.
    LS_HEADER-INFO = 'BILL OF MATERIALS'.
    APPEND LS_HEADER TO LT_HEADER.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = LT_HEADER
    I_LOGO = 'ENJOYSAP_LOGO'
    I_END_OF_LIST_GRID =
    ENDFORM.
    FORM USER_COMMAND_BOM USING RF_UCOMM_BOM LIKE SY-UCOMM
    SEL_FIELD TYPE SLIS_SELFIELD.
    CASE RF_UCOMM_BOM.
    WHEN '&IC1'.
    SET PARAMETER ID 'MAT' FIELD WA_STPO-IDNRK.
    SET PARAMETER ID 'WRK' FIELD WA_MAST-WERKS.
    SET PARAMETER ID 'CSA' FIELD WA_MAST-STLAN.
    CALL TRANSACTION 'CS03' AND SKIP FIRST SCREEN.
    ENDCASE.[/code]

  • SUBTOTAL TEXT IN ALV GRID

    HI ALL,
    could any one  send me how to display the subtotal Text  in ALV grid output with code sample.
    with thanks.
    kannan

    hi,
    means u want to print some text instead of star ( coming in subtotal) ?
    If so than try like,
    *& Report  ZALV_LIST
    REPORT  zalv_list.
    TABLES : mseg.
    TYPE-POOLS : slis.
    DATA : BEGIN OF itab OCCURS 0,
            mblnr LIKE mseg-mblnr,
            matnr LIKE mseg-matnr,
            werks LIKE mseg-werks,
            menge LIKE mseg-menge,
            line_color(4) TYPE c,
           END OF itab.
    DATA : BEGIN OF itab1 OCCURS 0,
            mblnr LIKE mseg-mblnr,
            matnr LIKE mseg-matnr,
            werks LIKE mseg-werks,
            menge LIKE mseg-menge,
            line_color(4) TYPE c,
           END OF itab1.
    DATA : t_fcat TYPE slis_t_fieldcat_alv,
           t_eve TYPE slis_t_event,
           t_subtot TYPE slis_t_sortinfo_alv,
           subtot LIKE LINE OF t_subtot,
           wa_fcat LIKE LINE OF t_fcat,
           gd_layout    TYPE slis_layout_alv.
    DATA : gt_menge LIKE mseg-menge,
           st_menge LIKE mseg-menge.
    SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : doc FOR mseg-mblnr.
    SELECTION-SCREEN : END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_cat USING t_fcat.
      PERFORM build_eve.
      PERFORM build_layout.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM display.
    *&      Form  build_cat
          text
         -->TEMP_FCAT  text
    FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MBLNR'.
      wa_fcat-seltext_m = 'Material Doc.'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'Material'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Plant'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MENGE'.
      wa_fcat-seltext_m = 'Quantity'.
    wa_fcat-do_sum = 'Y'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
    subtot-spos = 1.
    subtot-fieldname = 'MBLNR'.
    subtot-tabname = 'ITAB'.
    subtot-up = 'X'.
    subtot-group = 'X'.
    subtot-subtot = 'X'.
    subtot-expa = 'X'.
    APPEND subtot TO t_subtot.
    ENDFORM.                    "build_cat
    *&      Form  build_eve
          text
    FORM build_eve.
      DATA : wa_eve TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = t_eve
        EXCEPTIONS
          list_type_wrong = 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.
      READ TABLE t_eve WITH KEY name =  slis_ev_top_of_page
                             INTO wa_eve.
      IF sy-subrc = 0.
        MOVE 'TOP_OF_PAGE' TO wa_eve-form.
        APPEND wa_eve TO t_eve.
      ENDIF.
    ENDFORM.                    "build_eve
    *&      Form  build_layout
          text
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-info_fieldname =      'LINE_COLOR'.
      gd_layout-subtotals_text = 'Sub Total'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  get_data
          text
    FORM get_data.
      SELECT mblnr matnr werks menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab
      WHERE mblnr IN doc.
      SORT itab BY mblnr.
      LOOP AT itab.
        AT NEW mblnr.
          LOOP AT itab WHERE mblnr = itab-mblnr.
            st_menge = st_menge + itab-menge.
            itab1-mblnr = itab-mblnr.
            itab1-matnr = itab-matnr.
            itab1-werks = itab-werks.
            itab1-menge = itab-menge.
            APPEND itab1.
          ENDLOOP.
          itab1-mblnr = 'Sub_Total'.
          itab1-matnr = ''.
          itab1-werks = ''.
          itab1-menge = st_menge.
          itab1-line_color = 'C710'.
          APPEND itab1.
          itab1-line_color = ''.
          CLEAR st_menge.
        ENDAT.
      ENDLOOP.
      LOOP AT itab.
        gt_menge = gt_menge + itab-menge.
      ENDLOOP.
      itab1-mblnr = 'Total'.
      itab1-matnr = ''.
      itab1-werks = ''.
      itab1-menge = gt_menge.
      itab1-line_color = 'C310'.
      APPEND itab1.
    ENDFORM.                    "get_data
    *&      Form  display
          text
    FORM display.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program             = 'ZALV_LIST'
         is_layout                      = gd_layout
         it_fieldcat                    = t_fcat
        it_sort                        = t_subtot
         it_events                      = t_eve
        TABLES
          t_outtab                       = itab1
    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
    *&      Form  top_of_page
          text
    FORM top_of_page.
      WRITE:/ 'Data'.
    ENDFORM.                    "top_of_page
    reward if useful....
    Edited by: Dhwani shah on Dec 20, 2007 1:20 PM

  • Reg subtotal text in ALV

    Hi,
    How to change the subtotal text in ALV grid display using classes.

    i think if you refresh the grid the subtotals will be refreshed
    CALL METHOD gr_alvgrid->REFRESH_TABLE_DISPLAY.

  • Passing the Total/Subtotal Text in ALV

    Hi All,
    I would like to know is there any chance with ALV to pass Total/Subtotal Text.
    PS:I'm not looking for the text ls_layout-totals_text = 'Grand Total'.
    ls_layout-subtotals_text = 'SubTotal'.
    What i'm looking for is In My below Output:
    112365               TDS Windsor Sequencing                           
    112365               TDS Windsor Sequencing                           
    112365               TDS Windsor Sequencing                           
    * Total  <Group text>  "Here My   total amount is showing                                                         
    112313               Operations and Engineering                       
    * Total   <Group text>      "Here My   total amount is showing                                                         
    112363               DCX Windsor                                      
    * Total      <Group text>            "Here My   total amount is showing                                                                               
    ** Subtotal <Group text>   "Here My  "SUB total" amount is showing of above three totals
    I've <Group text> in My Final ALV one of field, but need to show at the place of <Group text> in above output.
    PS:And For Totals/Subtotals i'm using standard function of ALV by passing IT_SORT(which is in Reuse_Alv..FM)
    Any Hints?
    Thank You,
    Cheers,
    Amit.

    Hi Amit,
      Please check this example..I used the event BEFORE_LINE_OUTPUT to populate the subtotal texts
    dynamically..Used the Field-symbols technique to populate the subtotals text...Hope this is what you
    are looking for.
    TYPE-POOLS: slis,kkblo.
    DATA: BEGIN OF wa,
            vbeln TYPE vbeln,
            posnr TYPE posnr,
            matnr TYPE matnr,
            netpr TYPE netpr,
            waerk TYPE waerk,
            text  TYPE char20,
          END OF wa.
    DATA: BEGIN OF wa_vbak,
            vbeln TYPE vbeln,
          END OF wa_vbak.
    DATA: i_event   TYPE slis_t_event,
          t_sort    TYPE slis_t_sortinfo_alv,
          s_sort    TYPE LINE OF slis_t_sortinfo_alv,
          l_s_event TYPE LINE OF slis_t_event.
    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
    DATA: s_layout       TYPE slis_layout_alv.
    DATA: v_repid        TYPE syrepid.
    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
    DATA: itab1          LIKE TABLE OF wa.
    DATA: itab           LIKE TABLE OF wa_vbak.
    START-OF-SELECTION.
    * Field catalog populate.
      s_fieldcatalog-col_pos = '1'.
      s_fieldcatalog-fieldname = 'VBELN'.
      s_fieldcatalog-rollname = 'VBELN'.
      s_fieldcatalog-outputlen = '12'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
      s_fieldcatalog-col_pos = '2'.
      s_fieldcatalog-fieldname = 'POSNR'.
      s_fieldcatalog-rollname = 'POSNR'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
      s_fieldcatalog-col_pos = '3'.
      s_fieldcatalog-fieldname = 'MATNR'.
      s_fieldcatalog-rollname = 'MATNR'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
      s_fieldcatalog-col_pos = '4'.
      s_fieldcatalog-fieldname = 'NETPR'.
      s_fieldcatalog-ref_tabname = 'VBAP'.
      s_fieldcatalog-ref_fieldname = 'NETPR'.
      s_fieldcatalog-do_sum = 'X'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
    * Get vbak
      SELECT vbeln UP TO 100 ROWS
      FROM
      vbak
      INTO TABLE itab.
      IF NOT itab[] IS INITIAL.
    * Get vbap
        SELECT vbeln posnr matnr netpr waerk arktx
        FROM vbap
        INTO TABLE itab1
        FOR ALL ENTRIES IN itab
        WHERE vbeln = itab-vbeln.
      ENDIF.
      v_repid = sy-repid.
    * Build sort internal table.
      s_sort-spos      = '1'.
      s_sort-fieldname = 'VBELN'.
      s_sort-tabname  = 'ITAB1'.
      s_sort-up = 'X'.
      s_sort-subtot = 'X'.
      s_sort-group = 'UL'.
      APPEND s_sort TO t_sort.
    * Get alv events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 2
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
    * Before line output.
      READ TABLE i_event  INTO l_s_event
                        WITH KEY name = 'BEFORE_LINE_OUTPUT'.
      IF sy-subrc = 0.
        MOVE 'BEFORE_LINE_OUTPUT' TO l_s_event-form.
        MODIFY i_event FROM l_s_event INDEX sy-tabix.
      ENDIF.
    * Populate dummy text.
      s_layout-subtotals_text = 'Dummy'.
    * Init
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program = v_repid.
    * Append
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                  = s_layout
          it_fieldcat                = t_fieldcatalog
          i_tabname                  = 'ITAB1'
          it_events                  = i_event
          it_sort                    = t_sort
        TABLES
          t_outtab                   = itab1
        EXCEPTIONS
          program_error              = 1
          maximum_of_appends_reached = 2
          OTHERS                     = 3.
    * Display
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    *&      Form  BEFORE_LINE_OUTPUT
    *       text
    *      -->GS_LINEINFO  text
    FORM before_line_output USING gs_lineinfo TYPE kkblo_lineinfo.
      FIELD-SYMBOLS: <fs_layout>  TYPE kkblo_layout.
      ASSIGN ('(SAPLKKBL)GT_STACK-IS_LAYOUT') TO <fs_layout>.
      CHECK sy-subrc = 0.
    * Check if it is subtotal line.
      CHECK gs_lineinfo-subtot = 'X'.
    * Get the text
      READ TABLE itab1 INTO wa INDEX gs_lineinfo-sumindex.
      IF sy-subrc = 0.
        <fs_layout>-subtotals_text = wa-text.
      ENDIF.
    ENDFORM.                    "BEFORE_LINE_OUTPUT
    Thanks
    Naren

  • How to get f4 help in alv grid in container-urgent

    hi,
    how to get f4 help in alv grid in container using abap objects
    ganesh

    Hi Ganesh,
    Did you have a look at sample report BCALV_TEST_GRID_F4_HELP ?
    Here is part of the header documentation:
    *& Report  BCALV_GRID_F4_HELP                                          *
    Purpose:
    ~~~~~~~~
    This report illustrates the use of f4-Help in an alv grid control.
    Background:
    ~~~~~~~~~~~
    There a two possibilities to implement an f4-Help in the alv grid
    control: one can either use standard f4-help or write one by Hand.
    For the former there is nothing to do at all. This report shows how
    to implement user-defined f4-help.
    I am sure you will find within this report the solution you are looking for.
    Reward points if this Helps.
    Manish

  • How to get the Text name to pass in the  parameter header in save_text

    Hi,
      I am trying to change the long text of operation for historical order by using the flat file.I am using the save_text to do this.I would like to know how  to get the text name in order to pass the parameter header in save_text.
      I went to the tcode iw62 to get the header information of the long text.300100000009200000001
    i would like to know what this 1000000092 indicates and where is this value updated in the table so that i can link it thru the order no  to get the link and pass it in the text_name.
      can anyone help me out?
    krishnan

    Hi,
    Your query is.
    I went to the tcode iw62 to get the header information of the long text.300100000009200000001
    i would like to know what this 1000000092 indicates
    In above number
    300 - Client
    1000000092 - AUFPL - Routing number of operations in the order (You can fetch this from table HIVG)
    00000001 - APLZL - General counter for order ( You can fetch this from table HIVG).
    BR,
    Vijay

  • How to get the text present in JTextArea

    i am writing application for some system to be computerised and i am not getting how to get the text present in text area and set it into database...can anybody suggest me solution??

    You must have named the TextArea like
    JTextArea textArea;so, use the getText() method like
    String strTextAreaContents = textArea.getText();You can then use JDBC to connect to the database that you want and save your contents that is now in strTextAreaContents.
    -- Srikanth

Maybe you are looking for

  • Printer not printing completely

    I purchased an HP2540 all in one printer yesterday, hooked it up to my Dell computer, running Windows Vista.  I did the complete set up, downloaded software, registered the printer online, etc.  Everything seemed to be okay until I tried to print the

  • I no longer have favicons in address bar (awesome bar)

    Firefox 14.0.1 I no longer have favicons in address bar (awesome bar): All that shows is a a generic graphic(globe?) that is grayed out. I do however still have fevicons in my bookmarks list. Thanks for your help!

  • Receiver: "Sending Cancelled" / Sender: "Completed...

    Receiver: "Sending Cancelled" Sender: "Completed transfer" Everytime I'm sent files on Windows.

  • What are waveform and thumbnail caches, when to delete?

    Trying to configure my system and wondering what are waveform cache files and thumbnail cache files. Also, I have a constant frames folder. When can I delete these files? Shane, got your DVD, love it. Best, Tom

  • Which Xcode version is compatible for Mac OS X v10.7 Lion ?

    Hi,     I buy a latest Mac mini with OS version of MacOS X v10.7 Lion.  On that, I install xcode of the version 4.2. But after that I am facing lot of problems while working,             The problems, I am facing are: