简体   繁体   中英

How to fix 'Unknown type -1 when trying to add field ID to record '

We are programming a sapjco client to automate certain things. However, one function seems to have problems initializing the functions. Other function blocks can connect correctly, but this one crashes when attempting to connect.

The function doesn't have an import. But we also tried it with import with the same result. So adding one doesn't seem to work as well

FUNCTION ZE237_GET_REZEPTID.

TYPES: BEGIN OF ZE237SOLLDATEN_TYP,
  id TYPE ZE237SOLLDATEN-ID,
  name TYPE ZE237SOLLDATEN-NAME,
  END OF ZE237SOLLDATEN_TYP.

DATA lt_table TYPE TABLE OF ZE237SOLLDATEN.

SELECT
  id name
  FROM ZE237SOLLDATEN
  INTO CORRESPONDING FIELDS OF TABLE T_EXPORTNAME.


ENDFUNCTION.
public IntellifarmSapFunction(JCoDestination destination, 
    JCoRepository repository, String functionname) throws JCoException, IllegalArgumentException {
    this.destination=destination;
    this.function = repository.getFunction(functionname); //crash here
}

Expected: A pointer of the function

Result: 'Unknown type -1 when trying to add field ID to record'

If any of the fields is of ABAP data type int8 then you need at least the JCo 3.0.18 patch level which adds support for this new data type.

You can download the latest JCo patch level from https://support.sap.com/jco

However, I do not recommend to use an ABAP integer type for an ID field. In ABAP integer types are usually used for calculating purposes only. The preferred data type for numerical data values like an ID should be a NUMC (type n) instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM