Skip to Content
0

Stateful ARFC2 connection between WebDynpro and R/3 system

Feb 09 at 11:51 AM

121

avatar image
Former Member

Hello Everyone,

We recently upgraded our SAP Portal to NW 7.5 and we are using NWDS 7.5 now. Our projects models were upgraded to ARFC2. Since then we have some problems - If an ARFC2 model is executed to call Lock FM at backend, lock is set, but when the control is back to WD, the lock is released, and another problem is global variables in FM are reinitialized which would normally not be the case if the state of the user is maintained.

We wanted to use note 2216054, but we have already had the latest version of components and all models have scope type WD_APPLICATION_SESSION_SCOPE after migrations.
Our java app use some wd components from different projects and these projects have own models. So we call FM from one model to set lock, then work with FMs from another models and etc.

We decided to use note 2501389 in our FM calls. We begin every call from method beginJCoContext() and end call by endJCoContext(). But nothing changed. After it we moved method endJCoContext() in the wdDoExit(). And our lock isn't released, it is good, but we see problem with session - when user opens new window with the same application, he begins to work in the same luw in backend, and lock doesn't raise error as foreign lock. So we don't know how it use. Maybe it helps only in call sequence in one method.

I want to know if there is a way to call two or more RFC function modules in an backend via ARFC2 and have only one session in the backend? How to configure/implement stateful connection in ARFC2 model?

Thanks in advance for you suggestions!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Milen Dontcheff
Feb 14 at 10:10 AM
1

Hello Olga,

Please find the answers to your questions:

1.

Q.:I want to know if there is a way to call two or more RFC function modules in an backend via ARFC2 and have only one session in the backend?

A.:

This scenario should be implemented with different sessions. Once a session is not used any more, you need to to make the JCO connection IDLE and move it back to the pool. When there are multi-step logical units of work (LUWs), in which several function modules are executed in a row and are committed afterwards, the business application should begin and end the statefull connections based on the requirement.

As you have found out, it has been introduced a new API 'disconnectAllStatefullSessions' at the same place where disconnectifAlive() is located.

Calling this API during the exit of the application would make the JCO connection IDLE and hence available for usage for another RFC module.

wdContext.current<model>InputElement().modelObject().modelInstance().disconnectAllStatefullSessions(); 

Without this change, the lock to the backend table would release as soon as the response is sent back to WebDynpro Java.

2.

Q.: How to configure/implement stateful connection in ARFC2 model?

A.:

For any scope, ARFC2 model performs STATELESS RFC call! This is how the ARFC2 models, in FRAMEWORK.SCA 7.50, work.

If there are multiple models using same JCO destination, then it is required to disconnect each connection by calling disconnectifAlive api.

It is up to the application to begin and to end statefull call sequence for statefull scenarios.

Call disconnectifAlive or disconnectAllStatefullSessions API during the exit of the application to avoid this issue(please refer note : 2316926 )

Regards,

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hello Milen,

thanks for answers!

I understood about model scope type and I added calling disconnectAllStatefullSessions method during the exit of the application (I haven't problem with disconnect my connections), but my problem with the lock to the backend table isn't solved. Can you explain me what I am doing wrong, please?

I want to set lock when application started and this lock must be live during user work with this app. And if user open new window with the same application, lock FM must returns info that this lock have already existed. How can I implement this?

I understand that I can make my connection is stateful only by method beginJCoContext(note 2501389) . After this method I call lock FM and my lock stays active. But when I call method endJCoContext I lose my lock. Without this methods (beginJCoContext/endJCoContext) my FMs work independently of each other and lock release as soon as the response is sent back to WebDynpro Java.

But how can I use these methods for long time (during user work with app)? It works in call sequence in one method. If I don't call method endJCoContext, I have stateful connection and can call another FMs(my lock is active in this time). But it works wrong then user opens new window with the same application. In this case lock FM adds cumulative counter for Lock Entry in sm12 and doesn't return info that this lock have already existed.

Thanks in advance, Milen!

0

Hello Olga,

I'm redirecting you the answer from the Development Support:

***

1.

The solution part in 2501389 contains the procedure to perform 2 RFM executions in single call sequence. Same can be followed for any number of models.

2.

When the same application is opened in new window , it is a new application session created. Would you please try changing the scope of the models to UC_SCOPETYPE and check the behavior?

3

By default ARFC2 connections are stateless. And to execute ARFC2 models in a call sequence(stateful), steps mentioned in note 2501389 needs to be followed. So far it looks like you are able to execute models in stateful sequence and have some problem when the same application is opened in new window.

***

Regards,

0
Former Member

Thank you very much for answers!
I have tried changing the scope of the models to UC_SCOPETYPE, but unfortunately nothing changed.

Please, can you explain me how to set lock to the backend table in the begin of application and to make this lock active in r3 while application running (not in single call sequence)?

If I understand correctly, I need to have active stateful connection for this goal. Otherwise (with stateless connection) I lose lock as soon as the response is sent back to WebDynpro Java. Right? I can create active stateful connection (which open while app working) only with methods from note 2501389. But how to use them when single call sequence is not enough for lock period, and you want to have active lock in r3 while application running? Is it realistic implement?
Thanks in advance, Milen!

0