cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a line in table with some fields filled

matteo_montalto
Contributor
0 Kudos

Hi all gurus, forgive the -probably- dumb question.

In a web dynpro, we have a custom table which is made up by 7/8 fields (columns).

There's then a standard button "Add line", which adds a row to the custom table.

The method which is associated to the button as event-handler is done as follows:

method ONACTIONON_ADD .
data: lo_table_id type string.
*get the id of the table on which the action has been invoked
  CALL METHOD wdevent->get_string
    EXPORTING
      name   = 'ID'
    receiving
      value  = lo_table_id
      .
*Invoke the mapper method
CALL METHOD wd_this->mo_dodm_i_ct->add_line
  EXPORTING
    IV_TABLE_ID = lo_table_id.

Now, I'd like to enhance this method in such way: any time a new row is added, some fields of the line should be automatically filled on the basis of certain criteria calculated at runtime.

I guess defining a post-exit on that method could do the trick; but since I'm completely noob on the argument, I'd like to receive some hints and inputs on the best way to realize my requirement.

Thanks,

M.

Edited by: Matteo Montalto on Nov 8, 2010 12:34 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Are you doing any modifications to standard component or is it a custom one.

Regards,

Lekha.

Answers (4)

Answers (4)

matteo_montalto
Contributor
0 Kudos

Solved, I did as follows to get the new entry (which is, by default, the last entry in the table):

CALL METHOD lo_table->move_last

RECEIVING

new_lead_selection = lo_row.

Then I can easily set my values (attributes) using:

CALL METHOD lo_row->set_attribute

EXPORTING

value = my_field_value

name = 'myfieldname'.

Thanks again!

matteo_montalto
Contributor
0 Kudos

Thank to you all for your fast reply, I'm gonna clarify on the task in response of your questions:

- the web dynpro I'm working on is absolutely a standard one; it's the one provided by SAP SRM 7 to manage a custom table for header data in purchasing documents. So, the method I posted above is the standard one associated to the behaviour of the button "Add row..".

- ADD_LINE is a standard method from the interface /SAPSRM/IF_CLL_DODM_I_CT, and has only IV_TABLE_ID as Importing parameter.. therefore there's no way to set fixed values for that entry using that method.

- I guess the post_exit method for ONACTION_ONADD will work; the question now is: what's the best way to implement it ?

Since I'm not expert on OO ABAP and webdynpro, I'm looking for hints and pseudocode; actually, in my post-exit I can easily get a ref to the custom header table:

DATA: lo_table    TYPE REF TO if_wd_context_node.

  lo_table = wd_context->GET_CHILD_NODE( name = 'THCUS' ).

The next step should be "get a reference to the empty row just added to the table"; and here I'm stuck'd. I hoped that getting the lead selection for the table would return me the desired entry, but that's not the case.

Former Member
0 Kudos

Hi Matteo,

What class is mo_dodm_i_ct ? Check if there are more parameters in method ADD_LINE, perhaps a structure to pass initial values. If it's not there you might want to add it (if it's a customer class) or create a subclass of it and redefine the ADD_LINE method to pass the parameters.

Cheers, Roel

Former Member
0 Kudos

Hi,

Is that method ONACTIONON_ADD is on event ON_DATA_CHECK then you can use a post exit with custom conditions to add

relevant data .

Regards,

Amit