cancel
Showing results for 
Search instead for 
Did you mean: 

abap code to update values in ztable

Former Member
0 Kudos

hi all,

i have created an webdynpro abap app in which i need to do two things:

1. create a button event which only upon click enables few inputtextfields and place the cursor on first one to make it editable

for which i need to enter the abap code

2.i want to update the values entered by user in those fields into my custom table and replace older values with this one

please guide me

i am very new to this and need your guidance

thanks and regards,

Manu

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

1. create a button event which only upon click enables few inputtextfields and place the cursor on first one to make it editable

>> Create an attribute in context of type WDY_BOOLEAN. Bind the readOnly property of the input fields to the created attribute, Now create an Action for the button and in onAction of the button enable/ disable the UI elements.

Check this wiki for reference:  http://wiki.sdn.sap.com/wiki/display/WDABAP/Simple+application+to+change+properties+of+UI+Elements+d...

2.i want to update the values entered by user in those fields into my custom table and replace older values with this one

>> Read the context attributes using get_attribute method of context node and update the data to data base.

Also please go through the basic tutorials here: http://scn.sap.com/docs/DOC-8863

Hope this helps u.,

Regards,

Kiran

Former Member
0 Kudos

hlo Kiran,

thanks for reply

i have binded the readonly property of all inputfields to  a new check attribute defined in context of both view and controller

and after that i refered to that link in which there is a method Method ONACTIONSHOW_HIDE

in this i don't know set_attribute_property is ?

pls highlight it a more so that i can write the exact code to run the application.

secondly,

i don't know how to Read the context attributes using get_attribute method of context node and update the data to data base.

reply soon

Thanks,

Manu

Former Member
0 Kudos

set_attribute_property is used to set property of attribute

following propert can be set

  1. visible value 1,
  2. required  value 2,
  3. read_only  value 3,
  4. enabled  value 4,

for get_attribute

click on wizard icon then click context button it display all your context node select your attribute from context node shown by wizard

there will be a radio button read (by deafult selected)

it will  automatically put code for  get_attribute

reward if helpful

former_member196213
Active Participant
0 Kudos

Hi Manu,

     Now as you have binded everything, its time to make all these things work together. Goto your onclick event ONACTION_SHOW_HIDE, Next to breakpoint buttons on TOP there is a button for wizard, click there and select set. Now browse through the context node and select the binded context. press ok. It will generate a code for you. All the code it generate could have been written manually but at starting its good to use these buttons.

    Make the value of your context node to abap_true. Ideally when we pass value directly to the fields property it is permanently implied to the fields. Now as we have binded input fields read only property to a contect attribute. We need to change the value of the context attribute based on click of button. Hence when we click on button ONACTION_SHOW_HIDE is called and inside that method we are setting the attribute to abap_false which will make the read only property of input field to false and your fields will be editable.

Now the situation is you can edit fields. To read and update these field you need another event. Say you have another button, wherein when you click it will save values. So for this we say we have even SAVE. Now goto your save event (or ONACTION_SAVE method).There again using the wizard select context attribute which you have binded to select read. Now collect all these values in your desired strucure and update into database directly as its a ztable.

Regards,

Vishal

Happy ABAPing

Answers (1)

Answers (1)

Former Member
0 Kudos

Updating a Z-table is just normal ABAP code that can be called from any method in the Web Dynpro. An exmaple will be the OnAction method of a save button. In general, DB updates should NOT be done in the Web Dynpro component directly. You should follow the guidelines of the MVC design pattern. It is OK to update the DB for testing or practice only.