cancel
Showing results for 
Search instead for 
Did you mean: 

To Display fixed values instead of Short Description in ABAP Webdynpro

Former Member
0 Kudos

I am using knb1 table - ktzlf field( DropDownByKey ). My requirement is to get the fixed values, but am getting short description. How to resolve it???

Eg:

fixed values                                   short description

     A                                                  partially delivered

     B                                                  delivered    

     C                                                  not delivered

     SPACE                                        processing

Thanks in Advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can use the following code.

     DATA lo_nd_<node>                     TYPE REF TO if_wd_context_node.
    DATA lo_nd_<node>_info              TYPE REF TO if_wd_context_node_info.
    DATA lt_values                               TYPE wdr_context_attr_value_list.
    DATA lw_values                             TYPE wdr_context_attr_value.

        lw_values-text   =  'A'.
        lw_values-value =  'A'.

        APPEND lw_values TO lt_values.
        CLEAR lw_values.

        lw_values-text   =  'B'.
        lw_values-value =  'B'.

        APPEND lw_values TO lt_values.
        CLEAR lw_values.

         lw_values-text   =  'C'.
        lw_values-value =  'C'.

        APPEND lw_values TO lt_values.
        CLEAR lw_values.

        APPEND INTIAL LINE TO LT_VALUES . " For Blank = Processing

         SORT lt_values AS TEXT.

      lo_nd_<node>_info->set_attribute_value_set(
        EXPORTING
          name      =    " Web Dynpro: Name of Context Element
          value_set =  lt_values   " All Fixed Values of an Attribute with Texts
      ).

Hope it will be useful to you.Else pls revert.

Thanks

KH

Former Member
0 Kudos

In the above code, what name should be given for Webdynpro context element?

Former Member
0 Kudos


Hi,

Web Dynpro: Name of Context Element = Name of attribute ( Node attribute) for which dropdown is binded.

Thanks

KH

Former Member
0 Kudos

Thanks Hawkins. But when I execute I get an error stating ''NULL' object reference not possible. (termination: RABAX_STATE)'. How to resolve this?

Thanks,

Jonathan.

Former Member
0 Kudos

Hi,

Can you pls share the snapshot of ST22 (Dump Analysis) and also your code.

Possiblity for error can be "No node reference i.e node reference is null'.

Thanks

KH

Former Member
0 Kudos

In init,

DATA lo_nd_NODE TYPE REF TO if_wd_context_node.

    DATA lo_nd_NODE_info TYPE REF TO if_wd_context_node_info.

    DATA lt_values TYPE wdr_context_attr_value_list.

    DATA lw_values TYPE wdr_context_attr_value.

lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
       lw_values-text   'A'.

        lw_values-value 'A'.
        APPEND lw_values TO lt_values.

        CLEAR lw_values.
        lw_values-text   'B'.

        lw_values-value 'B'.

        APPEND lw_values TO lt_values.

        CLEAR lw_values.

         lw_values-text   'C'.

        lw_values-value 'C'.

        APPEND lw_values TO lt_values.

        CLEAR lw_values.

        APPEND INITIAL LINE TO LT_VALUES . " For Blank = Processing

         SORT lt_values AS TEXT.
      lo_nd_NODE_info->set_attribute_value_set(

        EXPORTING

          name      =   'NODE' " Web Dynpro: Name of Context Element

          value_set lt_values   " All Fixed Values of an Attribute with Texts

      ).
Thanks,
Chithra
Former Member
0 Kudos

Hi,

What is your node name and attribute name?.

One statement is missing in your above code.

After lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ) , write below code

lo_nd_node_info = lo_nd_node->get_node_info( ).

If still the probelm persists, share snapshot of your node and attributes of your wdp component .

Thanks

KH

Former Member
0 Kudos

Hi Hawkins,

Its Working fine now.

Thanks,

Chithra

Answers (2)

Answers (2)

Former Member
0 Kudos

Alternate solution:

1. Use DropdownbyIndex

2. create Node DDKEY with 1:n cardinality, add attribute 'DDFLD' to it.

3. Bind the DDI to this attribute

4. in INIT method, write following code:


DATA lo_nd_ddkey TYPE REF TO if_wd_context_node.     " Node Reference to Dropdown
DATA lt_keys TYPE wd_this->elements_ddkey.             " Drodopwn Context Table  
DATA ls_keys TYPE wd_this->element_ddKEY.              " Dorpdown Context Workarea


*&- Navigate from <CONTEXT> to <DDKEY> via Lead Selection
  lo_nd_ddkey = wd_context->path_get_node( path = `DDKEY` ).


*&- Store Entries
        ls_keys-ddfld = 'A'.
        APPEND ls_keys TO lt_keys.

        ls_keys-ddfld = 'B'.
        APPEND ls_keys TO lt_keys.


*&- Check If Table is Initial and Append Initial Line
  IF lt_keys IS INITIAL.
    APPEND INITIAL LINE TO lt_keys.
  ENDIF.                             

*&- Bind Values to Context
  lo_nd_reports->bind_table( new_items = lt_keys set_initial_elements = abap_false ).

Use code generator as much as you can expeciall for context node references. Once generated, remove unwanted code elements and add whatever custom code you may want to add. You can also dynamically read domain values using FM 'DD_DOMA_GET' and set the dropdown internal table values.

Former Member
0 Kudos

there is no KTZLF field in KNB1 table in my system. When you use dropdownbykey and you bind only the value of your context, this is the standard behavior.

Try DropdownbyIndex (or code your own if_wd_context_node_info=>set_attribute_values_list( ) and you still can use dropdownbykey. Please, search for those terms and you will find lots of articles.

Former Member
0 Kudos

Sorry. Knvv table- KZTLF