2013 Oct 22 9:06 AM
is it possible to assign a default value to a given attribute of a node instance upon creation?
e.g. when a new instance of a node is created, i always want an attribute to contain a certain default value...
cheers
--MIKE
2013 Oct 22 9:31 AM
Hi Mike,
you can create a determination which is triggered on create. In this determination you can set values.
Cheers,
Martni
2013 Oct 22 11:56 AM
Which release? We are on SAP_BW_FND 7.31 SP 4 and i cannot see the trigger "on create"...
2013 Oct 22 8:18 PM
Hi Mike,
For Martins solution you need to set the request node on create and only on create:
And Then configure under node category assignement after modify (and also only after modify):
But for node default values there is a better approach provided: The node class
In the conf_ui you can configure a node class on node level:
There you can enter a class which implements the interface /BOBF/IF_FRW_NODE. This interface provides a method for setting node default values:
Kind Regards
Aiko
2013 Oct 23 9:14 AM
any ideas, why this code is not working?
data:
root_records type /sesi/t_mw_root,
root_record type ref to /sesi/s_mw_root.
io_read->retrieve( exporting iv_node = is_ctx-node_key
it_key = it_key
iv_fill_data = abap_true
importing et_data = root_records ).
loop at root_records reference into root_record.
root_record->state = 'A'.
io_modify->update( iv_node = is_ctx-node_key
iv_key = root_record->key
is_data = root_record ).
endloop.
the node instance is created, but attribute STATE remains initial...
2013 Oct 23 10:16 AM
yes, you have to declare which attributes you want to change.
Use the parameter IT_CHANGED_FIELDS of the update method for that.
2013 Oct 23 2:03 PM
thanks martin. doesnt work ... sorry...
data:
root_records type /sesi/t_mw_root,
root_record type ref to /sesi/s_mw_root,
changed_field type line of /bobf/t_frw_name,
changed_fields type /bobf/t_frw_name.
io_read->retrieve( exporting iv_node = is_ctx-node_key
it_key = it_key
iv_fill_data = abap_true
importing et_data = root_records ).
changed_field = 'STATE'.
insert changed_field into table changed_fields.
loop at root_records reference into root_record.
root_record->state = 'A'.
io_modify->update( iv_node = is_ctx-node_key
iv_key = root_record->key
is_data = root_record
it_changed_fields = changed_fields ).
endloop.
2013 Oct 24 9:04 AM
For me the code looks good at first sight.
But it is better to use the constants for the attribute names instead of a text literal.
There should be a generated constant interface for your business object and you can find the attributes there:
<constant interface of your BO>=>sc_node_attribute-root-state
2013 Oct 24 1:36 PM
I use the constant now, but it does not work... any other suggestions?
2013 Oct 24 3:20 PM
Which way did you choose? Via Determination or Node Class? Did you set a Break-Point in the code and checked, if he stopped there during creation of an instance?
2013 Oct 25 9:38 AM
I implemented a Node class. I can see that all this is running successfully in debugger, but unfortunately, nothing is really changed in the newly created node instance...