Calculate the length of the SAP type QUAN when using an RFC-Server

This sample shows how to calculate the length of the SAP type QUAN in .NET.

When defining the SAP type QUAN in your RFC Server you also have to define it as a BCD (binary coded decimal) in .NET. The length in .NET is not the same as in SAP. Every digit from SAP needs a half byte. At the end you have to round up to a complete byte.

Example:

4 digits: 4 * 0.5 + 0.5 = 2.5 -> 3 byte Length
13 digits: 13 * 0.5 + 0.5 = 7 -> 7 byte Length

The following code converts a QUAN field in SAP with the length 13,3:

MYRFCTable.Columns.Add("BREIT", 7, 3, RFCTYPE.BCD);

Last update: January 2, 2024