cancel
Showing results for 
Search instead for 
Did you mean: 

Getting moving text and sorted values in dropdrow by key

arjun_thakur
Active Contributor
0 Kudos

hi experts,

I am working on a component which has the following requirements:

1) I need to have moving/rolling/scrolling text in a view. Is it possible to have rolling text in wd-abap?

2) I need to populate a dropdown by key with values which are fetched from a standard table.I am using value-set to populate the drop down. The standard table has 2 fields, one contain keys and other contains value for that key. The field which has keys is the primary key of the table. so when i populated the drop down using a value-set the values are populated in a sorted manner , but they are sorted according to the key, hence the value that appears in the drop down are not in alphabatical order. Is there any way to get those values in alphabatical order.

Thanks in advance

regards

arjun

Accepted Solutions (0)

Answers (2)

Answers (2)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>I need to have moving/rolling/scrolling text in a view. Is it possible to have rolling text in wd-abap?

If you are 7.0 Enhancement Package 1, then you can use the FlashIslands UI element. You can create a Flex COmponent to do the rolling/scrolling text quite easily.

Former Member
0 Kudos

Hi,

I retrieved the country names into an internal table lt_t005t using the below query.

SELECT * FROM t005t INTO CORRESPONDING FIELDS OF TABLE lt_t005t  WHERE
           spras = 'E'.
sort lt_t005t by land1 descending.

here without sort we get the vlaues in Ascending manner.

But now I changed the order.

Now to the DROPDOWNBYKEY where we need to bind the LAND1 for the SelectedKey and do the rest.

Populate the value set as below -

READ TABLE lt_t005t INTO ls_t005t INDEX 1.

ls_valueset-value = ls_t005t-land1.

ls_valueset-text = ls_t005t-landx.

APPEND ls_valueset TO lt_valueset.

Like this add the other values either by looping at the table or using READ.

lr_nodeinfo->set_attribute_value_set(

EXPORTING

name = 'LAND1'

value_set = lt_valueset ).

Now I can view the values in the drop down by desceding manner.

We dont have any UI for the scrolling text or any property.

For the scrolling text - Refer this link to achieve scrolling text by other way.

https://wiki.sdn.sap.com/wiki/display/Snippets/Addmarqueetoportalpage-sample+code

Regards

Lekha

arjun_thakur
Active Contributor
0 Kudos

hi lekha,

I have tried your method, but i am getting a run time error :"Error when inserting or changing in a sorted table

".

the code which i have used is

CALL METHOD cl_wd_dynamic_tool=>get_table_data

EXPORTING

tab_name = 'T005T'

row_count = 0

IMPORTING

data = it_t005t.

SORT it_t005t BY landx descending.

loop at it_t005t into wa_t005t.

if wa_t005t-spras eq sy-langu.

value-key = wa_t005t-land1.

value-value = wa_t005t-landx.

append value to value_set.

endif.

endloop.

i am getting the error in the append statement. Plz help.

thanks in advance

regards

arjun

Former Member
0 Kudos

Hi,

Change the statement of the sort

SORT it_005 by LAND1 DESECNDING.

when ever you bind the SelectedKey on the drop down to the LAND1 then we need to sort the Internal table by that Key.

Let me know the error also.

Regards

Lekha

arjun_thakur
Active Contributor
0 Kudos

hi lekha,

i have used this code as well : SORT it_005 by LAND1 DESECNDING.

if i use Append statement then i m getting "Error when inserting or changing in a sorted table " error.

if i use insert statement then i m getting values sorted according to land1 but i want them to be sorted according to landx.

regards

arjun

Former Member
0 Kudos

Hi,

Have you declared the it_t005t as a table of standard type or sorted table.

If you have declared the table as a sorted table then we cant sort that table again and while appending try to pass the values in a sorted manner only other wise it throws error.

Please paste your code for more clarification.

FYI,

i wrote the code in the WDDOMODIFYVIEW -

data:

  ls_t005t     type t005t,
  lt_t005t     type standard table of t005t,
  node_country type ref to if_wd_context_node,
  elem_country type ref to if_wd_context_element,
  stru_country type if_main=>element_country,
  lt_valueset type table of wdr_context_attr_value,
  ls_valueset type wdr_context_attr_value,
  lr_node type ref to if_wd_context_node,
  lr_nodeinfo type ref to if_wd_context_node_info.

select * from t005t into corresponding fields of table lt_t005t  where   spras = 'E'.
sort lt_t005t by land1 descending.

* navigate from <CONTEXT> to <COUNTRY> via lead selection
node_country = wd_context->get_child_node( name = if_main=>wdctx_country
 ).

* get element via lead selection
  elem_country = node_country->get_element(  ).


* get all declared attributes
  elem_country->get_static_attributes(
    importing
      static_attributes = stru_country ).

  node_country->bind_table(
      new_items            = lt_t005t
*    SET_INITIAL_ELEMENTS = ABAP_TRUE
*    INDEX                = INDEX
         ).

lr_node = wd_context->get_child_node( 'COUNTRY' ).
  lr_nodeinfo = lr_node->get_node_info( ).

*GET the database table values into internal table and fill lt_valueset
*like the example

  read table lt_t005t into ls_t005t index 1.
  ls_valueset-value = ls_t005t-land1.
  ls_valueset-text = ls_t005t-landx.
  append ls_valueset to lt_valueset.


  read table lt_t005t into ls_t005t index 2.
  ls_valueset-value = ls_t005t-land1.
*   Key that is bound to context attribute
  ls_valueset-text = ls_t005t-landx.
  append ls_valueset to lt_valueset.

  read table lt_t005t into ls_t005t index 3.
  ls_valueset-value = ls_t005t-land1.
  ls_valueset-text = ls_t005t-landx.
  append ls_valueset to lt_valueset.

  lr_nodeinfo->set_attribute_value_set(
  exporting
  name = 'LAND1'
  value_set = lt_valueset ).

I have bound the SELECTEDKEY to the LAND1 of the context node COUNTRY.

Regards

Lekha

Former Member
0 Kudos

Hi Arjun,

The problem might be you are giving row_count is 0.But you hav to pass some value to that.

that means no of rows you want to receive.

arjun_thakur
Active Contributor
0 Kudos

hi lekha,

i am using this code:

METHOD initcountry .

DATA: node_info TYPE REF TO if_wd_context_node_info.

Internal table of type T005T

DATA it_t005t TYPE TABLE OF t005t.

DATA wa_t005t type t005t.

Refrence to type T005T

FIELD-SYMBOLS: <tablet005t> TYPE t005t.

DATA: value TYPE wdy_key_value,

value_set TYPE wdy_key_value_table.

CLEAR value_set.

Assign memory for getting node info

node_info = wd_context->get_node_info( ).

node_info = node_info->get_child_node( 'CN_COUNTRYCODE' ).

Read table using class, method

CALL METHOD cl_wd_dynamic_tool=>get_table_data

EXPORTING

tab_name = 'T005T'

row_count = 0

IMPORTING

data = it_t005t.

SORT it_t005t BY land1 descending.

loop at it_t005t into wa_t005t.

  • read table it_t005t into wa_t005t INDEX sy-index.

if wa_t005t-spras eq sy-langu.

value-key = wa_t005t-land1.

value-value = wa_t005t-landx.

append value to value_set.

endif.

endloop.

Initiate drop down with the value set

node_info->set_attribute_value_set(

name = 'CA_COUNTRYCODE' value_set = value_set ).

ENDMETHOD.

Former Member
0 Kudos

Hi,

What is the problem/error you are getting in your code.

Regards,

Lekha.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Your problem is that wdy_key_value_table is a sorted table type. You can't just append to a sorted table type. You don't have to use the type wdy_key_value_table. I suggest using the data type wdr_context_attr_value_list instead. That is the correct type expected by set_attribute_value_set. See this example:

data l_activities type zpm_activity_typ_tbl.
  l_activities = wd_assist->read_all_activities( ).
  data lt_valueset type wdr_context_attr_value_list.
  field-symbols <wa_act> like line of l_activities.
  field-symbols <wa_vs>  like line of lt_valueset.

  loop at l_activities assigning <wa_act>.
    append initial line to lt_valueset assigning <wa_vs>.
    <wa_vs>-value = <wa_act>-activity_type.
    <wa_vs>-text  = <wa_act>-activity_desc.
  endloop.

  data lo_nd_meeting type ref to if_wd_context_node.
* navigate from <CONTEXT> to <MEETING> via lead selection
  lo_nd_meeting = wd_context->get_child_node( name = wd_this->wdctx_meeting ).
  data lo_node_info type ref to if_wd_context_node_info.
  lo_node_info = lo_nd_meeting->get_node_info( ).
  lo_node_info->set_attribute_value_set(
     name = 'ACTIVITY_TYPE'
     value_set = lt_valueset ).