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 · 3 comments
Open

GetFunctionMetadata will get the old metadata #95

dotneterwhj opened this issue May 10, 2024 · 3 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();
    }

@basis100
Copy link

@dotneterwhj

Call RFC return data, I always declare a class first and then compile the execution file,

for example my codes:
var result = connection.CreateFunction("ZSAP_LIGHT_ADS_GET").Invoke<Get_OutputTable>(inputpara);

class Get_OutputTable 
{
    [SapName("OT_LIST")]
    public Get_OutputItem[] Items { get; set; }
}

class Get_OutputItem
{
    [SapName("MANDT")]
    public string MANDT  { get; set; }

    [SapName("UUID")]
    public string UUID { get; set; }
 }

I want to configure the class in a text file without having to compile the program every time.
Do you have any ideas? Or can you show me your codes?

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

3 participants