Search code examples
jcos4hana

Unknown type when creating JCoFunction for S4


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 ?


Solution

  • 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.