on 10-12-2009 2:30 PM
Hi Experts..
I will CITY_FROM and CITY_TO values using wizard.
Now my requirement is to CONCATENATE this two values into a another attribute to display
Hi Yogesh,
If you do not have set attribute method in your code wizard then you need to some work around.
Just use read context method and after getting the code of read context. Just remove word IMPORTING and replace get_attribute with set_attribute
I hope it helps.
Regards,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI experts,
To set the attribute value I need to use code wizard. But in code wizard I have option to only Read attribute values. But I dint found option to set attribute values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yugesh ,
check if ur using ERP EnhP4 or otherwise u can directly set the values .
1 u read the context attribute using the code wizard CNTRL + F7
2 instead of get_attribute method , use set_attribute method
u can do it this way :
* set single attribute
lo_el_city->set_attribute(
EXPORTING
name = `CITY_CONCATENATION`
value = lv_city ).
I hope it wud help u .
regards,
amit
Hi ,
now this is a very simple task , most of the things u have to do thru code wizard
for reading context node and attributes using code wizard :
1 press CONTROL + F7
2 click on the radio button Read context node/ attribute
3 press F4
4 choose the attribute under ur context node, which u want to get/set using the wizard
for ur specific example u may do it like this way , :
get the attribute value for CITY_TO & CITY_FROM
DATA lo_nd_cn_city TYPE REF TO if_wd_context_node.
DATA lo_el_cn_city TYPE REF TO if_wd_context_element.
DATA ls_cn_city TYPE wd_this->element_cn_city .
DATA lv_city_to LIKE ls_city-city_to.
* navigate from <CONTEXT> to <CN_VISIBLE> via lead selection
lo_nd_city = wd_context->get_child_node( name = wd_this->wdctx_city_to ).
* get element via lead selection
lo_el_city = lo_nd_city->get_element( ).
* get single attribute
lo_el_city->get_attribute(
EXPORTING
name = `CITY_TO`
IMPORTING
value = lv_city_to ).
similarly read the context attribute CITY_FROM
now u wud be having ur value in two variables
lv_city_to & lv_city_from
do concatenation
DATA : lv_city type string.
concatenate lv_city_to lv_city_from into lv_city separated by space.
as u have already read the context node using the code wizard , u need not to run it again.
now simply read the context attribute CITY_CONCATENATE with value lv_city like this :
* set single attribute
lo_el_city->set_attribute(
EXPORTING
name = `CITY_CONCATEANTE`
IMPORTING
value = lv_city ).
I hope it wud help . try to play more with code wizard in WDABAP
refer this help as well :
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/3b/29933f09a5fb47e10000000a114084/content.htm
regards,
amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yugesh ,
Although a very simple process , I wud like to explain u thru steps , which may be easy for a beginner in WD ABAP to grasp.Proceed like this :
1 Make a context node and under this node ,say CITY make 3 attributes , say :
CITY_FROM , CITY_TO , CITY_CONCATENATE of type string
2 Now in ur method , in which u want to do the concatenation , make use of the code wizard.
3 firstly u have to obtain , what is the value in the attributes , CITY_FROM and CITY_TO . for this , u can get_attribute method of the node refrence if_wd_context_element .
4 u concatenate both the parameters , using the usual CONCATENATE ABAP statement
5 like ur get_attribute method , there is a method set_attribute , thru which u can set the value of a context attribute.
regards,
amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First get the value of both attributes in following way.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_city_from LIKE ls_context-city_from.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `CITY_FROM`
IMPORTING
value = lv_city_from ).
DATA lv_city_to LIKE ls_context-city_to.
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `CITY_TO`
IMPORTING
value = lv_city_to ).
then concatenate using following code.
DATA lv_attr1 LIKE ls_context-attr1.
CONCATENATE lv_city_from lv_city_to into lv_attr1 SEPARATED BY space.
then finally set it to the final attribute. to set attribute read attribute using code wizard and change get to set and remove word importing.
* set single attribute
lo_el_context->set_attribute(
EXPORTING
name = `ATTR1` " ATTR1 is the name of attribute.
value = lv_attr1 ).
I hope it helps.
Regards,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
please try to solve this yourself or look for related posts, this is fairly easy thing to do and you can do it with little research.
regards
manas dua
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.