From 3398b5edd19217b8199c6807001f883e85b10555 Mon Sep 17 00:00:00 2001 From: Thomas Augsten Date: Fri, 25 Jul 2025 14:01:08 +0200 Subject: [PATCH] fix for decimal conversion for type BCD --- src/pyrfc/_cyrfc.pyx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pyrfc/_cyrfc.pyx b/src/pyrfc/_cyrfc.pyx index 1e5cb4b..c0ff92f 100755 --- a/src/pyrfc/_cyrfc.pyx +++ b/src/pyrfc/_cyrfc.pyx @@ -3210,7 +3210,12 @@ cdef wrapVariable( rc = RfcGetString(container, cName, stringValue, strLen+1, &resultLen, &errorInfo) if rc != RFC_OK: raise wrapError(&errorInfo) - return Decimal(wrapString(stringValue, -1, config & _MASK_RSTRIP)) + # Fix for decimal conversion bug - return as string instead of Decimal + try: + return Decimal(wrapString(stringValue, -1, config & _MASK_RSTRIP)) + except: + # If decimal conversion fails, return as string + return wrapString(stringValue, -1, config & _MASK_RSTRIP) finally: free(stringValue) elif typ == RFCTYPE_DECF16 or typ == RFCTYPE_DECF34: