cancel
Showing results for 
Search instead for 
Did you mean: 

Dropdownbykey: get the key and the value

former_member429661
Participant
0 Kudos

Hi all,

i have a UI "dropdownbykey" with streetnr. and streetname

key name

0100 Am Bach

0200 Detmolder

.

.

etc.

For an update i need streetnr. and streetname.

Here is the event when someone change the UI "dropdownbykey"

********************************************************************************

method ONACTIONONSELECT_STRNAM .

data: key TYPE string,

value type string.

DATA lo_nd_pd_details TYPE REF TO if_wd_context_node.

DATA lo_el_pd_details TYPE REF TO if_wd_context_element.

DATA ls_pd_details TYPE wd_this->element_pd_details.

DATA lv_strnr TYPE wd_this->element_pd_details-strnr.

DATA lv_strnam TYPE wd_this->element_pd_details-strnam.

DATA lo_nd_strnam TYPE REF TO if_wd_context_node.

DATA lo_el_strnam TYPE REF TO if_wd_context_element.

DATA ls_strnam TYPE wd_this->element_strnam.

DATA lv_key TYPE wd_this->element_strnam-key.

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

lo_nd_pd_details = wd_context->get_child_node( name = wd_this->wdctx_pd_details ).

  • @TODO handle non existant child

  • IF lo_nd_pd_details IS INITIAL.

  • ENDIF.

  • get element via lead selection

lo_el_pd_details = lo_nd_pd_details->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_pd_details IS INITIAL.

ENDIF.

  • @TODO fill attribute

  • lv_geahh = 1.

key = wdevent->get_string( 'KEY' ).

  • value = wdevent->get_data( 'KEY' ). "here i need the value for the streetname

lo_nd_strnam = wd_context->get_child_node( name = wd_this->wdctx_strnam ).

lo_el_strnam = lo_nd_strnam->get_element( ).

lo_el_strnam->get_attribute( EXPORTING name = `KEY` IMPORTING value = lv_key ).

lv_strnr = key.

lv_strnam = lv_key.

  • set single attribute

lo_el_pd_details->set_attribute( name = `STRNR` value = lv_STRNR ).

lo_el_pd_details->set_attribute( name = `STRNAM` value = lv_STRNAM ).

endmethod.

How can i get the information in this event ?

key = wdevent->get_string( 'KEY' ). <== this ist the key-information. OK.

But what's with the value ?

  • value = wdevent->get_data( 'KEY' ). "here i need the value for the streetname

Thanks in advance...

--Bernd

Accepted Solutions (1)

Accepted Solutions (1)

Madhu2004
Active Contributor
0 Kudos

HI ,

Simplest and easiest way is have these valueset values buffered in global internal table in component controller and read them using the key.

Regards,

Madhu

Answers (3)

Answers (3)

former_member429661
Participant
0 Kudos

Hi all,

thanks for the answers. I found a solution. On basics it is that what your answers suggested.

OK. Thanks a lot.

--Bernd

former_member429661
Participant
0 Kudos

Hi chinnaiya,

sorry i should explain how i filled the DDBK-Box. I didn't use a domain, i filled it "hardcoded" with a own written class with a table defines as wdy_key_value_table.

method WDDOINIT .
     DATA lr_node_info TYPE REF TO if_wd_context_node_info.
     DATA ls_value TYPE wdy_key_value.
     DATA lt_value_set TYPE wdy_key_value_table.
 
 
    .
    .
    .
     CALL METHOD zcl_dichte=>get_strnam
       IMPORTING
         exp_table =  lt_value_set. 
 

     lr_node_info = wd_context->get_node_info( ).
     lr_node_info = lr_node_info->get_child_node( 'STRNAM' ).
 *    ----- Set attribute info
     lr_node_info->set_attribute_value_set( name = 'KEY' value_set = lt_value_set ). 
 endmethod.

Edited by: Bernward Henkel on Aug 17, 2010 1:00 PM

Edited by: Bernward Henkel on Aug 17, 2010 1:03 PM

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Instead of declaring lt_value_set as a local variable, try declaring it as a controller attribute. This will keep the internal table alive and you can read from it later in your event processing. Just do a read on this internal table with the key and get your description.

Former Member
0 Kudos

HI Bernward,

then insted of using the FM just read your internal table with the key to retrive the text

data  : ls_parameter TYPE  wdr_event_parameter_list,
             ls_ddk TYPE wdr_event_parameter,
             lv_value TYPE string .
     ls_parameter = wdevent->parameters .
  LOOP AT  ls_parameter INTO ls_ddk WHERE  name = 'KEY'.
 
    CALL METHOD wdevent->get_string
      EXPORTING
        name  = 'KEY'
      RECEIVING
        value = lv_value.   " you will get the key value here
*call your class here
           CALL METHOD zcl_dichte=>get_strnam
       IMPORTING
         exp_table =  lt_value_set. 

  Read table lt_value set with key = lv_value .
    if sy-subrc eq 0 .
          " read the text . 
  endif.

or

As thomas said . assign your internal table values to the attributes that can be accesed and read it with the key value

Regards

Chinnaiya P

Former Member
0 Kudos

HI Bernward ,

pls look at the piece of code .. for getting the key and text

data  : ls_parameter TYPE  wdr_event_parameter_list,
             ls_ddk TYPE wdr_event_parameter,
             lv_value TYPE string .
     ls_parameter = wdevent->parameters .
  LOOP AT  ls_parameter INTO ls_ddk WHERE  name = 'KEY'.

    CALL METHOD wdevent->get_string
      EXPORTING
        name  = 'KEY'
      RECEIVING
        value = lv_value.   " you will get the key value here
CALL FUNCTION 'FM_DOMAINVALUE_CHECK'
 EXPORTING
   I_DOMNAME               =  s_class      " pass the domain name here 
* TABLES
   T_DD07V                 = lt_domain_text  " this table will hold the value range values of domain 
* EXCEPTIONS
*   INPUT_ERROR             = 1
*   VALUE_NOT_ALLOWED       = 2
*   OTHERS                  = 3
          .

read table lt_domain_text with key DOMVALUE_L = lv_value . 
if_sy-subrc eq 0 .
  * read the text 
endif .

Regards

chinnaiya P