Skip to Content
avatar image
Former Member

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 30, 2007 at 08:03 AM

    Hi,

    for looping in the output node, you should write

    <output node>.moveNext(); //in for loop

    so as to move to next record , other wise it will compare with same record again and again.

    and also add

    <output node>.moveFirst(); //before the for loop(outside)

    hope it helps

    regards

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 30, 2007 at 08:28 AM

    hi

    good

    this

    for (int i = n - 1; i >= 0; --i) executing once so that it is giving the correct result for the one employee,check this code in the debug mode ,if it is working for only one employee than put this inside the loop and see the difference.

    thanks

    mrutyun^

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 30, 2007 at 08:48 AM

    Hi Abdulla,

    If your above requirement is on load of the view then may be you can eliminate getting those value populated based on the condition in the backend.

    but if you dont have access to the backend and you nedd to do it in the code itsself then you need to follow Valery's advice (i.e accessing the element based on indexing)

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 30, 2007 at 08:13 AM

    Abdullah,

    You are comparing filter values with currently selected row, but now tih row at index. Should be:

    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();
      
      final IPrivate<ControllerName>.ItabNode node =  wdContext.nodeBirhtday_List().nodeItab();
      // loop backwards to avoid index troubles
      for (int i = node.size() - 1; i >= 0; --i) {
        final IPrivate<ControllerName>.ItabElement el = node.getItabElementAt(i);
        current_date    = el.getGbdat().getDate();
        current_month = el.getGbdat().getMonth();
     		
        if ( ( current_date != date_today ) && ( current_month != month_today ) )
          node.removeElement(el);
      }
      //@@end
    }
    

    Valery Silaev

    SaM Solutions

    http://www.sam-solutions.net

    Add comment
    10|10000 characters needed characters exceeded