Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Table View Iterator using MVC approach

I see most of the solutions in SDN is for Classical BSP page programming model and very few for MVC design pattern. Could someone please help me understand how to use iterator using MVC? This is what I did and it is giving me error - "A dynamic type conflict occurred during reference assignment."




Implemented the interface IF_HTMLB_TABLEVIEW_ITERATOR in a class - ZPESTVI_REVWTYPE

Defined class attribute M_ROW_REF instance public type ref to zt_revw_type (table type)

Implemented the methods:


FIELD-SYMBOLS: <def> LIKE LINE OF p_column_definitions.

APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.


<def>-SORT = 'X'.

APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.


<def>-EDIT = 'X'.

<def>-SORT = 'X'.

APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.


<def>-EDIT = 'X'.

<def>-SORT = 'X'.


m_row_ref ?= p_row_data_ref.


CASE p_column_key.


p_replacement_bee = CL_HTMLB_CHECKBOX=>FACTORY

( id = p_cell_id

checked = 'm_row_ref->ACTV_FLAG' ).



In my controller:


  • create the iterator

create object c_iterator type ZPESTVI_REVWTYPE.

  • create view instance

v_revwtype = create_view( view_name = 'zrevwtype.htm').

v_revwtype->set_attribute( name = 'v_tviterator' value = c_iterator ).

where c_iterator is defined as controller attribute instance public type ref to IF_HTMLB_TABLEVIEW_ITERATOR.


In my view:

<htmlb:form id="MyForm">

<htmlb:tableView id = "tv1"

visibleRowCount = "15"

selectionMode = "LINEEDIT"

table = "//vmodelsetup/m_revwtype"

iterator = "<%= v_tviterator %>" />


where v_tviterator is defined as page attribute type ref to IF_HTMLB_TABLEVIEW_ITERATOR.


First of all it doesn't work. Secondly, how do I display the checkbox with data binding?

Please help.




>Now, the output displays checkbox with label "Flag" next to it. How do I get rid of the lable "Flag"? I tried using text=' ' but that didn't work.

Because you are data binding it is pulling the field description automatically from the reference field. In ABAP there is an important difference between ' ' and ` `. With ' ' any trailing spaces are elimitated. Therefore nothing is passed to the text attribute and the binding value is used. However try ` ` instead. This usage preserves trailing spaces.

>Other fields are available for edit only when I select the record but all checkboxes are available for input. How do I control this?

You are creating the inner control so it is your responsibility to set if the control is ready for input or not. RENDER_CELL_START has an import parameter (P_EDIT_MODE) to tell you if the cell is in edit mode or not. If the entire table is in edit mode then you might have to read the line selection of your table. Either way you would control this by simply setting the disabled attribute of the factory method for the checkbox element.

>Finally, how can I enhance this screen to support select/insert/update/delete operation?

You will have to add your own buttons or menu options that trigger server side events. From there you can manipulate the internal table (deleting/adding rows) and edit mode/line selection index.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question