Change Column Headings in ALV Report Using OO

Hi Friends,
I am using OO to display a report with ALV Grid
I tried to change the column names but it still takes the column names from the DDIC.
My declaration is as  follows
Data: num type dmbtr.
TRY.
            lr_column ?= lr_columns->get_column( columnname = 'NUM' ).
            lr_column->set_output_length('7').
            lr_column->set_long_text( ' Value' ).
           lr_column->set_short_text( ''() ).
            lr_column->set_medium_text( 'Value' ).
          CATCH cx_salv_not_found INTO gr_error.
            gr_msg = gr_error->get_text( ).
            MESSAGE gr_msg TYPE 'I'.
        ENDTRY.
*--- display report
        gr_table->display( ).
      CATCH cx_salv_msg.
        WRITE: 'Error displaying grid! - cx_salv_msg'(044).
      CATCH cx_salv_not_found.
        WRITE: 'Error displaying grid! - cx_salv_not_found'(004).
      CATCH cx_salv_data_error.
        WRITE: 'Error displaying grid! - cx_salv_data_error'(005).
      CATCH cx_salv_existing.
        WRITE: 'Error displaying grid! - cx_salv_existing'(006).
I need the column name as VALUE but it displays as Amount LC in the alv report.
Thanks
chaithanya

Hey hello,
you have to change short medium and log text
look at this:
gr_columns = (Table got from factory)->get_columns( ).
  gr_column = gr_columns->get_column('NAme').
  gr_column->set_long_text('new name long').
  gr_column->set_medium_text('new name medium').
  gr_column->set_short_text('new name short ).
it will help
thanks
Edited by: Alfito on Nov 28, 2011 9:31 AM

Similar Messages

  • How to catch changed column values in alv oops using grid

    My requirement needs to catch changed column values in alv oops using grid .any method to do this.
    please help me out ,
    Tks in advance

    Have a look into the SAP standarad Programs those programs have the edit option on the ALV output.
    BCALV_EDIT_01
    BCALV_EDIT_02
    BCALV_EDIT_10.
    Regards,
    Gopi ,
    Reward points if helpfull.

  • Change Column Heading in ALV Report

    Hi,
    I have developed a ALV Report, showing correct output.
    Problem is that Column Heading is not showing correct...means it is showing as per field name. But We want to change as per our understand. i.e. One column heading is like Unrestricted Stock but we want Unrestricted Stock...(BILF is an indicator)..
    We have write in the code..
    FORM build_fieldcat10.
      CLEAR fieldcat_ln.
      ADD 1 TO col_pos.
      fieldcat_ln-ref_tabname = 'MARD'.
      fieldcat_ln-fieldname   = 'LABST'.
      fieldcat_ln-seltext_m   = 'BILF Unrest.Stock'.
      fieldcat_ln-key         = space.
      fieldcat_ln-do_sum      = space.
      fieldcat_ln-col_pos     = col_pos.
      fieldcat_ln-no_out      = space.
      fieldcat_ln-qfieldname  = space.
      fieldcat_ln-hotspot     = space.
      APPEND fieldcat_ln TO fieldcat.
    ENDFORM.                    " BUILD_FIELDCAT1
    But after change the selection text...not showing correct text..How can i change Column heading???
    Please help me..

    Thanks a lot dear..
    My problem resolved by using SCRTEXT_L.

  • Change column headers in ALV report

    Hi experts,
    I have created a new simple ALV report (it uses only internal tables, no structures). I would like to change the names of column headers in the ALV report. Is this possible? How can I do it?
    Thanks in advanced.

    Thanks for your reply,
    I am trying to use the code mentioned in the link but I think that something
    is missing, probably a CASE statement before WHEN in the LOOP.
    Can you help me? What do I have to put before WHEN statement?
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = <program name>
          i_structure_name       = <DDIC structure>
          i_bypassing_buffer     = 'X'
        CHANGING
          ct_fieldcat            = gi_fieldcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.                           "#EC *
      LOOP AT gi_fieldcat INTO wa_fieldcat.
          WHEN 'XXXX'.
            wa_fieldcat-seltext_s    = 'Fac'.
            wa_fieldcat-seltext_m    = 'Factory'.
            wa_fieldcat-seltext_l    = 'Factory'.
            wa_fieldcat-reptext_ddic = 'Factory'.
        MODIFY gi_fieldcat FROM wa_fieldcat.
      ENDLOOP.

  • ALV report using the field catalog

    which is the quickest way to generate an ALV report using the field catalog merge.  without needing to build the field catalog manually .
    is it easier to create a structure and passe it in the field catalog merge .  if yes can i have an example plzzzz

    hI
    Supports the creation of the field catalog for the ALV function modules
    based either on a structure or table defined in the ABAP Data
    Dictionary, or a program-internal table.
    The program-internal table must either be in a TOP Include or its
    Include must be specified explicitly in the interface.
    The variant based on a program-internal table should only be used for
    rapid prototyping since the following restrictions apply:
    o Performance is affected since the code of the table definition must
    always be read and interpreted at runtime.
    o Dictionary references are only considered if the keywords LIKE or
    INCLUDE STRUCTURE (not TYPE) are used.
    If the field catalog contains more than 90 fields, the first 90 fields
    are output in the list by default whereas the remaining fields are only
    available in the field selection.
    If the field catalog is passed with values, they are merged with the
    'automatically' found information.
    Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
    display it using the basic ALV grid functionality(including column total). The example details the main
    sections of coding required to implement the ALV grid functionality:
                             Data declaration
                             Data retrieval
                             Build fieldcatalog
                             Build layout setup
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKKO table.                                         *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL

  • REUSE_ALV_GRID_DISPLAY (column headings from ALV to EXCEL) Max please help

    Hi Max,
    If you remember in one of my last post I asked for changing the column headings in ALV display for example from 'Material' to 'Material used'.
    I am using
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
          I_CALLBACK_PROGRAM                = repid
          IT_FIELDCAT                       = field_body
          I_SAVE                            = g_save
          IS_VARIANT                        = g_variant
          IT_EVENTS                         = events
        TABLES
          T_OUTTAB                          = itab.
    And you suggested me the following way....
    loop at field_body into field_wa.
    case field_wa-fieldname.
      when 'Material'.
         field_wa-seltext_l = 'Material used'.
         field_wa-seltext_m = 'Material used'.
         field_wa-seltext_s = 'Material used'.
    endcase.
    modify field_body from field_wa.
    endloop.
    It is working well. In ALV display the column heading is changed to what I wanted. But the question is when I export the displayed ALV to Excel using ALV functionality, Export->Spreadsheet... I see that <b>I dont get the Column Heading into Excel as it was in the ALV display.</b>
    I get in the Excel as 'Material u' or 'Mat. Used'. But when I add this line in the code.....
    when 'Material'.
         field_wa-seltext_l = 'Material used'.
         field_wa-seltext_m = 'Material used'.
         field_wa-seltext_s = 'Material used'.
        <b> field_wa-outputlen = 20.</b>
    Then I see that I get the complete heading in the Excel. But this way the columns with outputlen 20 are taking much space in ALV display.
    Is there any fix for this. May be not mentioning the outputlen but still get the column headings into Excel as it was in ALV display.
    Anyone with ideas please respond. Waiting for replies. Thanks

    Hi
    The labels have a fixed size:
    seltext_l is long   text: 20 char
    seltext_m is medium text: 15 char
    seltext_s is short  text: 10 char
    The text 'Material used' is long 13 char so you should write:
    field_wa-seltext_l = 'Material used'.
    field_wa-seltext_m = 'Material used'.
    field_wa-seltext_s = 'Mat. used'.
    You can try to set the field colwidth_optimize of parameter IT_LAYOUT.
    This field should optimize the width of the colunm
    So
    data layout type SLIS_LAYOUT_ALV.
    layout-colwidth_optimize = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = repid
    IT_LAYOUT   = layout       
    IT_FIELDCAT = field_body
    I_SAVE = g_save
    IS_VARIANT = g_variant
    IT_EVENTS = events
    TABLES
    T_OUTTAB = itab.
    and you can decide which label has to be used:
    field_wa-seltext_l = 'Material used'.
    field_wa-seltext_m = 'Material used'.
    field_wa-seltext_s = 'Mat. used'.
    If you want to set the short text
    field_wa-ddictxt   = 'S'.
    ...medium
    field_wa-ddictxt   = 'M'.
    ...long
    field_wa-ddictxt   = 'L'.
    Max

  • ALV Reports using Class Methods

    Hi Experts,
    How can we generate ALV report using class and in that How can we define SLIS_EVENTS.
    Can I provide all the that functionality the way I used to by calling FM
    SLIS_ALV_REUSE_LIST_DISPLAY  ?
    - Like Header comment, event, data grouping , sort etc.
    You may please send any url or document or any example.
    Thanks in advance.
    Regards,
    Tushar Choksi

    Hi,
    The ALV object Grid methods allow the same functionality as ALV grid report function modules but are displayed within
    a screen (dialog program). SAP has provided a suit of programs which demonstrate how to For examples see standard SAP
    programs as detailed below:
    BCALV_EDIT_01 This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.
    BCALV_EDIT_02 This report illustrates how to set chosen cells of an ALV Grid Control editable.
    BCALV_EDIT_03 In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.
    The report checks the input value(s) semantically and provides protocol messages in case of error
    BCALV_EDIT_04 This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to
    implement the saving of the new data.
    BCALV_EDIT_05 This example shows how to use checkboxes within an ALV Grid Control. You learn:
    (1) how to define a column for editable checkboxes for an attribute of your list
    (2) how to evaluate the checked checkboxes
    (3) how to switch between editable and non-editable checkboxes
    BCALV_EDIT_06 This example shows how to define a dropdown listbox for all cells of one column in an editable ALV
    Grid Control.
    BCALV_EDIT_07 This example shows how to define dropdown listboxes for particular cells of your output table.
    BCALV_EDIT_08 This report implements an ALV Grid Control with an application specific F4 help. The following aspects
    are dealt with:
    (1) how to replace the standard f4 help
    (2) how to pass the selected value to the ALV Grid Control
    (3) how to build an f4 help, whose value range depend on a value of another cell.
    some links.
    www.sapgenie.com
    www.abap4u.com
    http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm
    download the PDF from following link.
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    Regards,
    Satish

  • Download alv report using layout variant in background

    Hi All,
    I want to download an Alv report using layout varaint in background job.
    can any one please help me.
    i.e...
    I am facing a problem in downloading a text file to the Application server.
    My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant.
    Will rewards to helpfull ans
    regards
    Chetan

    hey seshu,
    I am facing a problem in downloading a text file to the Application server.
    My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant.

  • How to add the double headings in Alv Report.

    Hi All,
    Plz suggest me how to add the double headings in ALv Report.
    Ram

    Hi,
    Try out this program....
    REPORT  ypm_historycard_rep.
    TYPE-POOLS : slis.
    DATA : it_cbm TYPE STANDARD TABLE OF mara.
    DATA : it_layout TYPE STANDARD TABLE OF slis_layout_alv WITH HEADER LINE,
           wa_fcat TYPE slis_fieldcat_alv,
           it_fcat TYPE slis_t_fieldcat_alv.
    START-OF-SELECTION.
      SELECT  *
      FROM  mara
      INTO CORRESPONDING FIELDS OF TABLE  it_cbm
      where matnr = 'D80K7'.
    END-OF-SELECTION.
      it_layout-zebra = 'X'.
      it_layout-colwidth_optimize = 'X'.
      it_layout-f2code = '&ETA'.
      APPEND it_layout.
      DEFINE macro4fcat.
        wa_fcat-col_pos = &1.
        wa_fcat-fieldname = &2.
        wa_fcat-tabname = &3.
        wa_fcat-seltext_l = &4.
        append wa_fcat to it_fcat.
        clear wa_fcat.
      END-OF-DEFINITION.
      macro4fcat    '1'  'MATNR'         'IT_CBM'   'MATERIAL NO'    .
      DESCRIBE TABLE it_cbm.
      IF sy-ucomm = '&F03'.
        MESSAGE 'hi hello good morning "press enter button" this is quiz' TYPE 'S'.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
      i_callback_program                = sy-repid
    i_callback_html_top_of_page       = 'HTML_TOP_OF_PAGE'
      is_layout                         = it_layout
      it_fieldcat                       = it_fcat
       i_save                            = 'A'
      TABLES
      t_outtab                          = it_cbm
      EXCEPTIONS
      program_error                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *&      Form  html_top_of_page
    *       text
    *      -->TOP        text
    FORM html_top_of_page USING top TYPE REF TO cl_dd_document.
      DATA: l_text(255) TYPE c.
      DATA: text1(255)  TYPE c.
      DATA: t_header TYPE REF TO cl_dd_table_element ,
            wa_header TYPE REF TO cl_dd_table_area.
      CALL METHOD top->add_gap
        EXPORTING
          width = 10.
      CALL METHOD top->add_text
      EXPORTING
        text          = 'hello'
        sap_style     = 'HEADING'
    CALL METHOD top->add_gap
        EXPORTING
          width = 20.
      CALL METHOD top->add_text
      EXPORTING
        text          = 'HOW ARE YOU'
        sap_style     = 'HEADING'.
        CALL METHOD TOP->new_line
    *      EXPORTING
    *        repeat =
        CALL METHOD top->add_gap
        EXPORTING
          width = 50.
      CALL METHOD top->add_text
      EXPORTING
        text          = '____________________________________________________________'
        sap_style     = 'HEADING'.
        CALL METHOD TOP->new_line
    *      EXPORTING
    *        repeat =
        CALL METHOD top->add_gap
        EXPORTING
          width = 90.
      CALL METHOD top->add_text
      EXPORTING
        text          = 'YOU CAN TRY LIKE THIS'
        sap_style     = 'HEADING'.
    ENDFORM.                    "html_top_of_page
    Regards
    Debarshi

  • Example of  a Simple ALV Report using Function Modules (not OO)

    Hi,
    I am new to ABAP. Where can I get a proper Example of  a Simple ALV Report using Function Modules?  I searched the forum but did not find a proper solution. Kindly help.
    Smruthi.
    Edited by: Smruthi Acharya on Jan 29, 2009 7:13 PM

    Hi,
    Use this demo code:-
    REPORT  z_alv01 MESSAGE-ID zmsg.
    *          TABLES
    TABLES : ekpo.
    *          TYPE POOLS
    TYPE-POOLS : slis.
    *          TYPE DECLARATION
    TYPES : BEGIN OF t_ekpo,
              ebeln TYPE ekpo-ebeln,
              ebelp TYPE ekpo-ebelp,
              matnr TYPE ekpo-matnr,
              werks TYPE ekpo-werks,
              menge TYPE ekpo-menge,
            END OF t_ekpo.
    *          PARAMETERS
    PARAMETERS : s_var TYPE disvariant-variant.
    *          DATA DECLARATION
    *VARIABLES
    DATA : check(1),
           rep_id TYPE sy-repid.
    *INTERNAL TABLE TYPE OF ZEKPO
    DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE.
    *FIELD CATALOG
    DATA : it_field TYPE slis_t_fieldcat_alv,
           wa_field TYPE slis_fieldcat_alv.
    *SORTING
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *FOR TOP OF THE PAGE
    DATA : it_top TYPE slis_t_listheader,
           wa_top TYPE slis_listheader.
    *FOR END OF THE PAGE
    DATA : it_end TYPE slis_t_listheader,
           wa_end TYPE slis_listheader.
    *TO CAPTURE EVENTS AND HANDLE
    DATA : it_event TYPE slis_t_event,
           wa_event TYPE slis_alv_event.
    *FOR GRID TITLE
    DATA : wa_title TYPE lvc_title.
    *FOR LAYOUT
    DATA : wa_layout TYPE slis_layout_alv.
    *FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
    DATA : it_exclude TYPE slis_t_extab,
           wa_exclude TYPE slis_extab.
    *FOR VARIANT
    DATA : wa_variant TYPE disvariant.
    *          INITIALIZATION
    INITIALIZATION.
      check = 'X'.
      rep_id = sy-repid.
      wa_variant-report = sy-repid.
    *GET DEFUALT ON THE SELECTION SCREEN FOR DEFAULT DISPLAY
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc = 0.               " IF DEFAULT VARIANT FOUND
        s_var = wa_variant-variant.  " PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN ON VALUE REQUEST
    *          TO GET THE F4 HELP FOR VARIANT
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant                = wa_variant
    *   I_TABNAME_HEADER          =
    *   I_TABNAME_ITEM            =
    *   IT_DEFAULT_FIELDCAT       =
         i_save                    = 'A'
    *   I_DISPLAY_VIA_GRID        = ' '
       IMPORTING
    *   E_EXIT                    =
         es_variant                = wa_variant
       EXCEPTIONS
         not_found                 = 1
         program_error             = 2
         OTHERS                    = 3.
      IF sy-subrc = 0.
        s_var = wa_variant-variant. " PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN
    *          TO CHECK THE EXISTENCE FOR VARIANT
    AT SELECTION-SCREEN.
      wa_variant-variant = s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc <> 0.
        MESSAGE w001.
      ENDIF.
    *          START OF SELECTION
    START-OF-SELECTION.
      SELECT ebeln
             ebelp
             matnr
             werks
             menge
             FROM ekpo
             INTO TABLE it_ekpo.
    *          FIELD CATALOG
      wa_field-fieldname = 'EBELN'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'PO #'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'EBELP'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Line Item'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MATNR'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 15.
      wa_field-seltext_l = 'Material'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'WERKS'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 6.
      wa_field-seltext_l = 'Plant'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MENGE'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Qty.'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      wa_field-do_sum = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
    *          SORT W.R.T. PURCHASE ORDER NUMBER
      wa_sort-spos = 1.
      wa_sort-fieldname = 'EBELN'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = check.
      wa_sort-subtot = check.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    *          FOR GRID TITLE
      wa_title = 'Hello'.
    *          FOR LAYOUT
      wa_layout-zebra = check.
    *          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
      wa_exclude-fcode = '&OUP'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&ODN'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&OAD'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *  wa_exclude-fcode = '&AVE'.
    *  APPEND wa_exclude TO it_exclude.
    *  CLEAR wa_exclude.
      wa_exclude-fcode = '&INFO'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *          POPULATE ALL EVENTS INTO INTERNAL TABLE
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_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.
      READ TABLE it_event INTO wa_event WITH KEY name = 'END_OF_LIST'.
      wa_event-form = 'END'.
      MODIFY it_event FROM wa_event INDEX sy-tabix.
      CLEAR wa_event.
    *          DISPLAY RECORDS IN ALV GRID
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = rep_id
    *   i_callback_pf_status_set          = 'PF'
       i_callback_user_command           = 'COMMAND'
       i_callback_top_of_page            = 'TOP'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
       i_grid_title                      = wa_title
    *   I_GRID_SETTINGS                   =
       is_layout                         = wa_layout
       it_fieldcat                       = it_field
       it_excluding                      = it_exclude
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
       i_save                            = 'A'
       is_variant                        = wa_variant
       it_events                         = it_event
    *   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
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_ekpo
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    *&      Form  top
    *       TO WRITE THE HEADER
    FORM top.
      REFRESH it_top.
      wa_top-typ = 'S'.
      wa_top-key = text-001.
      wa_top-info = rep_id.
      APPEND wa_top TO it_top.
      CLEAR wa_top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_top
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "top
    *&      Form  end
    *       TO WRITE THE FOOTER
    FORM end.
      REFRESH it_end.
      wa_end-typ = 'S'.
      wa_end-key = text-001.
      wa_end-info = rep_id.
      APPEND wa_end TO it_end.
      CLEAR wa_end.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_end
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "end
    *&      Form  pf
    *       FOR PF-STATUS WITH USER DEFINED BUTTONS
    *      -->RT_EXTAB   text
    FORM pf USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZTG_PF_ALV'.
    ENDFORM.                    "pf
    *&      Form  command
    *       TO HANDLE USER ACTIONS AGAINST PF-STATUS
    *      -->UCOMM      text
    *      -->SELFIELD   text
    FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA : ok_code TYPE sy-ucomm.
      ok_code = ucomm.
      CASE ok_code.
        WHEN 'T_DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL DOWN'.
        WHEN 'DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'DOWN'.
        WHEN 'UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'UP'.
        WHEN 'T_UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL UP'.
      ENDCASE.
    ENDFORM.                    "command
    Hope this helps you.
    Thanks & Regards,
    Tarun Gambhir

  • Alv report using oops ABAP

    hi friendz,
    can any one of u give an example, how to build alv report using oops abap ?
    thanks in advance.
    points for sure
    regards,
    Vijaya

    Hi Vijaya,
    I hope the following code upto your requirement.
    *& Report  ZMAT_ALV_GRID                                               *
    REPORT  ZCL_CLASS1.
    TYPES: BEGIN OF T_MARA,
             MATNR TYPE MARA-MATNR,
             MAKTX TYPE MAKT-MAKTX,
             WERKS TYPE MARD-WERKS,
             LGORT TYPE MARD-LGORT,
             LABST TYPE MARD-LABST,
           END OF T_MARA.
    *DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA.
    DATA: IT_MARA TYPE T_MARA OCCURS 0.
    DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          O_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: X_FLDCAT TYPE LVC_S_FCAT.
    DATA: IT_FLDCAT TYPE LVC_T_FCAT.
    DATA: I_LAYOUT TYPE LVC_S_LAYO.
    DATA: X_SORT TYPE LVC_S_SORT.
    DATA: I_SORT TYPE LVC_T_SORT.
    TABLES: MARA.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
    PARAMETERS: P_CHK AS CHECKBOX.
    START-OF-SELECTION.
      PERFORM GET_DATA.
      PERFORM GENERATE_FLDCAT.
      PERFORM GENERATE_LAYOUT.
      PERFORM DO_SORT.
      SET SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
       SET PF-STATUS 'MAIN'.
    SET TITLEBAR 'xxx'.
       PERFORM BUILD_ALV.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_ALV
          text
    FORM BUILD_ALV .
    CREATE OBJECT O_CONT
       EXPORTING
          CONTAINER_NAME              = 'MAT_CONTAINER'
       EXCEPTIONS
         CNTL_ERROR                  = 1
         CNTL_SYSTEM_ERROR           = 2
         CREATE_ERROR                = 3
         LIFETIME_ERROR              = 4
         LIFETIME_DYNPRO_DYNPRO_LINK = 5
         others                      = 6.
         CREATE OBJECT O_GRID
           EXPORTING
              I_PARENT          = O_CONT
           EXCEPTIONS
             ERROR_CNTL_CREATE = 1
             ERROR_CNTL_INIT   = 2
             ERROR_CNTL_LINK   = 3
             ERROR_DP_CREATE   = 4
             others            = 5.
    CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
       EXPORTING
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = ' '
         IS_LAYOUT                     = I_LAYOUT
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
       CHANGING
         IT_OUTTAB                     = IT_MARA
         IT_FIELDCATALOG               = IT_FLDCAT[]
         IT_SORT                       = I_SORT
       IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        others                        = 4.
    ENDFORM.                    " BUILD_ALV
    *&      Form  GET_DATA
          text
    FORM GET_DATA .
    SELECT A~MATNR
          B~MAKTX
          C~WERKS
          C~LGORT
          C~LABST
    INTO TABLE IT_MARA
    FROM MARA AS A
    INNER JOIN MAKT AS B
    ON BMATNR = AMATNR
    INNER JOIN MARD AS C
    ON CMATNR = AMATNR
    WHERE A~MATNR IN S_MATNR
    AND   B~SPRAS = SY-LANGU.
    ENDFORM.                    " GET_DATA
    *&      Form  GENERATE_FLDCAT
          text
    FORM GENERATE_FLDCAT .
    *CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
      I_BUFFER_ACTIVE              =
       I_STRUCTURE_NAME             = 'ZSMARA'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           =
      I_INTERNAL_TABNAME           = ' '
    CHANGING
       CT_FIELDCAT                  = IT_FLDCAT
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3.
    X_FLDCAT-COL_POS = 1.
    X_FLDCAT-FIELDNAME = 'MATNR'.
    X_FLDCAT-OUTPUTLEN = '18'.
    X_FLDCAT-REPTEXT = 'Material No'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 2.
    X_FLDCAT-FIELDNAME = 'MAKTX'.
    X_FLDCAT-OUTPUTLEN = '48'.
    X_FLDCAT-REPTEXT = 'Material Desc'.
    X_FLDCAT-TOOLTIP = 'Material Desc'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 3.
    X_FLDCAT-FIELDNAME = 'WERKS'.
    X_FLDCAT-OUTPUTLEN = '5'.
    X_FLDCAT-REPTEXT = 'Plant'.
    X_FLDCAT-TOOLTIP = 'Plant'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 4.
    X_FLDCAT-FIELDNAME = 'LGORT'.
    X_FLDCAT-OUTPUTLEN = '5'.
    X_FLDCAT-REPTEXT = 'S.Loc'.
    X_FLDCAT-TOOLTIP = 'S.Loc'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 5.
    X_FLDCAT-FIELDNAME = 'LABST'.
    X_FLDCAT-OUTPUTLEN = '20'.
    X_FLDCAT-REPTEXT = 'Quantity'.
    X_FLDCAT-TOOLTIP = 'Quantity'.
    X_FLDCAT-DO_SUM = 'X'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    ENDFORM.                    " GENERATE_FLDCAT
    *&      Form  GENERATE_LAYOUT
          text
    FORM GENERATE_LAYOUT .
      I_LAYOUT-ZEBRA = 'X'.
      I_LAYOUT-FRONTEND = 'X'.
      I_LAYOUT-GRID_TITLE = 'ALV GRID USING OOPS'.
      I_LAYOUT-NUMC_TOTAL = 'X'.
    ENDFORM.                    " GENERATE_LAYOUT
    *&      Form  DO_SORT
          text
    FORM DO_SORT .
    X_SORT-FIELDNAME = 'MATNR'.
    X_SORT-UP = 'X'.
    X_SORT-SUBTOT = 'X'.
    IF P_CHK = 'X'.
       X_SORT-EXPA = SPACE.
    ELSE.
       X_SORT-EXPA = 'X'.
    ENDIF.
    APPEND X_SORT TO I_SORT.
    ENDFORM.                    " DO_SORT
    inorder to execute this code perfectly, do the following things.
    1. Create a Graphical Screen 100.
    2. Place a Custom Control on that screen and give name as MAT_CONTAINER.
    3. activate the screen.
    and execute the program.
      if this suits requirement award points.
    satish

  • Column Headings in the report and adding an extra field to the report

    Hi All.
    I had an issue like i need to put column headings for a report and I want to add an extra field to the report.
    The problem here is that the report was actually cloned from a Query.At the time of cloning,they forgot to add the column headings.
    Now we need to add the column headings for the same.How can we proceed for this and where we need to add our code?
    How to add an extra field  to the existing report?
    Any pointers will be very much helpful.
    Regards,
    SSR.

    Hi,
    you can get this done in 2 ways:
    1 - Change the query to add another column and the re-generate the report
    2 - If changing query is not possible, you can change the report it self for adding extra field. If you look at the code, it will be more like normal ABAP code. you can easily modify it (If you are ABAPer) for your additional requirements.
    thnx,
    ags.
    Edited by: Agasti Kale on Jun 12, 2008 6:26 PM

  • ALV report using OOPS concept.

    Hi,
    Please help me in writing ALV report using OOPS concept as i have never used this concept before.Please post a clear picture for this.
    Thanks in advance.

    Hi
    Refer this code:
    REPORT zcls_alv_oops MESSAGE-ID z1.
    TABLES : mara.
    Types Declaration..\
    TYPES :
    BEGIN OF t_mara,
    matnr TYPE matnr,
    mtart TYPE mtart,
    maktx TYPE maktx,
    END OF t_mara,
    BEGIN OF t_marc,
    matnr TYPE matnr,
    werks TYPE werks_d,
    mtart TYPE mtart,
    maktx TYPE maktx,
    END OF t_marc.
    Internal Tables Declaration..\
    DATA :
    i_mara TYPE TABLE OF t_mara,
    i_marc TYPE TABLE OF t_marc,
    i_fcat1 TYPE lvc_t_fcat,
    i_fcat2 TYPE lvc_t_fcat.
    Constants Declaration..\
    CONSTANTS :
    c_cont1 TYPE scrfname VALUE 'CONT1',
    c_cont2 TYPE scrfname VALUE 'CONT2'.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    SELECT-OPTIONS:
    s_matnr FOR mara-matnr NO INTERVALS.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS :
    p_hotspt RADIOBUTTON GROUP r1 DEFAULT 'X',
    p_bttn RADIOBUTTON GROUP r1.
    SELECTION-SCREEN END OF BLOCK b1.
    \* Class forward referncing.
    CLASS lcl_rcvr_class DEFINITION DEFERRED.
    \* Pointers Declaration..
    DATA :
    lp_rcvr TYPE REF TO lcl_rcvr_class,
    lp_cont1 TYPE REF TO cl_gui_custom_container,
    lp_cont2 TYPE REF TO cl_gui_custom_container,
    lp_grid1 TYPE REF TO cl_gui_alv_grid,
    lp_grid2 TYPE REF TO cl_gui_alv_grid.
    \* Local Class Definiton.
    CLASS lcl_rcvr_class DEFINITION.
    PUBLIC SECTION.
    METHODS :
    hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
    IMPORTING e_row_id e_column_id es_row_no,
    handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
    IMPORTING e_row e_column.
    ENDCLASS.
    \* Local Class Implementation.
    CLASS lcl_rcvr_class IMPLEMENTATION.
    METHOD hotspot_click.
    DATA :
    wa_mara TYPE t_mara,
    wa_marc TYPE t_marc.
    DATA :
    l_index TYPE sy-tabix.
    READ TABLE i_mara INTO wa_mara INDEX e_row_id-index.
    IF sy-subrc EQ 0.
    REFRESH i_marc.
    SELECT matnr
    werks
    INTO TABLE i_marc
    FROM marc
    WHERE matnr EQ wa_mara-matnr.
    IF sy-subrc EQ 0.
    LOOP AT i_marc INTO wa_marc.
    l_index = sy-tabix.
    wa_marc-mtart = wa_mara-mtart.
    wa_marc-maktx = wa_mara-maktx.
    MODIFY i_marc FROM wa_marc INDEX l_index
    TRANSPORTING mtart maktx.
    ENDLOOP.
    CALL SCREEN 200.
    ELSE.
    MESSAGE e121 WITH text-005 wa_mara-matnr.
    ENDIF.
    ENDIF.
    ENDMETHOD.
    METHOD handle_double_click.
    DATA :
    wa_mara TYPE t_mara,
    wa_marc TYPE t_marc.
    DATA :
    l_index TYPE sy-tabix.
    READ TABLE i_mara INTO wa_mara INDEX e_row-index.
    IF sy-subrc EQ 0.
    REFRESH i_marc.
    SELECT matnr
    werks
    INTO TABLE i_marc
    FROM marc
    WHERE matnr EQ wa_mara-matnr.
    IF sy-subrc EQ 0.
    LOOP AT i_marc INTO wa_marc.
    l_index = sy-tabix.
    wa_marc-mtart = wa_mara-mtart.
    wa_marc-maktx = wa_mara-maktx.
    MODIFY i_marc FROM wa_marc INDEX l_index
    TRANSPORTING mtart maktx.
    ENDLOOP.
    CALL SCREEN 200.
    ELSE.
    MESSAGE e121 WITH text-005 wa_mara-matnr.
    ENDIF.
    ENDIF.
    ENDMETHOD.
    ENDCLASS.
    \* Start of Selection
    START-OF-SELECTION.
    \* Extract the Material Master data for the Input Material.
    SELECT a~matnr
    a~mtart
    b~maktx
    INTO TABLE i_mara
    FROM mara AS a
    INNER JOIN makt AS b
    ON a~matnr EQ b~matnr
    WHERE a~matnr IN s_matnr
    AND b~spras EQ sy-langu.
    END-OF-SELECTION.
    IF NOT i_mara\[\] IS INITIAL.
    \* Call Screen to display the Material Master data.
    CALL SCREEN 100.
    ELSE.
    MESSAGE s121 WITH text-006.
    ENDIF.
    \*& Module DISP_GRID OUTPUT
    \* text
    MODULE disp_grid OUTPUT.
    \* Build the Field catelog for Material Master data.
    PERFORM build_fcat.
    \* Display the Material Master data using ALV.
    PERFORM disp_alv.
    ENDMODULE. " DISP_GRID OUTPUT
    \*& Module USER_COMMAND_0100 INPUT
    \* text
    MODULE user_command_0100 INPUT.
    \*when exit or cancel is clicked program has to come out
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'CANC'.
    LEAVE PROGRAM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    \*& Form build_fcat
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM build_fcat.
    DATA : ws_fcat TYPE lvc_s_fcat.
    ws_fcat-fieldname = 'MATNR'.
    ws_fcat-scrtext_m = text-001.
    ws_fcat-tabname = 'I_MARA'.
    IF p_hotspt EQ 'X'.
    ws_fcat-hotspot = 'X'.
    ENDIF.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MTART'.
    ws_fcat-scrtext_m = text-002.
    ws_fcat-tabname = 'I_MARA'.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MAKTX'.
    ws_fcat-scrtext_m = text-003.
    ws_fcat-tabname = 'I_MARA'.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ENDFORM. " build_fcat
    \*& Form disp_alv
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM disp_alv.
    IF lp_cont1 IS INITIAL.
    \* Create the Container Object of Material Master.
    CREATE OBJECT lp_cont1
    EXPORTING
    container_name = c_cont1
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6 .
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Create the Object for Grid of Material Master.
    CREATE OBJECT lp_grid1
    EXPORTING
    i_parent = lp_cont1
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Dipslay Material Master data by calling method.
    CALL METHOD lp_grid1->set_table_for_first_display
    CHANGING
    it_outtab = i_mara
    it_fieldcatalog = i_fcat1
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Set Handler for the Hot Spot Event.
    CREATE OBJECT lp_rcvr.
    IF p_hotspt EQ 'X'.
    SET HANDLER lp_rcvr->hotspot_click FOR lp_grid1.
    ELSE.
    SET HANDLER lp_rcvr->handle_double_click FOR lp_grid1.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDFORM. " disp_alv
    \*& Module STATUS_0100 OUTPUT
    \* text
    MODULE status_0100 OUTPUT.
    SET PF-STATUS 'MAIN_STAT'.
    SET TITLEBAR 'T_100'.
    ENDMODULE. " STATUS_0100 OUTPUT
    \*& Module STATUS_0200 OUTPUT
    \* text
    MODULE status_0200 OUTPUT.
    SET PF-STATUS 'PLANT_STAT'.
    SET TITLEBAR 'T_200'.
    ENDMODULE. " STATUS_0200 OUTPUT
    \*& Module DISP_GRID_plant OUTPUT
    \* text
    MODULE disp_grid_plant OUTPUT.
    \* Build the Field catelog for Material Plant data.
    PERFORM build_fcat_plant.
    \* Display the Material Master Plant data using ALV.
    PERFORM disp_alv_plant.
    ENDMODULE. " DISP_GRID_plant OUTPUT
    \*& Module USER_COMMAND_0200 INPUT
    \* text
    MODULE user_command_0200 INPUT.
    \*when exit or cancel is clicked program has to come out
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'CANC'.
    LEAVE PROGRAM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0200 INPUT
    \*& Form build_fcat_plant
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM build_fcat_plant.
    DATA : ws_fcat TYPE lvc_s_fcat.
    ws_fcat-fieldname = 'MATNR'.
    ws_fcat-scrtext_m = text-001.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'WERKS'.
    ws_fcat-scrtext_m = text-004.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MTART'.
    ws_fcat-scrtext_m = text-002.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MAKTX'.
    ws_fcat-scrtext_m = text-003.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ENDFORM. " build_fcat_plant
    \*& Form disp_alv_plant
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM disp_alv_plant.
    IF lp_cont2 IS INITIAL.
    \* Create the Container Object of Material Plant data.
    CREATE OBJECT lp_cont2
    EXPORTING
    container_name = c_cont2
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Create the Object for Grid of Material Plant data.
    CREATE OBJECT lp_grid2
    EXPORTING
    i_parent = lp_cont2
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Dipslay Material Plant data by calling method.
    CALL METHOD lp_grid2->set_table_for_first_display
    CHANGING
    it_outtab = i_marc
    it_fieldcatalog = i_fcat2
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDIF.
    ENDIF.
    ELSE.
    \* Call method 'REFRESH_TABLE_DISPLAY' to refresh the grid data.
    CALL METHOD lp_grid2->refresh_table_display.
    ENDIF.
    ENDFORM. " disp_alv_plant
    Thanks
    Vasudha

  • A simple ALV report using classes & methods ...

    i want a  simple ALV report using classes & methods ...
    my requirement : i have to use classes & methods instead  of calling a function module to display in grid or list format.
               plz send me with explanation ASAP...it's very urgent..
               Thanks in advance .

    Hi
    Please refer
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    U can use methods for vreating ALVs.
    There is a method named set_table_for_first_display in OOP Concepts.
    Use this Object Oriented Approach for ALV Creation
    Calling the method set_table_for_first_display
    CALL METHOD cust_alv->set_table_for_first_display
    EXPORTING
    is_layout = gst_layout
    CHANGING
    it_outtab = gt_list
    it_fieldcatalog = gt_fcat
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Object Creation and all
    Creation of Object for Container
    CREATE OBJECT cust_container
    EXPORTING
    container_name = 'ALV_CONTAINER'
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Creation of Object for ALV Grid
    CREATE OBJECT cust_alv
    EXPORTING
    i_parent = cust_container
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Layout settings
    gst_layout-zebra ='X'.
    gst_layout-cwidth_opt = 'X'.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
    I_BUFFER_ACTIVE =
    I_STRUCTURE_NAME = 'ZCS_INACTV_CUST'
    I_CLIENT_NEVER_DISPLAY = 'X'
    I_BYPASSING_BUFFER =
    CHANGING
    ct_fieldcat = gt_fcat
    EXCEPTIONS
    INCONSISTENT_INTERFACE = 1
    PROGRAM_ERROR = 2
    OTHERS = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Calling the method set_table_for_first_display
    CALL METHOD cust_alv->set_table_for_first_display
    EXPORTING
    is_layout = gst_layout
    CHANGING
    it_outtab = gt_list
    it_fieldcatalog = gt_fcat
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    For object oriented concepts refer this link https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47
    Reaward if helpful

  • End of Page event in ALV report using SALV class[cl_salv_hierseq_table]

    Hi ,
    have been working on a ALV report using the class SALV cl_salv_hierseq_table
    I am facing few issues pertaining to two things:
    1. Displaying some subtotal text along with the subtotals.
    Example refer the standard demo example: SALV_DEMO_HIERSEQ_FORM_EVENTS
    Now instead of A 17 and A26 I would like to show text like Subtotal for the Carrid.for subtotals and grand totals
    Like   Subtotal for A 17 is :      XXXXXXX
              GrandTotal is         :      YYYYYY
    2. We have a page break and a new page for every purchasing group as in the standard example SALV_DEMO_HIERSEQ_FORM_EVENTS for CARRID.
    I need to display some variable values as number of documents ,total number of records etc at the end of each CARRID group before a new page starts for the next CARRID.Please note i do not want it on every page.it should only be diaplyed at the end of page whose next page would be for next CARRID.[basically at end of every carrid]Example:after displaying all details for AA need to display the number of records for that carrid at the end of the page[as page break is based on CARRID]/
    Thanks
    Jyotsna

    at end of page event, for CL_SALV_EVENTS_HIERSEQ, has some useful parameters allowing to know where you are at the time of event
    parameter VALUE is of type CL_SALV_FORM which contains public attribute IF_SALV_FORM~ACCDESCRIPTION; you can slo get contents of it
    about text of total/subtotal, this is normally set in the layout

Maybe you are looking for

  • Multiple users on the same device

    Can I have 2 or more users on the same device? I want to use a Kindle Fire HD when traveling with separate accounts for my wife and myself.

  • Solved Audigy 2 cracking noises in particular situat

    The annoying crack/pop sounds can be caused by other PCI-cards. Take my case for instance: a PCI card called "SkyStar2" (a satellite TV tuner) used the PCI-bus in such a way that new chunks of sound for the Audigy did not arri've in time. Clicks/pops

  • CP Buy & Sell add final_loading_ani.gif when waiting for update IE

    CRM 7.0 We run B2B ISA now, when a search is running the user can see the internet explorer search bar is working. We are trying to implment Channel Management and when we launch ISA from the Buy & Sell tab, a new window opens for ISA but is within a

  • Warning message when repairing permissions

    I Just repaired permissions and the usual large list showed up. But this time I got a message that says: "Warning: SUID file "System/Library/CoreService...ent" has been modified and will not be repaired. I navigated to that site and could not find a

  • How can we use BDoc for replication BP industry data

    Hi sap guru's,   I am siva, i am working IS-U and CRM, give me the solutions for my requirment. Bussiness Partner Industry data replication using BDoc, it means when the new industry add to the Bussiness partner then the industry data automatically t