cancel
Showing results for 
Search instead for 
Did you mean: 

How to SET a value to an attribute usibng WIZARD?

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member40425
Contributor
0 Kudos

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

Answers (5)

Answers (5)

Former Member
0 Kudos

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.

Former Member
0 Kudos

With Enhancement Pack 4 onwards , you do have option for Set in Code Wizard.

So please check the EHP on which you are working. It must be lower than 4.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

former_member40425
Contributor
0 Kudos

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

Former Member
0 Kudos

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