on 05-27-2009 5:15 AM
hi all,
Many thanks to all ur answers in advance.
Is it possible to create a node programmatically instead of creating a node in Component controller using GUI.
If so please let me know the code.
Hi,
Following code will add the child node "FLIGHT" to the context root node.
like wise, you can also create the context attributes. Use the if_wd_context_node_info to define the metadata of the node.
DATA lo_nd_info_root TYPE REF TO if_wd_context_node_info.
DATA lo_nd_info_flights TYPE REF TO if_wd_context_node_info.
lo_nd_info_root = wd_context->get_node_info( ).
CALL METHOD lo_nd_info_root->add_new_child_node
EXPORTING
name = 'FLIGHTS'
is_mandatory = ABAP_FALSE
is_mandatory_selection = ABAP_FALSE
is_multiple = ABAP_TRUE
is_multiple_selection = ABAP_FALSE
receiving
child_node_info = lo_nd_info_flights
.
Thanks,
Rahul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is another method of doing the same where we create the attributes individually:
DATA: lr_root_info TYPE REF TO if_wd_context_node_info,
lr_flights_info TYPE REF TO if_wd_context_node_info,
lr_bookings_info TYPE REF TO if_wd_context_node_info,
lv_attribute TYPE wdr_context_attribute_info.
* get meta data info of root context node
lr_root_info = wd_context->get_node_info( ).
* First define node then define attribute by attribute
* create node with name 'FLIGHTS' (without attributes)
CALL METHOD lr_root_info->add_new_child_node
EXPORTING name = 'FLIGHTS'
is_mandatory = abap_true
is_mandatory_selection = abap_false
is_multiple = abap_false
is_multiple_selection = abap_false
is_singleton = abap_true
is_initialize_lead_selection = abap_true
is_static = abap_false
RECEIVING child_node_info = lr_flights_info.
* define attribute CARRID
lv_attribute-name = 'CARRID'.
lv_attribute-type_name = 'S_CARR_ID'.
lv_attribute-value_help_mode = '0'.
CALL METHOD lr_flights_info->add_attribute
EXPORTING attribute_info = lv_attribute.
* define attribute CONNID
lv_attribute-name = 'CONNID'.
lv_attribute-type_name = 'S_CONN_ID'.
lv_attribute-value_help_mode = '0'.
CALL METHOD lr_flights_info->add_attribute
EXPORTING attribute_info = lv_attribute.
* define attribute fldate
lv_attribute-name = 'FLDATE'.
lv_attribute-type_name = 'S_DATE'.
CALL METHOD lr_flights_info->add_attribute
EXPORTING attribute_info = lv_attribute.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jagadeeshan,
Yes its quite possible to create a node & its attributes dynamically. Just go through the code snippets below:
Regards,
Uday
DATA: lr_root_info TYPE REF TO if_wd_context_node_info,
lr_flights_info TYPE REF TO if_wd_context_node_info.
* get meta data info of root context node
lr_root_info = wd_context->get_node_info( ).
************* Define node and all attributes in one step ********************
* create node with name 'FLIGHTS' of DDIC type SFIGHT
* this will also create attributes for all fields of structure SFLIGHT!
* IS_STATIC = ABAP_FALSE: This node can be deleted at runtime
* Cardinality: 1:1
* Selection Cardinality: 0:n
CALL METHOD lr_root_info->add_new_child_node
EXPORTING STATIC_ELEMENT_TYPE = 'SFLIGHT'
name = 'FLIGHTS'
IS_MANDATORY = ABAP_TRUE
IS_MANDATORY_SELECTION = ABAP_FALSE
IS_MULTIPLE = ABAP_FALSE
IS_MULTIPLE_SELECTION = ABAP_TRUE
IS_SINGLETON = ABAP_TRUE
IS_INITIALIZE_LEAD_SELECTION = ABAP_TRUE
receiving child_node_info = lr_flights_info.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Senthil,
Yes, it is possible to create a node and its attributes dynamically or to say programatically.
DATA:
* Node Info
rootnode_info TYPE REF TO if_wd_context_node_info,
* Context Nodes
dyn_node TYPE REF TO if_wd_context_node,
tabname_node TYPE REF TO if_wd_context_node,
* String (for table name)
tablename TYPE string.
* get node info of context root node
rootnode_info = wd_context->get_node_info( ).
* Get the name of the table to be created
tabname_node = wd_context->get_child_node( name = 'INPUT' ).
tabname_node->get_attribute( EXPORTING name = 'TABLENAME'
IMPORTING value = tablename ).
TRANSLATE tablename TO UPPER CASE.
* create sub node named TEST1 of structure (tablename)
cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
parent_info = rootnode_info
node_name = tablename
structure_name = tablename
is_multiple = abap_true ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check this tutorial, it will give you an idea
[https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4c70444a-0801-0010-7688-9e4bd844b783]
Hope it helps!
Regards,
Radhika.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the method ADD_NEW_CHILD_NODE in IF_WD_CONTEXT_NODE_INFO helps to add a new child node to a parent node
Plz hk this link:
http://help.sap.com/saphelp_nw04s/helpdata/en/af/cb744176cb127de10000000a155106/frameset.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.