1

I am getting below error while creating JCoFunction object for BAPI "SWNC_STATREC_READ_INSTANCE" for S/4HANA system. But, I am able to create object for R/3 system.

java.lang.IllegalArgumentException: Unknown type -1 when trying to add field MESSAGE_ID to record [Ljava.lang.String;@42c4641f
    at com.sap.conn.jco.rt.AbstractMetaData.add(AbstractMetaData.java:256)
    at com.sap.conn.jco.rt.DefaultRecordMetaData.add(DefaultRecordMetaData.java:363)
    at com.sap.conn.jco.rt.AbapRepository$DDICHelper.constructMetaData(AbapRepository.java:2889)
    at com.sap.conn.jco.rt.AbapRepository$DDICHelper.constructMetaData(AbapRepository.java:2734)
    at com.sap.conn.jco.rt.AbapRepository$DDICHelper.constructMetaData(AbapRepository.java:2824)
    at com.sap.conn.jco.rt.AbapRepository$DDICHelper.queryRecordMetaData(AbapRepository.java:2421)
    at com.sap.conn.jco.rt.AbapRepository.queryRecordMetaData(AbapRepository.java:1108)
    at com.sap.conn.jco.rt.AbapRepository.queryRecordMetaData(AbapRepository.java:703)
    at com.sap.conn.jco.rt.AbapRepository.getRecordMetaData(AbapRepository.java:929)
    at com.sap.conn.jco.rt.AbapRepository$DDICHelper.queryFunctionTemplate(AbapRepository.java:2110)
    at com.sap.conn.jco.rt.AbapRepository.queryFunctionTemplate(AbapRepository.java:1044)
    at com.sap.conn.jco.rt.AbapRepository.queryFunctionTemplate(AbapRepository.java:623)
    at com.sap.conn.jco.rt.AbapRepository.getFunctionTemplate(AbapRepository.java:885)
    at com.sap.conn.jco.rt.BasicRepository.getFunction(BasicRepository.java:163)
    at com.grc.riskanalysis.util.SAPUtil.getReportTypeTxns(SAPUtil.java:1201)

Below is the Java code to create JCoFunction object:

final JCoDestination destination = getDestination(sapSystemVO.getDestinationName().trim());
            JCoFunction function = destination.getRepository().getFunction("SWNC_STATREC_READ_INSTANCE");

Is there any other way to create object for this BAPI for S/4HANA system?

Any additional authorizations are required to user to create JCoFunction object in S/4HANA ?

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Ram
  • 423
  • 4
  • 26

1 Answers1

3

The issue is not related to R/3 or S/4HANA, but to the use of the "latest" ABAP types (int8, UTCLONG, etc.) in the parameters of the RFC-enabled function module you call from JCo, i.e. with an old S/4HANA version your JCo program could successfully call SWNC_STATREC_READ_INSTANCE if its parameter interface doesn't refer to the newest ABAP types.

Solution: install and use the latest JCo library.

References (depending on JCo version):

EDIT: referenced notes edited after trixx remark about the different JCo flavors.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • 1
    Thank you. It worked with latest JCO library. This latest version requires the Visual Studio 2013 runtime libraries to be installed on the Windows server. – Ram Apr 08 '23 at 06:41
  • 1
    @Sandra: Your answer and solution is correct, but keep in mind that the listed SAP notes refer to the embedded JCo library in NetWeaver AS Java only. For the JCo standalone connector, SAP publishes specific notes referring to their software component "SAP JCO", e.g. note [2531996](https://launchpad.support.sap.com/#/notes/2531996). – Trixx Apr 16 '23 at 17:28
  • 1
    @Trixx Thank you, I didn't realize. Answer edited and other references also added to make it a better answer. – Sandra Rossi Apr 17 '23 at 07:15
  • @Sandra: You are very conscientious and deserve your high rep score. :) utclong support was added to JCo standalone as of version 3.1.2 (can be seen in the SDK's shipped releasenotes.html). However, as this was the first GA release of JCo 3.1, there doesn't seem to exist a specific SAP note for this patch level in this exceptional case. – Trixx Apr 17 '23 at 11:06