cancel
Showing results for 
Search instead for 
Did you mean: 

I have a table with info and would like to select an item from that table

DebbieCloud
Participant
0 Kudos

Hi

I have a table with info (course info that I searched for) and would like to select an item from that table to use for further use in my application.

It must work more or less like the tree structure where I can use an On Action select.

In other words; let say I am looking for all courses with "Advisor" it its descriptin / name, I want to click on one of the names and use it lets say to book people on.

Could some please assist me with this.

Regards

Debbie

Accepted Solutions (1)

Accepted Solutions (1)

DebbieCloud
Participant
0 Kudos

Hi

The datasource for my table is the node searchcatalog. Under this node there is an attribute calles description where the items found are displayed.

I changed my code as follow:

data: ls_table type wd_This->Elements_searchcatalog,

lr_element type ref to if_wd_context_element.

DATA lo_nd_searchcatalog TYPE REF TO if_wd_context_node.

DATA lo_el_searchcatalog TYPE REF TO if_wd_context_element.

DATA ls_searchcatalog TYPE wd_this->element_searchcatalog.

  • navigate from <CONTEXT> to <SEARCHCATALOG> via lead selection

lo_nd_searchcatalog = wd_context->get_child_node( name = wd_this->wdctx_searchcatalog ).

  • @TODO handle not set lead selection

IF lo_nd_searchcatalog IS INITIAL.

ENDIF.

  • get element via lead selection

lo_el_searchcatalog = lo_nd_searchcatalog->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_searchcatalog IS INITIAL.

ENDIF.

  • get all declared attributes

lo_el_searchcatalog->get_static_attributes(

IMPORTING

static_attributes = ls_searchcatalog ).

lo_nd_searchcatalog->get_lead_selection->( exporting index = wdevent->index importing

element = lr_element ).

lr_element->get_static_attributes->( importing static_attributes = ls_table ).

wd_context->set_attribute( exporting name = 'SELECTED' value = ls_table-description ).

When I try to activate it errors with: List elements that take up more than one line is not allowed. This error at the sentence: lo_el_searchcatalog->get_static_attributes(

If you cannot assist me further I will understand. Thank you.

Former Member
0 Kudos

Remove this part of your code . It is not required.

  • get all declared attributes

lo_el_searchcatalog->get_static_attributes(

IMPORTING

static_attributes = ls_searchcatalog ).

i think if you will you use same code as given by Lekha , it would work.

Former Member
0 Kudos

Hi,

DATA lo_nd_searchcatalog TYPE REF TO if_wd_context_node.
DATA lo_el_searchcatalog TYPE REF TO if_wd_context_element.
DATA ls_searchcatalog TYPE wd_this->element_searchcatalog.
* navigate from <CONTEXT> to <SEARCHCATALOG> via lead selection
lo_nd_searchcatalog = wd_context->get_child_node( name = wd_this->wdctx_searchcatalog ).

* @TODO handle not set lead selection
IF lo_nd_searchcatalog IS not  INITIAL.
* get element via lead selection
lo_el_searchcatalog = lo_nd_searchcatalog->get_lead_selection( ).
ENDIF.


* @TODO handle not set lead selection
IF lo_el_searchcatalog IS not INITIAL.
* get all declared attributes
lo_el_searchcatalog->get_static_attributes(
IMPORTING
static_attributes = ls_searchcatalog ).
ENDIF.

wd_context->set_attribute( exporting name = 'SELECTED' value = ls_searchcatalog-description ).

Answers (8)

Answers (8)

DebbieCloud
Participant
0 Kudos

Hi

I have used her code, but had to use the wizard to read my node. I deleted that part you said, but then it just give the same error if I try to active for the next section:

  • @TODO handle not set lead selection

IF lo_el_searchcatalog IS INITIAL.

ENDIF.

If I delete the entire node and only leave:

DATA lo_nd_searchcatalog TYPE REF TO if_wd_context_node. It also errors with the same message.

Please assist.

Regards

Debbie

Former Member
0 Kudos

Normally steps for this are :

1. create the ref for node.(if_wd_context_node)

2. create the element of the node.(if_wd_context_element)

3. Get the selected row into the element.(using lead selection )

4. Fetch the value of attributes from the element.(get_static_attributes).

I hope this would help you in understanding the code.

DebbieCloud
Participant
0 Kudos

Hi Lekha

On the Onleadselect of my table, if have only put in:

data: ls_table type wd_This->Elements_searchcatalog.

wd_context->set_attribute

exporting

name = 'SELECTED'

value = ls_table.

If I want to activate, it give an error to say wd_context->set_attribute has not been defined. Please could you tell me what is wrong?

I have also linked the Selected context attribute to my input field.

Thanks for you assistance.

Regards

Debbie

Former Member
0 Kudos

Hi,

data: ls_table type wd_This->Element_searchcatalog,

lr_element type ref to if_wd_context_element.

USe code wizard to read the node -


lo_nd_searchcatalog = wd_context->get_child_node( name = wd_this->wdctx_searchcatalog ).

CALL METHOD lo_nd_searchcatalog->get_lead_selection
receiving
element = lr_element.

if lr_element is not initial.
lr_element->get_statitc_attributes->
importing
static_attributes = ls_table.
endif.

wd_context->set_attribute
exporting
name = 'SELECTED'
value = ls_table-advisor.

"Feild name that you want to nshow in Inputfield. check the fieldsname(advisor)

Regards,

Lekha.

Edited by: Lekha on Aug 28, 2009 4:28 PM

DebbieCloud
Participant
0 Kudos

Hi Lekha

Thanks; I found the tick for Transfer UI Parameters.

You refer to a Method I have to call, but we will not have such a method called that (there is also not a standard one)? Am I wrong in saying that?

Regards

Debbie

Former Member
0 Kudos

hi Debbie,

You dont have to call the method.

The method is automatically called on lead selection of a row.

Just implement the method, write the code inside it and activate . It will wrk..

Former Member
0 Kudos

Just check that input field which you are having is binded to an Attribute named 'Selected' .

Otherwise below code will give you error.

wd_context->set_attribute

exporting

name = 'SELECTED'

value = ls_table-advisory.

DebbieCloud
Participant
0 Kudos

Hi Lekha

Must I add that parameter exactly like you put below (in my ONLEADSELECT) or must something be changed for my web dynpro?

It says it it not defined when I try to activate. Sorry if it sound stupid, but I am fairly new at this, but is learning a lot.

Regards

Debbie

Former Member
0 Kudos

Hi,

There is a event for TABLE UI elemnt named as onLeadSelect, check the box Transfer UI parameers. Then only

you can write the code as per my earlier reply.

Regards,

Lekha.

DebbieCloud
Participant
0 Kudos

Hi

I have an lv_searchname field where I type a word and the system find the results with all course names with lv_searchname's info in its wording.

Example:

lv_searchname = adviso

If I click on Search Now, the system will display the results as follow:

Advisors

Advisors / Brokers

Advisors Soft Skills Training

I now want to click on one of the results, eg. Advisors / Brokers and then the system must default that name to my Input field.

All three the entries found is displayed in my table.

Hope someone can assist.

Regards

Debbie

Former Member
0 Kudos

Hi,

Implement the event ONELADSELECT of the table. So that whenever a row is selected,

You can get tehe values.

In this event,

There is a parameter that wdevent that has Index.

CALL METHOD lo_nd_node->get_lead_selection

receiving

element = lr_element.

lr_element->get_statitc_attributes->

importing

static_attributes = ls_table.

Now set the attribute SELECTED that is bound to input field.

wd_context->set_attribute

exporting

name = 'SELECTED'

value = ls_table-advisory. "The fieldname that you wanted to show in Input field.

Or

In the WDEVENT parameters you can get the context element in NEW_ROW_ELEMENT.

Regards,

Lekha.

Edited by: Lekha on Aug 28, 2009 2:02 PM

DebbieCloud
Participant
0 Kudos

Hi Lekha

The Input field is outside the table in a transparent container. In the table a few hits could be found. I need to select one which I would then like to default to my Input field.

Regards

Debbie

DebbieCloud
Participant
0 Kudos

Hi

I have a search option where I search for a course with lets say Advisor in the wording. So now I find the search results which is displayed in my table rows.

I would now like to click on one of these search results (Course names) and let it default specific information at the bottom of my table into fields that I set up. So if I click on the search result let say which is called Advisor Training, I would like that name to default to my Input field that I created to let say change the name of the course.

I wish we could attach screenshots or word documents with the example (what I am trying to do).

Regards

Debbie

Former Member
0 Kudos

Hi,

As per my understanding,

When you get the value from search criteria into lv_vbeln(for you: course id)

try o fill the table to which the TABLE UI element is bound.

Select * from vbak into table lt_vbak where vbeln = lv_vbeln  "Have your own logic for retrieval
lo_nd_vbak->bind_table( lt_vbak ).  "For you it would be course details table

I have question, is this Input field outside the table or a part of table column.

If it is outside, it might be bound to some attribute right (for ex :SELECTED)

Now,

wd_context->set_attribute
exporting
name = 'SELECTED'
value = lv_vbeln.

Regards,

Lekha.

Former Member
0 Kudos

Hi,

Can you be more clear.

You can get the selected value and what you want to do next.

Regards,

Lekha