on 02-19-2009 5:43 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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
---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
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.
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
Does str1 and str2 of youyr code has values?
Can yost the line in which you are getting the exception?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.