cancel
Showing results for 
Search instead for 
Did you mean: 

Webdynpro context: (invalidate)

Former Member
0 Kudos

Hi there,

My application consists of 2 DC's:

-a data DC in which all the data models are contained

-a bupa DC in which the models are used, and implementation of context, plugs etc are done

When I update a BuPa via my application the values are updated in the abap backend, but when I navigate my application the old values are still shown.

When I refresh the application, the new values are shown..

So what to do to ensure that the newest values are always shown?

I tried doing this with wdContext invalidate (so it will recall the supply function) in the following way:


public void TriggerBuPaMyAccounts( )
  {
    //@@begin TriggerBuPaMyAccounts()
	myAcctsInput = new __Cernum__Crm_Bb_Bupa_Myaccounts_Input();
	myAcctsOutput = new __Cernum__Crm_Bb_Bupa_Myaccounts_Output();
	try{
		wdContext.nodeOutputMyAccounts().invalidate();
		myAcctsInput.execute();
	}
	catch(Exception e){
		msgMngr.reportException(e.toString(), false);
		msgMngr.reportSuccess("error: " + e.getCause());
	}
	myAcctsOutput = myAcctsInput.getOutput();
	this.wdThis.wdGetContext().nodeOutputMyAccounts().bind(myAcctsOutput);
    //@@end
  }

But that didn't help. Did I do anything wrong or...? Any suggestions?

I would rather not use wdContext.reset, or is that 'safe'? If I had to implement that, where should I do it?

Thanks!

Kind regards,

Allan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Can you shift the invalidate code:

wdContext.nodeOutputMyAccounts().invalidate();

to the position after:

this.wdThis.wdGetContext().nodeOutputMyAccounts().bind(myAcctsOutput);

or after the line where it is used last and then check the output.

I think it will help.

Bcoz in my scenario, i used the code for invalidating a node after its function was over and not before the start of use of that node.

Regards.

Rajat

Answers (2)

Answers (2)

monalisa_biswal
Contributor
0 Kudos

wdContext.nodeOutputMyAccounts().invalidate();

add this line after myAcctsInput.execute();

Remove these lines:

myAcctsOutput = myAcctsInput.getOutput();

this.wdThis.wdGetContext().nodeOutputMyAccounts().bind(myAcctsOutput);

invalidate() method refreshes model node data with the new elements.

public void TriggerBuPaMyAccounts( )

{

//@@begin TriggerBuPaMyAccounts()

myAcctsInput = new __Cernum__Crm_Bb_Bupa_Myaccounts_Input();

myAcctsOutput = new __Cernum__Crm_Bb_Bupa_Myaccounts_Output();

try{

myAcctsInput.execute();

wdContext.nodeOutputMyAccounts().invalidate(); //Synchronize with the new result set

}

catch(Exception e){

msgMngr.reportException(e.toString(), false);

msgMngr.reportSuccess("error: " + e.getCause());

}

//@@end

}

Hope this helps!

Monalisa

Former Member
0 Kudos

Hi Allan,

The problem does not lie in the context. It's in your connection to the SAP-backend. There is some kind of cache used while your connection is open. So close the connection after you call a the RFC/bapi that changes the Accounts.

something like:

finally {
	DynamicRFCModel modelinst;
	modelinst = (DynamicRFCModel) WDModelFactory.getModelInstance([ModelName].class);
	modelinst.disconnectIfAlive();
}

Replace the [[ModelName]] with the name of your model

This should close your connection everytime you call the rfc.

Groeten,

Jeschael

Former Member
0 Kudos

Thanks for the suggestions!

@JV;

Your suggestion provided the best results.

But with some tables, the content does not get refreshed (does this mean the connection is still open?)

How can you check if this connection is open and which connections are used?

Can you tell me why it works with most models, but not with a particular one?

I implemented it the same way as the rest:


public void TriggerBuPaMyAccounts( )
  {
    //@@begin TriggerBuPaMyAccounts()
	myAcctsInput = new __Cernum__Crm_Bb_Bupa_Myaccounts_Input();
	myAcctsOutput = new __Cernum__Crm_Bb_Bupa_Myaccounts_Output();
	try{
		myAcctsInput.execute();
	}
	catch(Exception e){
		msgMngr.reportException(e.toString(), false);
		msgMngr.reportSuccess("error: " + e.getCause());
	}
	//wdContext.nodeOutputMyAccounts().invalidate();
	myAcctsOutput = myAcctsInput.getOutput();
	this.wdThis.wdGetContext().nodeOutputMyAccounts().bind(myAcctsOutput);
	
	DynamicRFCModel modelinst;
	modelinst = (DynamicRFCModel) WDModelFactory.getModelInstance(BuPaMyAccountsModel.class);
	modelinst.disconnectIfAlive();
    //@@end
  }

Thanks!

Kind regards

A

Former Member
0 Kudos

Hi Allan,

The model defines which connections you use. One model (normally) has its own connection, which is used over and over again in one webdynpro application, as long as you do not close it.

You have to close the connection in the method where you change the data in the backend

Like this:

public void TriggerBuPaMyAccounts( )
  {
    //@@begin TriggerBuPaMyAccounts()
	myAcctsInput = new __Cernum__Crm_Bb_Bupa_Myaccounts_Input();
	myAcctsOutput = new __Cernum__Crm_Bb_Bupa_Myaccounts_Output();
	try{
		myAcctsInput.execute();
	        myAcctsOutput = myAcctsInput.getOutput();
	        this.wdThis.wdGetContext().nodeOutputMyAccounts().bind(myAcctsOutput);
	}
	catch(Exception e){
		msgMngr.reportException(e.toString(), false);
		msgMngr.reportSuccess("error: " + e.getCause());
	}  finally {
	  DynamicRFCModel modelinst;
	  modelinst = (DynamicRFCModel) WDModelFactory.getModelInstance(BuPaMyAccountsModel.class);
	modelinst.disconnectIfAlive();
}
    //@@end
  }

Note: This code seems to read the data. I am talking about a finally clause when writing the data.

J

Former Member
0 Kudos

Great info, erg bedankt!

Another question, you are talking about using the finally clause when writing data.

So, does this mean that it is not necessary to close the connection for models which only read data?

Or do you mean it has to be implemented differently in that case...?

KR

A

Former Member
0 Kudos

Hi Allen,

All connections should be closed, at the latest when ending the application (WDDoExit). Otherwise you will be running out of connections and you won't have connections left (there is a pool) for other users.

1. When writing data and you want to read it again you will have to close the connection. (You can also guess that everything went well if you didn't get an error and add the user-input to the table yourself)

2. (A lot more complex:) Connections are especially important when setting a lock. These locks are connection dependent and a lock on a table element has to be removed before closing the connection. Otherwise all users will have to wait for a time-out on the lock. When using locks you will have to have some transaction-management.

Your code was problematic because

(1) you did expect output although there might have been an error.

(2) you always want to close the connection even if you leave your method in the catch-clause. (Not that big a problem in your code)

Regards,

J