Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem in deleting rows

Hi experts,

in the following method. I am deleting the records from the BAPI output table where the date and month do not correspond to todays date and current month.

When I execute the BAPI for one employee it gives me the correct output. ie one record. But when I execute it for all the employees and when I use the following code. It gives me a blank output.

  public void wdDoInit()
  {
    //@@begin wdDoInit()
    int date_today, current_date;
    int month_today, current_month;
    char date_satisfied, month_satisfied;
    Date date = new Date(System.currentTimeMillis());
    date_today = date.getDate();
    month_today = date.getMonth();
    
	int n = wdContext.nodeBirhtday_List().nodeItab().size();
	int leadSelected = wdContext.nodeBirhtday_List().nodeItab().getLeadSelection();
	//	loop backwards to avoid index troubles
	for (int i = n - 1; i >= 0; --i) {
 		current_date  = wdContext.nodeBirhtday_List().nodeItab().currentItabElement().getGbdat().getDate();
 		current_month = wdContext.nodeBirhtday_List().nodeItab().currentItabElement().getGbdat().getMonth();
 		
 		if (( current_date != date_today ) && ( current_month != month_today ))
 		{
			wdContext.nodeBirhtday_List().nodeItab().removeElement(wdContext.nodeBirhtday_List().nodeItab().
						getElementAt(i)); 
 		}
		
			}	
    //@@end
  }

can anybody please suggest me the solution

Regards

Abdullah

Former Member
Former Member replied

Abdullah,

I am sorry , that i suggested moveNext and moveFirst, since in your case it is starting from backward,

your code is fine , but what i think you are skipping is moving to previous record, when it is run for just one record, that is acting as current record and it is getting executed fine. but when you have more than one record , you are looping right but you are not moving to previous recor, so add

node.movePrevious();//just before the end of for loop(but in loop)

and

node.moveLast();//just before the start of for loop(outside loop)

keep your code as you have used earlier and remofe my earlier suggestion.

it will work

let me know if you face problem

regards

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question