cancel
Showing results for 
Search instead for 
Did you mean: 

Using Search Help Selected Value to Derive/Update another Table Field

mike_mcinerney
Participant
0 Kudos

I'm new at WD4A, and Iu2019ve coded up some of the ALV tutorial examples and I'm working on my first APP. I need to present the user with a table of data with values to update. . The app allows a user to set a new responsible person based on a pernr (employee number) . Here's what a record looks like:


Field1                            r/o
Field2                            r/o
Field3                            r/o
Current Responsible PERNR         r/o 	
Current Responsible NAME          r/o 	
New Responsible PERNR             r/w    (needs a search help as well)
New Responsible NAME              r/o to user, but app will derive value from NEW pernr and fill it in 	

NewResponsiblePERNR and NewResponsibleNAME are initially blank.

There is a search help on the NewResponsiblePERNR

When the user selects a value from the search help, it populates the NewResponsiblePERNR.

At that point, I want to capture the NewResponsiblePERNR value and use it to derive the pernr's ename from table PA0001 and put that value in the NewResponsibleNAME field. I've read in the forum that wdDoModifyView should be where I can insert my derivation into the table, but I'm not sure how to capture what data changed, and how to update the table with my derived value?

Looking fwd to your replies...

...Mike

Accepted Solutions (0)

Answers (2)

Answers (2)

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

You can refer below thread .

[;

Priya

Former Member
0 Kudos

hi ,

follow these steps:

1. After you selecte the search help for New Responislbe person, domodify gets triggered.

2. In the wddomodify, get the value of New Responsible person by reading the attribute binded to it.

3. Now if Value entered is not initial, write a selecte query to fetch the name based on pernr no.

4. Finally bind the name fetched with the attribute binded to New Responsible person name.

Wdomodify :

************* *Read the New REsponsible person Pernr* ***********
  DATA lo_nd_cn_sflight TYPE REF TO if_wd_context_node.
  DATA lo_el_cn_sflight TYPE REF TO if_wd_context_element.
  DATA ls_cn_sflight TYPE wd_this->element_cn_sflight.
  DATA lv_carrid LIKE ls_cn_sflight-carrid.
* navigate from <CONTEXT> to <CN_SFLIGHT> via lead selection
  lo_nd_cn_sflight = wd_context->get_child_node( name = wd_this->wdctx_cn_sflight ).
* get element via lead selection
  lo_el_cn_sflight = lo_nd_cn_sflight->get_element(  ).
* get single attribute
  lo_el_cn_sflight->get_attribute(
    EXPORTING
      name =  `PERNR`
    IMPORTING
      value = lv_carrid ).

****** *Check whethre a value has been entered in PERNR* *************
if lv_carrid is not initial.

*************Select Name based on pernr entered* ***********
select ename from pa001 into lv_ename where pernr = lv_carrid.

*******Set the Name atttribute with the ename value fetched* *****
  lo_el_cn_sflight->set_attribute(
      name =  `NAME`
      value = lv_cename ).
endif.

mike_mcinerney
Participant
0 Kudos

Saurav,

Thank you for providing a thorough explanation and code.

This was helpful, but leaves me with two problems.

1) It seems to work, but only on the first record in the alv output.

2) When the user goes to save the data, my data_check()_ method no longer identifies changed data.

...Mike