问题
The is a follow-up question of SAP RFC: nuc_length vs uc_length
With PyRFC I can get the func_description like this:
get_function_description(rfc_name)
Per field I can read uc_length
and nuc_length
.
How can I determine the number of unicode characters which I can put into the field if nuc_length=40 and uc_length=80?
回答1:
Unfortunately this is not possible, I think. From the given length in bytes you can only calculate a maximum number of characters which would fit into this field.
For unicode ABAP systems we know that SAP stores the character data in code pages 4102 / 4103 which is UTF-16 (big and little endian format). That means a character needs at least 2 bytes, i.e. the maximum length can be calculated as uc_length / 2 = 40 chars in your example. I don't think that SAP already uses any 4-byte character yet. However, this would be possible with code pages 4102 / 4103. Therefore it depends on which Unicode character you will put in the field, it might be that less than 40 characters could be stored in a field with uc_length=80.
This is even more difficult with non-Unicode ABAP systems. As long as you only use code page 1100 with English logon language, a character usually only needs 1 byte. But if for example, using Japanese and code page 8000, then text data can contain mixed US-ASCII characters and Japanese characters. That means the text field may contain both: 1-byte characters and 2-byte characters. And to make it even more difficult, even 3-byte characters exist for all non-unicode code pages including code page 1100. For example, there are some SAP specific character icons/symbols with this length. Hence, the nuc_length=40 field can contain 40 Unicode characters at the maximum, but also only 13 characters in the worst case. It depends on which code page is being used and which Unicode characters you are filling into the field.
来源:https://stackoverflow.com/questions/58203229/determine-the-number-of-characters-which-are-allowed-in-a-field