cancel
Showing results for 
Search instead for 
Did you mean: 

create new record in Table

Former Member
0 Kudos

Hi Experts,

I need a clarification regarding table settings, presetly I'm displaying a table with records in edit mode avaiable in data base, but user wants to create new records in the table. Please suggest me how to make create new record in table control.

Thanks & Regards

Sridhar

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank you Shruti Rathour , problem was solved.

Former Member
0 Kudos

Hi,

You can add an ADD button and enter the following code in its event handler method.

method onactionadditem .

data:

node_material type ref to if_wd_context_node,

elem_material type ref to if_wd_context_element,

stru_material type if_entry=>element_material .

/* navigate from <CONTEXT> to <MATERIAL> via lead selection */

node_material = wd_context->get_child_node( name = if_entry=>wdctx_material ).

/* get element via lead selection */

elem_material = node_material->get_element( ).

/* alternative access via index

Elem_Material = Node_Material->get_Element( Index = 1 ).

@TODO handle non existant child */

if ( elem_material is initial ).

call method node_material->create_element

receiving

element = elem_material

.

endif.

/* get all declared attributes */

elem_material->get_static_attributes(

importing

static_attributes = stru_material ).

call method node_material->bind_structure

exporting

new_item = stru_material

set_initial_elements = abap_false

.

endmethod.

Hope this will help.

Thanks

Shruti

abhimanyu_lagishetti7
Active Contributor
0 Kudos

put an add button and save button in the layout

in event handler of the add button , place the code

data: lr_node type ref to if_wd_context_node.

data: str_node type <context node type>.

data: lr_element type ref to if_wd_context_element.

lr_node = wd_context->get_child_node( '<node name>' ).

lr_element =

lr_node->bind_element( new_item = str_node set_initial_elements = abap_false ).

Abhi