cancel
Showing results for 
Search instead for 
Did you mean: 

Calling RfcClose() while handle in use causes my C++ application to crash

Former Member
0 Kudos

Hi!

I was hoping someone here could help me with this. I am using librfc32u.dll in my application. My application invokes RFCs on SAP, using the SDK function RfcCallReceiveEx(). At times, this call takes too long, so, from another thread, I do a RfcClose() on the connection handle.

Nearly all the time this seems to work (i.e., it successfully cancels the execution). But a couple of times I have seen that it causes my application to crash.

I wanted to know whether such a programming approach is allowed or not.

Thanks,

Mustansir

P.S. If this is not the appropriate forum for this question, please help me out and let me know where i should redirect this question to. Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi Mustansir,

how are youdoing ?

closing the connection handle is an unpredictable methodology, as it depends where it is in the execution phase and also there will be many system resources which will not be recycled into regular usage

from a programming point of view, i'd not recommend it's usage

if you are aware that the RFC that you invoke takes time, it could be simpler to use asynchronous mode of interaction ( rather than the sync)

http://help.sap.com/saphelp_nw2004s/helpdata/en/d9/15cd02ea537a47ac150de532cc1a79/content.htm

with respect,

amit

Former Member
0 Kudos

Hi Amit.

Thanks a lot for your response.

Yes, I was also looking into Async as an alternative. However, my main aim is to cancel the Rfc Call if it is taking more than a specified amount of time. Do you know if there is any API which I can use for that? I see that the RFC SDK header files define a function called RfcCallReceiveTimed() which takes a timeout parameter. However, there is a comment above it which says that this function is internal. I was hoping there might be a similar function open to all which I can use.

Thanks,

Mustansir

Former Member
0 Kudos

Hi Mustansir,

you could look at exception handling classes, which would do the cleanup necessary.

please let me put forward the view that there is no structured apporach for your requirement of killing a RFC.

The RFC represents a piece of functionality which will cost a number of units of time on yours and other systems

if you are not satisfied with the lead time for a result i would look at the following :

1> ways to return partial results which can be aggregated

2> optimize the RFC to return faster

3> narrower data sets of input to get optimized data

unfortunately i cannot recommend an exception handling case to be used as a regular method, as it reflects poor programming choices, will be almost impossible for another person to maintain, and will then ignore exceptions when they actually do occur to be ignored

please look at the bigger picture in the software development lifecycle, i will be glad to help you find a way thru the requirement, but cannot help in what u ask

with respect,

amit

Former Member
0 Kudos

Hi Mustansir,

thank you for the very helpful answer reward points

with respect,

amit