Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to add multiple records in table thru form via Submit button

Hi all

i have small requirement as follows.

i have a view in which i have 3 UI elements one is webdynpro form,Table UI element and third one is submit button.

now at runtime when i will enter the details in the form and click on the submit button then those record details has been stored in Table. then next time again when i submit the form with details then the table contains all records of current and existing ...so table has to maintain mutile records thru form via submit form..

i need sample code on the same.

points are always rewardable

Thanks

Sunil

replied

Assume you have three fields in the form: Name, dob and address

First define your context:

at root context: create three attributes

name of type string

dob of type date

address of type string

now for table you must create a node name tNode and copy the same attributes into tNode.

your context should look like this:

context
  + name
  + dob
  + address
  + tNode
      + name
      + dob
      + address

I hope you know how to map context attributes to the table and form elements. now you can put following code in your submit button action:

	IPrivate<your view name>.ITNodeElement item = wdContext.createTNodeElement();
		
	item.setName(wdContext.currentContextElement().getName());
	item.setDob(wdContext.currentContextElement().getDob());
	item.setAddress(wdContext.currentContextElement().getAddress());

	wdContext.nodeTNode().addElement(item);

	//This will clear your form data
	wdContext.currentContextElement().setName("");
	wdContext.currentContextElement().setDob(null);
	wdContext.currentContextElement().setAddress("");

;

This will show records into UI table as you insert them.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question