Floating Point Fields and the SAP Query Connector

Problem

The SAP function module RFC_READ_TABLE does not handle FLTP (floating point) fields well in all cases.

SAP 4.6C and Lower

In SAP 4.6C and lower systems, the call to RFC_READ_TABLE will throw a SYSTEM_FAILURE exception (short dump with ABAP runtime error ASSIGN_CAST_WRONG_ALIGNMENT, or a message Error in ASSIGN assignment in program SAPLSDTX in the NLINK Event Viewer). The query will succeed if FLTP fields are not in field list, but will short dump if FLTP fields are included in the field list.

SAP 4.7 and Above

In some SAP 4.7 and ECC systems, call to RFC_READ_TABLE will throw the exception if you try to query the table at all, even if you don’t ask for the FLTP field in your results.

Solution

There are several options:

  1. Depending on the various patches you have in your SAP system, you may have a function module BBP_RFC_READ_TABLE which can be used instead. If this RFC exists, assign it to the Alternate RFC External System Attribute and try it. This may work.
  2. If you don’t need the FLTP field, you can create a database View that contains the other fields you do need but no FLTP fields and query that View instead.
  3. If you do need the FLTP field, or if you don’t want to create a new View, you can apply the code changes in SAP note 758278, either modifying RFC_READ_TABLE or creating a copy. If you create a new function module, then you will need to specify it (e.g., Z_RFC_READ_TABLE, or whatever you end up naming it) in the Alternate RFC External System Attribute for the SAP for Query External System(s).
  4. If Note 758278 is not available, you can get the same code from Note 1175255 under the Correction Instructions for SAP 46C or newer systems. This note also provides instructions for manually creating the Function Module. (They call it BBP_RFC_READ_TABLE in this note but you can use your own naming convention.) If you use this note please recognize that we are not advising you to implement the entire note. Use this note only to obtain the fixed RFC_READ_TABLE code.

The Fix to the Fix

If you choose to apply the code changes from either SAP note, be aware that the SAP-provided code is written for the 1.234.456,789 Decimal Notation setting.

The following code snippet is a fix-to-the-fix that works with 1,234,456.789 notation. (This occurs four times throughout the code.) The fix “as-is” from SAP should work with 1.234.456,789 notation.

Troubleshooting

Incorrect Numeric Values  

It is important to understand that the code section shown above must be in synch with the Decimal Notation setting on the SAP id(s) that NLINK uses. (You can find this setting on the Defaults tab in the SU01 transaction.)

If the user id is set to 1.234.456,789 and you do implement the fix-to-the-fix, or if the user id is set to 1,234,456.789 and you do not implement the fix-to-the-fix, you will find that packed values (e.g., QUAN fields such as MARA-NTGEW) will not come across consistently.

You will usually notice that some values look like they need to be multiplied or divided by 1000. This is because the mismatch between decimal notation and the ABAP code leads to missing or extra decimals (e.g., a value of 4,700 (American) comes across as 4.700). Small numbers (3 digits or less) that don’t have any decimal places will not be affected, so the “error” may seem sporadic.

Empty / Missing Result Records  

In NLINK versions 5.0.0.93 and prior, it is a requirement that the fields in the structures used in the alternate RFC keep the same names as specified in the SAP note(s). The usual suspect is the DATA parameter. This parameter uses a structure that contains a single field, which must be called WA.

If the field name is something other than WA, the RFC will run fine in SE37, but you will notice missing and/or incomplete data in NLINK.

Message from NLINK Server: Failed adding default value ' ' for DISTINCT in BBP_RFC_READ_TABLE

If your SAP system has an existing copy of BBP_RFC_READ_TABLE, it may not have the same signature as the suggested code in the SAP notes referenced above. Some versions of NLINK Server expect these parameters (DISTINCT and FIX) to exist in any function module you specify as an alternate for RFC_READ_TABLE.

In this case, make a copy of the BBP_RFC_READ_TABLE function module and add two single-character (LIKE SONV-FLAG), optional Import parameters named DISTINCT and FIX. This will bypass the error message from the NLINK Server, but be aware that the function may still fail with the same alignment exception as the original RFC_READ_TABLE function. In this case, use the code from the SAP notes in your new function module, and be sure to see the comments about the decimals in the "fix to the fix" section above.