SAP / gorfc

SAP NW RFC Connector for GO
Apache License 2.0
94 stars 42 forks source link

List all the RFC's and its schema using gorfc #39

Open aashakabra opened 11 months ago

aashakabra commented 11 months ago

Is there any way we can get the list of all RFC's and its schema using gorfc third party. Which methods can be used to do so? Something similar to SAP JCo library.

bsrdjan commented 11 months ago

With "all RFCs" you mean all RFCs used in your scenario, like RFCs whose names are listed in some input file?

Can you share some more info on your scenario and how the schema should be used? In design-time, using CLI for example, or in your application run-time, to dynamically read schemas of arbitrary RFCs?

aashakabra commented 11 months ago

We have a filter text box where if I mention SFTC* then I should be able to fetch all the RFC's starting from SFTC and display it in dropdown. Based on the RFC clicked on the dropdown, I should be able to fetch the fields(dynamically) of that RFC and able to display on input tab.

to further make actual runtime call. I am using gorfc.Connection's Call method to perform runtime operation.

Using Jco library I am able to perform both design time operation of fetching list of all RFC's based on text filter and display the schema/fields of the selected RFC so that I can take input from user and then perform runtime operation. But I am trying to see if I can do both design time operations using go library.

bsrdjan commented 11 months ago

Not sure how JCo exactly is doing it but the RfcGetFunctionDesc from SAP NW RFC SDK could be exposed, like Python RFC method get_function_description() for example.

Usage example is examples/clientPrintDescription.py,

RFM schema retrieved by this method looks like this: https://github.com/SAP/PyRFC/tree/main/tests/data, if it fits your requirements

aashakabra commented 11 months ago

Thankyou for suggestion. I think current method gorfc.Connection.GetFunctionDescription should help with the input and output fields of mentioned RFC. Right?

Is there any method available in gorfc that can help to list down all the RFC's starting from some keyword like SFTC* ?

bsrdjan commented 11 months ago

Yes, gorfc.Connection.GetFunctionDescription sounds promising. The gorfc method to list RFCs can only pass the selection like STFC* to some ABAP RFC, to get the list of RFCs from ABAP system. I don't know if such RFC exists and how JCo is doing it. Perhaps to ask in SAP ABAP Community ?

bsrdjan commented 11 months ago

The RFC_FUNCTION_SEARCH is ABAP RFC that returns the list of ABAP RFC names.

aashakabra commented 11 months ago

Is there any plan to make such functionality available in https://github.com/SAP/gorfc ?

bsrdjan commented 11 months ago

Not to my knowledge

aashakabra commented 11 months ago

Okay.

With JCo client I am able to use call above function in this manner- JCoFunction func = client.getRepository().getFunction("RFC_FUNCTION_SEARCH");

My requirement is to do something like this using golang.

bsrdjan commented 11 months ago

Yes, you can do it the same way in golang. It is standard function module call like in README examples

aashakabra commented 11 months ago

Thankyou, I was able to do so using below snippet-

params1 := map[string]interface{}{
        "FUNCNAME": "STFC*",
    }

r1, _ := conn.Call("RFC_FUNCTION_SEARCH", params1)
aashakabra commented 11 months ago

Hello bsrdjan, Can you please let me know what does nucLen and ucLen in FunctionDescription mean?

I can see for few RFC, having the RFCTYPE_CHAR has nucLen = 3 and ucLen=6 whereas another parameter having same type RFCTYPE_CHAR has nucLen = 1 and ucLen = 2

bsrdjan commented 11 months ago

it is unicode and non-unicode length