mydoghasworms / nwrfc

SAP Netweaver RFC SDK wrapper via Ruby-FFI
http://ceronio.net/nwrfc/
28 stars 14 forks source link

Getting value of timestamp type field (e.g. domain TZNTSTMPL) results in error #7

Closed mydoghasworms closed 10 years ago

mydoghasworms commented 10 years ago

Can be replicated with calling function SXMB_GET_MESSAGE_LIST and getting value of EX_FIRST_TS.

RfcGetChars(02007588, "EX_FIRST_TS", buf=02D50678, buf len=18, errorInfo=02D536C0)
<< RfcGetChars returned RFC_BUFFER_TOO_SMALL
    RFC_ERROR_INFO.key: RFC_BUFFER_TOO_SMALL
    RFC_ERROR_INFO.message: value with the type RFCTYPE_CHAR does not fit into given buffer with the length 18 required buffer length 22
mydoghasworms commented 10 years ago

Error happens in DataContainer method [] when getting value for type :RFCTYPE_BCD.

mydoghasworms commented 10 years ago

A workaround at the moment is to change lib/datacontainer.rb to make the buffer somewhat bigger in the case of a BCD type by an arbitrary number of bytes so that it is big enough. At the moment I don't know what the correct way is to determine the buffer size for BCD, whether it's only this type or if I even cover this in the tests. But the following works for me:

when :RFCTYPE_BCD
          size = metadata[:nucLength] + (metadata[:decimals] || 0)
          #buf = FFI::MemoryPointer.new(:uchar, size*2)
          buf = FFI::MemoryPointer.new(:uchar, size*2 + 10) #<-- increase buffer size
          rc = NWRFCLib.get_chars(@handle, metadata[:name].cU, buf, size, @error.to_ptr)