cancel
Showing results for 
Search instead for 
Did you mean: 

problem in saving or update the data in the table

Former Member
0 Kudos

hi ,

i have created a button (save) and onaction event i have writen the code but when iam going tho edit the data or inserting the new data , it showing on the brouser but it is not sving into the data base

method onactionsave.

data:

lo_element type ref to if_wd_context_element,

lo_node type ref to if_wd_context_node.

lo_node = wd_context->get_child_node( name = 'your node name here' ).

lo_element = lo_node->create_element( ).

lo_node->bind_element( new_item = lo_element set_initial_elements = abap_false ).

endmethod.

suggest me the aswer or the code to update or save it into the database

thanks & regards...

sarfaraz

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

When you say not saving in the database are you trying to update a Data Dictionary Table? could you explain a bit more what you are tring to achieve

Regards

Carl

Former Member
0 Kudos

my requirement is that user can change the existing data and also fill the blank column i mean the missing one , which should be update in the data base

Former Member
0 Kudos

As long as the blank column is bound correctly to the context you should be able to read the data back out of the context and update the database.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sarfraz,

do in this way....

when you click buton save it will trigger the action event.In that method retrieve the data from table.

Check this code how to retrieve the data from table.

here i am giving my code. I am showing SFLIGHT details in my table check the below code.

data:
      node_sflight           type ref to if_wd_context_node,
      elem_sflight           type ref to if_wd_context_element,
      lt_elements            type WDR_CONTEXT_ELEMENT_SET,
      stru_sflight           type if_main=>element_sflight_node,
      it_flights             type if_main=>elements_sflight_node.

*   navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
    node_sflight_node = wd_context->get_child_node( name =
if_main=>wdctx_sflight_node ).

*   get element via lead selection
*    elem_sflight_node = node_sflight_node->get_element(  ).
     lt_elements = node_sflight->get_elements( ).

*   get all declared attributes
    loop at lt_elements into elem_sflight.
    elem_sflight->get_static_attributes(
      importing
        static_attributes = stru_sflight ).

    append stru_sflight to it_flights.
    endloop.

    modify ZSFLIGHT99 from table it_flights.
    if sy-subrc eq 0.

    endif.

Hope this will help you.

Thanks

Suman

Former Member
0 Kudos

Hello,

This occurs because you only updated the context, not the transparent table.

Try to recover the data from the context and then save it to the table.


DATA:
  lr_context TYPE REF TO if_wd_context_node,
  lt_table     TYPE <THE TABLE TYPE>.

lr_context = wd_context->get_child_node( name = <NODE_NAME> ).

lr_context->get_attributes_table( IMPORTING table = lt_table ).

MODIFY <TRANSPARENT TABLE> FROM TABLE lt_table.

Regards