Edit the column in ALV tree

Hi Experts ,
                      I want to edit the column contents in a ALV tree and the save the content . I am using CL_ALV_gui_tree class to build the tree structure.please help on this
With regards
RKM

Hi,
In the field catalog internal table ,
Fcat-edit  = 'X'.
This makes the particular field as editable mode. append to field catelog internal table.
include into your internal table.
in the structure.
   types: cellstyles type lvc_t_styl.
call this class
class lcl_event_handlers definition.
  public section.
    methods:handle_button_click for event button_click of cl_gui_alv_grid
                                                          importing  es_row_no.   " METHOD TO HANDLE PUSH BUTTON
endclass.                "lcl_event_handlers DEFINITION
class lcl_event_handlers implementation.
method handle_button_click.
perform handle_button_click using   es_row_no .   " ACTION TO BE PERFORMED WHEN CLICKING ON PUSH BUTTON
endmethod.
layout :
gs_layout-stylefname = 'CELLSTYLES'.
endclass.
ls_style-fieldname = 'BUTTON'.
ls_style-style = cl_gui_alv_grid=>mc_style_button.
append ls_style to wa_str-cellstyles.
***********button name
   wa_str-button = 'SAVE'.
   modify it_str from wa_str transporting button.

Similar Messages

  • Average sum for a column in ALV tree layout

    Hi,
    I've trying to set an average sum for a column in an ALV tree report.  In the field catalog i set the DO_SUM field to 'X' and this will do a total sum, but I can't find out how in the code to do the average sum.
    Also to get round this I was going to just set a default display variant with the "average" sum option saved after i had manually selected the columns and set it to this.  Problem with this is that when i re-run it, the sum comes back as a total rather than an average.  I have tried setting display variants on the SAP example ALV tree programs and the same thing happens.
    Does anyone know how i can get round this?
    Cheers
    Matt.

    Hi,
    In addition to setting DO_SUM = 'X' you need to specify function in H_FTYPE field. It should be set to 'AVG' in your case.
    ls_fielcat-do_sum = 'X'.
    ls_fieldcat-h_ftype = 'AVG.

  • How to download the datas of ALV tree without passing iternal table

    Hi,
      I want to download the values of ALV tree output in an Excel file without using any internal table.
    Please suggest your thoughts on the same.
    Regards,
    Shasiraj.C
    Edited by: Raj Shasi on Aug 1, 2008 8:44 AM

    There is one option -Export' in menu bar of ALV grid itself. Click on that and then click 'Local File'. Then choose 'Spreadsheet' option and provide local PC path for download.
    Regards,
    Aparna Gaikwad

  • Free the contentes of alv tree

    how to free the contents of alv tree?

    Hi kailash,
    Good Check the below example program for ALV Tree ( Complete Example)
    Demo Program on ALV Tree Control
    REPORT  zdemo_alv_tree.
    CLASS cl_gui_column_tree DEFINITION LOAD.
    CLASS cl_gui_cfw DEFINITION LOAD.
    DATA tree1  TYPE REF TO cl_gui_alv_tree_simple.
    INCLUDE <icon>.
    INCLUDE bcalv_simple_event_receiver.
    DATA: gt_sflight      TYPE sflight OCCURS 0,   " Output-Table
          gt_fieldcatalog TYPE lvc_t_fcat,         " Field Catalog
          gt_sort         TYPE lvc_t_sort,         " Sorting Table
          ok_code         LIKE sy-ucomm.           " OK-Code
    END-OF-SELECTION.
      CALL SCREEN 100.
    *&      Form  BUILD_FIELDCATALOG
    This subroutine is used to build the field catalog for the ALV list
    FORM build_fieldcatalog.
    get fieldcatalog
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'SFLIGHT'
        CHANGING
          ct_fieldcat      = gt_fieldcatalog.
    change fieldcatalog
      DATA: ls_fieldcatalog TYPE lvc_s_fcat.
      LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.
        CASE ls_fieldcatalog-fieldname.
          WHEN 'CARRID' OR 'CONNID' OR 'FLDATE'.
            ls_fieldcatalog-no_out = 'X'.
            ls_fieldcatalog-key    = ''.
          WHEN 'PRICE' OR 'SEATSOCC' OR 'SEATSMAX' OR 'PAYMENTSUM'.
            ls_fieldcatalog-do_sum = 'X'.
        ENDCASE.
        MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
      ENDLOOP.
    ENDFORM.                               " BUILD_FIELDCATALOG
    *&      Form  BUILD_OUTTAB
    Retrieving the data from the table and filling it in the output table
    of the ALV list
    FORM build_outtab.
      SELECT * FROM sflight INTO TABLE gt_sflight.
    ENDFORM.                               " BUILD_OUTTAB
    *&      Form  BUILD_SORT_TABLE
    This subroutine is used to build the sort table or the sort criteria
    FORM build_sort_table.
      DATA ls_sort_wa TYPE lvc_s_sort.
    create sort-table
      ls_sort_wa-spos = 1.
      ls_sort_wa-fieldname = 'CARRID'.
      ls_sort_wa-up = 'X'.
      ls_sort_wa-subtot = 'X'.
      APPEND ls_sort_wa TO gt_sort.
      ls_sort_wa-spos = 2.
      ls_sort_wa-fieldname = 'CONNID'.
      ls_sort_wa-up = 'X'.
      ls_sort_wa-subtot = 'X'.
      APPEND ls_sort_wa TO gt_sort.
      ls_sort_wa-spos = 3.
      ls_sort_wa-fieldname = 'FLDATE'.
      ls_sort_wa-up = 'X'.
      APPEND ls_sort_wa TO gt_sort.
    ENDFORM.                               " BUILD_SORT_TABLE
    *&      Module  PBO  OUTPUT
    This subroutine is used to build the ALV Tree
    MODULE pbo OUTPUT.
      IF tree1 IS INITIAL.
        PERFORM init_tree.
      ENDIF.
      SET PF-STATUS 'ZSTATUS'.
    ENDMODULE.                             " PBO  OUTPUT
    *&      Module  PAI  INPUT
    This subroutine is used to handle the navigation on the screen
    MODULE pai INPUT.
      CASE ok_code.
        WHEN 'EXIT' OR 'BACK' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
          CALL METHOD cl_gui_cfw=>dispatch.
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                             " PAI  INPUT
    *&      Form  exit_program
          free object and leave program
    FORM exit_program.
      CALL METHOD tree1->free.
      LEAVE PROGRAM.
    ENDFORM.                               " exit_program
    *&      Form  register_events
    Handling the events in the ALV Tree control in backend
    FORM register_events.
    define the events which will be passed to the backend
      DATA: lt_events TYPE cntl_simple_events,
            l_event TYPE cntl_simple_event.
    define the events which will be passed to the backend
      l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_click.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
      APPEND l_event TO lt_events.
      CALL METHOD tree1->set_registered_events
        EXPORTING
          events                    = lt_events
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
    set Handler
      DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.
      CREATE OBJECT l_event_receiver.
      SET HANDLER l_event_receiver->on_add_hierarchy_node
                                                            FOR tree1.
    ENDFORM.                               " register_events
    *&      Form  build_header
          build table for header
    FORM build_comment USING
          pt_list_commentary TYPE slis_t_listheader
          p_logo             TYPE sdydo_value.
      DATA: ls_line TYPE slis_listheader.
    LIST HEADING LINE: TYPE H
      CLEAR ls_line.
      ls_line-typ  = 'H'.
    LS_LINE-KEY:  NOT USED FOR THIS TYPE
      ls_line-info = 'ALV TREE DEMO for ****************'.
      APPEND ls_line TO pt_list_commentary.
      p_logo = 'ENJOYSAP_LOGO'.
    ENDFORM.                    "build_comment
    *&      Form  init_tree
    Building the ALV-Tree for the first time display
    FORM init_tree.
      PERFORM build_fieldcatalog.
      PERFORM build_outtab.
      PERFORM build_sort_table.
    create container for alv-tree
      DATA: l_tree_container_name(30) TYPE c,
            l_custom_container TYPE REF TO cl_gui_custom_container.
      l_tree_container_name = 'TREE1'.
      CREATE OBJECT l_custom_container
          EXPORTING
                container_name = l_tree_container_name
          EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
    create tree control
      CREATE OBJECT tree1
        EXPORTING
            i_parent              = l_custom_container
            i_node_selection_mode =
                                  cl_gui_column_tree=>node_sel_mode_multiple
            i_item_selection      = 'X'
            i_no_html_header      = ''
            i_no_toolbar          = ''
        EXCEPTIONS
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
    create info-table for html-header
      DATA: lt_list_commentary TYPE slis_t_listheader,
            l_logo             TYPE sdydo_value.
      PERFORM build_comment USING
                     lt_list_commentary
                     l_logo.
    repid for saving variants
      DATA: ls_variant TYPE disvariant.
      ls_variant-report = sy-repid.
    register events
      PERFORM register_events.
    create hierarchy
      CALL METHOD tree1->set_table_for_first_display
        EXPORTING
          it_list_commentary = lt_list_commentary
          i_logo             = l_logo
          i_background_id    = 'ALV_BACKGROUND'
          i_save             = 'A'
          is_variant         = ls_variant
        CHANGING
          it_sort            = gt_sort
          it_outtab          = gt_sflight
          it_fieldcatalog    = gt_fieldcatalog.
    expand first level
      CALL METHOD tree1->expand_tree
        EXPORTING
          i_level = 1.
    optimize column-width
      CALL METHOD tree1->column_optimize
        EXPORTING
          i_start_column = tree1->c_hierarchy_column_name
          i_end_column   = tree1->c_hierarchy_column_name.
    ENDFORM.                    " init_tree
    Good Luck and thanks
    AK

  • While editing the columns in ADo net source not refresh the columns

    Hi,
    When i am editing the columns in the adonetsource can't able to edit it.
    EG:
    id       name     sal are the available columns
    select id, 'name' as ename,sal from emp.
    I Edited this query as :
    select  id, 'empname' as ename,sal from emp
    It won't affect in the source. & how to change the query using expression. in adonetsource there is no data access mode as from varible.   pls help on it.
    Thanks

    Hi Sai,
    Let me know what you are trying to Edit in columns. You want to alias the column name or you want to edit the string of column.
    Column Aliasing : 
    select id, name as EmpName, sal from emp
    Check with this and let me know if you still facing issues.
    Regards,
    Vaishu

  • Editing of a  Column of ALV Tree(OOPS) node

    is it possible to edit a column of node of ALV tree.
    i am using ALV class "CL_GUI_ALV_TREE".
    After searching existing threads, for the same issue..i found the following.
    1) Editable Tree ALV
      ( displays pop up window where user can change values and then transfer these changes back to ALV tree)
    2) Editable Field in ALV TREE Display Using OOPs
         (this approach is not working for ALV Tree)
    But i want to edit directly coulmn of a node of ALV tree.
    is it possible in  OOPS ALV Tree?
    if it possible, can any one provide the sample code,

    As you already noticed, this is not possible, but you may edit your fields outside the tree and bring your changes back to tree. I struggled with the same once but eventually used described alternative. If you use saplink you may check upgrade [chain and rename|http://code.google.com/p/saplink-chain-and-rename/downloads/list] where this approach is released. The code is free so you will be able to study and copy whatever you need from it.
    Editing in a pop up is also an alternative here.
    Regards
    Marcin

  • Edit a field in ALV tree in a subscreen of a module pool

    Hi
    I want to make a field editable in the ALV tree based on some condtions in a subscreen of a module pool.  I used the edit = 'X' field in the fieldcatalog still it  is showing the field as display and not edit.
    Please help me to get the field as editable and save it to the database table.
    Please not this is ALV TREE
    Regards,
    Mozila

    Hi Mayank,
    Thanks for the reply
    I am using oops method.
    I tried making the field which is to be made editable  as wa_fieldcatalog-edit = 'X'. But its not working. I didnt get you when you said  edit in layout object.
    I also went through the demo programs but these programs are not having editable fields.
    My code is as follows:
    IF tree4 IS INITIAL.
    * create container for alv-tree
      l_tree_container_name = 'TREE4'.
      CREATE OBJECT l_custom_container
        EXPORTING
          container_name              = l_tree_container_name
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5.
    * create tree control
      CREATE OBJECT tree4
        EXPORTING
          i_parent                    = l_custom_container
          i_node_selection_mode       = cl_gui_column_tree=>node_sel_mode_multiple
          i_item_selection            = 'X'
          i_no_html_header            = 'X'
          i_no_toolbar                = 'X'
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          illegal_node_selection_mode = 5
          failed                      = 6
          illegal_column_name         = 7.
    * create hierarchy
      CALL METHOD tree4->set_table_for_first_display
        EXPORTING
          is_layout       = s_layo
        CHANGING
          it_sort         = it_sort
          it_outtab       = it_final
          it_fieldcatalog = it_fieldcat.
    ELSE.
      CALL METHOD tree4->refresh_table_display
        EXPORTING
          it_sort           = it_sort
        EXCEPTIONS
          program_error     = 1
          failed            = 2
          cntl_system_error = 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.
    endif.

  • How to align text {center/left/right} in  the column of ALV grid

    Hai all,
    I am displaying one check box in the ALV grid, but default it is coming left align in the column,
    how can i assign it to the center of the column.
    Thanks,
    SREEVATHSAVA.G
    Edited by: SREE on Aug 14, 2009 7:53 AM

    Hi,
    DATA:
      lr_model type ref to cl_salv_wd_config_table,
      lr_col type ref to cl_salv_wd_column.
    lr_col = lr_model->if_salv_wd_column_settings->get_column( 'EMPID' ).
    lr_col->SET_H_ALIGN(value = CL_WD_TABLE_COLUMN=>E_H_ALIGN- CENTER).
          AUTO TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '00', " TableColumnHAlign.auto
          CENTER TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '01', " TableColumnHAlign.center
          FORCED_LEFT TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '04', " TableColumnHAlign.forcedLeft
          END_OF_LINE TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '05', " TableColumnHAlign.endOfLine
          FORCED_RIGHT TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '06', " TableColumnHAlign.forcedRight
          BEGIN_OF_LINE TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '07', " TableColumnHAlign.beginOfLine
    Regards,
    Lekha.

  • Average of the column in ALV report

    Hi,
      I am working on an ALV report and for one of the column, i am calculating the average with fieldcatalog property do_sum = 'C'.
    I am sorting the output table for 2 fields and whenever I am expanding/compressing the sorted fields the average of the column is changing. Please let me know how do I get this average calculated constant. It should not change when the user collapses/expands on the sorted field.
    Regards
    Rashmi

    The same question has been asked in this thread:
    Compute average of a report column
    I have offered a solution but as I've said it's not great but it may meet your needs.
    Or another forum user may review and be able to suggest a better solution.
    Does the average need to be part of the report?
    Could you calculate it and display it within a page item below the report instead?

  • In reference to Adjusting  the width of the column in ALV

    Hi All,
    This is in reference to the thread Adjusting size of column
    Here LR_COL is of type what?
    I did as follows.
    data: lr_column type ref to cl_salv_wd_column.
    create object lr_column.
    I am getting an error saying "The obligatory parameter "ID" had no value assigned to it."
    Can any one help me out.
    Regards,
    Yugesh

    hi Yugesh ,
    FYI , there are different methods to get and set the Width and Algnment in ALV
    SET_WIDTH    : Set width of column
    GET_WIDTH  : Get width of column
    SET_H_ALIGN : Set horizontal alignment of elements
    GET_H_ALIGN : Get horizontal alignment of elements
    declare a variable of type reference cl_salv_wd_column , get the ref of the column and use the above 4 methods for width and alignment
    Regards,
    amit

  • Totalling the columns in ALV Grid

    Hello All,
    I have a output with amount and currencies. The problem i am facing is, the amount is in USD and in GBP and it is giving me single value. It is not splitting the USD amount from the GBP amount.
    Also, I am doing a subtotal based on material. This is the most important requirement.
    Can anybody help me out in this.
    Thanks,
    Salil
    I am giving the below piece of code if you want to refer it.
      DATA: gr_alv        TYPE REF TO cl_salv_table,
            lr_display    TYPE REF TO cl_salv_display_settings,
            lr_columns    TYPE REF TO cl_salv_columns_table,
            lr_column     TYPE REF TO cl_salv_column_table,
            lr_functions  TYPE REF TO cl_salv_functions_list,
            lr_sorts      TYPE REF TO cl_salv_sorts,
            lr_print      TYPE REF TO cl_salv_print,
            lr_column_f   TYPE REF TO cl_salv_columns,
            gr_error      TYPE REF TO cx_salv_not_found ,
            lr_layout     TYPE REF TO cl_salv_layout.
      DATA: key     TYPE salv_s_layout_key,
            gr_msg  TYPE string.
      IF NOT lt_output[] IS INITIAL.
        TRY.
    * Create ALV instance - use CALL METHOD since this is a static method
            CALL METHOD cl_salv_table=>factory
              IMPORTING
                r_salv_table = gr_alv
              CHANGING
                t_table      = lt_output.
            lr_display = gr_alv->get_display_settings( ).
            lr_display->set_list_header( text-ttl ).
    * Get functions object and then set all the functions to be allowed
            lr_functions = gr_alv->get_functions( ).
            lr_functions->set_all( ).
            DATA: lv_field TYPE lvc_fname.
    * Get column settings object and then optimize the column widths to the
    * data
            lr_columns = gr_alv->get_columns( ).
            lr_columns->set_optimize( ).
    *--- set column header for custom field Difference in Qty
            TRY.
                lr_column ?= lr_columns->get_column( 'BUCHM2' ).
                lr_column->set_output_length('12').
                lr_column->set_long_text( 'Diff Qty' ).
                lr_column->set_short_text( 'Diff Qty' ).
                lr_column->set_medium_text( 'Diff Qty' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Difference in Qty Abs
            TRY.
                lr_column ?= lr_columns->get_column( 'BUCHM3' ).
                lr_column->set_output_length('13').
                lr_column->set_long_text( 'Diff Qty(Abs)' ).
                lr_column->set_medium_text( 'Diff Qty(Abs)' ).
    *            lr_column->set_short_text( 'Diff Qty(Abs)' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Difference in Value
            TRY.
                lr_column ?= lr_columns->get_column( 'VALUE' ).
                lr_column->set_output_length('15').
                lr_column->set_long_text( 'Value Diff' ).
                lr_column->set_medium_text( 'Value Diff' ).
                lr_column->set_short_text( 'Value Diff' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Difference in Value Abs
            TRY.
                lr_column ?= lr_columns->get_column( 'VALUE_ABS' ).
                lr_column->set_output_length('15').
                lr_column->set_long_text( 'Value Diff(Abs)' ).
                lr_column->set_medium_text( 'Value Diff(Abs)' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Status
            TRY.
                lr_column ?= lr_columns->get_column( 'STATUS' ).
                lr_column->set_output_length('15').
                lr_column->set_long_text( 'PI Item Status' ).
                lr_column->set_medium_text( 'PI Item Status' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Status
            TRY.
                lr_column ?= lr_columns->get_column( 'TOTAL' ).
                lr_column->set_output_length('15').
                lr_column->set_long_text( 'Total Value Diff' ).
                lr_column->set_medium_text( 'Total Value Diff' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    * Optimize the column widths for printing.
            lr_print = gr_alv->get_print( ).
            lr_print->set_print_parameters_enabled( value = 'X' ).
            lr_print->set_column_optimization( value = 'X' ).
    *--- This code is to get the layout,save the layout and display the
    *    layout
            lr_layout = gr_alv->get_layout( ).
            lr_layout->set_default( cl_salv_layout=>true ).  " allow default
            key-report = sy-repid.
            lr_layout->set_key( key ).
           lr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
            DATA: init_layout TYPE slis_vari.
            init_layout = p_layout.
            lr_layout->set_initial_layout( init_layout ).
    *--- display report
            gr_alv->display( ).
          CATCH cx_salv_msg.
            WRITE: 'Error displaying grid! - cx_salv_msg'.
          CATCH cx_salv_not_found.
            WRITE: 'Error displaying grid! - cx_salv_not_found'.
          CATCH cx_salv_data_error.
            WRITE: 'Error displaying grid! - cx_salv_data_error'.
          CATCH cx_salv_existing.
            WRITE: 'Error displaying grid! - cx_salv_existing'.
        ENDTRY.
      ELSE.
        MESSAGE s004.
      ENDIF.

    Can you use something like function module CONVERT_CURRENCY_BY_RATE to convert one set of currencies so all amounts are in the same currency before you display them in the ALV?
    - April King

  • To make different colours for the columns of ALV report in Grid display.

    Hai Friends,
                       I have created an ALV report in grid display method by using the call function reuse_alv_grid_display.
    I have obtained the report.In that report i want to change the colour of each column.Plz provide the answer with a sample program.
                    Thank u.

    hi i had a program  for the rows with diff colors....do the same thing for the columns..
    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,
      line_color(4) type c,     "Used to store row color attributes
    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.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = '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-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).
    Set layout field for row attributes(i.e. color)
      gd_layout-info_fieldname =      'LINE_COLOR'.
    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
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           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.
    data: ld_color(1) type c.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    *Populate field with color attributes
    loop at it_ekko into wa_ekko.
      ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
      if ld_color = 8.
        ld_color = 1.
      endif.
      concatenate 'C' ld_color '10' into wa_ekko-line_color.
    wa_ekko-line_color = 'C410'.
      modify it_ekko from wa_ekko.
    endloop.
    endform.                    " DATA_RETRIEVAL
    regards,
    venkat

  • How to resize the column of alv depending upon the textbox settings in i.e

    Hi,
    I am using ALV component in one of my WD applications. ALV has a column date. If i resize the textbox from the internet explorer setting ( page->textsize in i.e.7) to anything greater than medium, the content of the columns is hidden.
    For example, if the date is displayed as 25/07/2010, after resizing it appears as 25/07...
    i have tried using column property of the alv : set_width and set_resizable, but it doesnt give the desired output.
    Please give ur suggestions.
    Regards,
    Varuna

    Hi,
    Would increasing the width of ALV itself help?
    using IF_SALV_WD_TABLE_SETTINGS~SET_WIDTH().
    Regards,
    Aditya.

  • How to unhide the column in Alv table

    Hi Experts,
        Initially i have created webdynpro Alv table with 8 columns ,later i have added one more attribute/column to the node to display extra column
    but in the output ,alv table not displaying the 9th column,Instead the column is getting hidden which i came to know clicking on settings in alv table output.If i make changes in Alv table settings it getting displaying,can anyone tell me how to unhide this field.
    Regards
    Sandesh

    Hi Sandesh,
         It is possible that the user you are loggin in with, might have a layout saved.
    You can try logging in with different user and see if its still hidden.
    The explicit code to hide and unhide a column :
    lo_alv_column->set_visible( if_wdl_core=>visibility_none ).
    may be  you can use the above code and make column visibility true(cahnge parameter).
    Regards,
    Tashi

  • How can i display a CheckBox in one of the column of ALV?

    Hi All,
    I want to dispaly a one  column  of CHECKBOXes in my ALV  Report.so i take attribute CHK_BOX TYPE CHECKBOX in the context.when i testing it doesn't showing any checkboxes.just i shows a ordinary column with name checkbox.
    How can i resolve it?
    Regards,
    Ravi

    Hi Ravi,
    Do the following to set any alv column as Check box .
    create an instance of ALV component
      DATA:
        lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage,
        lr_column_settings     TYPE REF TO if_salv_wd_column_settings,
        lr_input_field         TYPE REF TO cl_salv_wd_uie_input_field,
        lr_chk_box             TYPE REF TO cl_salv_wd_uie_checkbox,
        lr_table_settings      TYPE REF TO if_salv_wd_table_settings,
        lr_salv_wd_table       TYPE REF TO iwci_salv_wd_table,
        lr_column              TYPE REF TO cl_salv_wd_column.
      lr_salv_wd_table_usage = wd_this->wd_cpuse_alv( ).
      IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
        lr_salv_wd_table_usage->create_component( ).
      ENDIF.
      lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
      wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
      lr_table_settings ?= wd_this->alv_config_table.
    * Set ALV as editable
      lr_table_settings->set_read_only( abap_false ).
    * Get Column reference
      CALL METHOD wd_this->alv_config_table->if_salv_wd_column_settings~get_column
        EXPORTING
          id    = 'CURR_ISO'
        RECEIVING
          value = lr_column.
    * Create a checkboc
      CREATE OBJECT lr_chk_box
        EXPORTING
          checked_fieldname = 'CURR_ISO'.
    * Set the cell editor type to the check box.
      CALL METHOD lr_column->set_cell_editor
        EXPORTING
          value = lr_chk_box.
    and to set the check box as editable, do the following.
    lr_table~IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( abap_false ).
    Hope this helps.
    Regards,
    Sravan Varagani

Maybe you are looking for