javajcosapjco3

Reflection of FM parameters in JCo


I have a problem with the dynamic receipt of the list of parameters and their values when calling the Function Module (with DESTINATION parameter as SAP JCo Server) and then processing it using Java (in SAP JCo Server).

The point is that I need a dynamic way to get information in JCo Server (using Java) about what SAP RFC function and with what parameters (Importing, Exporting, Changing and Tables) was called in SAP (because my JCo Server server "listens" for SAP RFC calls and I have to store information about these calls from SAP).

I know that (for example for Importing Parameters) using command:

JCoParameterList ParameterList = function.getImportParameterList(); 

in Java I can receive this data, but how to deal with this variable of type JCoParameterList? I.e. how can I get information from this variable ParameterList on the name of the parameters, their types and the values with which they were called in SAP?

I will be grateful for any suggestions on how in Java we can retrieve this data from object of type JCoParameterList!

Kind regards, Andrew


Solution

  • JCoParameterList contains a list of JCoParameterField instances. JCoParameterField in turn inherits from JCoField, which gives you methods to set or get the parameter value. JCoParameterList allows you to iterate through the list of parameters, check what kind of parameter they are, get their value etc.

    JCoParameterList parameters = function.getImportParameterList();
    JCoParameterFieldIterator it = parameters.getParameterFieldIterator();
    while (it.hasNextField()) {
        JCoParameterField field = it.nextParameterField();
        // field.getName() gives you the name
        // field.getString() gives you the parameter value as string
        // field.getExtendedFieldMetaData() gives you the field metadata
    
    }