Skip to Content
author's profile photo Former Member
Former Member

ITAREATOR FOR A TABLEVIEW ( HELP ! )

hi there,

need some help on using an iterator.

Where can i find some documentation about using an itrator for a tableview ?

Main reason for using it, is to get some spaninfo in my tableview.

best regards

ali

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Oct 17, 2003 at 04:32 PM

    Hi Ali,

    Note 577305 contains a small documentation to getting started with iterators.

    My recipe to use iterator is the following:

    - Create a new class ZCL_HTMLB_TABLEVIEW_ITERATOR.

    - In interfaces add IF_HTMLB_TABLEVIEW_ITERATOR.

    - I take the column definitions from a database table: ZBSPTVC.

    This approach allows you to configure the table view just adding records in the table. If you need

    a new field just maintan the table !

    The table has the following structure:

    APPLICATION_NAME

    TABLEVIEW_ID

    COLUMN_KEY

    SEQUENCE

    WIDTH

    INNER_ELEMENT

    IE_TYPE

    IE_SHOWHELP

    HELPTABLE

    KEYFIELD

    VALUEFIELD

    LANGUAGEFIELD

    WHERE_CLAUSE

    The primary key are the first three fields.

    The fields HELPTABLE, KEYFIELD, VALUEFIELD, LANGUAGEFIELD and WHERE_CLAUSE

    are used in my solution for Matchcodes thru RFC. I pass these parameters to the the function

    module RFC_READ_TABLE in order to show popup help values from the RFC destination.

    Table ZBSPTVC has a text table TBSPTVCT with the following fields:

    APPLICATION_NAME

    TABLEVIEW_ID

    COLUMN_KEY

    LANGUAGE

    TITLE

    I created also a view ZBSPTVCV with joins ZBSPTVC and ZBSPTVT

    - Attributes of the class:

    TV_COLUMNS, private, type table of ZBSPTVC.

    MODEL, private, type ref to 'your model (MVC design pattern)'

    - Code of Method IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS .

    -

    -


    METHOD if_htmlb_tableview_iterator~get_column_definitions .

    • ZTV_COLUMN is a structure similar to ZBSPTVC.

    DATA: tv_column TYPE ztv_column,

    tv_coldef TYPE tableviewcontrol.

    CLEAR p_column_definitions.

    CLEAR p_overwrites.

    LOOP AT tv_columns INTO tv_column.

    tv_coldef-columnname = tv_column-column_key.

    tv_coldef-title = tv_column-title.

    tv_coldef-width = tv_column-width.

    APPEND tv_coldef TO p_column_definitions.

    ENDLOOP.

    ENDMETHOD.

    -

    -


    TV_COLUMNS is a table type for ZBSPTVC.

    ZTV_COLUMN is a structure similar to ZBSPTVC.

    - Code of Method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START

    -

    -


    METHOD if_htmlb_tableview_iterator~render_cell_start .

    DATA: inputfield TYPE REF TO cl_htmlb_inputfield,

    tv_column TYPE ztv_column,

    _value TYPE string.

    READ TABLE tv_columns INTO tv_column WITH TABLE KEY column_key = p_column_key.

    CHECK sy-subrc = 0.

    IF tv_column-inner_element = 'INPUTFIELD'.

    CREATE OBJECT inputfield.

    inputfield->id = p_cell_id.

    inputfield->type = tv_column-ie_type.

    inputfield->width = '100%'.

    inputfield->cellvalue = 'X'.

    inputfield->showhelp = tv_column-ie_showhelp.

    IF inputfield->showhelp = 'X'.

    inputfield->onvaluehelp = showf4help_string( inputfield = p_cell_id

    rfcdes = model->rfcdes

    helptable = tv_column-helptable

    keyfield = tv_column-keyfield

    valuefield = tv_column-valuefield

    languagefield = tv_column-languagefield

    whereclause = tv_column-where_clause

    parm1 = tv_column-parm1

    parm2 = tv_column-parm2

    parm3 = tv_column-parm3

    parm4 = tv_column-parm4 ).

    ENDIF.

    inputfield->_value = p_cell_binding.

    p_replacement_bee = inputfield.

    IF p_edit_mode IS NOT INITIAL.

    p_style = 'padding-right:2px;'.

    ENDIF.

    CONCATENATE p_style 'font-size:x-small' INTO p_style.

    ENDIF.

    ENDMETHOD.

    -

    -


    Comments: My model has an attribute rfcdes that points to RFC destination

    - Code of Method CONSTRUCTOR

    -

    -


    METHOD CONSTRUCTOR .

    • Importing: application_name TYPE char30

    * tableview_id TYPE char30

    * model TYPE REF TO "your model class"

    SELECT * FROM zbsptvcv

    INTO CORRESPONDING FIELDS OF TABLE tv_columns

    WHERE application_name = application_name

    AND tableview_id = tableview_id

    AND spras = sy-langu

    ORDER BY sequence.

    me->model = model.

    ENDMETHOD.

    -

    -


    - Code of SHOWF4HELP_STRING

    METHOD SHOWF4HELP_STRING .

    CONCATENATE 'ShowF4Help( '''

    inputfield ''','''

    rfcdes ''','''

    helptable ''','''

    keyfield ''','''

    valuefield ''','''

    languagefield ''','''

    whereclause ''','''

    parm1 ''','''

    parm2 ''','''

    parm3 ''','''

    parm4 ''')'

    INTO showf4str.

    ENDMETHOD.

    -

    -


    - Code (section) of the layout:

    <htmlb:tableView id = "lines"

    design = "TRANSPARENT"

    selectionMode = "LINEEDIT"

    onRowSelection = "LineSelected"

    table = "//model/item_data"

    footerVisible = "false"

    iterator = "<%= model->tv_iterator %>" />

    - Method DO_INIT, of the controller class, creates an instance (MODEL) of the model and calls a method MODEL->INIT that contains the instantiation of the iterator:

    CREATE OBJECT tv_iterator

    EXPORTING

    application_name = 'ZFMBB'

    tableview_id = 'LINES'

    model = me.

    - I know all this seems a little trick but the return is great. This iterator can be reused in every BSP. By now it deals only with inputfields but I am adding processing for other types of elements.

    If you have any doubts contact me.

    paulo.pedroso@sap.com

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.