cancel
Showing results for 
Search instead for 
Did you mean: 

Disconnect method

sid-desh
Advisor
Advisor
0 Kudos

Hi,

I am using an Adaptive RFC model for fetching data from backend. I would like to confirm whether the EXECUTE method in the model object has a call to DISCONNECT method to log out from the SAP system or do we need to

call this method explicitly.

Please give suggestions.

Regards

Sidharth

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sidharth,

by default, the AdaptiveRFC model opens a connection lazily (on-demand) and keeps this connection for the duration of the currently running Web Dynpro application. This means, that if you close the browser window, or if you enter a new URL, or if you refresh, WD will terminate the running application instance and any connection still open will be released to the pool.

This default is configured as part of your model in the DevStudio. You can see this configuration, when you open an arbitrary ModelClass of your model and look at the ModelSettings in the "Properties" Tab.

The name of the property for specifying the maximum duration of a connection is called "modelInstance_defaultScope". The default value is "APPLICATION_SCOPE" (meaning as long as the application is running).

If you want to close a connection immediately each time the response is returned to the Browser, then you can use the value "TASK_SCOPE".

Additionally, you can specify how long to manage the connection at runtime, thereby overriding the defaults configured as mentioned previously.

Example:

<pre> Bapi_Flight_Getdetail_Input input =

new Bapi_Flight_Getdetail_Input(<b>WDModelScopeType.APPLICATION_SCOPE</b>);

Bapi_Flight_Getdetail_Input input2 =

new Bapi_Flight_Getdetail_Input(<b>WDModelScopeType.TASK_SCOPE</b>);

</pre>You can also use the WDModelFactory for creating models with a specific scope:

<pre> Flight myModel = (Flight)WDModelFactory.getModelInstance(Flight.class, WDModelScopeType.TASK_SCOPE);

</pre>If you need to disconnect manually (e.g. if you're using APPLICATION_SCOPE and need to disconnect before the application ends), then you can do the following:

<pre> input.modelInstance().<b>disconnectIfAlive()</b>;

</pre>

Please have a look at the JavaDoc of <b> IWDDynamicRFCModel </b> as well as <b> WDModelFactory </b> for more details.

Ciao, Markus

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Sidarth,

the default LogicalSystem is available as a static constant in your Model.

Example for a Model called "Flight":

application destination:<pre> Flight.DEFAULT_SYSTEMNAME</pre> metadata destination:<pre> Flight.DEFAULT_RFCMETADATA_SYSTEMNAME</pre>

You can set the application destination explicitly via runtime api:

<pre> Flight model =(Flight)WDModelFactory.getModelInstance(Flight.class);

model.<b>setSystemName("YOUR_DESTINATION")</b>;

</pre>

<u>But please be aware:</u>

the SystemName set dynamically using the mentioned api <b>MUST</b> point to the same Technical System as the Metadata destination. In other words, you can not get your application data from one system (lets say "HRX") and configure the metadata to be fetched from a different system (lets say "CRM"). This will raise an exception because the metadata is inconsistent with the system you are fetching the data from.

Additionally, the name of the Metadata destination can not be changed via api. This is due to the fact, that Web Dynpro requires access to the metadata before the first line of application code even runs.

If you require running an application against a different backend system than configured by default, then this is possible by specifying the alternative destination via URL parameter when starting the application:

<pre>sap.wdarfc.useSys=<DEFAULT_SYSTEM>:<SUFFIX_OF_MAPPED_SYSTEM></pre>In newer versions, not "." but "-" is used as separator:

<pre>sap-wdarfc-useSys=<DEFAULT_SYSTEM>:<SUFFIX_OF_MAPPED_SYSTEM></pre>

The following URL starts the application "FlightApp" and maps the logicalSystem "WD_MODELDATA_DEST" to logicalSystemName "WD_MODELDATA_DEST<b>B20</b>", as well as mapping the logicalSystem "WD_RFC_METADATA_DEST" to logicalSystemName "WD_RFC_METADATA_DEST<b>B20</b>":<pre> <u>htip://Yourhost:50000/webdynpro/dispatcher/local/Flight/FlightApp?</u>

<u>sap.wdarfc.useSys=WD_MODELDATA_DEST:B20&sap.wdarfc.useSys=WD_RFC_METADATA_DEST:B20</u>

</pre>

Remarks: the new SystemName used in the URL must begin with the previous SystemName and be at most 3 characters longer than the previous name. The full SystemName must be configured properly in the WD ContentAdmin. In the URL Parameter, you must only use the Suffix, not the full name. These restrictions were required to enforce security guidelines as well as to help keep URLs as short as possible.

Ciao, Markus

Former Member
0 Kudos

Hi Markus!

You have said that one can not modify the METADATA Jco Destination. It happens that I have created an Model and, accidentally mispelled the name o METADATA Jco Destination when doing so.

Now the J2EE engine is throwing an WDRuntimeException saying that the wrong destination doesn't exist in SLD, although I've already changed it in the project properties back there in NWDS.

How can I solve this?

Regards,

Flavio Rasseli

sid-desh
Advisor
Advisor
0 Kudos

Hi Markus,

Thanks for the elaborate response. Will definitely have a look at this and check out what you have suggested. I the mean time can you please also help me out with another scenario.

Can we also somehow check the JCO destinations being used by the model instance and change the same at runtime.

Regards

Sidharth

sid-desh
Advisor
Advisor
0 Kudos

Hi,

Any help in this regard will be helpful. I just need to confirm on this issue.

Regards

Sidharth