cancel
Showing results for 
Search instead for 
Did you mean: 

WD ALV set_focus doesn't work

Former Member
0 Kudos

Hey guys,

my task is to use set_focus to switch to a specific row and column.

I had a look at the example from SAP SALV_WD_TEST_TABLE_FOCUS. Of course this works, but when i use this statements in my ALV nothing happens.

I even built the example in my ALV so i could use the same way for jumping to a special cell.

I'm really upset, because any idea i had, didn't work.

Perhaps one of you can help me with this?

My ALV contains different columns, like PSTYP, WERKS, LGORT, MENGE, MEINS, etc.

Perhaps i have to say, that the ALV is enabled for inputs. this really works fine.

but when i now try to use the example, nothing happens, although the debugger doesn't mention any problems.

I created a button and two input fields, of course with context binding.

Here's my code:

method ONACTIONSPRINGEN .

   DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

   lo_cmp_usage =   wd_this->wd_cpuse_cpu_alv( ).

   IF lo_cmp_usage->has_active_component( ) IS INITIAL.

     lo_cmp_usage->create_component( ).

   ENDIF.

DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .

lo_interfacecontroller =   wd_this->wd_cpifc_cpu_alv( ).

   DATA lo_nd_focus TYPE REF TO if_wd_context_node.

   DATA lo_el_focus TYPE REF TO if_wd_context_element.

   DATA ls_focus TYPE wd_this->element_focus.

* navigate from <CONTEXT> to <FOCUS> via lead selection

   lo_nd_focus = wd_context->get_child_node( name = wd_this->wdctx_focus ).

* @TODO handle non existant child

* IF lo_nd_focus IS INITIAL.

* ENDIF.

* get element via lead selection

   lo_el_focus = lo_nd_focus->get_element( ).

* @TODO handle not set lead selection

   IF lo_el_focus IS INITIAL.

   ENDIF.

* get all declared attributes

   lo_el_focus->get_static_attributes(

     IMPORTING

       static_attributes = ls_focus ).

   lo_interfacecontroller->set_focus(

    column = ls_focus-column                            " string

     index = ls_focus-index             " i

   ).

endmethod.

Perhaps anyone had this problem too and can help me with that?

hoping for an answer,

regards

Mathias

Accepted Solutions (1)

Accepted Solutions (1)

amy_king
Active Contributor
0 Kudos

Hi Mathias,

The example code used in SALV_WD_TEST_TABLE_FOCUS  works for me to set focus on a particular cell of the ALV. Note that to set focus on a cell, the cell itself must first be editable.

To set an ALV column as editable, please take a look at document .

Cheers,

Amy

Former Member
0 Kudos

Hi Amy,

first, thanks for the quick response.

i didn't know, that this only works with editable ALV, but fortunately my ALV is editable, because the user should fill the ALV and i want the webdyndpro to jump to the first position, where a mistake is found. For that reason i want to use the set focus method, but it doesn't work.

i'm going to try to make the editable alv editable again, perhaps this works but i don't think so.

Are there any other solutions? Should i perhaps add some more coding or any further informations that could help?

cheers,

Mathias

EDIT: i tried it now, but nothing changed. I think i will have a deeper look at the debugger and check if the index and the column are set or get lost.

amy_king
Active Contributor
0 Kudos

Hi Mathias,

"I want the webdyndpro to jump to the first position, where a mistake is found."

If you have issued an error message as part of a standard action, the phase model stops its processing. Have you verified in debugging that the code to set focus is being executed?

Cheers,

Amy

Former Member
0 Kudos

hi Amy,

yes i did it.

But in discussions with my colleagues, we decided to use Table Control instead of ALV, because of some other mistakes we didn't found a solution for. We think we can solve our "jump" problem in table control.

Beside of this, thanks for your help and your ideas!

Answers (0)