cancel
Showing results for 
Search instead for 
Did you mean: 

how to add multiple records in table while submit the form with details

Former Member
0 Kudos

Hi all

how to add multiple records in a table while submitting the form with the details.

for every submit i need to store one record in table. if submit second time onwards then table contains previous all record details along with current record details...

can any body send the sample code on the same?

Regards

Sunil

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

I had worked on same requirement, It is simple just use ArrayLIst. I also answered same question in the earlier thread also.Hope this fullfills your requirement.

Let Assume you have three fields Number,Name and Marks. You want to take input of three fields in Form from User and show all the appended values in Table. The following is sample code for that

1) //Declare a ArrayList in Public Part

//@@begin others

ArrayList list=new ArrayList();

//@@end

2) // Under your Action Button do the following code

public void onActionupdate(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionupdate(ServerEvent)

//Create an Element of node that is pointed to table on each action.

IPrivateExcelviw.IAbcElement ele = wdContext.createAbcElement();

//set the values to your table element getting values from form node

ele.setNo(wdContext.currentAbcElement().getNo());

ele.setName(wdContext.currentAbcElement().getName());

ele.setMarks(wdContext.currentAbcElement().getMarks());

//Add the element to the ArrayList

list.add(ele);

//Invalidate the Form node such that the values in Form will be cleared

wdContext.nodeAbc().invalidate();

//Bind ArrayList to the node that is pointed to Table UI wdContext.nodeAbc().bind(list);

//@@end

}

Here in this example I had used only one node (ABC) for both Form and Table element. Hope you understand this and your requirement is solved. Revert me if you need any clarifications on this.

Regards

Raghu

Former Member
0 Kudos

I have just replied to similar question few minutes ago check it out:

regards,

Jawed Ali

former_member192434
Active Contributor
0 Kudos

Hi Suresh,

first you need to put all input data into the any collection object(ArrayList) and then base on the no of recoreds you have in collection, you can iterate it into the table

Thanks

Former Member
0 Kudos

hi!

this is a sample code to add records in table.

//create node

IPrivateSDNView.ITableDataNode node = wdContext.nodeTableData();

IPrivateSDNView.ITableDataElement ele = null;

//iterate through table

for(int i=0;i<tableRecords.length;i++)

{

//create table element

ele = node.createTableDataElement();

// set your data to all attributes

ele.setId();

//add element

node.addElement(ele);

}

Former Member
0 Kudos

Hi,

You might have got a table for your input wherein you are setting your parameters. Just keep on adding using the addElement() method the number of records that you want to submit.

Regards,

Murtuza