on 04-28-2008 2:50 PM
Hi Experts,
I have a dynamic table which contains the column XXX in ascending order.
Means the table is sorted in ascending order.column XXX looks like this:-
column XXX (ascending order--Before incertiopn 6 record)
..........
A
A
A
B
B
C
............
my problem:- i have to group one perticular type(Say A) and at the end of the group,i have to insert my own record.After incertion the same table will look like this:
modified table:-
column XXX (ascending order--After incertion-8 records)
............
A
A
A
............
Gropup A ends here so Here My own record I have to incert
............
B
B
............
Gropup B ends here so Here My own record I have to incert
............
C
............
Gropup C ends here so Here My own record I have to incert
............
I tried doing this ,but some how its inserting multiple records.
......................................
My code:
....
int p=0;
bapi1stElement = bapiNode.getEt_Writeoff1ElementAt(p);
ref1= bapi1stElement.getAttributeAsText(column1Fieldname);//Take the first element as reference1
for(p =0; p < wdContext.nodeEt_Writeoff1().size(); ){
bapi2ndElement= bapiNode.getEt_Writeoff1ElementAt(p+1);//1
ref2= bapi2ndElement.getAttributeAsText(column1Fieldname);//Take the Second element as reference2
if(ref1.equalsIgnoreCase(ref2)){ // Compare the 2 element
//What is the value of ref 1 and Ref2
//msgMgr.reportSuccess("I m in IFFF");
//sumSubTotal = sumSubTotal.add(colreplace2);
} else{ //if they are not equal insert my record
//Add the element-->at position-p
sumElement = bapiNode.createEt_Writeoff1Element(new Zfrm_Writeoff_P());
sumElement.setStatus("$");
sumElement.setZzbusunit_D("##");
bapiNode.addElement(p,sumElement);
if(p+2 < wdContext.nodeEt_Writeoff1().size()){
//msgMgr.reportSuccess("I AM IN ELSE--Chk the size"+pindex);
bapi1stElement = bapiNode.getEt_Writeoff1ElementAt(p+2);//3
ref1= bapi1stElement.getAttributeAsText(column1Fieldname);
msgMgr.reportSuccess("I AM IN ELSE--Chk the REF1"+ref1);
p=p+2;
}
}
}//This is for loo
..............................................................
Please help with some code to group the similar column .
Regards
-Sandip
Hi Sandeep,
As your table is already in ascending order, you can use the control-break logic....
- Read the first element (i.e. column1 value) into say ActualVal.
- Copy it to some variable say Temp.
p=0
Start loop ex: while p<=nodesize
{
- Check if ActualVal and Temp are equal
- If they are equal do nothing --- (just move the pointer to next element i.e. increment P )
- If they are not equal
- Insert your row
p = p+2
- Read the current Elements Column1 Value into ActualVal.
- Copy the current Elements Column1 Value to Temp.
}//end of loop
regards
Ramesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI ,
I am using the same logic.Its separating the group properly.
But still its adding multiple table records when the grouping is finished.
Can u please chk if I am wrong some where:-
My code:-
My table name:-Et_Writeoff1
.............................
IPrivateExportexView.IEt_Writeoff1Node bapiNode = wdContext.nodeEt_Writeoff1();int p = 0;
String temp="";
bapi1stElement = bapiNode.getEt_Writeoff1ElementAt(p);
ref1= bapi1stElement.getAttributeAsText(column1Fieldname).trim();//First element
temp = ref1;//Put it in a veriable
for(p =0; p <wdContext.nodeEt_Writeoff1().size(); ){
if(temp.equalsIgnoreCase(ref1.trim())){
msgMgr.reportSuccess("The values are equal");
//do nothing
p=p+1;
bapi1stElement = bapiNode.getEt_Writeoff1ElementAt(p);
ref1= bapi1stElement.getAttributeAsText(column1Fieldname).trim();
}else{
//Insert the record at p
sumElement = bapiNode.createEt_Writeoff1Element(new Zfrm_Writeoff_P());//Is thisline creating Problem??
sumElement.setAttributeValue(column2,averageforSubtotal);
sumElement.setZzbusunit_D("**");
bapiNode.addElement(p,sumElement);//inserting in this Position
//Increase the counter
p=p+2;
newElement = bapiNode.getEt_Writeoff1ElementAt(p);
ref1= newElement.getAttributeAsText(column1Fieldname).trim();
temp = ref1;
}
.............................
Please suggest me.
Regards
-Sandip
HI Please suggest me the solution for this problem.
Regards
-Sandip
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.