cancel
Showing results for 
Search instead for 
Did you mean: 

How to read input value from table view iterator

Former Member
0 Kudos

Hi,

I am creating an application in MVC/BSP. I am using table view controller to get data and display them. My table view is as follows :

<htmlb:tableView id = "comp"

headerText = "Component Details"

headerVisible = "true"

design = "alternating"

visibleRowCount = "12"

fillUpEmptyRows = "true"

onRowSelection = "MyEventRowSelection"

selectionMode = "LINEEDIT"

keyColumn = "Itm_num"

table = "//ma/data_comp"

iterator = "<%= tv_iterator %>" >

<BR><BR>

I am able to change the table view and change the data and save it. When I input the data, it gets stored in the internal table 'data_comp'.

However I have a problem if the field is date type. I am able to display the data, but not able to change and save the same. When I debug the code, the values are not passed to the internal table.

Would appreciate if some one could help me on this.

Here is my table view column code :

<htmlb:tableViewColumn columnName = "validto"

wrapping = "true"

width = "100"

edit = "TRUE"

title = "Valid to">

</htmlb:tableViewColumn>

Thanks,

VJ Sudharsan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Brian

When I put the code :

p_replacement_bee = CL_HTMLB_INPUTFIELD=>FACTORY id = p_cell_id value = pcell_binding type = 'DATE' showHelp = 'TRUE' cellValue = 'TRUE' ). ENDIF.

I get a syntax error :

'Formal Parameter "_Value " does not exist. However, the parameter "VALUE" has a similar name.

Thanks,

VJ Sudharsan

former_member181879
Active Contributor
0 Kudos

Just replace with:


DATA: if TYPE REF TO cl_htmlb_inputfield.
if = cl_htmlb_inputfield=>factory( ... )
if->_value = p_cell_binding.
p_replacement_bee = if.

The one thing that really costs us a lot of time and money (keep in mind it is now already 1am for me!) is when people open OSS problems and at the same time post their problems in SDN. And this without even mentioning it at either place. So now I worked hours to help you. Tomorrow a colleague will run into your OSS problem and also work hours? This is definitely not good style, and not the way we work.

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Brian,

Thank you very much for the help. I am able to change the date now. I will post a detail working code once I validated everything.

I have closed the OSS note and will keep this in mind in future.

Thanks,

VJ Sudharsan

Former Member
0 Kudos

Here is the working Example :

Define table view in the views :

<htmlb:tableView id = "comp"

headerText = "Component Details"

headerVisible = "true"

design = "alternating"

visibleRowCount = "12"

fillUpEmptyRows = "true"

onRowSelection = "MyEventRowSelection"

selectionMode = "LINEEDIT"

keyColumn = "Itm_num"

table = "//ma/data_comp"

iterator = "<%= tv_iterator %>" >

Implement Interface

IF_HTMLB_TABLEVIEW_ITERATOR

in your class

Redefine following methods in your class

IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS

IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_ROW_START

IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START

To read/update the date field in the iterator, append following code in method : IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START

IF p_column_key CS 'VALIDFROM'

AND p_edit_mode IS NOT INITIAL.

M_ROW_REF = cl_htmlb_inputfield=>factory(

id = p_cell_id

  • value = p_cell_binding

type = 'DATE'

showHelp = 'TRUE'

cellValue = 'TRUE' ).

M_ROW_REF->_value = p_cell_binding.

p_replacement_bee = M_ROW_REF.

ENDIF.

where VALIDFROM in one of the field in table "//ma/data_comp" that should be read and updated.

Thanks,

VJ Sudharsan

Former Member
0 Kudos

Hi Brain,

Here is the code from render_cell_start (None, if you see all the codes are commented, as it did not work for me).

method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START .

  • data M_ROW_REF type ref to ZDATA_COMP .

  • if m_row_ref->validfrom = ''.

  • endif.

  • CASE p_column_key.

  • WHEN 'VALIDFROM'.

  • IF p_edit_mode IS NOT INITIAL.

  • data : date TYPE STRING.

  • date = m_row_ref->VALIDFROM.

  • p_replacement_bee = CL_HTMLB_INPUTFIELD=>FACTORY(

  • id = p_cell_id

  • value = date

  • type = 'DATE'

  • showHelp = 'TRUE'

  • cellValue = 'TRUE' ).

  • ENDIF.

  • endcase.

endmethod.

Thanks,

VJ Sudharsan

former_member181879
Active Contributor
0 Kudos

Of course, if the code is commented out, it will not work:)

What you have to now look at, is the following concept. You have defined a binding string to your table. Now you want to render a specific cell in this table. The inputField does not know about your binding string, as you don't tell it that. You have to extend the binding string to exactly the cell you want to render, and supply it to the inputfield.

Luckily, the list of input parameters for the iterator call already contains everything you need. You should look (also in debugger) at all those nice P_* parameters been pushed into the method. The one you are interested in, is: P_CELL_BINDING.

Plus a few other minor errors in your code. I suspect that you got many dumps? I am not sure whether you are interested in validto (per previous SDN append) or validfrom as in this source (assumed)?


method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START .

  IF  p_column_key CS 'VALIDFROM'
  AND p_edit_mode  IS NOT INITIAL.
    p_replacement_bee = CL_HTMLB_INPUTFIELD=>FACTORY(
                           id    = p_cell_id
                          <b>_value = p_cell_binding</b>
                            type = 'DATE'
                        showHelp = 'TRUE'
                       cellValue = 'TRUE' ).
  ENDIF.
endmethod.

I have not tested the above code. It should just be to put you back on the road again. The most important aspect is the _value attribute we set (the underscore is important!). Maybe one day I will write a weblog about this. Not soon. What we do, is pass into the binding string for the value the actual binding path to exactly this cell we are rendering. We do not set the value itself.

With this, you should be able to now complete your code. Maybe afterwards you append a working example to help other people?

Furthermore, I don't think any of your restore logic is required. As long as all your inputfields are working via model binding, the data will find its own way back!

++bcm

Former Member
0 Kudos

Hi Brain,

Thanks for your reply.

Couple of things I would like to clarify. when I said, 'I am rendering the specific column via the iterator', I mean the table defined in iterator 'data_comp' has many fields. As I do not want all the fields to be displayed on the output, I am passing specific fields needed, using table view column.

Here is my code for the same :

<htmlb:tableView id = "comp"

headerText = "Component Details"

headerVisible = "true"

design = "alternating"

visibleRowCount = "12"

fillUpEmptyRows = "true"

onRowSelection = "MyEventRowSelection"

selectionMode = "LINEEDIT"

keyColumn = "itm_num"

table = "//ma/data_comp"

iterator = "<%= tv_iterator %>" >

<BR><BR>

<htmlb:tableViewColumns>

<htmlb:tableViewColumn columnName = "zzlvl_anal"

wrapping = "true"

width = "100"

title = "Level"

edit = "FALSE">

</htmlb:tableViewColumn>

<htmlb:tableViewColumn columnName = "MATERIAL"

wrapping = "true"

width = "100"

edit = "TRUE"

title = "Material">

</htmlb:tableViewColumn>

<htmlb:tableViewColumn columnName = "QTY"

wrapping = "true"

width = "100"

edit = "TRUE"

title = "Quantity">

</htmlb:tableViewColumn>

<htmlb:tableViewColumn columnName = "validto"

wrapping = "true"

width = "100"

edit = "TRUE"

title = "Valid to">

</htmlb:tableViewColumn>

</htmlb:tableViewColumns>

</htmlb:tableView>

Button for Update

<td><htmlb:button id="UpdateComp"

text="Update Comp"

tooltip="Update Components"

design = "EMPHASIZED"

onClick="UpdateComp"/></td>

In the 'DO handle Event Method'

case htmlb_event->server_event.

when 'UpdateComp'.

me->ma->update_flag = 'C'.

me->ma->do_update( ).

In the method do_update.

data: s_data_comp type zdata_comp

loop at data_comp into s_data_comp.

update zdata_comp

set .....

where .....

endloop.

In the above instance, I am not using row selected as I would want to change all the lines in the table.

As I said, If I change the Qty value, I am able to see the changed value in data_comp internal table and able to save. However the date field is the one on which I have the problem.

In one of your note on 'Tableview' you have mention that there is an example SBSPEXT_TABLE for the table view. Wen I go to SE80 to look for this example, I do not see this appplication. Would appreciate, if you could help me in locating this.

Thanks,

VJ Sudharsan

Former Member
0 Kudos

Hi

I guess the example SBSPEXT_TABLE is available after SP 28. You can still look into the example SBSPEXT_HTMLB and choose the table option. I usually use table iterator for customizing the columns.

-Suresh

Former Member
0 Kudos

You should really check out these links they makes the tableView very easy.

<a href="/people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator">BSP Programming: HTMLB TableView Iterator</a>

<a href=" Element - Dynamic tableView with Internal Table</a>

You can adjust the fields you want to view dynamically just by adjusting your select statement when you call your table. You can define the rows in the tableView the way you want them, then when the tableView passing the data to the Iterator it displays those selected in the select statement.

former_member181879
Active Contributor
0 Kudos

Hmmm...

I write: "<i>Append only the 10 lines of code that handle you use in your iterator to setup the bee for this column.</i>". You append for me N lines of code, but exactly the 10 lines I want is missing.

Let me repeat this: <b>please append the complete body of render_cell_start here. Nothing more, nothing less.</b>

Writing is a powerful thing. But all my writing will not help, if the same powerful reading is not applied. Especially as English is not the native language for most of us. Not even me. Which means, take the time to read! If possible, read it twice. (Which I did with your appends!) It is worth it!

I already know where the error is. I just need your code to verify this, and then to show you the right way to do it. I will try to check back later tonight.

++bcm

Former Member
0 Kudos

Hi Craig,

I am not sure which SP you are referring to. Here is the details on our system.

SAP_BASIS 620 0030 SAPKB62030

SAP_ABA 620 0030 SAPKA62030

SAP_BW 310 0010 SAPKW31010

PI_BASIS 2003_1_620 0006 SAPKIPYH56

WP-PI 600_620 0000 -

BI_CONT 310 0010 SAPKIBIAQ0

FINBASIS 150 0006 SAPK-15006INFINBASIS

SEM-BW 320 0006 SAPKGS3206

ST-A/PI 01D_BCO620 0000 -

ST-PI 003C_620 0001 SAPKITLPR1

Hope this helps you.

Thanks,

VJ Sudharsan

Former Member
0 Kudos

SAP_BASIS 620 0030 SAPKB62030

SAP_ABA 620 0030 SAPKA62030

was a topic that we talked about the various problems with the different SP levels. I'm sure Brian will be able to help you out more but you might want to take a look at the topic just as well.

Former Member
0 Kudos

Hi Brain,

I am rendering the specific column via the iterator. In the table view, I had mentioned key column as item number. There are many components for an item number. So when I click on the line, it edits all the components data (several lines in the table view). The edited information is available in the internal table 'data_comp'. When I change any values, it changes the internal table, except the date. I did add the code

dataType = "DATE"

but the problem still persists. Would appreciate your help on this very much.

Thanks,

VJ Sudharsan

Former Member
0 Kudos

What SP are you at for you system? Perhaps that will help Brian in finding a solution?

former_member181879
Active Contributor
0 Kudos

First in terms of SPs, if you are using design2002, everything should be fine. For design2003, things only look good in very high 30 numbers.

If you write "I am rendering the specific column via the iterator" then my comments are all invalid. Once you use the iterator for the column, the type plays no role. You set up the input field to render,a nd it must be correct (which includes setting the databinding into the inputfield correct!).

Append only the 10 lines of code that handle you use in your iterator to setup the bee for this column. We can at least quickly look.

However, from reading your text ("When I change any values, it changes the internal table, except the date") I get the impression that you know what you are doing, and this sounds like bug. If we can not resolve it, we will have to go via OSS.

++bcm

former_member181879
Active Contributor
0 Kudos

Are you rendering this specific column via the iterator, or do you let the tableView handle the column?

You do not set the column type. Typo?


<htmlb:tableViewColumn columnName = "validto"
                       ...
                       <b>dataType   = "DATE"</b> />

++bcm