cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Basics

Former Member
0 Kudos

Hi Experts,

I am new to webdynpro abap and can anyone please tell me how to hardcode values to a  node ?

Thanks in advance.

Regards,

Murali Krishnan.

Accepted Solutions (0)

Answers (3)

Answers (3)

ramakrishnappa
Active Contributor
0 Kudos

Hi Murali,



Murali Krishnan wrote:

I am new to webdynpro abap and can anyone please tell me how to hardcode values to a  node ?

Do you mean, you need to set the data to context node ? If so, use code wizard as suggested by Mr. Chandra

We can set the data to context attribute/element/node as below


data lo_node type ref to if_wd_context_node.

data lo_element type ref to if_wd_context_element.

data ls_data           type wd_this->element_YOUR_NODE_NAME.

data lt_data            type wd_this->elements_YOUR_NODE_NAME.

lo_node = wd_context->get_child_node( name = 'YOUR_NODE_NAME').

lo_element = lo_node->get_element( ). " Note: it gets you the element reference based on lead selection

"Set data to a context attribute

lo_element->set_attribute(

     exporting

          name = 'ATTRIBUTE_NAME'

          value = 'MY_VALUE' ).

" Set data to all context attributes of a context element

lo_element->set_static_attributes(

                    value = ls_data ).

" Set data to context node

lo_node->bind_table(

     new_items = lt_data ).

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

data lo_node type ref to if_wd_context_node.

data lo_element type ref to if_wd_context_element.

data ls_data           type wd_this->element_YOUR_NODE_NAME.

data lt_data            type wd_this->elements_YOUR_NODE_NAME.

Can you please explain about this declaration part?

Thanks in advance.

Regards,

Murali Krishnan N

Former Member
0 Kudos

type wd_this->element_YOUR_NODE_NAME.

'YOUR_NODE_NAME'--> This is your node name...

Former Member
0 Kudos

lets say node name (demo_node) attribute name (name) type 'string'.

 

DATA lo_nd_demo_node TYPE REF TO if_wd_context_node.

  DATA lo_el_demo_node TYPE REF TO if_wd_context_element.

  DATA ls_demo_node TYPE wd_this->element_demo_node.

  DATA lv_name TYPE wd_this->element_demo_node-name.

ramakrishnappa
Active Contributor
0 Kudos

Hi Murali,

Please find my explanation as below


data lo_node type ref to if_wd_context_node." lo_node is object reference to context node

data lo_element type ref to if_wd_context_element. " lo_element is object reference to context element

data ls_data           type wd_this->element_YOUR_NODE_NAME. " ls_data is work area, which contains single instance of your node

data lt_data            type wd_this->elements_YOUR_NODE_NAME." lt_data is an internal table, which contains up to 'N" instances

Let us say you have created a context node "TEST_NODE"... then declaration part for work area and internal table is as follows

data ls_data           type wd_this->element_TEST_NODE."work area

data lt_data           type wd_this->elements_TEST_NODE." internal table

Regards,

Rama

Former Member
0 Kudos

Also what is the difference between instance and element?

Thanks in advance.

Regards,

Murali Krishnan N

ramakrishnappa
Active Contributor
0 Kudos

Hi Murali,

Here, context element is an instance of context node.

Please go through the below link for more info on cardinality

Context Node: Properties (SAP Library - Web Dynpro for ABAP)

Hope this helps you in understanding the concept.

Regards,

Rama

former_member222068
Active Participant
0 Kudos

Hi Murali,

As a beginner i recommend you to use the below link for reference of Web Dynpro ABAP basic applications.

http://scn.sap.com/docs/DOC-8863

Thanks & Regards,

Sankar Gelivi

Former Member
0 Kudos

Create the node and attribute, lets say node name (demo_node) attribute name (name) type 'string'.

Just use the code wizard by "set context" functionality....

Select the attribute and ok.. Following code will come automatically. 

DATA lo_nd_demo_node TYPE REF TO if_wd_context_node.

  DATA lo_el_demo_node TYPE REF TO if_wd_context_element.

  DATA ls_demo_node TYPE wd_this->element_demo_node.

  DATA lv_name TYPE wd_this->element_demo_node-name.

  lo_nd_demo_node = wd_context->get_child_node( name = wd_this->wdctx_demo_node ).

  lo_el_demo_node = lo_nd_demo_node->get_element( ).

  lo_el_demo_node->set_attribute(

    name =  `NAME`

    VALUE = lv_name).

" Now you write your own value in the lv_name before calling set_attribute name...

lv_name = 'Murali'.  " Provide the compatible value..

  lo_el_demo_node->set_attribute(

    name =  `NAME`

    VALUE = lv_name).