cancel
Showing results for 
Search instead for 
Did you mean: 

Send table data ArrayIndexOutofBoundsException: -1

Former Member
0 Kudos

Hi,

I have a RFC (Z_ET_SAVE_EFFORT) which takes one table row as input and saves it to the backend

Z_ET_SAVE_EFFORT_INPUT

|-----> I_TABLE (This is the input node. Model structure - Zet_Test1)

| -


> Category

| -


> Date

| -


> Projid

| -


> OUTPUT (this is the output node)

| -


> Status (indicates whether data was saved or not)

On click of the button SAVE I call the action OnSave. In that I have written the following code :

A. Zet_Test1 tst = new Zet_Test1();

B. IPrivateEffortDetail.II_TableElement par = wdContext.createI_TableElement(tst);

C. wdContext.nodeI_Table().addElement(par);

On pressing the SAVE button the following execption gets thrown:

arrayIndexOutofboundsException : -1 on line C.

Please help.

Regards

Shankar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Shankar,

Did you import the BAPI in your studio and changed something afterwards?

Because when you did so you have to restart your J2EE engine to update the model in your server cache. The ArrayIndexOutOfBoundsException -1 happens a lot when you did not restart the server. Just an idea.

Regards,

Christophe

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Christophe,

Thanks for the amazing reply. Your idea was right.

I restarted the engine and everything worked on fine.

Rgds,

Shankar

Former Member
0 Kudos

Hi,

As suggested above, I tried the following code in the OnActionSave method:

Z_Et_Save_Effort_Input ip = new Z_Et_Save_Effort_Input();

Zet_Test1 table = new Zet_Test1();

table.setProj_Id("20748");

table.setDate("24.07.2006");

table.setCategory("Leave");

ip.addZet_Test1(table);

wdContext.nodeZ_Et_Save_Effort_Input.bind(ip);

But I get the following error in the line table.setProj_Id("20478");

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Couldnt find info for class com.sap.effort.tool.Zet_Test1 in model com.sap.effort.tool.EffortTool@d4323b[scope=APPLICATION_SCOPE]

I tried Repairing the ProjectStructure and Classpath, but it never worked.

Regards,

Shankar

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

try this code,

Z_Et_Save_Effort_Input ip = new Z_Et_Save_Effort_Input();

Zet_Test1 table = new Zet_Test1();

Zet_Test1.Zet_Test1_List list = new Zet_Test1.Zet_Test1_List();

//set your values for tables here

table.setProj_Id(<value>);

list.addZet_Test1(table);

ip.setZet_Test1(list);

wdContext.nodeZ_Et_Save_Effort_Input.bind(ip);

and then execute the modelobject.

I think It should dolve your problem.

regards,

abhijeet.

Please appreciate if it solves your problem.

Abhinav_Sharma
Contributor
0 Kudos

Hi Shankar,

You want ot pass the table to your RFC. Here, you can do that:

Z_Et_Save_Effort_Input ip = new Z_Et_Save_Effort_Input();

wdContext.nodeZ_Et_Save_Effort_Input().bind(ip);

Loop for getting values from webdynpro table:

for(int i = 0 ; i < wdContext.node<Datasource of WD Table which you want to pass>; i++){

IPrivate<ViewName>.<Datasource of WD Table which you want to pass>Element ele = wdContext.node<Datasource of WD Table which you want to pass>.getElementAt(i);

Zet_Test1 table = new Zet_Test1();

table.setProj_Id(ele.getProj_Id());

table.setDate(ele.getDate());

table.setCategory(ele.getCategory());

ip.addZet_Test1(table);

}

ip.execute();

Hope this will work for you as I've tested it in my webdynpro application.

Abhinav

PS : Do reward points if it helps.

Former Member
0 Kudos

Hi,

Use this following code pass the compatable data then that should work see the all the data types once such that u can pass ur data.

Z_ET_SAVE_EFFORT_INPUT input = new Z_ET_SAVE_EFFORT_INPUT

();

wdcontext.nodeZ_ET_SAVE_EFFORT_INPUTElement().bind(input);

I_TABLE table= new I_TABLE();

// here do u have any input inthis node pass like metion below.

table.set(varName("");

table.set....

After this.

input.setTABLE(tble);

input.setCatogory("Value");

input.setDate("dd/mm/yyyy);

input.setProjId(value);

aftert this.

try{

wdContext.currentZ_ET_SAVE_EFFORT_INPUTElement().modelObject().execute();

wdContext.nodeOutPut.Invalidate();

}

catch(EX e)

{

e.prstack();

}

Otherwise gothru this thread the same requierment.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/creating...

Thanks,

Lohi.

chintan_virani
Active Contributor
0 Kudos

Shankar,

Have u tried setting the values for I_Table element first and then adding the element.

Try adding following code after step B.

par.setCategory(<some value>);
par.setDate(<some value>);
par.setProjid(<some value>);
wdContext.nodeI_Table().addElement(par);

<b>- Chintan</b>

Former Member
0 Kudos

Hi,

U need to bind this to ur node.

wdContext.nodeI_Table().addElement(par);

Change like and try

wdContext.nodeI_Table().bind(par);

Thanks,

Lohi.