cancel
Showing results for 
Search instead for 
Did you mean: 

Error: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3

Former Member
0 Kudos

Hi Experts,

I am getting following error message:

java.lang.IndexOutOfBoundsException: Index: 3, Size: 3

at java.util.ArrayList.RangeCheck(ArrayList.java:507)

at java.util.ArrayList.get(ArrayList.java:324)

at com.sap.aii.proxy.framework.core.JcoBaseList.get(JcoBaseList.java:268)

at com.sap.aii.proxy.framework.core.AbstractList.get(AbstractList.java:230)

at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCList.get(DynamicRFCList.java:281)

... 35 more

Detailed Error Information

Detailed Exception Chain

java.lang.IndexOutOfBoundsException: Index: 3, Size: 3

at java.util.ArrayList.RangeCheck(ArrayList.java:507)

at java.util.ArrayList.get(ArrayList.java:324)

at com.sap.aii.proxy.framework.core.JcoBaseList.get(JcoBaseList.java:268)

at com.sap.aii.proxy.framework.core.AbstractList.get(AbstractList.java:230)

at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCList.get(DynamicRFCList.java:281)

at com.sap.tc.webdynpro.progmodel.context.Node$ModelElementList.getElement(Node.java:2549)

at com.sap.tc.webdynpro.progmodel.context.Node$MappedElementList.getElement(Node.java:2399)

at com.sap.tc.webdynpro.progmodel.context.Node.getElementAtInternal(Node.java:621)

at com.sap.tc.webdynpro.progmodel.context.Node.getElementAt(Node.java:628)

at com.sastech.app.models.TimesheetView.onActionFindRecord(TimesheetView.java:196)

at com.sastech.app.models.wdp.InternalTimesheetView.wdInvokeEventHandler(InternalTimesheetView.java:365)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)

at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:132)

at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)

at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:299)

at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:759)

at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:712)

at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:261)

at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:160)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)

at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

Can you please help me in resolving the issue? The code which is causing the above error is as below:

IPrivateTimesheetView.ICategoriesElement categoryElement;

String wbs ="h";

for (int i=1 ; i<=wdContext.currentWorklistElement().node().size() ; i++){

categoryElement = wdContext.createCategoriesElement();

wbs = wdContext.nodeWorklist().getElementAt(i).getAttributeAsText("Reciever_Wbs_Element");

categoryElement.setCategoryText(wdContext.currentWorklistElement().getReciever_Wbs_Element() );

categoryElement.setSeries1Value(8);

categoryElement.setSeries2Value(2);

wdContext.nodeCategories().addElement(categoryElement);

wbs = "";

}

Regards,

S

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Experts,

Further to the above message, please note that follwoing line is causing the error:

wbs = wdContext.nodeWorklist().getElementAt(i).getAttributeAsText("Reciever_Wbs_Element");

Can you please help me?

Regards,

S

Former Member
0 Kudos

Hi Stuart,

try

for (int i=0 ; i < wdContext.currentWorklistElement().node().size() ; i++){

instead of

for (int i=1 ; i<=wdContext.currentWorklistElement().node().size() ; i++){

regards,

christian

Former Member
0 Kudos

Hi,

I have done this. However, I am still getting same error message.

Regards,

S

former_member185029
Active Contributor
0 Kudos

Hello Stuart,

just try to print the size of node.

wdContext.nodeWorklist().size();

Also make sure that you have not incremented i inside the loop.

Ashutosh

former_member182372
Active Contributor
0 Kudos

Stuart, do you delete elements from node inside the loop?

former_member182294
Active Contributor
0 Kudos

This is other way of doing same thing, this might be helpful.

replace your old code with this:

IPrivateTimesheetView.ICategoriesElement categoryElement;

String wbs ="h";

for (int i=0 ; i<wdContext.nodeWorklist.size() ; i++){

wdContext.nodeWorkList().setLeadSelection(i);

categoryElement = wdContext.createCategoriesElement();

wbs = wdContext.currentWorklistElement().getReciever_Wbs_Element();

categoryElement.setCategoryText(wbs);

categoryElement.setSeries1Value(8);

categoryElement.setSeries2Value(2);

wdContext.nodeCategories().addElement(categoryElement);

wbs = "";

}

Regards

Abhilash

Former Member
0 Kudos

Thanks Abhilash,

The issue got resolved. Now I am facing another issue. I have further modified the code. The new code is as below.

IPrivateTimesheetView.ICategoriesElement categoryElement;

String wbs ="h";

double num1 = 0;

for (int i=0 ; i<wdContext.nodeWorklist().size() ; i++){

wdContext.nodeWorklist().setLeadSelection(i);

categoryElement = wdContext.createCategoriesElement();

wbs = wdContext.currentWorklistElement().getReciever_Wbs_Element();

num1 = wdContext.currentWorklistElement().getDay1();

categoryElement.setCategoryText(wbs);

categoryElement.setSeries1Value(8);

categoryElement.setSeries2Value(2);

wdContext.nodeCategories().addElement(categoryElement);

wbs = "";

}

Following line is causing the problem:

num1 = wdContext.currentWorklistElement().getDay1();

The error is "Type Mismatch: Can not convert from string to double."

Is there is any workaround to resolve the issue?

In R/3 datatype of Day1 is String. However in the front end I am using double for num1. I can not use any other datatype in front end as it is needed for displaying the graph.

I tried using following

num1 = (double) wdContext.currentWorklistElement().getDay1();

However I am getting following error.

Can not cast from String to double.

Can you please help me?

Regards,

S

former_member185029
Active Contributor
0 Kudos

Hi,

use wrapper classes for typecasting

in this case use

String strNum =wdContext.currentWorklistElement().getDay1();

num1 = Double.parseDouble(strNum);

Regards,

Ashutosh

Former Member
0 Kudos

Hi,

I am using following code:

IPrivateTimesheetView.ICategoriesElement categoryElement;

String wbs ="h";

double d ;

String Day1 =" ";

for (int i=0 ; i<wdContext.nodeWorklist().size() ; i++){

wdContext.nodeWorklist().setLeadSelection(i);

categoryElement = wdContext.createCategoriesElement();

wbs = wdContext.currentWorklistElement().getReciever_Wbs_Element();

Day1 = wdContext.currentWorklistElement().getDay1();

d = Double.parseDouble(Day1) ;

categoryElement.setCategoryText(wbs);

categoryElement.setSeries1Value(d);

categoryElement.setSeries2Value(2);

wdContext.nodeCategories().addElement(categoryElement);

wbs = "";

The issue has got resolved. However, now I am getting following error:

java.lang.NumberFormatException: empty String

Can you please help me in resolving the issue?

Regards,

S

former_member185029
Active Contributor
0 Kudos

Hi,

modify as below

Day1 = wdContext.currentWorklistElement().getDay1();

if(""!=Day1 && null!=Day1)
 d = Double.parseDouble(Day1) ;

Ashutosh

Former Member
0 Kudos

Hi,

The new code is

IPrivateTimesheetView.ICategoriesElement categoryElement;

String wbs ="h";

double d =0;

String Day1 ="";

for (int i=0 ; i<wdContext.nodeWorklist().size() ; i++){

wdContext.nodeWorklist().setLeadSelection(i);

categoryElement = wdContext.createCategoriesElement();

wbs = wdContext.currentWorklistElement().getReciever_Wbs_Element();

Day1 = wdContext.currentWorklistElement().getDay1();

if(""!=Day1 && null!=Day1)

d = Double.parseDouble(Day1) ;

categoryElement.setCategoryText(wbs);

categoryElement.setSeries1Value(d);

categoryElement.setSeries2Value(2);

wdContext.nodeCategories().addElement(categoryElement);

wbs = "";

However I am still getting following error.

java.lang.NumberFormatException: empty String

Can you please help me?

Regards,

S

former_member185029
Active Contributor
0 Kudos

Hi,

Hmmmmm!

How about this change?


Day1 = wdContext.currentWorklistElement().getDay1();
 
if( null!=Day1 && ! Day1.trim().equals(""))
 d = Double.parseDouble(Day1) ;

Ashutosh

Former Member
0 Kudos

Hi Ashutosh,

This is unfortunately not working. I am still getting following error:

" java.lang.NumberFormatException: empty String "

Can you please help me?

Regards,

S

former_member182294
Active Contributor
0 Kudos

Use this code:

Day1 = wdContext.currentWorklistElement().getDay1();

if( Day1 != null && Day1.trim().length()>0)

d = Double.parseDouble(Day1) ;

Regards

Abhilash

former_member185029
Active Contributor
0 Kudos

Hi,

Define following funtion to validate.


 public boolean isNumber(String strNum)   
     {
	String strValidChars = "0123456789.";
	boolean blnNumber=true;
	char chrNum;

	for (int i = 0; i < strNum.length() && blnNumber == true; i++) 
	{ 
	chrNum = strNum.charAt(i); 
	if ((i == 0) && (chrNum == '-')) // check first character for minus sign
	continue;
	if (strValidChars.indexOf(chrNum) == -1) 
	{
	blnNumber = false;
	}
	}
	return blnNumber;

}	

   

Add this condition in if as

if(null != Day1 && isNumber(Day1))
d= Double.parseDouble(Day1);

Let me know is there is any problem

Former Member
0 Kudos

Hi Abhilash,

Thanks. The code is working fine. Now, I am facing another problem. In back end certain data (sum_hrs) is stored as String. The values are like 7,00. This 7,00 has be converted into 7.00. How we can do it?

The code is as below. I tried using replace function. However it is not working.

IPrivateTimesheetView.ICategoriesElement categoryElement;

String wbs ="h";

double d =0;

String sum_hrs ="";

for (int i=0 ; i<wdContext.nodeWorklist().size() ; i++){

wdContext.nodeWorklist().setLeadSelection(i);

categoryElement = wdContext.createCategoriesElement();

wbs = wdContext.currentWorklistElement().getReciever_Wbs_Element();

sum_hrs = wdContext.currentWorklistElement().getSum_Hours();

sum_hrs = sum_hrs.replace(",",".");

if( sum_hrs != null && sum_hrs.trim().length()>0)

d = Double.parseDouble(sum_hrs) ;

categoryElement.setCategoryText(wbs);

categoryElement.setSeries1Value(d);

wdContext.nodeCategories().addElement(categoryElement);

wbs = "";

The error message is

java.lang.NoSuchMethodError: java.lang.String.replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

Can you please help me?

Regards,

S

Former Member
0 Kudos

Hi Abhilash,

Thanks. The code is working fine. Now, I am facing another problem. In back end certain data (sum_hrs) is stored as String. The values are like 7,00. This 7,00 has be converted into 7.00. How we can do it?

The code is as below. I tried using replace function. However it is not working.

IPrivateTimesheetView.ICategoriesElement categoryElement;

String wbs ="h";

double d =0;

String sum_hrs ="";

for (int i=0 ; i<wdContext.nodeWorklist().size() ; i++){

wdContext.nodeWorklist().setLeadSelection(i);

categoryElement = wdContext.createCategoriesElement();

wbs = wdContext.currentWorklistElement().getReciever_Wbs_Element();

sum_hrs = wdContext.currentWorklistElement().getSum_Hours();

sum_hrs = sum_hrs.replace(",",".");

if( sum_hrs != null && sum_hrs.trim().length()>0)

d = Double.parseDouble(sum_hrs) ;

categoryElement.setCategoryText(wbs);

categoryElement.setSeries1Value(d);

wdContext.nodeCategories().addElement(categoryElement);

wbs = "";

The error message is

java.lang.NoSuchMethodError: java.lang.String.replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

at com.sastech.app.models.TimesheetView.onActionFindRecord(TimesheetView.java:253)

at com.sastech.app.models.wdp.InternalTimesheetView.wdInvokeEventHandler(InternalTimesheetView.java:365)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)

at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)

... 26 more

Can you please help me?

Regards,

S

former_member185029
Active Contributor
0 Kudos

Hello Stuart,

Have you tried the solution that I gave?

Please refer to my previous message.

Ashutosh

Former Member
0 Kudos

Hi Ashutosh,

Thanks for your reply. The solution has worked. I am awarding full marks to you for the help.

Regards,

S

Answers (0)