Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetFunctionMetadata will get the old metadata #95

Open
dotneterwhj opened this issue May 10, 2024 · 2 comments
Open

GetFunctionMetadata will get the old metadata #95

dotneterwhj opened this issue May 10, 2024 · 2 comments

Comments

@dotneterwhj
Copy link

When Sap RFC function changed the field, the .net program must be restarted to get the metadata after the change, otherwise the metadata obtained is before the change. Is there any way to get the latest metadata without restarting the .net program?

@campersau
Copy link
Contributor

SapNwRfc doesn't cache this info, maybe SAP is caching it for that connection? Have you tried opening a new connection (without connection pool) to get the function metadata?

public ISapFunctionMetadata GetFunctionMetadata(string functionName)
{
IntPtr functionDescriptionHandle = _interop.GetFunctionDesc(
rfcHandle: _rfcConnectionHandle,
funcName: functionName,
errorInfo: out RfcErrorInfo errorInfo);
errorInfo.ThrowOnError();
return new SapFunctionMetadata(_interop, functionDescriptionHandle);
}

@dotneterwhj
Copy link
Author

SapNwRfc doesn't cache this info, maybe SAP is caching it for that connection? Have you tried opening a new connection (without connection pool) to get the function metadata?

public ISapFunctionMetadata GetFunctionMetadata(string functionName)
{
IntPtr functionDescriptionHandle = _interop.GetFunctionDesc(
rfcHandle: _rfcConnectionHandle,
funcName: functionName,
errorInfo: out RfcErrorInfo errorInfo);
errorInfo.ThrowOnError();
return new SapFunctionMetadata(_interop, functionDescriptionHandle);
}

Thanks for your quick reply.
I've already used new connection. Here is my code

service.AddTransient<ISapConnection>(_ => new SapConnection(sapParam));

---

private readonly ISapConnection _connection;

public InterfaceSapQueryHandler(ISapConnection connection)
{
    _connection = connection;
}
public override void Handle(InterfaceSapQuery request)
{
    try
    {
        _connection.Connect();
        var functionMetadata = _connection.GetFunctionMetadata(request.SapFunction);
    }
    finally
    {
        _connection.Disconnect();
        _connection.Dispose();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants