cancel
Showing results for 
Search instead for 
Did you mean: 

difference of Set_Atribute and get_Attribute

Former Member
0 Kudos

Hi ,

Please let me know what is difference of Set_Atribute and get_Attribute ?

Thanks,

Asha

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Thanks

Former Member
0 Kudos

Hi,

it's a really tough one, I'd propose you go and have a look at some SAP Notes, or rather open OSS ticket. Probably SAP developers may help here.

regards

Stefan

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi,

>

> it's a really tough one, I'd propose you go and have a look at some SAP Notes, or rather open OSS ticket. Probably SAP developers may help here.

>

> regards

> Stefan

I believe that Stefan was joking (please tell me you were joking). Please do not actually open an OSS ticket asking what the difference between SET and GET attribute is.

Former Member
0 Kudos

HAI ,

The major difference between the get_attribute and the set_attribute is

get_attributes:

if u need to assign a value or else compare the value with that corresponding attribute which u define in the node.

for example if u want to check whether the user name and the password are correct or not which are as follows :

lo_el_cn_username->get_attribute(

EXPORTING

name = `username`

IMPORTING

value = lv_username).

lo_el_cn_password->get_attribute(

EXPORTING

name = `password`

IMPORTING

value = lv_password).

if lv_username = 'SAP' and lv_password = 'WEBDYNPROABAP'.

MESSAGE S888(SABAP) WITH 'LOGIN SUCCESSFUL'.

endif.

Set_attributes:

if u want to change the characteristics of the particular attribute for ex to change the value of that attribute \

we can use the set_attribute

for example

lo_el_cn_password->Set_attribute(

EXPORTING

name = `password`

IMPORTING

value = ''ABAPWEBDYNPRO').

HERE i just hard cored the value to the attribute password as abapwebdynpro.

This s the difference betwenn set attribute and get attribute.ope

With Reagrds,

R.Dhinesh Raj.

Former Member
0 Kudos

Hi Asha,

The name even suggests you the meaning and difference.

SET_ATTRIBUTE : This method is used to set the values to the context attributes.

For Eg: Consider you have a node MARA in your context and it has got an attribute 'MATNR'.

now you retrived the MATNR value into l_matnr .

SELECT SINGLE MATNR INTO L_MATNR FROM MARA.

And now you want to set this value to the context attribute MATNR.

  • set single attribute

lo_el_mara->set_attribute(

exporting

name = `MATNR`

value = l_matnr).

GET ATTRIBUTE : This method is used to retrive the value of the context node attribute.

For Eg:

Now you want to retrive the context attribute MATNR value into lv_matnr and now you use GET_ATTRIBUTE.

  • get single attribute

lo_el_mara->get_attribute(

exporting

name = `MATNR`

importing

value = lv_matnr ).

I hope you understood from this example.

Regards

Madhu

Edited by: Madhavi Latha Puchakayala on Jan 20, 2009 6:15 AM

pranav_nagpal2
Contributor
0 Kudos

Hi Asha,

Get Attribute is basically to get data from context attribute in a variable....

see the code below.... i am getting value from context attribute CA_PERNR to a variable lv_ca_pernr

lo_el_cn_pernr->get_attribute(
    EXPORTING
      name =  `CA_PERNR`
    IMPORTING
      value = lv_ca_pernr ).

Set attribute is basically to set the value in a particular context attribute from a variable...

see the code below for example.....

lo_el_cn_pernr->set_attribute(
    EXPORTING
      name =  `CA_PERNR`
      value = lv_ca_pernr ).

regards

Pranav

Former Member
0 Kudos

Hi,

Set Attribute :

It is for setting an element or value for the attribute. Just export the value and name of the attribute for setting the value. u can also use the lead selection which automatically refer to the attribute in the context node or use the user defined lead selection by calling SET_LEAD_SELECTION_INDEX( INDEX = ). method before u setting the attribute.

Get Attribute :

It is for getting the values which is stored in the attribute of the context node by exporting the name of the attribute and import the value of the attribute. The value of the attribute which u getting should be type specific. use lead selection for getting the value quickly.

Regards,

Ragu.

arjun_thakur
Active Contributor
0 Kudos

Hi Asha,

Set_attribute method is used to set a value in an context attribute. It has 2 importing parameters: 'name' : name of the attribute and 'value': value that you want to assign to that attribute. The value which you pass should be compatible with the attribute type.

get_attribute method is used to read the value of any attribute. It has 1 importing parameter: 'name' : name of attribute and 1 exporting parameter: 'value': value of that attribute. This method retrieves the value of an attribute and save it in a variable.

The coding for both the methods you can get with the help of code wizard.

I hope it helps.

Regards

Arjun