on 10-17-2008 6:30 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.