Reflection of FM parameters in JCo

Tags: , , ,

I have a problem with the dynamic receipt of the list of parameters and their values when calling the Function Module in SAP (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 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 Informations 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


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


Source: stackoverflow