cancel
Showing results for 
Search instead for 
Did you mean: 

Read avlue of input Field

Former Member
0 Kudos

Hello All,

I am new to web Dyn Pro. I have to read the value of the input Field on the click of button.

For that I creted a application. In the aplication a create a start view. In the layout of

start view I define two field one input field and other is button. And define inbound Plug

and the outbound Plug. In the context tab I create a node node1. In the node define an

attibute of type String.Then in the layout Bind the input field value with the context node

attibute. And also define the event on the onAction of the Button as onclick.And also drag

the view in the window.Now my requirement is to get the value of the input field on the

click on button in the onclick action.

PLease suggest me what code I have to write in the onAction to read the value of input Field

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Create a node in your context and declare an attribute of type string. Bind this attribute to the "value" property of your input field.

Once you enter a value in the input field and click the button, all you have to do is read the attribute value from the context. You can use the wizard to help you with the code.

Hope this helps.

Regards,

Nithya

Former Member
0 Kudos

Hello Nithya,

Thansk for your quick reply.

Can you please tell me What type of wizad is used to generate the code.

Points will be surely alloted,

Regards

Harpreet

Former Member
0 Kudos

Hi Harpeet,

Once you invoke the code wizard using Ctrl + F7, in the dialog window that pops up, just choose the option "Read context/node" and choose your context attribute.

Regards,

Ram

Former Member
0 Kudos

Hi Harpreet,

The wizard will be in your toolbar in object navigator. You can see it next to the "external breakpoint" icon.

Regards,

Nithya

Former Member
0 Kudos

Hello,

Thanks of your replies.

I used the first option Method used in current controller with my method ONACTIONON_CLICK.

It generate only following piece of code.

.


method ONACTIONON_CLICK .

  wd_this->onactionon_click(
    wdevent =                           " ref to cl_wd_custom_event
  ).


endmethod.

Regrads

Harpreet

Former Member
0 Kudos

Hi,

You have selected the option to fire an event. You should select the option "Read context node/attribute" in the wizard.

Then using F4 help, select the context which you want to read. You can directly select an attribute itself. Then the code will be generated. Go through some beginners tutorials which will probably help you with screenshots.

Regards,

Nithya

Former Member
0 Kudos

Hi Harpeet,

The option you have chosen is used to call a method. Since you have chosen an event handler method, you have to supply the formal parameters - which is not possible.

So, to read the attribute, use the read context/attribute option and select your attribute name.

Before this, you need to create an event handler for your button. This can be done by specifying a name in the 'OnAction' (under 'events') in the properties for the button. Once this is done, just double click on the method name to open the code editor for the event handler.

Once you are inside the event handler, you can use the code wizard to read the value.

Regards,

Ram

Former Member
0 Kudos

hi.

you can find an example how to read the context in this wiki:

https://wiki.sdn.sap.com/wiki/display/WDABAP/Context

Cheers,

Sascha

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks a lot Nithya. I have assign you ful points.

Now I have another query I have to go to the next page and passing the value of the inputfield in the next page.I will open a new thread for that.

Regards

Harpreet

Former Member
0 Kudos

Hi Harpeet,

You can use the code wizarrd (ctrl + F7) to read the context attribute that you have bound to the input field.

Regards,

Ram