cancel
Showing results for 
Search instead for 
Did you mean: 

NullPointerException while implementing FlightBooking

Former Member
0 Kudos

Hi all,

I am trying to run the pdf HANDLING TRANSACTIONS USING BAPIs,but while running it is giving as error as given below

java.lang.NullPointerException

at com.sap.tut.webdynpro.tutorial.FlightBookingView.wdDoInit(FlightBookingView.java:99)

at com.sap.tut.webdynpro.tutorial.wdp.InternalFlightBookingView.wdDoInit(InternalFlightBookingView.java:255)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)

at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)

at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:274)

at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)

the code at the point where error is occuring


 public void wdDoInit()
  {
    //@@begin wdDoInit()
	wdContext.currentUiElementsElement().setGroupVisible(WDVisibility.NONE);
    //@@end
  }

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Padma,

ur wdContext.currentUiElementsElement() is null.have u initialized it??

regards

Sumit

Former Member
0 Kudos

hi,

how to initlize wdContext.currentUiElementsElement()

Regards

Padma

Former Member
0 Kudos

HI

I<XX>Element ABC=wdContext.create<XX>Element();

ABC.setXX("");

...

..

..

wdContext.node<XX>Element().addElement(ABC);

Regards

Chaitanya.A

Former Member
0 Kudos

Hi Padma,

If you want to initialize the nodelement then you can follow these:

IPrivate<viewname>.I<nodename>Element ele = wdContext.node<nodename>().create<nodename>Element();

ele.setGroupHeader(<value>);

ele.setGroupVisibility(WDVisibility.VISIBLE);

wdContext.node<nodename>().addElement(ele);

This is how you would set the value and initialize the node element.

Regards,

Murtuza

Former Member
0 Kudos

Hi,

I changed the cardinality of the node to 1..n from 0..n

so that error got cleared.But now i have a container with group of UI elements where we have to enter values..followed by button Book,but that container UI elements are not in Editable state.

Can u plz tell me y i am getting this??

Regards

Padma

Former Member
0 Kudos

Hi Padma

for that you need to create a node and in the last you need to add the node to the context.following is the sample code to do so.

I<XX>Element ABC=wdContext.create<XX>Element();
ABC.setXX("");
...
..
..
wdContext.node<XX>Element().addElement(ABC);

Regards

Chaitanya.A

Former Member
0 Kudos

Hi Padma,

Are these UI elements binded to attributes within node if yes then change the cardinality of that node to 1:n from 0:n

Regards,

Murtuza

Former Member
0 Kudos

Hi Padma,

UI elements can be in non editable state when either the ui elements are not binded to attribute or there is no element created under the node.

u have to create the element to make them editable.

regards

Sumit

Former Member
0 Kudos

Hi ,

May I know, to which property have you bound the attribute 'GroupVisible'?

Why are you setting it to 'none'?

I hope this must be the cause for your problem...

Prabhakar.

Former Member
0 Kudos

Hi,

Deploy once, by blocking that line in doInit().

Prabhakar

Former Member
0 Kudos

Hi,

this is the sample tutorila avialable in sap login.

I applied template for the container and i selected data from the context (Bapi_Flbooking_Createfromdata_Input)(Booking_Data)..In this attributes like AirLine,FlightNum..etc

the cardinality of (Bapi_Flbooking_Createfromdata_Input) is 1..n and selction is 0.n

the cardinality of )(Booking_Data) is 0..1 and selection is 0..1..

and the cardinality of )(Booking_Data).. is not in editable state

can any one tell me y the caontainer where i have to enter my data to book flight is not in editable state

Regards

Padma

Former Member
0 Kudos

Padma,

Is Booking Data node of yours is a subnode of Bapi_Flbooking_Createfromdata_Input. If yes then you need to create an object of your Booking Data Node and set the values in there and add that node to your input node.

Bapi_Flbooking_Createfromdata_Input input = new Bapi_Flbooking_Createfromdata_Input();

Booking_data bd = new Booking_Data();

bd.set<attributename>(<value>);

input.add(bd);

wdContext.nodeBapi_Flbooking_Createfromdata_Input().bind(input);

Regards,

Murtuza

Former Member
0 Kudos

Hi Murtuza,

I created an object of that..and that problem got solved.

I have one more dout regarding Insert and Update of data in sap R/3 database.

For ex-i am having a module where i have data of all grocery items.If i want to add some more items to my database should i need to import the same model again and call wdContext.currentPoOrder_Input.modelObject.execute()

Regards

Padma

Former Member
0 Kudos

Padma,

If your RFC accepts table as an input then you can give multiple records to be inserted in one go from WD and you don't have to import everytime as that is a single time process. You need to re-import if there is some change in RFC from back-end.

Just as we added a single element just in the previous reply we can add such multiple elements and then at the end only execute once.

Regards,

Murtuza

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Padma,

Bring the attribute '

GroupVisible

' to the context node, and change the code in doInit() as

public void wdDoInit()
  {
    //@@begin wdDoInit()
	wdContext.currentContextElement().setGroupVisible(WDVisibility.NONE);
    //@@end
  }

I hope, This must sure work for you.

regards,

Prabhakar.

Former Member
0 Kudos

Hi

its a better approach if you create value attributes direclty rather than creating node and then attributes.

you are getting error because you are using visibilty property to an element which is not created yet.

so first wdcontext.createUIelement

add that uielement and try the same code

Regards

Chaitanya.A

Former Member
0 Kudos

Hi,

Check and try changing the cardinality of the node 'UiElements'.

or

Keep the Visibility Attribute directlry under Context.

regards,

Prabhakar.

Former Member
0 Kudos

hi padma..

u r changing dynamically property of ui element...............

that has to be written in "do modify"

in do modify just write

if(first time)

{

your code

}

it will work

Former Member
0 Kudos

Hi Padma,

Your UiElements node is not being populated and it is empty and thus it is resulting in an error. Where are you adding an element to this node in your application.

Regards,

Murtuza

Former Member
0 Kudos

Hi Padma

Did you used the following type for your <u><i>setGroupVisible</i></u> value attribute?

com.sap.ide.webdynpro.uielementdefinitions.Visibility

Regards

Chaitanya.A

Former Member
0 Kudos

Hi,

I created a node called UiElements and 2 attributes in that are GropuVisible,GroupHeader

the type of GroupVisible is com.sap.ide.webdynpro.uielementdefinitions.Visibility

and the type of GroupHeader is String

so i am not getting where the error might be....

Regards

Padma

Former Member
0 Kudos

Hi Padma,

If you have to just set the header and visibility property then don't put those attributes inside the node and have normal value attributes with the name GroupHeader and GroupVisibility

now you can directly set its value like this:

wdContext.currentContextElement().setGroupHeader("<value>");

wdContext.currentContextElement().setGroupVisibility(WDVisibility.VISIBLE);

//to make it visible

wdContext.currentContextElement().setGroupVisibility(WDVisibility.None);

//Invisible

Regards,

Murtuza