cancel
Showing results for 
Search instead for 
Did you mean: 

How to assign a value to Component controller node

Former Member
0 Kudos

Hi Experts,

Suppose, I'm getting the pernr & ename from pa0001 by using select statement...... and now

What my question is how to assign the values of pernr & ename to the component nodes of attribute..

Please, give me the details...

Regards,

J.Pavan.

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

suppose you have created a node PA_ND1 in the compcontroller

which has these two fields

map the node to one node in the view also

where you want to fill the attributes.

then

write the code like below for the requirement.

data nd type ref to if_wd_context_node.
nd = wd_context->get_child_node( 'PA_ND1' ).
data ls_pa_nd1 type wd_this->element_pa_nd1.


select *  from pa0001 into CORRESPONDING FIELDS OF ls_pa_nd1 where  pernr = '00000003'.
endselect.
nd->bind_structure( ls_pa_nd1 ).

and for this

Hi sarbjeet singh,

I'm using the following code to get the pernr & ename
now i want to assign the pernr & ename in my node of attribute * l_pernr & l_ename. *
now you tell me what to do???

DATA: gv_pernr TYPE persno,
gv_ename type EMNAM,
lt_ee_tab TYPE TABLE OF pernr_us,
ls_ee_tab TYPE pernr_us.

SELECT SINGLE pernr FROM pa0105 INTO gv_pernr
WHERE usrty EQ '0001' AND
usrid EQ sy-uname AND
begda LE sy-datum AND
endda GE sy-datum.

select single ename from pa0001 into gv_ename
WHERE pernr EQ gv_pernr AND
begda LE sy-datum AND
endda GE sy-datum.

Regards,
J.Pavan.

data nd type ref to if_wd_context_node.
nd = wd_context->get_child_node( 'PA_ND1' ).

nd->set_attribute(
name = 'l_pernr '
value =  gv_pernr

)
nd->set_attribute(
name = ' l_ename'
value = gv_ename

)

thanks

sarbjeet singh

Answers (1)

Answers (1)

gill367
Active Contributor
0 Kudos

Hi

Use set_attribute method fo the context node to set the value of the attribute.

have you got the values in an internal table.

loop on this and then you can either directly fill the node by using the bind_table( ) method of the node .

or you can fill it one by one .

thanks

sarbjeet singh

Former Member
0 Kudos

Thanks for reply,

No, am not taking the internal table am just taking an variable that should be assign to the node of attribute.

because pernr and ename should be automatically populated to the input field of UI element that's the reason am taling the variable.

Is that set attribute method and bind method is enough are any methods should i call???

Regards,

J.Pavan.

Former Member
0 Kudos

Hi Venkat,

Using SET_ATTRIBUTE you can set values to attributes.. for single attribute

lo_el_current->set_attribute(

name = `EMP_NAME`

value = lv_emp_name ).

If you want to set values to all attributes.. use .. // for table(list of values ) use bind_table

  • set all declared attributes

lo_el_new->set_static_attributes(

static_attributes = ls_new ).

node->bind_table( lt_new ).

Chers,

Kris.

Edited by: kissnas on May 17, 2011 11:52 AM

gill367
Active Contributor
0 Kudos

Set_attribute is more than enough for it.

you just need to bind those context attributes to the input field

then populate the attirbute by using the set_attribute method .

this will automatically show the value in the input field also.

thanks

sarbjeet singh

Former Member
0 Kudos

Thanks for reply,

If you don't mind can you please tell clearly i mean with example...

please

Regards,

J.Pavan.

Former Member
0 Kudos

Hi Venkat

This is simple Example based on perner iam retriving name and position. and i am setting this valeus to some attributes.

Check the example code..

DATA lo_nd_input TYPE REF TO if_wd_context_node.

DATA lo_el_input TYPE REF TO if_wd_context_element.

DATA ls_input TYPE wd_this->element_input.

DATA lv_pernr TYPE wd_this->element_input-pernr.

  • navigate from <CONTEXT> to <INPUT> via lead selection

lo_nd_input = wd_context->get_child_node( name =

wd_this->wdctx_input ).

  • get element via lead selection

lo_el_input = lo_nd_input->get_element( ).

  • set single attribute

lo_el_input->get_attribute(

EXPORTING

name = `PERNR`

IMPORTING

value = lv_pernr ).

select single ename

into lv_ename

from pa0001

where pernr = lv_pernr.

select single plans

into lv_pos

from pa0001

where pernr = lv_pernr.

lo_el_current->set_attribute(

name = `EMP_GRP`

value = lv_ename).

lo_el_current->set_attribute(

name = `EMP_SUB_GRP`

value = lv_pos).

Cheers,

Kris.

Former Member
0 Kudos

Hi sarbjeet singh,

I'm using the following code to get the pernr & ename

now i want to assign the pernr & ename in my node of attribute * l_pernr & l_ename. *

now you tell me what to do???

DATA: gv_pernr TYPE persno,

gv_ename type EMNAM,

lt_ee_tab TYPE TABLE OF pernr_us,

ls_ee_tab TYPE pernr_us.

SELECT SINGLE pernr FROM pa0105 INTO gv_pernr

WHERE usrty EQ '0001' AND

usrid EQ sy-uname AND

begda LE sy-datum AND

endda GE sy-datum.

select single ename from pa0001 into gv_ename

WHERE pernr EQ gv_pernr AND

begda LE sy-datum AND

endda GE sy-datum.

Regards,

J.Pavan.

Former Member
0 Kudos

Hi Venkat,

// Read your node here.. which contains pernr and ename attributes.. and this code after that.

DATA: gv_pernr TYPE persno,

gv_ename type EMNAM,

lt_ee_tab TYPE TABLE OF pernr_us,

ls_ee_tab TYPE pernr_us.

SELECT SINGLE pernr FROM pa0105 INTO gv_pernr

WHERE usrty EQ '0001' AND

usrid EQ sy-uname AND

begda LE sy-datum AND

endda GE sy-datum.

select single ename from pa0001 into gv_ename

WHERE pernr EQ gv_pernr AND

begda LE sy-datum AND

endda GE sy-datum.

lo_el_current->set_attribute( // instead of lo_el_current give your element name

name = `PERNR`

value = lv_pernr).

lo_el_current->set_attribute(

name = `NAME`

value = lv_name).

cheers,

Kris.