saprfcpyrfc

The meaning of nuc_length and uc_length parameters in PyRFC?


My favorite search engine (ecosia) could not find the canonical docs from upstream (SAP) about the meaning of uc_length vs nuc_length.

What is the difference between both?

I get these parameters with a modified version of clientPrintDescription.py

nuc_length--vs--uc_length


Solution

  • I can't be sure what they do in the Python script, but based on my ABAP/SAP knowledge, I can easily say that:

    A non-Unicode ABAP-based system uses one byte to encode each character, while a Unicode ABAP-based system uses two bytes to encode each character. From ABAP 7.50, all systems are Unicode.

    In Unicode ABAP-based system, strings of characters and text fields can store Unicode characters from U+0000 to U+FFFF. Note that characters U+D800 to U+DFFF are considered like actual characters by the ABAP runtime environment (dixit ABAP documentation: "The ABAP programming language supports a subset covered by UCS-2 and not the full UTF-16 set.")

    Note that structured parameters are made of several fields which can mix characters and non-characters, the "uc_length" will double the number of bytes only of the character fields. There are also some dummy bytes between fields because of "alignment".

    In your example, a text field of 80 bytes in a Unicode system corresponds to 40 characters.