cancel
Showing results for 
Search instead for 
Did you mean: 

ArrayIndexOutofBoundsException

Former Member
0 Kudos

hi,

I have an application where i use a RFC to Zsm_Actual_Allocation_Input to take input values like startDate,endDate, skills

and execute and populate values in a table.While i pass values for 'skills' only and execute the RFC, it runs fine and

populate values in the table .But while i pass the values for startDate,endDate it always throws an exception saying

java.lang.ArrayIndexOutOfBoundsException: -1

Any clue regarding the error??

Am posting my code along with this :

IPublicTdc_DataCust.IZsm_Actual_Allocation_InputNode AllocationInputNode = wdThis

.wdGetTdc_DataCustController()

.wdGetContext()

.nodeZsm_Actual_Allocation_Input();

Zsm_Actual_Allocation_Input input = new Zsm_Actual_Allocation_Input();

for(int i = 0;i<AllocationDetailsNode.size();++i)

{

AllocationDetailsElement = AllocationDetailsNode.getCtx_vn_AllocationDetailsElementAt(i);

Date dt = AllocationDetailsElement.getStartDate();

try

{

input.setR_Skills("X");

input.setFrom_Date(dt);

input.setTo_Date(AllocationDetailsElement.getEndDate());

}

catch(Exception e)

{

wdComponentAPI.getMessageManager().reportException(""+ e.toString(),false);

}

}

AllocationInputNode.bind(input);

NB : AllocationDetailsNode is the node containing the values of Startdate and Enddate entered by the user from the front-end.

Accepted Solutions (1)

Accepted Solutions (1)

lokesh_kamana
Active Contributor
0 Kudos

Hi,

Try this it may help you

for (int i = AllocationDetailsNode.size()- 1; i >= 0; --i)

It may do the trick for you.

Thanks & Regards,

Lokesh

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi

I think that your problem is in this line :

AllocationInputNode.bind(input);

U should not use bind If u want to add an element , this is how u should do it:

AllocationInputNode.addElement(input);

This code will add the element named input to the node .

Hope it helps

Nitsan

lokesh_kamana
Active Contributor
0 Kudos

Hi,

Is ur issue reolved or not.

Thanks & Regards,

Lokesh

Former Member
0 Kudos

hi Mamai,

check the line number on which you are getting the exception and check the corresponding line of code in the class. This help to narrow down the code where the exception is occuring. And please post the code where you got the exception

Former Member
0 Kudos

Hi,

I suspect that you may be passing too many parameters. Check the signature of the BAPI. You said that you passed BOTH the date values and it gave you this error. See if you also get this when only passing one date. If you still dont get the error passing the 3rd parameter (last date) might be the culprit.

Cheers,

Christiaan

Former Member
0 Kudos

Hi,

I have chkecked the parameters that need to be passed....I am passing them in the right way but still getting error :

java.lang.ArrayIndexOutOfBoundsException: -1

former_member192434
Active Contributor
0 Kudos

put this code out side the try block epecially getting EndDate()

input.setTo_Date(AllocationDetailsElement.getEndDate());

Former Member
0 Kudos

hey,

Putting the code

input.setTo_Date(AllocationDetailsElement.getEndDate());

outside the TRY block didnt help....

Exceptions are coming at two lines :

input.setFrom_Date(dt);

input.setTo_Date(AllocationDetailsElement.getEndDate());

Former Member
0 Kudos

Hi,

Check that the format of the date passed is same as expected by R/3.

Also, see that:

AllocationDetailsNode is instantiated for the node for which it was meant. As, you have missed out the line of code wherein you have instantiated this node so kindly check that too.

Regards,

Murtuza

Former Member
0 Kudos

Hi Mamai,

try by changing the code

for(int i = 0;i<AllocationDetailsNode.size();++i)

to

for(int i = 0;i<AllocationDetailsNode.size(); i++)

ArrayIndexOutOfBoundsException is thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.

Former Member
0 Kudos

hey i changed it to

i++....but still getting the same error :

java.lang.ArrayIndexOutOfBoundsException: -1

Any more clues??