cancel
Showing results for 
Search instead for 
Did you mean: 

Putting data to R3 table

Former Member
0 Kudos

Hi,

I am trying to put data to R3 table while putting data to r3 table i should get a error message if the same name is already exist. If not it should Enter.

At present i have done all the things. But while inserting data i am getting java.lang.NullPointerException

wht might be the reason.

I have written code like this.

try{
    	String str1=wdContext.currentBapi_Fm_Sw_InputElement().getStname();
		String str2=wdContext.currentBapi_Fm_Sw_InputElement().getStnumb();
		Bapi_Fm_Sw_Input input=new Bapi_Fm_Sw_Input();
		input.setStname(str1);
		input.setStnumb(str2);
		wdContext.currentBapi_Fm_Sw_InputElement().modelObject().execute();
		String ch=wdContext.currentOutputElement().getDup();
		wdComponentAPI.getMessageManager().reportSuccess(ch);
		if((Integer.parseInt(ch))==1)
		wdComponentAPI.getMessageManager().reportSuccess("duplicate");
		else
		wdComponentAPI.getMessageManager().reportSuccess("Inserted a row");
    
    }catch(Exception e)
    {
    	wdComponentAPI.getMessageManager().reportSuccess((e.getCause()).toString());
    }

Here Dup is the value which get will be zero if it doesn't have duplicate row.

else it will be one if it has the duplicate value.

Regards,

H.V.Swathi

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try to invalidate the Output node after you excute .

wdContext.currentBapi_Fm_Sw_InputElement().modelObject().execute();

<h3>wdContext.nodeOutput().invalidate();</h3>

Then try to get the value.

String ch=wdContext.currentOutputElement().getDup();

Regards

Akshaya

Former Member
0 Kudos

Hi Swathi

I have seen your code what you pasted.

1) You have not binded your object to the Node before executing the model.

Bapi_Fm_Sw_Input input=new Bapi_Fm_Sw_Input();

input.setStname(str1);

input.setStnumb(str2);

wdContext.nodeBapi_Fm_Sw_Input().bind(input);

wdContext.currentBapi_Fm_Sw_InputElement().modelObject().execute();

Try with this you wont get NullPoiter Exception bind is missing in your code.

Bind Properly.

2)

Even put the condition for the below statements also

if(wdContext.nodeBapi_Fm_Sw_Input().size()>0){

String str1=wdContext.currentBapi_Fm_Sw_InputElement().getStname();

String str2=wdContext.currentBapi_Fm_Sw_InputElement().getStnumb();

}

Rgds

-SS

Edited by: Sridhar Sabbani on Feb 19, 2009 6:56 AM

Former Member
0 Kudos

Hi,

try{

String str1=wdContext.currentBapi_Fm_Sw_InputElement().getStname();

String str2=wdContext.currentBapi_Fm_Sw_InputElement().getStnumb();

Bapi_Fm_Sw_Input input=new Bapi_Fm_Sw_Input();

input.setStname(str1);

input.setStnumb(str2);

wdContext.nodeBapi_Fm_Sw_Input().bind(input);

wdContext.currentBapi_Fm_Sw_InputElement().modelObject().execute();

wdComponentAPI.getMessageManager().reportSuccess("duplicate1");

String ch=wdContext.currentOutputElement().getDup();

wdComponentAPI.getMessageManager().reportSuccess(ch.toString());

wdComponentAPI.getMessageManager().reportSuccess("duplicate2"+ch);

if(ch.equals("y"))

wdComponentAPI.getMessageManager().reportSuccess("duplicate");

else if(ch.equals("N"))

wdComponentAPI.getMessageManager().reportSuccess("Inserted a row");

}catch(Exception e)

{

wdComponentAPI.getMessageManager().reportSuccess(e.toString());

}

I did what ever u told but now i am getting this error .


duplicate1
	java.lang.ArrayIndexOutOfBoundsException: -1

Can u tell the solution plz.

Regards,

H.V.Swathi

Former Member
0 Kudos

Hi Swathi

comment code after execute model.

Run the application. Remove the comment next line and run the application....

You tell me which line of code is getting error.I will give you the inputs.

By seeing your code

what I understood is you need to execute RFC by passing 2 import parameters.

what you are doing is taking str1 and str2 values from same RFC before execution.

How you will get str1 and str2 values.

try with hardcode with str1 and str2 u wont get any error.

Rgds

-SS

Edited by: Sridhar Sabbani on Feb 19, 2009 7:39 AM

Former Member
0 Kudos

Hi,

I am getting error in this line of code.

String ch = wdContext.currentOutputElement().getDup();

Dup is the value which is fetching from bapi function.It can be Y or N.

It will be Y if it has any duplicate value in table.

N if it doesn't have any duplicate value in r3 Table and entered successfully.

And i am getting the value str1 and str2 from 2 Input fields in the view.

Regarsd,

H.V.Swathi

Former Member
0 Kudos

Hi Swathi,

String ch = wdContext.currentOutputElement().getDup();

Means: currentOutputElement is wrong.

1) Check name of the exact output node element in the Context of RFC whre u will get the output from teh RFC

2) and also put if condtion for this statement.

if (wdContext.nodeOutputElement().size()>0){

String ch = wdContext.currentOutputElement().getDup();

}

Rgds

-SS

Former Member
0 Kudos

Hi,

I tried in the same way what u told but still i am getting

java.lang.ArrayIndexOutOfBoundsException: -1

while running the application.

Regards,

H.V.Swathi

Former Member
0 Kudos

Hi

Can you send the complete RFC(Bapi_Fm_Sw) structure nodes menas Root node child node structures from Webdynpro context.

Rgads

-SS

Edited by: Sridhar Sabbani on Feb 19, 2009 10:21 AM

Former Member
0 Kudos
---Bapi_Fm_Sw_Input
  --Output
      -Dup
     -Stname1
     -Stnumb1
 --Stname
 --Stnumb

Is the structure of the context attribute in Customer controller.

I am takning this to the View .

This dup attribute value i want.

String ch =wdContext.currentOutputElement().getDup();

This line is giving problem.

Regards,

H.V.Swathi

Edited by: H.V Swathi on Feb 19, 2009 11:00 AM

Former Member
0 Kudos

Hi Swathi,

Have you changed the structure of the RFC means (added or deleted any import or export parameter into the RFC) after creating the model , bcoz v got similar ArrayIndexOutOfBounds Exception :-1 in one such senario, we were without any clue why arrayindexoutofbounds exception coming, Later came to know that its bcoz of the structure change !!!!!!!! Check it out , thought this piece of info may be helpful !!!!

Regards,

Sam Charles J.

Former Member
0 Kudos

hi

please execute the RFC in the backend ECC you have have clear idea of what should be

passed as paramaters and what should be the output ,when yout provide the input ,

does dup is showing any output in the backend .

create two attribue(value attributes) bind them to the input fields .

then fetch the values entered in the input fields ;

conside ; name1 and nam2 as value attr.

String abc= wdcontext.currentcontextelement.getname1();

String xyz = wdcontext.currentcontextelement.getname1();

next Create RFC input

ZRFC rfc = new ZRFC();

rfc.setsname(name1);

rfc.setsname1(name2);

wdcontext.noderfc.bind(rfc);

then execute the RFC rfc.input or modelobject.excute();

then get the dup value print it and then check whether it is printing the value

hope this should help you

Former Member
0 Kudos

Hi Swathi

I can see the node Output for under RFC : Bapi_Fm_Sw_Input.

Is there any with same node name Output in the other RFC's of your context?

Try with below code also.

String ch=wdContext.nodeBapi_Fm_Sw_Input()currentOutputElement().getDup();

Rgds

-SS

Former Member
0 Kudos

Hi,

I have created the model again and created it again but still i am getting the error.

Regards,

h.V.Swathi

Former Member
0 Kudos

Does str1 and str2 of youyr code has values?

Can yost the line in which you are getting the exception?