CELL VARIANT

Hi Experts,
Could you provide me detailed information on how to use the cell variants in a normal table in Webdynpro ABAP (using the cell variants to make a read-only field as input field/dropdown field on the click of a button).
Thanks in Advance,
Mirza.

Hi Mirza,
Please go through this excellent [blog|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0e7461d-5e6c-2b10-dda9-9e99df4d136d] by Suman Kumar in which he explains usage of cell variants to make the cells of a column as checkboxes or textviews dynamically.
Regards,
Uday

Similar Messages

  • Enhancing a standard component - Table Cell Variant

    Hi Forum,
    I am trying to enhance the standard WD component /SAPSRM/WDC_UI_SC_DOTC_BD view V_SC_DOTC_BASIC in SRM 7.0 .
    The requierment that for certain condition the Quantity cell in a row should be read only.
    Carried out the following steps:
    1. Created an enhancement
    2. In the standard table column ITEMS_TABLE_QUANTITY  [Columns] , removed the standard inputfield.
    3. Added two cell variants ZITEMS_TABLE_QUANTITY_CV1  [CellVariants]  and ZITEMS_TABLE_QUANTITY_CV2  [CellVariants]  first one contans a text view and second contains inputfield. Variant key for first one is DISPLAY and for second one is EDITABLE.
    4. Enhanced the method WDDOMODIFYVIEW with below code:
    **Read the ITEMS table
      DATA lo_nd_items TYPE REF TO if_wd_context_node.
      DATA lt_items TYPE wd_this->elements_items.
      DATA ls_item LIKE LINE OF lt_items.
      DATA lo_el_context TYPE REF TO if_wd_context_element.
      DATA ls_context TYPE wd_this->element_context.
      DATA lv_disable_quantity TYPE wd_this->element_context-enable_quantity.
      DATA lr_table_column TYPE REF TO cl_wd_table_column.
    ** navigate from <CONTEXT> to <ITEMS> via lead selection
      lo_nd_items = wd_context->path_get_node( path = `COMP_CONTEXT.ITEMS` ).
      lo_nd_items->get_static_attributes_table( IMPORTING table = lt_items ).
      lr_table_column ?= view->get_element( 'ITEMS_TABLE_QUANTITY' ).
      LOOP AT lt_items INTO ls_item .
        IF  ls_item-catalogid EQ 'VEP_Staples_D0'.
          lr_table_column->set_selected_cell_variant( value = 'DISPLAY' ).
        ELSE.
          lr_table_column->set_selected_cell_variant( value = 'EDITABLE' ).
        ENDIF.
      ENDLOOP.
    But even after the condition is true ALL cell i.e. the complete column is DISABLED or when the condition is false the COMPLETE column is enabled instead of enabling disabling ONLY THE SPECIFIC CELL.
    Is there a problem with the code in WDDOMODIFYVIEW or something else?
    Thanks,
    Anubhav

    Hi  Saravanan
    Under ITEMS node I added one more Node(cv_quantity) and one attribute(cell_variant_quantity) with in this node.
    And code in WDDOMODIFYVIEW :
    DATA lo_nd_items TYPE REF TO if_wd_context_node.
      DATA lt_items TYPE wd_this->elements_items.
      DATA ls_item LIKE LINE OF lt_items.
      DATA lo_el_context TYPE REF TO if_wd_context_element.
      DATA ls_context TYPE wd_this->element_context.
      DATA lr_table_column TYPE REF TO cl_wd_table_column.
    ** navigate from <CONTEXT> to <ITEMS> via lead selection
      lo_nd_items = wd_context->path_get_node( path = `COMP_CONTEXT.ITEMS` ).
      lo_nd_items->get_static_attributes_table( IMPORTING table = lt_items ).
      lr_table_column ?= view->get_element( 'ITEMS_TABLE_QUANTITY' ).
      DATA lo_nd_cv_quantity TYPE REF TO if_wd_context_node.
      DATA lo_el_cv_quantity TYPE REF TO if_wd_context_element.
      DATA ls_cv_quantity TYPE wd_this->element_cv_quantity.
    IF first_time EQ abap_true.
      lr_table_column->set_selected_cell_variant( value = 'EDITABLE' ).<--Initially ALL cells shoud be editable
    ELSE.
      lr_table_column->bind_selected_cell_variant( path = 'COMP_CONTEXT.ITEMS.CV_QUANTITY.CELL_VARIANT_QUANTITY' )  .
    * navigate from <CONTEXT> to <CV_QUANTITY> via lead selection
      lo_nd_cv_quantity = wd_context->path_get_node( path = `COMP_CONTEXT.ITEMS.CV_QUANTITY` ).
      IF lo_nd_cv_quantity is BOUND.
      lo_el_cv_quantity = lo_nd_cv_quantity->get_element( ).
          LOOP AT lt_items INTO ls_item .
            IF  ls_item-catalogid EQ 'VEP_Staples_D0' AND ls_item-number_int IS NOT INITIAL AND ls_item-description IS NOT INITIAL.
              lo_el_cv_quantity->set_attribute(
                                                name =  `CELL_VARIANT_QUANTITY`
                                                value = 'DISPLAY' ).
            ELSEIF ls_item-catalogid NE 'VEP_Staples_D0' OR ( ls_item-number_int  IS INITIAL AND ls_item-description IS INITIAL ) ."If the condition is not satisfied OR no item is added to that line
              lo_el_cv_quantity->set_attribute(
                                                name =  `CELL_VARIANT_QUANTITY`
                                                value = 'EDITABLE' ).
            ENDIF.
          ENDLOOP.
    ENDIF.
    ENDIF.
    Now If I add an item that DO NOT satisfy the comdition to be read only, for that row the quantity is enabled but for all the rows below it quantity cells are DISABLED.
    Hope my issue is clear?
    Thanks a lot,
    Anubhav

  • Example ---Defining Cell Variants: TableSingleMarkableCell-Getting error

    Hi All,
          We are trying an example of cell variant concept of table as given in NetWeaver help. But after deploying we are getting folllowing error. Please guide me.
    <b>Create a value attribute attributePointer, switch to the Properties, click … for the property type, and select the Java Simple Type. Enter com.sap.tc.webdynpro.progmodel.api.IWDAttributePointer and confirm with Ok</b>---
    I am not able to get this type..I have chosen ---com.sap.ide.webdynpro.uielementdefinitions.AttributePointer
    Thanks in Advance,
    Gangadhar.
    <b>Error we are getting is</b>  
    java.lang.NoClassDefFoundError: com/sap/tc/webdynpro/clientserver/uielib/standard/api/IWDAbstractTableColumn
         at java.lang.Class.getDeclaredConstructors0(Native Method)
         at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
         at java.lang.Class.getConstructors(Class.java:865)
         at com.sap.tc.webdynpro.progmodel.generation.ControllerHelper.createDelegate(ControllerHelper.java:68)
         at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.<init>(DelegatingView.java:41)
         at com.sap.tc.webdynpro.progmodel.view.ViewManager.createUninitializedView(ViewManager.java:486)
         at com.sap.tc.webdynpro.progmodel.view.ViewManager.getView(ViewManager.java:523)
         at com.sap.tc.webdynpro.progmodel.view.ViewManager.bindRoot(ViewManager.java:421)
         at com.sap.tc.webdynpro.progmodel.view.ViewManager.init(ViewManager.java:130)
         at com.sap.tc.webdynpro.progmodel.view.InterfaceView.initController(InterfaceView.java:41)
         at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.displayToplevelComponent(ClientComponent.java:135)
         at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:404)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:618)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:48)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:160)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    <b>Example we are trying is</b>
    You need the option to select a single cell to provide a value help for individual cells, for example.
    The interface TableSingleMarkableCell allows you to group cell variants in any way as you like and to make a single cell selectable in this group. The following example shows how to proceed if you want to implement a selection of a single cell from an entire table.
    Prerequisites
    You have created an applicaton with a component and view in your Web Dynpro project.
    Procedure
    Creating the Context
           1.      Create a value node TableNode for the data of the table and insert three value attributes of the type String for the table columns.
           2.      Create a value attribute selectedCellVariant of the type String in the TableNode.
           3.      Create a value attribute attributePointer, switch to the Properties, click … for the property type, and select the Java Simple Type. Enter com.sap.tc.webdynpro.progmodel.api.IWDAttributePointer and confirm with Ok.
    Creating the View
           1.      Open the context menu in the Outline, select Apply Template and then Table. In the subsequent dialog box from the context, select three attributes for the columns (col1, col2, col3). Confirm by choosing Finish
           2.      Set the property selectionMode of the table to none.
    Repeat the steps for each column.
           3.      Highlight the column and open the context menu. Select Insert Cell Variant, TableSingleMarkableCell and confirm with Finish.
           4.      Enter the same value for each TableSingleMarkableCell for the property variantKey - for example, variant1
           5.      Insert a cell editor of the type TextView in each TableSingleMarkableCell.
    Binding the UI Elements
           1.      Bind the text property of each TextView to the column in which the property is contained.
           2.      Bind the attributeToMarkproperty of the corresponding TableSingleMarkableCell to the column in which the element is contained.
           3.      Bind the selectedCellVariantproperty of each TableColumn to the context attribute selectedCellVariant.
           4.      Add the following source code to the wdDoInit method.
    wdDoInit()
    1
    2
    3
    IPrivateUseSingleMarkableCellsView.ItableNodeElement elem;
          int count = 10;
    // Fill dummy data
         for(int i=0; i<count; i++) {
             elem = wdContext.nodeTableNode().createTableNodeElement();
             wdContext.nodeTableNode().addElement(elem);
             elem.setCol1(“1.” + i);
             elem.setCol2(“2.” + i);
             elem.setCol3(“3.” + i);
    // set TableSingleMarkableCell as a variant for the table
             elem.setSelectedCellVariant(“variant1”);
                For each element that is created in the for loop and is then added, the
                TableSingle MarkableCell is set as a cell variant in row 3.
           5.      Add the following source code to the wdDoModifyView method.
    wdDoModifyView()
    IWDAttributeInfo markedDataInfo = wdContext.currentContextElement().getAttributePointer(“attributePointer”).getAttributeInfo();
                            ((IWDTableSingleMarkableCell) view.getElement(“TableSingleMarkableCell1”)).bindMarkedData(markedDataInfo);
                            ((IWDTableSingleMarkableCell) view.getElement(“TableSingleMarkableCell2”)).bindMarkedData(markedDataInfo);
         1.                          ((IWDTableSingleMarkableCell) view.getElement(“TableSingleMarkableCell3”)).bindMarkedData(markedDataInfo);
    The current AttributeInfo is now retrieved at every change of the view and is bound to the context using the markedDataproperty.
    Result
    Each single cell can be selected separately. You can define an action and in its method, you can determine the coordinates of the currently selected cell using the following code:
    IWDAttributePointer attPointer = wdContext.currentContextElement().getAttributePointer();
    Message was edited by:
            Gangadharayya Hiremath

    Hi Gangadhar,
    at first: you are right: you have to choose
    com.sap.ide.webdynpro.uielementdefinitions.AttributePointer
    and not the other one. I already updated the documentation for this.
    In which SP are you working?
    Kind Regards
    Stefanie

  • How to add cell editor to cell variant dynamically?

    Hi everyone,
      I'm developing a web dynrpo component. In one of the views , I need to modify the view dynamically
    because the data structure only can be determined at runtime. And the table column should have two
    cell variants. I don't know the exact cell variant class which should be used. I only find an abstract class about cell variant CL_WD_ABSTR_TABLE_CELL_VAR , but I can't find any method in this class which
    can add cell editor under this cell variant.
    Thanks in advance.

    Hi Sireesha,
    Thanks for link you provided.
    I am able to add Column with CommandImageLink.And onclick of that link i am able to display another popup.
    Now another problem which i am facing is when i select one row from popup and click "Ok" i have to modify some columns from Dyanamic table which is displayed on main page.
    For this.
    1)First i took the selected row from dyanamic table to update that perticular row depending upon the row which i select from popup.
    if you see the code above i am refaring the list as collection for data.So i am updating that collection but again it is refreshing to it's original value.
    because number of times getList() method of bean get's called equal to number of columns. which brings the values from database.
    Here On click of popup's Ok button I don't want to save the data for table i just want to show there in some column's .and After click on SAVE button from table i have to save it.
    Let me help how can i modify the Dynamic table's data.
    Thanks for all help.
    Jaydeep

  • Use of Cell Variant for a normal table

    Hi Experts,
    I have a requirement in a normal table where a row is first in read-only mode, then on click of edit button (given on that row),
    the row should become editable and also edit button should become invisible and two more buttons update/cancel have to be visible. How to achieve this using a cell variant for this normal table.
    A detailed reply would be appreciated.
    Thanks in Advance,
    Mirza Hyder.

    Hi Mirza,
    Cell variant property is used to chenge the cell property not for other.That means in one cell you want checkbox and in other cell you want textview like this you can change the property of cell as you want.
    Test this standard program WDR_TEST_TABLE in that test view cell varint for your understanding.
    Coming to your requirement.You can do in this way.
    Check in the below thread in that i gave code to make the entire row is editable when you click on the lead selection of row.I gave code for ALV.I hope that code is use ful for you.
    How to make all columns of alv editable
    To make tool bar buttons disable and enable:Write your logic in method handler of lead selection event like change the visible property of button to none.
    Note: In the event handler method you dont get reference of view.You only get reference of view in WDDOMODIFYVIEW only so take a global variable of type ref to if_wd_view and populate that global variable in method WDODIFYVIEW.So that you can access any view element in any method.
    For cell variant in ALV check this Article written by me.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0e7461d-5e6c-2b10-dda9-9e99df4d136d

  • Setting new cell variant for an alv table column

    Hi,
    I want to set a new cell variant for a column. Therefore I did the following steps:
    1. Create an object of CL_SALV_WD_CV_STANDARD
    2. SET_KEY( 'CELLVAR1 )
    3. set_cell_design([..]-goodvalue_medium )
    4. SET_EDITOR( lr_alv_input_field )
    After that I added the cell variant to the column by using the method "add_cell_variant".
    The last step is to call method SET_SELECTED_CELL_VARIANT.
    I checked my program by using get_selected_cell_variant( ) and the return string was okay.
    But when the table is displayed, the new cell variant isn't working. I defined an input field as the cell editor for my new cell variant but when the table is shown, it is just text - no input possible. In addition to that the selected cell design (goodvalue_medium , step 3) isn't working. So I think the cell variant is not used.
    Can you help me?
    Thanks & Regards,
    Hendrik

    Hi
    I wonder if you can help me please, I too am having issues implementing ALV cell changes in WDA?
    I am basically trying to dynamically change the individual color of a cell (not the entire column or row) dependant on certain criteria. I apologies but find that you are the closest resource for any potential information. Please see screen shot below.
    Currently my code is as follows:
    see: www.picasaweb.google.co.uk/dave.alexander69/Pictures#5244416971466907938
    data: lr_cv TYPE REF TO cl_salv_wd_cv_standard.
    loop at table 1 row data
            loop at table columns
              for the date columns only...
              IF <fs_column>-id(4) = 'CELL'.
               get and set column header dates from select option user input - done
                loop at table 2 row data (table 2 contains date ranges for row concerned)
                  MOVE: ls_zdata-variance TO lv_variance.
                  method 1 - as in sap press WD4A -:
                  lr_cv = cl_wd_table_standard_cell=>new_table_standard_cell(
                                                     view        = view
                                                    variant_key = lv_variance ).
                 as mentioned...
                  CREATE OBJECT lr_cv.
                  lr_cv->set_key( 'VARIANCE' ).
                  lr_cv->set_cell_design( '09' ).
                  lr_cv->set_editor( lr_input_field ).
                  lr_column->add_cell_variant( lr_cv ).
                  lr_column->set_cell_editor( lr_input_field ).
                  lr_column->set_sel_cell_variant_fieldname( 'VARIANCE' ).
                  lr_column->set_cell_design_fieldname( value = 'COLOR_CELL' ).
                  lr_field = lr_table->if_salv_wd_field_settings~get_field( <fs_column>-id ).
                  lr_field->if_salv_wd_sort~set_sort_allowed( abap_false ).
                  the only way I get cell coloring to work - but this is for entire column?
                  ls_zdata-color_cell = cl_wd_table_standard_cell=>e_cell_design-one.
                  MODIFY lt_zdata FROM ls_zdata..
                ENDLOOP.
              ENDIF.
              IF <fs_column>-id = 'COLOR_CELL'.
                CALL METHOD lr_column->set_visible( EXPORTING value = '00' ).
              ENDIF.
            ENDLOOP
          ENDLOOP.
    As you see I am in the dark a bit regarding cell variants and wonder if you can point me in a better direction.
    Many thanks for any help,
    Dave Alexander

  • Dynamic Cell variant assignment

    Hi
    I wish to dynamically assign a table variant with a cell editor of type checkbox and then check/uncheck/make readonly the field accordign various situations. I only wish this to happen on certain rows.
    So far I can achieve this my using context attributes and binding to these. My only concern is that there are a lot of extra attributes required as thses cell variants appear on 7 columns and then 8 tabs.
    I would prefer to achive this solution by using the view->get_element approach, but so far I have only managed to assign the cell variant to the entire column and not an individual cell.
    Any ideas?
    Cheers
    Ian
    Edited by: Ian Stubbings on Mar 10, 2008 8:52 AM

    Hi,
    In case of a checkbox, based on the value of the attribute bound to the checkbox column, the checkbox will be checked/unchecked. Anyways, you have to have a context node of cardinality 0...n, with an attribute which can be bound to the checkbox. As far as readonly property is concerned, you can have an additional attribute in the same context node, and bind that to the read-only property of the checkbox. Alternatively, I think you can use the SET_ATTRIBUTE_PROPERTY of the IF_WD_CONTEXT_ELEMENT class.
    Hope this helps.
    Regards
    Wenonah

  • Usage of Single Markable cell - Cell Variants.

    Hi,
    Using Cell Variant SingleMarkable Cell, is it possible to set different colours for cell's in a single column ..
    If its possible , could someone elobarate on how it works ? And provide info on attributeToMark and attribute pointer..?
    Thanks and Regards
    Bharathwaj

    Hi Bharathwaj,
    if you want to set different colors, just use the cell variant TableStandardCell.
    You can find documentation here:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/ed/785a42793d1653e10000000a155106/frameset.htm
    In this case it's described for a TableSingleMarkableCell, but it works in the same way for a TableStandardCell.
    Hope this helps
    Kind Regards
    Stefanie

  • Web dynpro      cell variant!!!!

    Hi everyone,
      I have a big problem in web dynpro UI development,How can I make it possible
    that there are two kinds of cell editor ,one is link to action the other is textview.
    because at run time , I need to change the cell property according to some variable's value.
    Thanks in advance.

    Hi everyone,
      I have a big problem in web dynpro UI development,How can I make it possible
    that there are two kinds of cell editor ,one is link to action the other is textview.
    because at run time , I need to change the cell property according to some variable's value.
    Thanks in advance.

  • How to disable a single cell in a table (and not the whole column)

    Hi there,
    I've got a webdynpro table with a few columns, rows can be created dynamically through a button in the table toolbar.
    Depending on the value of a certain cell I have to disable another cell (in the same row).
    I tried to manipulate the view in the modifyview but no joy. I also tried to manipulate the attribute property through the coding below:
      DATA lv_knttp TYPE knttp.
      lo_nd_kostl = wd_context->path_get_node( path = `MULTIVALUES.KOSTL` ).
      lo_el_kostl = lo_nd_kostl->get_element( ).
      lo_el_kostl->set_attribute_property(
      attribute_name = 'LTEXT'
              property       = lo_el_kostl->e_property-enabled
              value          = ''
    but it disables the whole column!!!! I just need the cell to be disabled (I thought the code above, through the lead selection, would affect a certain cell only - but I was wrong).
    Any ideas?
    Thanks!!!

    Hi,
    using cell variants you can do this.,
    check this article: [Cell Variants in WDA|http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynproforABAPCellVariants]
    Instead of binding the read only property of table as a whole , just bind the read only property of column group of table., You can do this bu drill down the table and select the required column and bind the read only column.,
    then In onAction Event of button .,
    loop the table, if condition satisfied set the read only property to true else false.,!!
    hope this helps u.,
    Thanks & regards,
    Kiran

  • How to get selected/focused cell from table, and action on clicked

    Hello Web Dynpro Community!
    i have a view with a table, (id "Table_0");
    table is 3x3 size, as celleditors i used inputfields; (standard binding to context with string atributes)
    below table i have textarea.
    when i select any cell in table i want to add that cell coords to textarea (col and row)
    i know that i should use onLeadSelect action, but i dont know exacly how. or to be precise.. how to access to ID and row variables in that action.
    the other problem is.. that onLeadSelect seems to work only when i change lead not the cell in same row.. so prabobly there is better way to do that..
    any ideas?
    Looking to hear from You.
    EDIT:
    Now i have following problem:
    i have a table 3x3 with one column as dropdownbykey box and 2 as TableSingleMarkableCell (and inputFields As editors).
    it works as i wanted:
    so when i click on one of those input cells, insert vale AND click enter then the action onEnter( for inputfield) is fired... i can get the coords of that cell..
    problem is.. that i want to get the coords before i click enter.. just when i click in cell.
    i tried to use onAction event for column.. but it doesnt work for TableSingleMArkableCells (but it works for ddk column correctly).
    so there is any way to do that?
    ie:
    below table i have inputfield (called  value).
    when i click on cell (and DO NOT press enter) i want to see the cell value in inputfield value.
    future (and target need) is that i need to show some additional text for specific Cell. (i have an Object with 2 strings attributes, one i want to show in cell, and one in inputfield when cell is clicked).
    M.
    Edited by: Michal Rowinski on Jan 16, 2008 9:51 AM

    You can use cell variant  for your requirement . Go through the below link
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c0310fd2-f40d-2a10-b288-bcbe0810a961
    Regards,
    Nethaji

  • F4 help for only a single cell in a table

    Dear All,
    The requirement here is to provide input help for only a particular cell in a table.
    This cannot be achieved by assigning search help to the attribute of the context as this will render all the cells of that particular column with F4 help. I tried applying the cell variant concept but only go up to a certain extent.
    I tried OVS as well. But for this to work we need to lead select the entry and then go ahead with F4, which will make is inconvenient for the user.
    I even searched the forum for some answers, but i could only go to a certain extent with the help of those.
    So, if anyone out there has any idea, please help me out. Also, if this is a repeat post by any chance (i think not) kindly provide me with the link of the original.
    Thanks and Best Regards,
    Pramod

    I am running older versions, so i didn't find any sample dynpros..
    You can try with this peace of code..nyways..
    DATA: LR_TABLE TYPE REF TO CL_WD_TABLE.
    DATA: LR_COLUMNS TYPE CL_WD_table_column=>tt_table_column.
    DATA: LR_COLUMN TYPE REF TO CL_WD_TABLE_COLUMN.
    DATA: LR_EDITOR TYPE REF TO CL_WD_VIEW_ELEMENT.
    DATA: LR_TEXT   TYPE REF TO CL_WD_TEXT_VIEW.
    DATA: BINDING TYPE STRING.
    DATA: LR_CELL TYPE REF TO CL_WD_TABLE_STANDARD_CELL.
    IF FIRST_TIME EQ ABAP_TRUE.
      LR_TABLE ?= VIEW->GET_ELEMENT( 'TBL_COMPONENTS' ).
      LR_COLUMNS = LR_TABLE->GET_COLUMNS( ).
      LOOP AT LR_COLUMNS INTO LR_COLUMN.
        LR_EDITOR ?= LR_COLUMN->GET_TABLE_CELL_EDITOR( ).
        BINDING = LR_EDITOR->BOUND__PRIMARY_PROPERTY( ).
        IF BINDING EQ 'RRSO.SOCOMP.POSNR' OR
           BINDING EQ 'RRSO.SOCOMP.MATNR' OR
           BINDING EQ 'RRSO.SOCOMP.KWMENG' OR
           BINDING EQ 'RRSO.SOCOMP.NETPR' OR
           BINDING EQ 'RRSO.SOCOMP.POPRICE' OR
           BINDING EQ 'RRSO.SOCOMP.QUANTITY'.
           LR_CELL = CL_WD_TABLE_STANDARD_CELL=>NEW_TABLE_STANDARD_CELL( VIEW = VIEW
                                VARIANT_KEY = 'TOTAL' ).
           IF BINDING EQ 'RRSO.SOCOMP.QUANTITY'.
             LR_TEXT = CL_WD_TEXT_VIEW=>NEW_TEXT_VIEW( VIEW = VIEW
                                                       TEXT = 'Total'
                                                       H_ALIGN = CL_WD_TEXT_VIEW=>E_H_ALIGN-FORCED_RIGHT ).
           ELSE.
             LR_TEXT = CL_WD_TEXT_VIEW=>NEW_TEXT_VIEW( VIEW = VIEW ).
           ENDIF.
           LR_CELL->SET_EDITOR( LR_TEXT ).
        ENDIF.
         LR_COLUMN->ADD_CELL_VARIANT( LR_CELL ).
      ENDLOOP.
    ENDIF.
    This code is for setting Text View as cell editor, instead text view u can take input field and use bind_value method to bind with another context attribute.
    Abhi

  • Dynamically change the cell editor in the table control

    Hi..
         I have 3 columns in a table . of which in one column we need to change the cell editor dynamically at runtime.
    i.e for example i have  columns as carrid, connid and fldate.
    For the first 2 rows the cell editor for the carrid  clomn shud be a dropdown and from there on in the next rows for the same  carrid column it shud be a input field.
    Can experts plz help me how to achieve this as this is very high priority issue....
    Regards,
    Madhu...

    This is actaully fairly simple to do.  You will need to add a cellVariant to your table column. You can then dataBind a context attribute to the selectedCellVariant property of the column to control which cellVariant will be used. This allows you to control row-by-row which cell editor you want to output.
    http://help.sap.com/saphelp_nw70/helpdata/EN/bd/5d9041d3c72e7be10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/EN/56/5e9041d3c72e7be10000000a1550b0/frameset.htm
    Also here is an example that I did the other day that uses Cell Variants within ALV.  This process is actually a little more complicated because you have to go through the ALV APIs.  To do this in a normal table is actually easier because you can create the cellVariant in the layout designer.
    Re: Freely-programmed value help for a single ALV cell

  • In Web Dynpro ABAP, Can we merge two cells of a row in a table ?

    In Web Dynpro ABAP, Can we merge two cells of a row in a table ?

    Hallo Jagannatha,
    the new table feature is available in SAP NetWeaver 7.0 EhP2 (SAP ERP 6.0 EhP5, SAP Business Suite 7i2010) named 'TableMultiEditorCell'. See [SAP Online Help|http://help.sap.com/saphelp_nw70ehp2/helpdata/en/9b/46bb0d339b42cc8d30636ca0c9f5b6/frameset.htm] for more details ...
    "This UI element is a table cell variant that enables several UI elements to be placed in one table cell. This type of cell can be used for "one click actions". ...
    Regards, Bertram

  • Dynamic Table UI Element with different data type for each cell

    Hi Experts,
    I have a problem with a dynamic Table UI Element in Web Dynpro ABAP. I have the following coding:
    METHOD set_col_row .
      TYPE-POOLS: icon.
      DATA:
        lv_node         TYPE REF TO if_wd_context_node,
        lv_node_info    TYPE REF TO if_wd_context_node_info,
        lv_element      TYPE REF TO if_wd_context_element,
        lt_attributes   TYPE wdr_context_attr_info_map,
        lv_table        TYPE REF TO cl_wd_table,
        lv_table_column TYPE REF TO cl_wd_table_column,
        lv_text_view    TYPE REF TO cl_wd_text_view,
        lv_image TYPE REF TO cl_wd_image,
        lv_text_edit TYPE REF TO cl_wd_text_edit,
        lv_header       TYPE REF TO cl_wd_caption,
        attribute       LIKE LINE OF lt_attributes,
        lv_index       TYPE string,
        lv_cur_row         TYPE i,
        path            TYPE string,
        lv_value           TYPE string,
        attr_name       TYPE string,
        l_trc_point_id  TYPE string,
        l_num_cols      TYPE string,
        l_num_rows      TYPE string,
        lv_text         TYPE string,
        lv_index2 TYPE i,
        lr_ress_selections TYPE REF TO /its/di_2_cpr_ress_selections,
        lt_comp_tab TYPE cl_abap_structdescr=>component_table,
        ls_comp_tab LIKE LINE OF lt_comp_tab,
        lv_count TYPE i,
        lv_col_count TYPE i,
        lv_col_count_read TYPE i,
        lv_index_read TYPE i,
        lv_num_cols_minus_1 TYPE i,
        lv_bind_lv_value TYPE string,
        wd_standard_cell TYPE REF TO cl_wd_table_standard_cell,
        lv_data_count TYPE i,
        lv_data_count_str TYPE string,
        wd_table_column TYPE REF TO cl_wd_table_column,
        lv_column_id TYPE string.
      FIELD-SYMBOLS:
         TYPE ANY.
    Instanz der Klasse /ITS/DI_2_CPR_RESS_SELECTIONS
      lr_ress_selections = /its/di_2_cpr_ress_selections=>factory( ).
      ASSIGN lr_ress_selections->gr_table->* TO gt_comp_tab.
      ls_comp_tab-name = 'SUMME'.
    APPEND ls_comp_tab TO lt_comp_tab.
    ls_comp_tab-name = 'CELL_VARIANT'.
      APPEND ls_comp_tab TO lt_comp_tab.
      CLEAR ls_comp_tab.
      l_num_rows = num_rows + 1.
      CONDENSE l_num_rows.
      l_num_cols = num_columns + 1.
      CONDENSE l_num_cols.
    UI-Element 'TABLE'
      lv_table ?= wd_this->m_view->get_element( 'TBL_TABLE' ).
      lv_table->remove_all_columns( ).
    Kontext-Knoten 'TABLE'
      lv_node = wd_context->get_child_node( 'TABLE' ).
      lv_node_info = lv_node->get_node_info( ).
      lv_node_info->remove_dynamic_attributes( ).
      attribute-type_name = 'STRING'.
      lv_num_cols_minus_1 = num_columns - 1.
    Für jede Spalte einmal tun
      DO lv_num_cols_minus_1 TIMES.
        lv_index = sy-index + 1.
        CONDENSE lv_index.
        lv_table_column = cl_wd_table_column=>new_table_column( ).
        lv_column_id = lv_table_column->id.
    Spaltenüberschriften setzen
        IF lv_index EQ 1. "Beim ersten Durchlauf --> erste Spalte = "Ressourcen"
          lv_text = text-010.
          sy-index = 0.
        ELSE. "Danach für jede weitere Spalte eine Zeile aus der gt_comp_tab nehmen
          lv_index_read = lv_index - 1.
          READ TABLE lt_comp_tab INDEX lv_index_read INTO ls_comp_tab.
          lv_text = ls_comp_tab-name.
          lv_header = cl_wd_caption=>new_caption( text = lv_text ).
          lv_table_column->set_header( lv_header ).
        ENDIF.
        CONCATENATE 'TABLE.A' lv_index INTO path.
        lv_text_view = cl_wd_text_view=>new_text_view( bind_text = path ).
        lv_table_column->set_table_cell_editor( lv_text_view ).
        lv_table_column->bind_selected_cell_variant( 'TABLE.CELL_VARIANT' ).
        lv_table->add_column( lv_table_column ).
        wd_table_column ?= wd_this->m_view->get_element( lv_column_id ).
    *****************Test Cell Variant*************************************************
        IF lv_index GT 1.
          LOOP AT .
              IF sy-tabix EQ lv_cur_row.
              Name zuweisen
                ASSIGN COMPONENT 'NAME' OF STRUCTURE .
              Zuweisen ob Blatt oder nicht
                lv_element->set_attribute( name = 'NAME' value = lv_value ).
                ASSIGN COMPONENT 'IS_LEAF' OF STRUCTURE set_attribute( name = attr_name value = lv_value ).
              ENDIF.
        ENDLOOP.
    Now my problem is, that I need for every ROW of my table UI Element a different cell editor. I know how to change it for the column. But is not my issue. I want to have images (traffic lights red and green) in some rows. The other rows should have numbers. The coding works, so that I have all the data at the right place in my table, only the images are shown as a string, because the cells of these rows have the cell editor Text_View. I tried something with cell variants (with cl_wd_table_standard_cell), but it was not possible for me to get a cell variant "image" in these cells/rows were I need it. 
    I hope you understand my problem and now what to do here.
    Thanks a lot in advance.
    Best Regards,
    Ingmar

    Hi Experts, I have a problem with a dynamic Table UI Element in Web Dynpro ABAP. I have the following coding: METHOD set_col_row . TYPE-POOLS: icon. DATA: lv_node TYPE REF TO if_wd_context_node, lv_node_info TYPE REF TO if_wd_context_node_info, lv_element TYPE REF TO if_wd_context_element, lt_attributes TYPE wdr_context_attr_info_map, lv_table TYPE REF TO cl_wd_table, lv_table_column TYPE REF TO cl_wd_table_column, lv_text_view TYPE REF TO cl_wd_text_view, lv_image TYPE REF TO cl_wd_image, lv_text_edit TYPE REF TO cl_wd_text_edit, lv_header TYPE REF TO cl_wd_caption, attribute LIKE LINE OF lt_attributes, lv_index TYPE string, lv_cur_row TYPE i, path TYPE string, lv_value TYPE string, attr_name TYPE string, l_trc_point_id TYPE string, l_num_cols TYPE string, l_num_rows TYPE string, lv_text TYPE string, lv_index2 TYPE i, lr_ress_selections TYPE REF TO /its/di_2_cpr_ress_selections, lt_comp_tab TYPE cl_abap_structdescr=>component_table, ls_comp_tab LIKE LINE OF lt_comp_tab, lv_count TYPE i, lv_col_count TYPE i, lv_col_count_read TYPE i, lv_index_read TYPE i, lv_num_cols_minus_1 TYPE i, lv_bind_lv_value TYPE string, wd_standard_cell TYPE REF TO cl_wd_table_standard_cell, lv_data_count TYPE i, lv_data_count_str TYPE string, wd_table_column TYPE REF TO cl_wd_table_column, lv_column_id TYPE string. FIELD-SYMBOLS:  LIKE LINE OF lt_attributes,  TYPE ANY TABLE,  TYPE ANY,  TYPE ANY,  TYPE ANY. * Instanz der Klasse /ITS/DI_2_CPR_RESS_SELECTIONS lr_ress_selections = /its/di_2_cpr_ress_selections=>factory( ). ASSIGN lr_ress_selections->gr_table->* TO . lt_comp_tab = lr_ress_selections->gt_comp_tab. ls_comp_tab-name = 'SUMME'. * APPEND ls_comp_tab TO lt_comp_tab. * ls_comp_tab-name = 'CELL_VARIANT'. APPEND ls_comp_tab TO lt_comp_tab. CLEAR ls_comp_tab. l_num_rows = num_rows + 1. CONDENSE l_num_rows. l_num_cols = num_columns + 1. CONDENSE l_num_cols. * UI-Element 'TABLE' lv_table ?= wd_this->m_view->get_element( 'TBL_TABLE' ). lv_table->remove_all_columns( ). * Kontext-Knoten 'TABLE' lv_node = wd_context->get_child_node( 'TABLE' ). lv_node_info = lv_node->get_node_info( ). lv_node_info->remove_dynamic_attributes( ). attribute-type_name = 'STRING'. lv_num_cols_minus_1 = num_columns - 1. * Für jede Spalte einmal tun DO lv_num_cols_minus_1 TIMES. lv_index = sy-index + 1. CONDENSE lv_index. lv_table_column = cl_wd_table_column=>new_table_column( ). lv_column_id = lv_table_column->id. * Spaltenüberschriften setzen IF lv_index EQ 1. "Beim ersten Durchlauf --> erste Spalte = "Ressourcen" lv_text = text-010. sy-index = 0. ELSE. "Danach für jede weitere Spalte eine Zeile aus der gt_comp_tab nehmen lv_index_read = lv_index - 1. READ TABLE lt_comp_tab INDEX lv_index_read INTO ls_comp_tab. lv_text = ls_comp_tab-name. lv_header = cl_wd_caption=>new_caption( text = lv_text ). lv_table_column->set_header( lv_header ). ENDIF. CONCATENATE 'TABLE.A' lv_index INTO path. lv_text_view = cl_wd_text_view=>new_text_view( bind_text = path ). lv_table_column->set_table_cell_editor( lv_text_view ). lv_table_column->bind_selected_cell_variant( 'TABLE.CELL_VARIANT' ). lv_table->add_column( lv_table_column ). wd_table_column ?= wd_this->m_view->get_element( lv_column_id ). ******************Test Cell Variant************************************************** IF lv_index GT 1. LOOP AT  ASSIGNING . ASSIGN COMPONENT 'TYPE' OF STRUCTURE  TO . ADD 1 TO lv_data_count. lv_data_count_str = lv_data_count. CONCATENATE 'A' lv_index lv_data_count_str INTO path. wd_standard_cell = cl_wd_table_standard_cell=>new_table_standard_cell( view = wd_this->m_view variant_key = 'FLDATE' ). IF  = '01' OR  = '04'. lv_image = cl_wd_image=>new_image( bind_source = path view = wd_this->m_view ). wd_standard_cell->set_editor( lv_image ). wd_standard_cell->set_cell_design( '01' ). ELSE. lv_text_view = cl_wd_text_view=>new_text_view( bind_text = path view = wd_this->m_view ). wd_standard_cell->set_editor( lv_text_view ). wd_standard_cell->set_cell_design( '02' ). ENDIF. wd_table_column->add_cell_variant( wd_standard_cell ). ENDLOOP. ENDIF. ************************************************************************************* CONCATENATE 'A' lv_index INTO attribute-name. lv_node_info->add_attribute( attribute ). ENDDO. DO num_rows TIMES." Für jede Zeile einmal tun lv_cur_row = sy-index. lv_element = lv_node->create_element( ). lv_node->bind_element( new_item = lv_element set_initial_elements = abap_false ). DO l_num_cols TIMES. ADD 1 TO lv_col_count. IF lv_count LT 1. LOOP AT  ASSIGNING . IF sy-tabix EQ lv_cur_row. * Name zuweisen ASSIGN COMPONENT 'NAME' OF STRUCTURE  TO . "NAME lv_value = . * Zuweisen ob Blatt oder nicht lv_element->set_attribute( name = 'NAME' value = lv_value ). ASSIGN COMPONENT 'IS_LEAF' OF STRUCTURE  TO . "NAME lv_value = . lv_element->set_attribute( name = 'IS_LEAF' value = lv_value ). ENDIF. ENDLOOP. ENDIF. IF lv_count GT 0. lv_col_count_read = lv_col_count - 1. lv_index = sy-index. LOOP AT  ASSIGNING . IF sy-tabix EQ lv_cur_row. CLEAR ls_comp_tab. READ TABLE lt_comp_tab INDEX lv_col_count_read INTO ls_comp_tab. ASSIGN COMPONENT ls_comp_tab-name OF STRUCTURE  TO . lv_value = . CONDENSE lv_index. CONCATENATE 'A' lv_index INTO attr_name. lv_element->set_attribute( name = attr_name value = lv_value ). ENDIF. ENDLOOP. ENDIF. lv_count = lv_count + 1. ENDDO. CLEAR lv_col_count. CLEAR lv_count. ENDDO. ENDMETHOD. I definied my table in Layout Tab of the View and create here in thos method dynamicly my columns. lv_table_column = cl_wd_table_column=>new_table_column( ). . . lv_table->add_column( lv_table_column ). In  I have my data that should be shown later in my table. So I create for each row in this fieldsymbol in a loop: lv_element = lv_node->create_element( ). lv_node->bind_element( new_item = lv_element set_initial_elements = abap_false ). Later I fill every cell in my table with a different value with this loop: LOOP AT  ASSIGNING . IF sy-tabix EQ lv_cur_row. CLEAR ls_comp_tab. READ TABLE lt_comp_tab INDEX lv_col_count_read INTO ls_comp_tab. ASSIGN COMPONENT ls_comp_tab-name OF STRUCTURE  TO . lv_value = . CONDENSE lv_index. CONCATENATE 'A' lv_index INTO attr_name. lv_element->set_attribute( name = attr_name value = lv_value ). ENDIF. ENDLOOP. Now my problem is, that I need for every ROW of my table UI Element a different cell editor. I know how to change it for the column. But is not my issue. I want to have images (traffic lights red and green) in some rows. The other rows should have numbers. The coding works, so that I have all the data at the right place in my table, only the images are shown as a string, because the cells of these rows have the cell editor Text_View. I tried something with cell variants (with cl_wd_table_standard_cell), but it was not possible for me to get a cell variant "image" in these cells/rows were I need it. I hope you understand my problem and now what to do here. Thanks a lot in advance. Best Regards, Ingmar

Maybe you are looking for