on 04-24-2007 12:23 PM
Hi,
I have created one context node called lang, in which i have created one attribute spras.
i have placed one ui element of type DropDownByKey in Layout.
following code is written in WDDOINIT of the view in which i have placed DropDownByKey UI Element.
DATA:
node_lang TYPE REF TO if_wd_context_node,
elem_lang TYPE REF TO if_wd_context_element,
stru_lang TYPE if_v_test=>element_lang ,
item_spras LIKE stru_lang-spras,
node_info TYPE REF TO if_wd_context_node_info,
wa_value_set TYPE wdy_key_value,
int_value_set TYPE wdy_key_value_table,
wa_t002t TYPE t002t,
int_t002t TYPE TABLE OF t002t.
* navigate from <CONTEXT> to <LANG> via lead selection
node_lang = wd_context->get_child_node( name = if_v_test=>wdctx_lang ).
node_info = node_lang->get_node_info( ).
SELECT * FROM t002t INTO TABLE int_t002t
WHERE spras = sy-langu.
SORT int_t002t BY sptxt.
IF sy-subrc EQ 0.
LOOP AT int_t002t INTO wa_t002t.
wa_value_set-key = wa_t002t-spras.
wa_value_set-value = wa_t002t-sptxt.
APPEND wa_value_set TO int_value_set.
CLEAR wa_value_set.
ENDLOOP.
ENDIF.
node_info->set_attribute_value_set(
name = 'SPRAS'
value_set = int_value_set ).
But at the time of execution i m getting following error
Fehler beim Einfügen in eine Tabelle mit eindeutigem Schlüssel
Please suggest the solution.
Thanks
Hi Vishal,
Please see component WDR_TEST_EVENTS.
See views DropDownByIdx and DropDownByKey .
in my sample application tried DropDownByIdx and I found it easrier .
This is what I did .
1 ) I took drop down box and I associated element of node to it.
2) I wrote this Supply function to fill node
***********************************************************************************************
method fillDropDown1 .
implicit available data objects
wd_Context type ref to if_wd_context_node.
wd_This type ref to if_DropDownByIdx.
data:
lt_attributes type standard table of if_dropdownbyidx=>element_dropdown1,
wa_attributes like line of lt_attributes,
lt_scarr type cl_wd_flight_model=>tt_scarr.
field-symbols:
<scarr> like line of lt_scarr.
cl_wd_flight_model=>get_scarr( importing et_scarr = lt_scarr ).
loop at lt_scarr assigning <scarr>.
wa_attributes-carrid = <scarr>-carrid.
insert wa_attributes into table lt_attributes.
endloop.
node->bind_elements( lt_attributes ).
endmethod.
***********************************************************************************************
Try It ....Hope this will help you.....:)
Cheers
Darshna.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vishal,
Please do not use WDY_KEY_VALUE_TABLE for the value set, but WDR_CONTEXT_ATTR_VALUE_LIST.
This table is not sorted.
Instead of KEY use VALUE
Instead of value use TEXT.
Ciao, Regina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In case your requirement is just to sort the languages and use them in a dropdown list then sort the table as you want and instead of the dropDownBykey just use the DropDownbyIndex that is much simple, you are not bothered about the key duplicaiton, you can always get the language selected by getting the index on the lead selection.
This simplifies your usage.
- Harish.
Hi,
As suggested by you instead of WDY_KEY_VALUE_TABLE I ve used WDR_CONTEXT_ATTR_VALUE_LIST which solves my problem of sorting the text (descriptive values) instead of key values.
for Screen 3 of my application in one method
DATA:
node_scr_3 TYPE REF TO if_wd_context_node,
node_info_scr_3 TYPE REF TO if_wd_context_node_info,
wa_value_set TYPE WDR_CONTEXT_ATTR_VALUE,
int_value_set TYPE WDR_CONTEXT_ATTR_VALUE_LIST.
* navigate from <CONTEXT> to <ACT_GROUP> via lead selection
node_scr_3 = wd_context->get_child_node( name = if_v_scr_3=>wdctx_scr_3 ).
node_info_scr_3 = node_scr_3->get_node_info( ).
wa_value_set-value = 'Commercial Conflict Checked'.
wa_value_set-text = 'Commercial Conflict Checked'.
APPEND wa_value_set TO int_value_set.
CLEAR wa_value_set.
wa_value_set-value = 'Conflict Check Required'.
wa_value_set-text = 'Conflict Check Required'.
APPEND wa_value_set TO int_value_set.
CLEAR wa_value_set.
wa_value_set-value = 'Money Laundered'.
wa_value_set-text = 'Money Laundered'.
APPEND wa_value_set TO int_value_set.
CLEAR wa_value_set.
node_info_scr_3->set_attribute_value_set(
name = 'ZZCLSTATUS'
value_set = int_value_set ).
for Screen 4 on my WD Application in one method
DATA:
node_scr_4 TYPE REF TO if_wd_context_node,
node_info_scr_4 TYPE REF TO if_wd_context_node_info,
wa_value_set TYPE WDR_CONTEXT_ATTR_VALUE,
int_value_set TYPE WDR_CONTEXT_ATTR_VALUE_LIST.
* navigate from <CONTEXT> to <ACT_GROUP> via lead selection
node_scr_4 = wd_context->get_child_node( name = if_v_scr_4=>wdctx_scr_4 ).
node_info_scr_4 = node_scr_4->get_node_info( ).
wa_value_set-value = 'Standard'.
wa_value_set-text = 'Standard'.
INSERT wa_value_set INTO TABLE int_value_set.
wa_value_set-value = 'Discounted'.
wa_value_set-text = 'Discounted'.
INSERT wa_value_set INTO TABLE int_value_set.
wa_value_set-value = 'Special'.
wa_value_set-text = 'Special'.
INSERT wa_value_set INTO TABLE int_value_set.
node_info_scr_4->set_attribute_value_set(
name = 'ZZRATYP'
value_set = int_value_set ).
On Saving the applicaiton It throws following error.
Note
The following error text was processed in the system RPS : The ASSERT condition was violated.
The error occurred on the application server iwdf1149_RPS_00 and in the work process 0 .
The termination type was: RABAX_STATE
The ABAP call stack was:
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/LSTANDARD===============CP
Now when I Save the application after changing the values of Screeen 4 as
wa_value_set-value = '1'.
wa_value_set-text = 'Standard'.
INSERT wa_value_set INTO TABLE int_value_set.
wa_value_set-value = '2'.
wa_value_set-text = 'Discounted'.
INSERT wa_value_set INTO TABLE int_value_set.
wa_value_set-value = '3'.
wa_value_set-text = 'Special'.
INSERT wa_value_set INTO TABLE int_value_set.
the text values from screen 3 & 4 the int_value_set gets saved into teh standard SAP Tables in the custom fields.
I am confused why it is not saving the values if I keep the values of screen4 as text i.e special, discounted and standard and on changin teh wa_value_set-value to numbers for screen 4 it gets saved along with the text values of screeen3.
Pls suggest.
Regards
Vishal
Hi Vishal,
For you case it is the problem here like in the followin code:
wa_value_set-key = wa_t002t-spras.
wa_value_set-value = wa_t002t-sptxt.
Here both fields must be passed as Characters only otherwise you will get the problem at the time of execution. You need to pass '01' instead of passing like 1. Most of the times this is the only problme. You will definetly resolve this with this inoformation.
Check the followin link for that also i answered
Warm Regards,
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vishal.
This means that you already have inserted an entry with the same key.
In t002t there a a lot of entries with the same spras value. In Hash or sorted tables
you can only insert a key once.
Cheers,
Sascha
Message was edited by:
Sascha Dingeldey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have checked the values. there are a two entries like below
A Arabic
a Afrikaans
now tell me how to take care of this?
I have modified the code as shown below to take care of these values
SELECT alaiso bsptxt
INTO CORRESPONDING FIELDS OF TABLE int_lang
FROM t002 AS a JOIN t002t AS b ON bsprsl = aspras
WHERE b~spras = sy-langu.
sort int_lang by laiso.
IF sy-subrc EQ 0.
LOOP AT int_lang INTO wa_lang.
wa_value_set-key = wa_lang-laiso.
wa_value_set-value = wa_lang-sptxt.
APPEND wa_value_set TO int_value_set.
CLEAR wa_value_set.
ENDLOOP.
ENDIF.
my question is i do not want to sort the table based on teh key, instead my requirement is to sort the populated descriptive values,
if I do so it gvies me the same error as mentioned earlier.
pls suggest.
Regards
Vishal
Message was edited by:
Vishal Kava
Hi Vishal.
When you insert key value entries into a sorted table, you have to make sure
that the keys are inserted in a sorted way.
For example if you insert key A, Key C and key B a system exception is thrown
cause the keys are not sorted.
When you sort your itab by sptxt you insert unsorted keys. This won' work.
In your case it seems to be better to use dropdownbyindex. You can sort your itab
by sptxt and bind the texts property of the dropdownbyindex to sptxt.
Hope this helps.
Cheers,
Sascha
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.