Edit rows of alv

Hi,
is it possible to have editable rows in an alv? I mena really the whole row, not a cell.

Hello
Since you want to make the entire row editable this is much easier than individual cells:
FORM set_editable_rows.
DATA:
  lt_celltab            TYPE lvc_t_styl,
  lt_celltab_edit    TYPE lvc_t_styl,
  ls_cell                TYPE lvc_s_styl,
ls_fcat                TYPE lvc_s_fcat,
ls_outtab           LIKE LINE OF gt_outtab.  " itab for ALV display
" Prefill LT_CELLTAB with all columns
  REFRESH: lt_celltab,
                   lt_celltab_edit.
  LOOP AT gt_fcat INTO ls_fcat.  " gt_fcat holds the fieldcatalog
    CLEAR: ls_cell.
    ls_cell-fieldname = ls_fcat-fieldname.
    ls_cell-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_cell INTO TABLE lt_celltab_edit.  " NOTE: SORTED table type !!!
    ls_cell-style = cl_gui_alv_grid=>mc_style_disabled.
    INSERT ls_cell INTO TABLE lt_celltab.  " NOTE: SORTED table type !!!   
  ENDLOOP.
  LOOP AT gt_outtab INTO ls_outtab.
    IF ( <condition is met for setting row editable> ).
      ls_outtab-celltab = lt_celltab_edit.
    ELSE.
      ls_outtab-celltab = lt_celltab.  " non-editable
    ENDIF.
    MODIFY gt_outtab FROM ls_outtab INDEX syst-tabix.
     TRANSPORTING celltab
  ENDLOOP.
ENDFORM.
Regards
  Uwe

Similar Messages

  • How to edit row in alv

    sir,
      explain me how to edit row in alv report in particular column.

    put in the fieldcatalog;;
    wa_fieldcat-edit = 'X'.
    wa_fieldcat-fieldname = 'NETPR'.
    wa_fieldcat-scrtext_m = 'Net Price'.
    wa_fieldcat-edit = 'X'. "sets whole column to be editable
    wa_fieldcat-col_pos = 7.
    wa_fieldcat-outputlen = 15.
    wa_fieldcat-datatype = 'CURR'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.

  • Editable rows on ALV Grid

    Hi.
    How can I make one column user-editable on ALV Grid?
    Thanks in advance,
    Brian Gonsales

    Hi,
      Check out the below links:
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    Thanks.

  • Editing rows and columns in alv reports in webdynpro abap

    how edit row and columns in webdynpro abap ?
    can i add colors to salv repotrs for below and above range of values  how ?
    if possible send source code for it.............

    hi
    check out this link for editing the columns of ALV
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0155eb5-b6ce-2b10-3195-d9704982d69b
    check out for this thread as well for coloring ALV
    Coloring of selected table cells: Ideas wanted
    regards,
    amit

  • How to Edit selected row in ALV

    Hi Experts,
                    I new to webdynpro ABAP. How to Edit the entire selected row in ALV. Please suggest?
    Thanks in advance.

    Hi,
    I guess you have created the node as dynamic and also set this to the ALV..
    1.  Have you created READ_ONLY attribute of type wdy_boolean inside the node to which the ALV is bound..If not create it first and set the default value for this readonly as abap_true...ie X.
    2.  Got the contents in the internal table.
    bind the table to the node..
    3.Instantiate the ALV.
    4. Now get teh column refrences of this ALV using the cl_salv_wd_config_table..and for columns
    use the cell editor type as cl_salv_wd_uie_input_field...
    loop through the column references and for all refrences create an object of type Input field and inside this class
    use the method set_read_only_field_name ( 'READ_ONLY' ).
    For the table settings if_salv_wd_table_settings of cl_salv_wd-config_table.. set the read only mode as abap_false..
    5 create the custom button in the ALV using the cl_salv_wd_fe_button..
    6 In this go for the events ON_FUCNTION and inside this method..do the coding
    7 .Initially the table will  be set to non editable..
    In the button handler....
    Get the refernece of this node to which the ALV is bound.....
    lr_node = wd_context->get_child_node( 'VBAK' ).  "dynamic node name
    lv_index  = lr_node->get_lead_selection_index ( ).
    loop at it_table into ls_table.
    if sy-tabix eq lv_index.
    ls_table-read_only = abap_false.  "editable
    else.
    ls_table-read_only = abap_true. "non editable
    endif.
    modify table
    endloop.
    lr_node->bind_table( lt_table ).
    If you have any doutbs just refer the previous thread posted on the same..
    You can follow the above steps to acheive thjs..
    Regards,
    Lekha.
    Edited by: Lekha on Dec 17, 2009 6:10 PM

  • How to make all the rows editable in webdynpro alv output

    Hi,
    How to make all the rows editable in webdynpro alv output.
    Thanks
    Rakshar

    Hi Rakshar,
    Check this wiki:
    http://wiki.sdn.sap.com/wiki/display/WDABAP/HowtoeditconditionallyrowofaALVtableinWebDynprofor+ABAP
    Regards

  • Insert a row in ALV

    Hi ,
    I need to insert a row in ALV output. On click of a Inser Row button a pop up should show with a parameter.Once the value in entered in the parameter enter is hit , the first column of the new row should have value put in that parameter as non editable field.
    The Insert row of standard toolbar inserts a blank row . Is there any way to incorporate the above logic in the standard toolbar?
    I'm using CL_GUI_ALV_GRID to display the ALV.
    It would be helpful if you provide sample coding.
    Thanks.
    Ajith
    Edited by: Ajith  Krishna on Oct 28, 2008 8:01 PM

    Hello Ajith
    The enhanced version of sample report ZUS_SDN_ALVGRID_EDITABLE_8A demonstrates how to implement your requirement.
    *& ZUS_SDN_ALVGRID_EDITABLE_8A
    *& Thread: Insert a row in ALV
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1105097"></a>
    *& Thread: Blanking values on ALV Grid Row Duplicate
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1057161"></a>
    *& Thread: Delete line event in ALV
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="945471"></a>
    REPORT  zus_sdn_alvgrid_editable_8a.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE knb1.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syst-repid,
      gt_fcat          TYPE lvc_t_fcat,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid          TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_outtab        TYPE ty_t_outtab.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          mt_sel_rows     TYPE lvc_t_row.
        CLASS-METHODS:
          handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING
              e_object
              sender,
          handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING
              e_ucomm
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_toolbar.
    * define local data
        DATA: ls_button     TYPE stb_button.
        LOOP AT e_object->mt_toolbar INTO ls_button.
          CASE ls_button-function.
            when cl_gui_alv_grid=>MC_FC_LOC_INSERT_ROW.
              ls_button-function = 'INSERT_ROW'.
              MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
            WHEN cl_gui_alv_grid=>mc_fc_loc_delete_row.
              ls_button-function = 'DELETE_ROW'.
              MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
            WHEN cl_gui_alv_grid=>mc_fc_loc_copy_row OR
                 cl_gui_alv_grid=>mc_fc_loc_copy.
              ls_button-function = 'COPY_ROW'.
              MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
            WHEN OTHERS.
              CONTINUE.
          ENDCASE.
        ENDLOOP.
      ENDMETHOD.                    "handle_toolbar
      METHOD handle_user_command.
    * define local data
        DATA: lt_rows       TYPE lvc_t_row,
              ls_row        TYPE lvc_s_row.
        REFRESH: mt_sel_rows.
        CASE e_ucomm.
          when 'INSERT_ROW'.
          WHEN 'DELETE_ROW'.
          WHEN 'COPY_ROW'.
          WHEN OTHERS.
            RETURN.
        ENDCASE.
        "   User wants to delete or copy rows => store them in class attribute
        "   and trigger PAI afterwards where we actually delete /copy the rows
        "   and do the recalculations (in case of deletion)
        CALL METHOD sender->get_selected_rows
          IMPORTING
            et_index_rows = mt_sel_rows
    *        et_row_no     =
    *   Trigger PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = e_ucomm
    *      IMPORTING
    *        rc       =
      ENDMETHOD.                    "user_command
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    PARAMETERS:
      p_bukrs      TYPE bukrs  DEFAULT '2000'  OBLIGATORY.
    START-OF-SELECTION.
      SELECT  * FROM  knb1 INTO CORRESPONDING FIELDS OF TABLE gt_outtab
             UP TO 15 ROWS
             WHERE  bukrs  = p_bukrs.
      PERFORM init_controls.
      SET HANDLER:
        lcl_eventhandler=>handle_toolbar      FOR go_grid,
        lcl_eventhandler=>handle_user_command FOR go_grid.
      " Used to replace standard toolbar function code with custom FC
      go_grid->set_toolbar_interactive( ).
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          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.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    **      CALL METHOD go_grid1->refresh_table_display
    ***        EXPORTING
    ***          IS_STABLE      =
    ***          I_SOFT_REFRESH =
    **        EXCEPTIONS
    **          FINISHED       = 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.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'INSERT_ROW'.
          perform INSERT_ROW.
        WHEN 'DELETE_ROW'.
          PERFORM delete_rows.
        WHEN 'COPY_ROW'.
          PERFORM copy_rows.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
      CALL METHOD go_grid->refresh_table_display
    *      EXPORTING
    *        IS_STABLE      =
    *        I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 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.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_FIELDCATALOG_KNB1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog_knb1 .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'KNB1'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        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.
    * Only non-key fields are editable
      ls_fcat-edit = 'X'.
      MODIFY gt_fcat FROM ls_fcat
        TRANSPORTING edit
        WHERE ( key NE 'X' ).
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          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.
    * Create ALV grid
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = go_docking
        EXCEPTIONS
          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.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog_knb1.
    * Display data
      CALL METHOD go_grid->set_table_for_first_display
        CHANGING
          it_outtab       = gt_outtab
          it_fieldcatalog = gt_fcat
        EXCEPTIONS
          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.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  delete_rows
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM delete_rows .
    * define local data
      DATA: ls_row    TYPE lvc_s_row.
      SORT lcl_eventhandler=>mt_sel_rows BY index DESCENDING. " !!!
      LOOP AT lcl_eventhandler=>mt_sel_rows INTO ls_row.
        DELETE gt_outtab INDEX ls_row-index.
      ENDLOOP.
      " After deleting rows do RE-CALCULATION
    *  perform RECALCULATION.
    ENDFORM.                    " delete_rows
    *&      Form  COPY_ROWS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM copy_rows .
    * define local data
      DATA: ld_next   TYPE i,
            ls_row    TYPE lvc_s_row,
            ls_outtab TYPE ty_s_outtab.
      SORT lcl_eventhandler=>mt_sel_rows BY index DESCENDING. " !!!
      LOOP AT lcl_eventhandler=>mt_sel_rows INTO ls_row.
        READ TABLE gt_outtab INTO ls_outtab INDEX ls_row-index.
        CLEAR: ls_outtab-akont. " In your case: clear GUID
        ld_next = ls_row-index + 1.
        INSERT ls_outtab INTO gt_outtab INDEX ld_next.
      ENDLOOP.
    ENDFORM.                    " COPY_ROWS
    *&      Form  INSERT_ROW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form INSERT_ROW .
    * define local data
      DATA: ld_value1  type SPOP-VARVALUE1,
            ls_outtab  TYPE ty_s_outtab.
      CALL FUNCTION 'POPUP_TO_GET_ONE_VALUE'
        EXPORTING
          textline1            = 'Enter Value (4 Chars):'
    *     TEXTLINE2            = ' '
    *     TEXTLINE3            = ' '
          titel                = 'Enter Value'
          valuelength          = 4
        IMPORTING
    *     ANSWER               =
          VALUE1               = ld_value1
        EXCEPTIONS
          TITEL_TOO_LONG       = 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.
      ls_outtab-kunnr = ld_value1.
      ls_outtab-bukrs = ld_value1.
      append ls_outtab to gt_outtab.
    endform.                    " INSERT_ROW
    Regards
      Uwe

  • Editable field in alv

    hiii
    when doing editable field in alv
    you set
    i_fieldcat-edit = C_X
    i_fieldcat-input = C_X
    P_selfield-refresh = C_X
    this is not working when i click on save the internal table is not keeping the change i have edit on the screen and the p_selfield value also has still the old value.
    but when i double click the p_selfield is keeping the editable value.  Please advise ??

    hi,
    Check out this sample program.The part for 'EDIT' is in Bold..
    report  zalv_color_display_edit.
    type-pools: slis.
    tables : zcust_master2.
    types : begin of wi_zcust_master2,
            zcustid like zcust_master2-zcustid,
            zcustname like zcust_master2-zcustname,
            zaddr like zcust_master2-zaddr,
            zcity like zcust_master2-zcity,
            zstate like zcust_master2-zstate,
            zcountry like zcust_master2-zcountry,
            zphone like zcust_master2-zphone,
            zemail like zcust_master2-zemail,
            zfax like zcust_master2-zfax,
            zstat like zcust_master2-zstat,
            field_style  type lvc_t_styl,
    end of wi_zcust_master2.
    data: it_wi_zcust_master2 type standard table of wi_zcust_master2
                                                     initial size 0,
          wa_zcust_master2 type wi_zcust_master2.
    data: fieldcatalog type slis_t_fieldcat_alv with header line.
    data: it_fieldcat type lvc_t_fcat,    
          wa_fieldcat type lvc_s_fcat,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type lvc_s_layo,     "slis_layout_alv,
          gd_repid     like sy-repid.
    start-of-selection.
      perform data_retrieval.
      perform set_specific_field_attributes.
      perform build_fieldcatalog.
      perform build_layout.
      perform display_alv_report.
    form build_fieldcatalog.
      wa_fieldcat-fieldname   = 'ZCUSTID'.
      wa_fieldcat-scrtext_m   = 'CUSTOMER ID'.
      wa_fieldcat-col_pos     = 0.
      wa_fieldcat-outputlen   = 10.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZCUSTNAME'.
      wa_fieldcat-scrtext_m   = 'CUSTOMER NAME'.
      wa_fieldcat-col_pos     = 1.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZADDR'.
      wa_fieldcat-scrtext_m   = 'ADDRESS'.
      wa_fieldcat-col_pos     = 2.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZCITY'.
      wa_fieldcat-scrtext_m   = 'CITY'.
      wa_fieldcat-col_pos     = 3.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZSTATE'.
      wa_fieldcat-scrtext_m   = 'STATE'.
      wa_fieldcat-col_pos     = 4.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZCOUNTRY'.
      wa_fieldcat-scrtext_m   = 'COUNTRY'.
      wa_fieldcat-col_pos     = 5.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZPHONE'.
      wa_fieldcat-scrtext_m   = 'PHONE NUMBER'.
      wa_fieldcat-col_pos     = 6.
    wa_fieldcat-edit        = 'X'. "sets whole column to be editable
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZEMAIL'.
      wa_fieldcat-scrtext_m   = 'EMAIL'.
      wa_fieldcat-edit        = 'X'. "sets whole column to be editable  wa_fieldcat-col_pos     = 7.
      wa_fieldcat-outputlen   = 15.
      wa_fieldcat-datatype     = 'CURR'.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZFAX'.
      wa_fieldcat-scrtext_m   = 'FAX'.
      wa_fieldcat-col_pos     = 8.
      wa_fieldcat-edit        = 'X'. "sets whole column to be editable
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZSTAT'.
      wa_fieldcat-scrtext_m   = 'STATUS'.
      wa_fieldcat-col_pos     = 9.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
    Set layout field for field attributes(i.e. input/output)
      gd_layout-stylefname = 'FIELD_STYLE'.
      gd_layout-zebra             = 'X'.
    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'
      call function 'REUSE_ALV_GRID_DISPLAY_LVC'
        exporting
          i_callback_program = gd_repid
          is_layout_lvc      = gd_layout
          it_fieldcat_lvc    = it_fieldcat
          i_save             = 'X'
        tables
          t_outtab           = it_wi_zcust_master2
        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
          text
    -->  p1        text
    <--  p2        text
    form data_retrieval .
      data: ld_color(1) type c.
      select zcustid zcustname zaddr zcity zstate zcountry zphone zemail
    zfax zstat up to 10 rows from zcust_master2 into corresponding fields of
    table it_wi_zcust_master2.
    endform.                    "data_retrieval
    *&      Form  set_specific_field_attributes
          populate FIELD_STYLE table with specific field attributes
    form set_specific_field_attributes .
      data ls_stylerow type lvc_s_styl .
      data lt_styletab type lvc_t_styl .
    Populate style variable (FIELD_STYLE) with style properties
    The following code sets it to be disabled(display only) if 'ZFAX'
    is NOT INITIAL.
      loop at it_wi_zcust_master2 into  wa_zcust_master2.
        if  wa_zcust_master2-zfax is not initial.
          ls_stylerow-fieldname = 'ZFAX' .
          ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
                                          "set field to disabled
          append ls_stylerow  to  wa_zcust_master2-field_style.
          modify it_wi_zcust_master2  from  wa_zcust_master2.
        endif.
      endloop.
    endform.                    "set_specific_field_attributes
    Hope this helps you,
    Arunsri

  • Deleting rows in alv report.

    Hi Experts,
                I want to delete a row in alv report output, It is duplicating  records in the report  and 'GRAND TOTAL' also be displayed . In under the report . <<removed_by_moderator>>
    Thanks,
    Dinesh.B
    Edited by: Vijay Babu Dudla on May 11, 2009 9:15 AM

    Hi,
    use the following code for deleting duplicate and adjacent records from itab
    delete ADJACENT DUPLICATES FROM itab.
    or
    sort itab by pernr.
    delete ADJACENT DUPLICATE FROM itab COMPARING pernr.
    Also, for grand total you can use fieldcat-do_sum    =  'X'  with the field catalog. It will give you total for the required column.
    Hope this solves your problem.
    Regards,
    Ibrar Munsif.

  • Coloring of a (specific) row in ALV report-How?

    Hi Experts,
    Am looking to assign a color for a (specific)row in ALV report.......so, pls. let me know How to get it done?
    thanq

    TABLES:LFA1.
    SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.
    DATA:BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    LAND1 LIKE LFA1-LAND1,
    ORT01 LIKE LFA1-ORT01,
    REGIO LIKE LFA1-REGIO,
    SORTL LIKE LFA1-SORTL,
    CFIELD(4) TYPE C,
    END OF ITAB.
    data:col(4).
    data:num value '1'.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR
    IN LIFNR.
    LOOP AT ITAB.
    concatenate 'C' num '10' into col .
    ITAB-CFIELD = col.
    num = num + 1.
    if num = '8'.
    num = '1'.
    endif.
    MODIFY ITAB.
    ENDLOOP.
    TYPE-POOLS:SLIS.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    LAYOUT-WINDOW_TITLEBAR = 'VENDORS DETAILS SCREEN'.
    LAYOUT-EDIT = 'X'.
    LAYOUT-info_fieldname = 'CFIELD'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = FCAT.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    this is for coloring cols
    REPORT ZBHCOLOR_COLS.
    TABLES:LFA1.
    SELECT-OPTIONS:C_LIFNR FOR LFA1-LIFNR. " FOR GRID ONLY
    PARAMETERS:LIST RADIOBUTTON GROUP ALV DEFAULT 'X',
    GRID RADIOBUTTON GROUP ALV.
    DATA:BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    LAND1 LIKE LFA1-LAND1,
    ORT01 LIKE LFA1-ORT01,
    SORTL LIKE LFA1-SORTL,
    REGIO LIKE LFA1-REGIO,
    COL TYPE LVC_T_SCOL,
    END OF ITAB.
    DATA:COLR TYPE LVC_S_SCOL.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB.
    LOOP AT ITAB.
    IF ITAB-LIFNR IN C_LIFNR.
    COLR-FNAME = 'NAME1'.
    COLR-COLOR-COL = '5'.
    COLR-COLOR-INT = '1'.
    COLR-COLOR-INV = '0'.
    COLR-NOKEYCOL = 'X'.
    APPEND COLR TO ITAB-COL.
    COLR-FNAME = 'LIFNR'.
    APPEND COLR TO ITAB-COL.
    MODIFY ITAB.
    ENDIF.
    ENDLOOP.
    TYPE-POOLS:SLIS.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
    LAYOUT-ZEBRA = 'X'.
    layout-coltab_fieldname = 'COL'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = FCAT.
    IF LIST = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    ELSEIF GRID = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    ENDIF.
    Reward points if useful.

  • Color a row with ALV GRID

    Hi my friends,
    I have written a small ALV Grid where some rows should be colored, dependend on their status in a table. But it's not working and I can't find out, why it is not working. I've already studied all the topics in this forum, which are related to 'row color alv grid', but I can't find the mistake in my code. Is anyone able to find out what is wrong here?
    Thanks a lot for your help!
    *& Report  /BMC_TST_SHOWLOG
    REPORT  /BMC_TST_SHOWLOG.
    TYPES: BEGIN OF log_table.
      TYPES:  log_level TYPE /bmc_log_message,
              cr_date TYPE /bmc_cr_date,
              message TYPE /bmc_log_message,
              linecolor(4) TYPE c.
    TYPES: END OF log_table.
    DATA: lt_log TYPE TABLE OF log_table with HEADER LINE,
          lt_log2 TYPE TABLE OF log_table with HEADER LINE,
          lt_log_list TYPE TABLE OF log_table,
          lt_line LIKE LINE OF lt_log_list,
          container_r TYPE REF TO cl_gui_custom_container,
          grid_r TYPE REF TO cl_gui_alv_grid,
          gc_custom_control_name TYPE scrfname VALUE 'CONTAINER_LOG',
          fieldcat_r TYPE lvc_t_fcat,
          layout_r TYPE lvc_s_layo,
          logA TYPE /bmc_log_level,
          logB TYPE /bmc_log_level,
          logC TYPE /bmc_log_level,
          logD TYPE /bmc_log_level,
          logE TYPE /bmc_log_level,
          ls_ct TYPE lvc_s_scol,
          ok_code LIKE sy-ucomm.
    *DATA BEGIN OF ls_log_list OCCURS 0.
    *DATA: log_level TYPE /bmc_log_message,
    *      cr_date TYPE /bmc_cr_date,
    *      message TYPE /bmc_log_message,
    *      rowcolor(4) TYPE c.
    *DATA END OF ls_log_list.
    *DATA: lt_log_list TYPE TABLE OF log_table.
    PARAMETERS: loglevlA  TYPE c AS CHECKBOX,
                loglevlB  TYPE c as CHECKBOX,
                loglevlC  TYPE c As CHECKBOX,
                loglevlD  TYPE c aS CHECKBOX,
                loglevlE  TYPE c AS CHECKBOX,
                dateA     TYPE /bmc_cr_date OBLIGATORY,
                dateB     TYPE /bmc_cr_date.
    CALL SCREEN 0200.
    MODULE user_command_0200 INPUT.
      CASE ok_code.
        WHEN 'BACK'.
          SET SCREEN 0.
          MESSAGE ID 'BC400' TYPE 'S' NUMBER '057'.
        WHEN OTHERS.
      ENDCASE.
    ENDMODULE.
    MODULE clear_ok_code OUTPUT.
      CLEAR ok_code.
    ENDMODULE.
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'DYNPRO200'.
      SET TITLEBAR 'D0200'.
    ENDMODULE.
    MODULE display_alv OUTPUT.
      PERFORM display_alv.
    ENDMODULE.
    FORM display_alv.
      IF grid_r IS INITIAL.
    *----Creating custom container instance
      CREATE OBJECT container_r
      EXPORTING
        container_name = gc_custom_control_name
      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.
    *--Exception handling
        ENDIF.
    *----Creating ALV Grid instance
        CREATE OBJECT grid_r
        EXPORTING
          i_parent = container_r
        EXCEPTIONS
          error_cntl_create = 1
          error_cntl_init = 2
          error_cntl_link = 3
          error_dp_create = 4
          others = 5.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
          PERFORM get_log_data.
    *----Preparing field catalog.
          PERFORM prepare_field_catalog CHANGING fieldcat_r.
    *----Preparing layout structure
          PERFORM prepare_layout CHANGING layout_r.
    *----Here will be additional preparations
    *--e.g. initial sorting criteria, initial filtering criteria, excluding
    *--functions
          CALL METHOD grid_r->set_table_for_first_display
          EXPORTING
            is_layout = layout_r
          CHANGING
            it_outtab = lt_log2[]
            it_fieldcatalog = fieldcat_r
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error = 2
            too_many_lines = 3
            OTHERS = 4.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
          ELSE.
            CALL METHOD grid_r->refresh_table_display
          EXCEPTIONS
            finished = 1
            OTHERS = 2.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
        ENDIF.
        CALL METHOD grid_r->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_enter.
        CALL METHOD grid_r->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_modified.
    ENDFORM.
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
        DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
        i_structure_name = '/BMC_LOG'
      CHANGING
        ct_fieldcat = pt_fieldcat[]
      EXCEPTIONS
        inconsistent_interface = 1
        program_error = 2
        OTHERS = 3.
      IF sy-subrc ne 0.
    *--Exception handling
      ENDIF.
      LOOP AT pt_fieldcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'UUID'.
            ls_fcat-no_out = 'X'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'LOG_LEVEL'.
            ls_fcat-coltext = 'Meldungsart'.
            ls_fcat-outputlen = '25'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'CR_DATE'.
            ls_fcat-coltext = 'Erstellungsdatum'.
            ls_fcat-outputlen = '20'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'CR_TIME'.
            ls_fcat-no_out = 'X'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'MESSAGE'.
            ls_fcat-coltext = 'Nachricht'.
            ls_fcat-outputlen = '50'.
            MODIFY pt_fieldcat FROM ls_fcat.
        ENDCASE.
    *    CASE ls_fcat-value.
    *      WHEN '1'.
    *        ls_fcat-line_color = 'c100'.
    *    ENDCASE.
      ENDLOOP.
    ENDFORM.
    FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
      ps_layout-zebra = 'X'.
      ps_layout-grid_title = 'Log'.
      ps_layout-smalltitle = 'X'.
      ps_layout-info_fname = 'linecolor'.
    ENDFORM.
    FORM get_log_data.
      if loglevlA = 'X'.
        logA = '1'.
      ENDIF.
      if loglevlB = 'X'.
        logB = '2'.
      ENDIF.
      if loglevlC = 'X'.
        logC = '3'.
      ENDIF.
      if loglevlD = 'X'.
        logD = '4'.
      ENDIF.
      if loglevlE = 'X'.
        logE = '5'.
      ENDIF.
      IF dateB ne 0.
        SELECT log_level cr_date message FROM /bmc_log INTO CORRESPONDING FIELDS OF TABLE lt_log_list WHERE log_level = logA
          OR log_level = logB OR log_level = logC OR log_level = logD OR log_level = logE and cr_date >= dateA and cr_date <= dateB.
      ELSE.
        SELECT log_level cr_date message FROM /bmc_log INTO CORRESPONDING FIELDS OF TABLE lt_log_list WHERE log_level = logA
          OR log_level = logB OR log_level = logC OR log_level = logD OR log_level = logE and cr_date >= dateA.
      ENDIF.
    *    and cr_date >= dateA.
        SORT lt_log_list ASCENDING.
        LOOP AT lt_log_list INTO lt_line.
        IF lt_line-log_level = '1'.
          lt_line-log_level = 'Info'.
          lt_line-linecolor = 'C100'.
        ENDIF.
        IF lt_line-log_level = '2'.
          lt_line-log_level = 'Warning'.
          lt_line-linecolor = 'C200'.
        ENDIF.
        IF lt_line-log_level = '3'.
          lt_line-log_level = 'Error'.
          lt_line-linecolor = 'C300'.
        ENDIF.
        IF lt_line-log_level = '4'.
          lt_line-log_level = 'Debug'.
          lt_line-linecolor = 'C400'.
        ENDIF.
        IF lt_line-log_level = '5'.
          lt_line-log_level = 'Trace'.
          lt_line-linecolor = 'C500'.
        ENDIF.
        APPEND lt_line TO lt_log2.
        ENDLOOP.
    ENDFORM.
    SELECTION-SCREEN BEGIN OF SCREEN 0100 TITLE text-001 AS WINDOW.
    SELECTION-SCREEN END OF SCREEN 0100.

    > change to this
    >
    > <b>ps_layout-stylefname = 'LINECOLOR'.</b>
    >
    > sorry ignore the above line
    >
    > just debug and check what is happening
    >
    > Message was edited by:
    >         Chandrasekhar Jagarlamudi
    Hi,
    I've changed the line to <b>ps_layout-stylefname = 'LINECOLOR'.</b>, but then I'm getting a runtime error 'ASSIGN_TYPE_CONFLICT' in program 'SAPLSLVC in line 2975'...
    I don't have any idea what is causing that.

  • Grey out a particular row in ALV based on some condition.

    Hi All,
    How can we grey out the particular row in ALV based on some condition( I am using the function modules and not OOPS).
    Regards
    Ramesh.

    Hello Ramesh
    In this case you need to add a specific field to your structure:
    TYPES: BEGIN OF ty_s_outtab.
    INLCUDE TYPE <my table or structure>.
    TYPES: CELLTAB   TYPE lvc_t_styl.  " name is arbitrary but this one is most frequently used
    TYPES: END OF ty_s_outtab.
    DATA: gt_outtab  TYPE STANDARD TABLE OF ty_s_outtab
                                 WITH DEFAULT KEY.
    You can use the fieldcatalog to make an entire column non-editable (LVC_S_FCAT-EDIT = ' ' ).
    However, in case of rows you need to inactivate all cells of this row. For sample coding please refer to thread:
    How to conditionally set ALV field as hotspot
    Regards
      Uwe

  • Grey out(disable) a row in ALV grid

    Hi,
    I want to know how to grey out(disable) row wise in ALV grid display.
    i..e.. Few rows in ALV grid display shoud be editable and few rows non editable based on certain condition.
    How do we do that....Please help.
    Thanks in advance.

    Hi,
    Since fieldcatalog is used to modify coloum and not the row, the fieldcatalog would not solve the problem.
    Thankyou.

  • Insert rows in ALV

    Hi,
    Want to insert rows in editable cell of ALV grid display without using classes and methods.
    Thanks in advance

    you need to have a button to append the Rows. it can be possible with the PF_STATUS event. and handling will be done using the User_command.
    FORM PF_STATUS using extab type slis_t_extab.
    set pf-status 'STANDARD' excluding extab.
    ENDFORM.
    FORM USER_COMMAND  using r_cuomm type sy-ucomm
       selfield type slis_selfield.
    case r_ucomm.
    when 'APPEND'.
      APPEND EMPTY LINE HERE to internal table
    endcase.
    selefield-refresh = 'X'.
    ENDFORM.

  • How to make editable cell in ALV TREE?

    Hi all,
    I have a problem to make the cell in item row (I mean not  the cell in hierarchy columns and not in the node row) in ALV tree editable.
    I know to make it in "normal" ALV, but my ALV is type class: cl_gui_alv_tree and the nodes are calculated in a sum.Can anyone help me to set the cell editable in ALV tree?
    Thank you a lot!
    Best regards,
    Danijela Zivanovic
    Message was edited by: Danijela Zivanovic

    HI,
    To make a column editable, it will be sufficient to set the field “<b>EDIT</b>” in the field catalog. The ALV Grid perceives if there are some editable fields and adds buttons for editing purposes. If you do not need these new buttons
    <u><i>if you want it in the Classes</i></u>
    For this procedure; add the name of the field to the field “FIELDNAME”, and pass “cl_gui_alv_grid=>mc_style_enabled” to make a field editable and “cl_gui_alv_grid=>mc_style_disabled” to make a field non-editable,
    <b>Example:</b>
    FORM adjust_editables USING pt_list LIKE gt_list[] .
    DATA ls_listrow LIKE LINE OF pt_list .
    DATA ls_stylerow TYPE lvc_s_styl .
    DATA lt_styletab TYPE lvc_t_styl .
    LOOP AT pt_list INTO ls_listrow .
    IF ls_listrow-carrid = 'XY' .
    ls_stylerow-fieldname = 'SEATSMAX' .
    ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled . APPEND ls_stylerow TO lt_styletab .
    ENDIF .
    IF ls_listrow-connid = '02' .
    ls_stylerow-fieldname = 'PLANETYPE' .
    ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled . APPEND ls_stylerow TO lt_styletab .
    ENDIF .
    INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles . MODIFY pt_list FROM ls_listrow .
    ENDLOOP .
    ENDFORM
    Thanks
    Sudheer

Maybe you are looking for