Search code examples
sap-erpsaprfcsapjco3

SAP JCo invoking BAPI_MATERIAL_DISPLAY


I was trying to invoke BAPI_MATERIAL_DISPLAY functional module from SAP JCo, This is how I pass my input parameter.

function.getImportParameterList().setValue("MATERIAL", "10");

From my program output I got

The material 10 does not exist or is not activated.

If I execute BAPI_MATERIAL_DISPLAY using SAP logon, I am getting the entry. Using debugger I found that my input is going as 00000000000010. And so returning response.

I don't know how to handle this in a proper way in SAP JCo.

I had directly passed the value 00000000000010 from SAP JCo and this time I got an error,

com.sap.conn.jco.JCoException: (104) JCO_ERROR_SYSTEM_FAILURE: Screen output without connection to user.

Hope SAP is opening a popup. Let me know how to solve both the issues in SAP JCo.


Solution

  • Field Material has a conversion exit routine. See also its domain MATNR in the DDIC. These conversion exits are always called automatically by SE37 but not when the Remote Function Module is called directly - like here from outside from a a JCo program.

    So if the BAPI expects to get certain parameters in their SAP internal representation format (I don't know if this is the case here), then you have to do this data transformation on your own beforehand, either by doing this purely within an own routine at Java side, or by calling the appropriate conversion routines at ABAP side via RFC.

    For more details on this I recommend to study SAP note 206068.

    Regarding your second question with the error message "Screen output without connection to user", I guess that this BAPI expects to have a connection to an SAP GUI for displaying the selected data. With a remote function call you don't have a SAP GUI connection by default, but you can attach a SAP GUI to your RFC connection with JCo, namely by specifying the additional logon parameter jco.client.use_sapgui=1. For this to work, an SAP GUI frontend (either for Windows or for Java) also needs to be installed on your host where JCo is running, of course.