cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding setting value to element of node through Field symbol.

Former Member
0 Kudos

Hi

I have a situaton in which the context of view have Node in which many subnode is there and the main node also have attribute. For sub node i can directly use bind element and bind value thru field symbol but for Attribute of main node I can get the refernece of attribute but i am not able to set attribute value using field symbols.Is ther any way where i can pass or bind the attribute with value from field symbol.

Regards

Dhiraj

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Sasha,

CALL METHOD ELEM_Z_BAPI_PO_SEARCH->SET_ATTRIBUTE

EXPORTING

VALUE = <fs>

NAME = `I_CREATED_BY`.

The Type of VALUE is 'DATA'

and type of Name is 'String'.

Former Member
0 Kudos

Hi Dhiraj.

Sorry, what I mean is what is the type of the field 'I_CREATED_BY' in the context element itself. I am just wondering whether you are trying to set table to a simple data type.

Cheers,

Sascha

Former Member
0 Kudos

Hi,

The Datatype is ERNAM in Context Element.

The procedure through Selection option screen the value will be populated in Range table

In one of the method i will get range table which will be in Type ref data form.

This range table i will assign to Field symbol which is of type Table. Then i am trying to Set attribute of element through this Field Symbol as follow

CALL METHOD ELEM_Z_BAPI_PO_SEARCH->SET_ATTRIBUTE

EXPORTING

VALUE = <fs_rangetab>

NAME = `I_CREATED_BY`.

Regards

Dhiraj

Former Member
0 Kudos

Hi Dhiraj.

Then you have to get the value from the range table first.

You cannot assign a range table to the field ernam. Thats why the system throws

the error.


data: lr_selfield         type ref to data.
data: ls_range          TYPE rsparams.
field-symbols:
                    <fs_range>       TYPE ANY.

ASSIGN lr_selfield->* TO <fs_rangetable>.
CREATE DATA lr_headerline LIKE LINE OF  <fs_rangetable>.
ASSIGN lr_headerline->* TO <fs_range>.
READ TABLE <fs_rangetable> INTO <fs_range> INDEX 1.
MOVE-CORRESPONDING  <fs_range> TO ls_range.

CALL METHOD ELEM_Z_BAPI_PO_SEARCH->SET_ATTRIBUTE
EXPORTING
VALUE = ls_range-low
NAME = `I_CREATED_BY`.

But if you need to bind the complete range table you should change to attributes type to the range table type.

Hope thsi helps a bit. Could be that there is a better solution for this.

Cheers,

Sascha

former_member215843
Active Participant
0 Kudos

Hi Dhiraj,

Could you please add a piece of coding to demonstrate what you want to do?

Ciao, Regina

former_member196517
Contributor
0 Kudos

Hi Dhiraj,

for every node you select the framework passes a string to your method which contains a path of node (internal use), if you try PATH_GET_ELEMENT method afterwards to get reference of node then you can do whatever you have asked for..

in your action handler add one parameter lc_path and then try using this...

element = wd_context->path_get_element( lc_path ).

  • navigate from <ENTRIES> to <SUB_ENTRIES> via lead selection

node_sub_entries = element->get_child_node( name = 'SUB_ENTRIES' ).

or even attributes.

thanks

Anuj

Former Member
0 Kudos

Hi Anuj,

I got thelement but now i ant to set attribute to that element throught field symbol

which is not happening .Is there any way where i can type cast in Assign and use it to set the attribute.

Former Member
0 Kudos

Hi Dhiraj.

You can use field symbols. Just use the method setAttribue of context element.

This works fine for me.


node_labels = wd_context->get_child_node( name = if_v_orderlist=>wdctx_labels ).
  elem_labels = node_labels->get_element(  ).
  elem_labels->set_attribute(
    EXPORTING
      name =  `ITEM_TABLE_TITLE`
      value = <fs> ).

Cheers,

Sascha

Former Member
0 Kudos

field symbols work.

The original field sybol is type any and typed from attribute.

The type info on attribute can be read from if_wd_context_node_info if requried.

regards

Phil.

Sample that works below


method WDDOINIT .
    FIELD-SYMBOLS <f1> type any.

    DATA:
      node_n1                             TYPE REF TO if_wd_context_node,
      elem_n1                             TYPE REF TO if_wd_context_element,
      stru_n1                             TYPE wd_this->element_n1 ,
      item_a1                             LIKE stru_n1-a1.
*   navigate from <CONTEXT> to <N1> via lead selection
    node_n1 = wd_context->get_child_node( name = wd_this->wdctx_n1 ).

*   get element via lead selection
    elem_n1 = node_n1->get_element(  ).

*   get single attribute
    elem_n1->get_attribute(
      EXPORTING
        name =  `A1`
      IMPORTING
        value = item_a1 ).

ASSIGN item_a1 to <f1>.

<f1> = 'in she goes'.
 elem_n1->set_attribute(
      EXPORTING
        name =  `A1`
        value = <F1> ).

endmethod.

Former Member
0 Kudos

Hi Sascha,

I did the same thing but still iam gettin error. The error is telling abt mismatch in Type . Is ther eany other way.

Thanks & Regards

Dhiraj

Former Member
0 Kudos

Hi.

Then you are transfering the wrong type. what is the type of the attribute and what

is the type you assigned to the field symbol? Please post your code.

Cheers,

Sascha

Former Member
0 Kudos

Hi Sascha,

The Field Symbol Type is table and pasing this field symbol in

CALL METHOD ELEM_Z_BAPI_PO_SEARCH->SET_ATTRIBUTE

EXPORTING

VALUE = <fs>

NAME = `I_CREATED_BY`.

In sysntax no error is there but in runtime its giving error

Former Member
0 Kudos

What is they type of I_CREATED_BY? Sounds like a simple data type.

Former Member
0 Kudos

Hi Dhiraj ,

If I_CREATED_BY is not defined as table type, then your field-symbol should not be table type .

Regards

Saurabh