Skip to Content
author's profile photo Former Member
Former Member

Table problem-

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 28, 2008 at 03:01 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Apr 28, 2008 at 02:36 PM

    HI Please suggest me the solution for this problem.

    Regards

    -Sandip

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.