cancel
Showing results for 
Search instead for 
Did you mean: 

Free Programmed Input Help and SALV_WD_TABLE (ALV component)

matt
Active Contributor
0 Kudos

I've created a Web Dynpro component, that uses the SALV_WD_TABLE component. In the context of the controller, I've a node with a number of elements. I've mapped the controller context to the view context of my compoennt (there is only one view). On one of those elements, I'm using a Freely Programmed Input Help. On others, I've used OVS, and these work fine.

The event handler for the input help component looks like this

  DATA lo_interfacecontroller TYPE REF TO ziwci_b09gc_costcentre_f4 .
  DATA l_costctr TYPE /bic/oilccostctr.

  DATA lo_nd_projects TYPE REF TO if_wd_context_node.

  DATA lo_el_projects TYPE REF TO if_wd_context_element.
  DATA ls_projects TYPE wd_this->element_projects.

  DATA lv_lcresctr TYPE wd_this->element_projects-lcresctr.

* Get selected from F4 value help
  lo_interfacecontroller = wd_this->wd_cpifc_cc_f4_usage( ).
  l_costctr = lo_interfacecontroller->get_selected( ).

* navigate from <CONTEXT> to <PROJECTS> via lead selection
  lo_nd_projects = wd_context->get_child_node( name = wd_this->wdctx_projects ).

* get element via lead selection
  lo_el_projects = lo_nd_projects->get_element( ).

* alternative access  via index
* lo_el_projects = lo_nd_projects->get_element( index = 1 ).

  lv_lcresctr = l_costctr.

* set single attribute
  lo_el_projects->set_attribute(
    name =  `LCRESCTR`
    value = lv_lcresctr ).

L_costctr is set fine. The problem is the lo_el_projects is always null, so I get a dump.

Any ideas?

matt

Accepted Solutions (1)

Accepted Solutions (1)

former_member450736
Active Participant
0 Kudos

if i understood correctly, project context is bound to ALV.

and cost center is separate input field where we have done freely programmed f4 help.

now what i dont see here is filling of context node projects ( with some values ), i guess this is the reason why it is always returning null.. is't it??

matt
Active Contributor
0 Kudos

With the test data I have, I have two rows displayed. When I use my Freely Programming Input Help for the cost centre field, I get the dump. ( When I use the OVS help on other fields in the table, it works fine, as does that standard data element help ).

If I modified the program a little, to use lo_el_projects = lo_nd_projects->get_element( index = 1 ), then I'm returned the first row. So it looks like the issue is with lead selection not being set.

former_member450736
Active Participant
0 Kudos

Hi Matt,

by default get_element will return lead selection element only, check if the project context node property 'initialize lead selection' is set.

otherwise we have to set lead selection explicitly, so in this case get_element which uses lead selection to select the element will not have anything to return.

matt
Active Contributor
0 Kudos

The project node "initialise lead selection" is not set. And for the purposes of the application, we do not want it to be. Further... when I tried that, I still got the same dump.

I'd be delighted to set the lead selection explicitly... if I could find out what it should be. If I've done the help on the first row, I don't want the selected value to appear on the second!

matt
Active Contributor
0 Kudos

I've resolved it.

In the SET_VALUE_HELP_LISTENER method on the value help component, the parameter LISTENER has an attribute of f4_context_element. This is the context element from which the value help was triggered.

I store this in an attribute of the value help component controller, and when I read the selected value, I also return the context.

  DATA lo_interfacecontroller TYPE REF TO ziwci_b09gc_costcentre_f4 .
  DATA l_costctr TYPE /bic/oilccostctr.

  DATA lo_el_projects TYPE REF TO if_wd_context_element.
  DATA ls_projects TYPE wd_this->element_projects.

* Get selected from F4 value help
  lo_interfacecontroller = wd_this->wd_cpifc_cc_f4_usage( ).
  lo_interfacecontroller->get_selected( IMPORTING e_costctr  = l_costctr
                                                  er_context = lo_el_projects ). 

* set single attribute
  lo_el_projects->set_attribute( name =  `LCRESCTR`
                                 value = l_costctr ).

Answers (0)