on 05-23-2010 3:39 PM
Hi,
I am facing Nullpoiner error while sending String input in Java Web Dynpro view
for a RFC with Inputfield XUBNAME.
Internally, XUBNAME is character with size 12.
Also, the input field in Java Web Dynpro is coming Read Only.
Regards
Pooja Malhotra
Edited by: poojaMCA2003 on May 23, 2010 4:42 PM
Hi,
Have u binded the input field to an attribute within a context node? if that is the case, then u have to initialize the object of the node for the input field to be enabled.
Try creating an attribute in the context and bind it to the input field. then the input field will be enabled.
Use this attribute to get the value and set it in the RFC.
Hope this helps you.
Regards,
Poojith MV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Poojith,
I have the RFC ZBP_VENDOR_PROFILE_UPDATE in SRM system.
The input parameter:
Parameter Name: BUS_PART_NO
TYPE XUBNAME
XUBNAME is of Data Type Char, Length 12.
Export Parameter:
FLAG type CHAR1
BUS_PARTNER type BU_PARTNER
BPEXT type BU_BPEXT
ADRNR type BU_ADDRCOMM.
-
The model had been added to the model DC vdmodel and then added to the public part of the DC.
This model had been used in the DC vdview.
The name of the view is: vdapplication3.
The name of the component is: Vdapplication.
The Model Controller Context had been dragged to the Component Controller.
Model Controller Structure:
-
Context -> Zbp_Vendor_Profile-->
Zbp_Vendor_Profile_Update__Input --> Bus_Part_No
Output-> Zbp_Vendor_Profile_Update_Output
Adrnr
Bpext
Bus_Partner
Flag
-
Zbp_Vendor_Profile_Update_Input had been dragged into the Component Controller.
-
Also, a new Value node name test and Value attribute named test had been created in the
view vdapplication3.
-
The implementation code is:
// -
// This file has been generated partially by the Web Dynpro Code Generator.
// MODIFY CODE ONLY IN SECTIONS ENCLOSED BY @@begin AND @@end.
// ALL OTHER CHANGES WILL BE LOST IF THE FILE IS REGENERATED.
// -
package com.vmp;
//
// IMPORTANT NOTE:
// ALL IMPORT STATEMENTS MUST BE PLACED IN THE FOLLOWING SECTION ENCLOSED
// BY @@begin imports AND @@end. FURTHERMORE, THIS SECTION MUST ALWAYS CONTAIN
// AT LEAST ONE IMPORT STATEMENT (E.G. THAT FOR IPrivateVdapplication3).
// OTHERWISE, USING THE ECLIPSE FUNCTION "Organize Imports" FOLLOWED BY
// A WEB DYNPRO CODE GENERATION (E.G. PROJECT BUILD) WILL RESULT IN THE LOSS
// OF IMPORT STATEMENTS.
//
//@@begin imports
import com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCExecuteException;
import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
import com.vmp.model.Zbp_Vendor_Profile_Update_Input;
import com.vmp.model.Zbp_Vendor_Profile_Update_Output;
import com.vmp.wdp.IPrivateVdapplication3;
//@@end
//@@begin documentation
//@@end
public class Vdapplication3
{
/**
Logging location.
*/
private static final com.sap.tc.logging.Location logger =
com.sap.tc.logging.Location.getLocation(Vdapplication3.class);
static
{
//@@begin id
String id = "$Id$";
//@@end
com.sap.tc.logging.Location.getLocation("ID.com.sap.tc.webdynpro").infoT(id);
}
/**
Private access to the generated Web Dynpro counterpart
for this controller class. </p>
*
Use <code>wdThis</code> to gain typed access to the context,
to trigger navigation via outbound plugs, to get and enable/disable
actions, fire declared events, and access used controllers and/or
component usages.
*
@see com.vmp.wdp.IPrivateVdapplication3 for more details
*/
private final IPrivateVdapplication3 wdThis;
/**
Root node of this controller's context. </p>
*
Provides typed access not only to the elements of the root node
but also to all nodes in the context (methods node<i>XYZ</i>())
and their currently selected element (methods current<i>XYZ</i>Element()).
It also facilitates the creation of new elements for all nodes
(methods create<i>XYZ</i>Element()). </p>
*
@see com.vmp.wdp.IPrivateVdapplication3.IContextNode for more details.
*/
private final IPrivateVdapplication3.IContextNode wdContext;
/**
A shortcut for <code>wdThis.wdGetAPI()</code>. </p>
Represents the generic API of the generic Web Dynpro counterpart
for this controller. </p>
*/
private final com.sap.tc.webdynpro.progmodel.api.IWDViewController wdControllerAPI;
/**
A shortcut for <code>wdThis.wdGetAPI().getComponent()</code>. </p>
Represents the generic API of the Web Dynpro component this controller
belongs to. Can be used to access the message manager, the window manager,
to add/remove event handlers and so on. </p>
*/
private final com.sap.tc.webdynpro.progmodel.api.IWDComponent wdComponentAPI;
public Vdapplication3(IPrivateVdapplication3 wdThis)
{
this.wdThis = wdThis;
this.wdContext = wdThis.wdGetContext();
this.wdControllerAPI = wdThis.wdGetAPI();
this.wdComponentAPI = wdThis.wdGetAPI().getComponent();
}
//@@begin javadoc:wdDoInit()
/** Hook method called to initialize controller. */
//@@end
public void wdDoInit()
{
//@@begin wdDoInit()
//String s = new String();
//Zbp_Vendor_Profile_Update_Input ze;
//@@end
}
//@@begin javadoc:wdDoExit()
/** Hook method called to clean up controller. */
//@@end
public void wdDoExit()
{
//@@begin wdDoExit()
//@@end
}
//@@begin javadoc:wdDoModifyView
/**
Hook method called to modify a view just before rendering.
This method conceptually belongs to the view itself, not to the
controller (cf. MVC pattern).
It is made static to discourage a way of programming that
routinely stores references to UI elements in instance fields
for access by the view controller's event handlers, and so on.
The Web Dynpro programming model recommends that UI elements can
only be accessed by code executed within the call to this hook method.
*
@param wdThis Generated private interface of the view's controller, as
provided by Web Dynpro. Provides access to the view controller's
outgoing controller usages, etc.
@param wdContext Generated interface of the view's context, as provided
by Web Dynpro. Provides access to the view's data.
@param view The view's generic API, as provided by Web Dynpro.
Provides access to UI elements.
@param firstTime Indicates whether the hook is called for the first time
during the lifetime of the view.
*/
//@@end
public static void wdDoModifyView(IPrivateVdapplication3 wdThis, IPrivateVdapplication3.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
//@@end
}
//@@begin javadoc:onActiondetail(ServerEvent)
/** Declared validating event handler. */
//@@end
public void onActiondetail(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActiondetail(ServerEvent)
//try {
String test=wdContext.currentTestElement().getTest();
Zbp_Vendor_Profile_Update_Input ze = new Zbp_Vendor_Profile_Update_Input();
// Zbp_Vendor_Profile_Update_Output zo = new Zbp_Vendor_Profile_Update_Output();
// Object s1= ze.getInputParameter();
// char a[]={'K','A','U','S','H','I','K'};
ze.setBus_Part_No(test);
// ze.setAttributeValue("Bus_Part_No",test);
//ze.setAttributeValue("Bus_Part_No","KAUSHIK ");
//bus =
//wdContext.nodeZbp_Vendor_Profile_Update_Input().createZbp_Vendor_Profile_Update_InputElement(ze);
// IPrivateVdapplication3.IZbp_Vendor_Profile_Update_InputElement elt =
// wdContext.nodeZbp_Vendor_Profile_Update_Input().createZbp_Vendor_Profile_Update_InputElement(ze);
// wdContext.nodeZbp_Vendor_Profile_Update_Input().addElement(elt);
wdContext.nodeZbp_Vendor_Profile_Update_Input().bind(ze);
//wdContext.nodeOutput().bind(zo);
//ze.modelInstance().zbp_Vendor_Profile_Update();
wdComponentAPI.getMessageManager().reportSuccess("In the try block");
try {
wdContext.currentZbp_Vendor_Profile_Update_InputElement().modelObject().execute();
} catch (WDDynamicRFCExecuteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// }
/*catch (NullPointerException ne) {
// TODO: handle exception
wdComponentAPI.getMessageManager().reportSuccess(ne.printStackTrace());
ne.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}*/
wdThis.wdFirePlugVdout();
//@@end
}
/*
The following code section can be used for any Java code that is
not to be visible to other controllers/views or that contains constructs
currently not supported directly by Web Dynpro (such as inner classes or
member variables etc.). </p>
*
Note: The content of this section is in no way managed/controlled
by the Web Dynpro Designtime or the Web Dynpro Runtime.
*/
//@@begin others
//@@end
}
-
The error is nullpointer exception in the line:
Zbp_Vendor_Profile_Update_Input ze = new Zbp_Vendor_Profile_Update_Input();
Do I need to reimport the model ?
Please suggest.
Regards
Pooja
Hi,
If there are any changes made to the structure in the RFC, u need to re-import the RFC, else there is no need to re-import.
Try executing the RFC in the SAP logon using SE37 transaction. Check if the RFC is working fine.
In the controller section:
Zbp_Vendor_Profile_Update_Input ze = new Zbp_Vendor_Profile_Update_Input();
wdContext().nodeZbp_Vendor_Profile_Update_Input().bind(ze);
//Set the input parameters
wdContext().nodeZbp_Vendor_Profile_Update_InputElement().setXUBNAME(<get the value from the Context>);
//execute the RFC
wdContext.currentZbp_Vendor_Profile_Update_InputElement().modelObject().execute();
if u do not pass any value, u will get a null pointer exception.
Regards,
Poojith MV
Hi Poojith,
In reply to your answer:
Hi,
If there are any changes made to the structure in the RFC, u need to re-import the RFC, else there is no need to re-import.
Try executing the RFC in the SAP logon using SE37 transaction. Check if the RFC is working fine.
The RFC is working fine with Input KAUSHIK.
In the controller section:
Zbp_Vendor_Profile_Update_Input ze = new Zbp_Vendor_Profile_Update_Input();
wdContext().nodeZbp_Vendor_Profile_Update_Input().bind(ze);
This is done.
//Set the input parameters
wdContext().nodeZbp_Vendor_Profile_Update_InputElement().setXUBNAME(<get the value from the Context>);
setXUBNAME would be setBus_Part_No(String);
get values from context means.... ?
I didnot do it.
//execute the RFC
wdContext.currentZbp_Vendor_Profile_Update_InputElement().modelObject().execute();
done it this way too.
if u do not pass any value, u will get a null pointer exception.
It's tru nullpointer is for no value being passed.
Regards,
Poojith MV
Hi Pooja,
Please use below code for finding null in your input parameters befor executing the RFC.
String strXUBNAME = wdContext().nodeZbp_Vendor_Profile_Update_InputElement().getXUBNAME().
if(strXUBNAME != null && !strXUBNAME.equalIgnoreCase(""))
{
//Set the input parameters
wdContext().nodeZbp_Vendor_Profile_Update_InputElement().setXUBNAME(<get the value from the Context>);
}
Hope it will helps
Regards
Arun
Hi,
get values from context means.... ?
I didnot do it.
1. Create a context attribute "RFCInput" in the context tab of View and Controller and do a context binding
2. Bind the Input field to it.
3. before the execute statement get the value from the RFCInput
ie
wdContext().nodeZbp_Vendor_Profile_Update_InputElement().setXUBNAME(wdContext().currentContextElement().getRFCInput());
this way, whatever is entered in the Input field will be passed to the RFC. U can check for the length in ur code as a validation
Hope this is clear.
Regards,
Poojith MV
Hi,
Dont worry about Xbuname. just pass a string value.
create a value node and value attribute of typr string. set cardinality of your value node to 1 to n.Input field will be visible.
For the null pointer error plz do the follwing things :
create a object of the input node of your deaired FM. set the model attribute by getting the value from your value attribute. Bind the object with the input node of the FM. then finally execute the FM.
I am not providing you with any code. plz reply if you need the code.
Plz check the above things and let me if there is any issue.
Thanks,
Subhabrata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Pooja,
Webdynpro java does not have character type defined.
IT will only take string type as character.For this you have to change the type from char to string in webdynpro explororer.
Follow the below steps to change the type:
1>Go to dictionary and exapnd it.
2>Select the variable:XUBNAME, right click and say edit.
3>It will allow you to change the type as string.
4>Save and deploy the application.
Regards,
Lavanya.G
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi pooja,
Just one thing make sure the cardinality of the node of the attribute is 1-n. And the null pointer + read only input field Error will be resolved and let us know if you face any more issues.
Regards
Jeetendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pooja,
To change context cardinality, open View or Component controller.
After that one context tab will be there at the view window.
Once you click the context tab, you will be able to see the context node structure.
Select the node right click and select property option.
At the bottom window you will get the property.
Select the cardinality and based on the requirement change the cardinality accordingly.
Hope this may help you.
Deepak!!!
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.