cancel
Showing results for 
Search instead for 
Did you mean: 

ALV component in WD - lookup name from pernr

former_member210563
Participant
0 Kudos

Hi,

I have an ALV table view with 4 fields visible:

PERNR

ENAME

SDATUM

EDATUM

These are all attributes of my custom Z table.

The user enters a value in PERNR either manually or from F4 selection. After having pressed ENTER on the number (PERNR), it has to fill ENAME with

the name from infotype PA0001. However, there is no onENTER event for the nodes. Will I use supply function on my node for this or where to place the lookup ?

Thanks in advance for your input.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

you can use ON_CELL_ACTION event of ALV.

your cell detail will be stored in R_PARAM parameter.

if helpful reward points

former_member210563
Participant
0 Kudos

Hi and thanks for your answer,

Do you know how to give point as I am looking at my Communcations page, but there is nothing that makes me able to give points ?

Perhaps you have an example of ON_CELL_ACTION use; I guess that I have to create the event-handler but where ?

Former Member
0 Kudos

Hi Peter,

1) You can create a method in the component controller to fire the event with

wd_this->fire_<event_name>_evt.

2) Create a event handler for ON_CELL_ACTION in the View Controller Method tab

3) Then use wd_comp_controlle->raise_event ()

former_member210563
Participant
0 Kudos

Hi and thanks for your input,

What I have done till now is:

1. I have created an event handler named ON_CELL_ACTION.

2. Then I went to wddomodifyview and coded this below to activate ON_CELL_ACTION. This is placed in my ALV view.

Now I just need to know how to lookup the ENAME from infotype PA0001 using PERNR.

Can that be done "normally" reading the attribute ?

Peter

****

Code for wddomodifyview:

* Here we activate the event handler of on_cell_action for looking up name of employee
* Data Declaration

  DATA: lo_cmp_usage TYPE REF TO if_wd_component_usage,
              lo_interfacecontroller TYPE REF TO iwci_salv_wd_table,
              lo_value TYPE REF TO cl_salv_wd_config_table.

* Instantiate ALV

  lo_cmp_usage = wd_this->wd_cpuse_alv_test( ).

  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
       lo_cmp_usage->create_component( ).
  ENDIF.

  lo_interfacecontroller = wd_this->wd_cpifc_alv_test( ).

* Call get_model of Interface Controller to get reference of ALV

  lo_value = lo_interfacecontroller->get_model(
                       ).

* Enable the ON_CELL_ACTION Event

  CALL METHOD lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled
    EXPORTING
      value = abap_true.

Former Member
0 Kudos

Hi

Yes, after those steps you just need to instantiate the node and set it as table operation.

DATA lo_nd_node TYPE REF TO if_wd_context_node.

     DATA lt_node TYPE wd_this->elements_node.

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

     lo_nd_mara = wd_context->get_child_node( name = wd_this->wdctx_mara ).

*   @TODO handle non existant child

*   IF lo_nd_node IS INITIAL.

*   ENDIF.

*  * @TODO compute values

*  * e.g. call a model function

     <Write your select query here in this to retrieve the data from PA0001 into table lt_node.>

*

     lo_nd_mara->bind_table( new_items = lt_node set_initial_elements = abap_true

former_member210563
Participant
0 Kudos

Hi,

I have now modifed/adjusted your code in ON_CELL_ACTION, but I still do not get a NAME

from PERNR in my ALV WD comp.

Code:

METHOD on_cell_action .

  DATA lo_nd_node TYPE REF TO if_wd_context_node.
  DATA lt_node TYPE wd_this->elements_node_alv.
  DATA ls_node TYPE wd_this->element_node_alv.

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

  lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node_alv ).

*     <Write your select query here in this to retrieve the data from PA0001 into table lt_node.>

  SELECT SINGLE pernr ename
    FROM pa0001
    INTO ls_node
    WHERE pernr = ls_node-pernr.

*  lo_nd_node->bind_table( new_items = lt_node->set_initial_elements = abap_true ).

  LOOP AT lt_node INTO ls_node.
    APPEND ls_node TO lt_node[].
  ENDLOOP.

  lo_nd_node->bind_table( new_items = lt_node set_initial_elements = abap_true ).

ENDMETHOD.

Former Member
0 Kudos

Have you binded your context node with data node in the component usage controller?

former_member210563
Participant
0 Kudos

Hi,

It was already binded, so do I have to rebind it after adding ON_CELL_ACTION ?; and what about the code ? It looks ok to me though ?

Peter

'

Former Member
0 Kudos

No it is not necessary to rebind. Your code looks fine. Can you put a break-point and check whether the value is populated in the table lt_node?

former_member210563
Participant
0 Kudos

Hi,

If I put a breakpoint in ON_CELL_ACTION or WDDOMODIFYVIEW, it is not called.

I use append row to open a new line and enter a pernr and hit enter, but nothing happens.

Former Member
0 Kudos

Where have you written the code, is it on ON_CELL_ACTION?

former_member210563
Participant
0 Kudos

Yes, in ON_CELL_ACTION

Former Member
0 Kudos

What coding have you written in WDDOMODIFYVIEW?

former_member210563
Participant
0 Kudos

METHOD wddomodifyview .



* Here we activate the event handler of on_cell_action for looking up name of employee



* Data Declaration

  DATA: lo_cmp_usage TYPE REF TO if_wd_component_usage,

        lo_interfacecontroller TYPE REF TO iwci_salv_wd_table,

        lo_value TYPE REF TO cl_salv_wd_config_table.



* Instantiate ALV



  lo_cmp_usage = wd_this->wd_cpuse_alv_test( ).



  IF lo_cmp_usage->has_active_component( ) IS INITIAL.

    lo_cmp_usage->create_component( ).

  ENDIF.



  lo_interfacecontroller = wd_this->wd_cpifc_alv_test( ).



* Call get_model of Interface Controller to get reference of ALV



  lo_value = lo_interfacecontroller->get_model(

                                              ).



* Enable the ON_CELL_ACTION Event



  CALL METHOD lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled

    EXPORTING

      value = abap_true.



ENDMETHOD.

former_member210563
Participant
0 Kudos

I have done some testing after having added this line to the wddomodifyview:

It now responds in the view if I just hit for instance the "Append Row" button and it should only respond to ENTER after the user has entered a PERNR.

lo_value->if_salv_wd_table_settings~set_data_check( '01' ).

Answers (0)