cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert a record in perticular position in the table

Former Member
0 Kudos

HI,

I have a dynamic table.I want to insert records of my own in specifil position(not at the END) say position -->11.How to insert in the table.

I tried with this code.My record is inserting perfectly.But its inserting the next record of the original table (12th position ) two times which should not happen.

Please see if I am wrong in this code:-

..................

IPrivateExportexView.IEt_Writeoff1Element bapi1stElement=null;

for(int p = 0;p < wdContext.nodeEt_Writeoff1().size(); p++){

if(p==11){ // I want to insert the record at position-->11

bapi1stElement = bapiNode.createEt_Writeoff1Element(new Zfrm_Writeoff_P());

bapi1stElement.setZzbusunit_D("##");// I m setting the value here

bapiNode.addElement(p,bapi1stElement);// I am inserting the record here

}

....................

Please suggest me.

Regards

-Sandip

Accepted Solutions (1)

Accepted Solutions (1)

former_member201361
Active Contributor
0 Kudos

hi,

To Insert the data in the particular row we should ensure that the the previous rows are filled.

For eg : if in a table we have only three rows , we want to insert the data in the 11th row then we have to fill the rows with empty values till 10th row and in the 11 th we can insert the data in the table .

Thanks and regards

Fistae

Edited by: Fistae on May 2, 2008 1:41 PM

Former Member
0 Kudos

HI,

I have total 70 records in my table.

I want to inset at a perticular position in the table.

Can u please tell me how to insert without any error.

Is there any error in my insertion code above?

I am fetching the data for the table from Et_Writeoff1 node.

Please suggest with sample code.

Regards

-Sandip

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I am assuming no other code inside the for loop. if that is the case, you can directly insert the element at the specified position but make a check for the size. You dont

need any "for" loop in this case. I checked locally for this scenario, I am not getting any duplicates. If you have any other code in the for loop, may be that other code is effecting the 12th record. If you have that other code, show me that code. I will check that again.

Kiran

former_member201361
Active Contributor
0 Kudos

hi,

In the Above code, u are executing the model for populating the table . but the datas are populated properly in the table and again when the if condition is true the data is fed again to the Table.

use this code:

IPrivateExportexView.IEt_Writeoff1Element bapi1stElement=null;

for(int p = 0;p < wdContext.nodeEt_Writeoff1().size(); p++){

if(p==11){ // I want to insert the record at position-->11

bapi1stElement = bapiNode.createEt_Writeoff1Element(new Zfrm_Writeoff_P());

bapi1stElement.setZzbusunit_D("##");// I m setting the value here

bapiNode.addElement(p,bapi1stElement);// I am inserting the record here

}

else{

set the values to empty or null

}

}

but i want to know whether u want to insert omly one table record or the whole data from the model to the table.

Thanks and regards

Fistae

Former Member
0 Kudos

Hi,

No actually I want to insert my records in the selected position of the table.Depending on the if () condition I want to insert the records.It may be one record or it may be more then one record.

Please suggest.

Regards

-Sandip

former_member201361
Active Contributor
0 Kudos

hi,

U can check the context attribute value.

if ((WDContext.currentURContextElement.geturAttribute =="" ) & p=11){

}

I think now u can insert the record based on ur Data.(Data Check is mandatory).

Thanks and regards

Fistae