on 04-30-2007 8:57 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhijeet,
I tried it the way you said using
wdContext.nodeBirhtday_List().nodeItab().moveFirst();
// 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));
}
wdContext.nodeBirhtday_List().nodeItab().moveNext();
}
It adds records...
According to Valerys Solution, the IPrivate<CustomController> doesnt show me the required nodes. and gives me 'Unable to resolve' error.
Can you please suggest where I am going wrong
Regards
Abdullah
Abdullah,
<i>According to Valerys Solution, the IPrivate<CustomController> doesnt show me the required nodes. and gives me 'Unable to resolve' error.</i>
I've used IPrivate<ControllerName> as a placeholder, you must substitute it with actual name of controller class -- like IPrivateCustomController or IPrivateMyComponentController.
VS
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
Dear Valery and Abhijeet,
Thanks a lot for the time you spent in helping me out. The problem was infact solved by both of you. I tried Abhijeets method first and then Valerys method. Both gave me the same output. And the silly mistake was on my part that I was using the && operator in the if condition rather than || operator. I wish I could have given you both 10 points. But its going to be only one person.
Regards
Abdullah
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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^
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.