I've ran into an issue where I'm referencing a field in a structure (which is of type date) that gives a error when it's not populated, but works fine when it's been set.
Am I using the library correctly? Or is this s bug?
I've ran the code below in IRB:
require 'nwrfc'
include NWRFC
SAP_USER = 'user'
SAP_PASS = "***pass**"
SAP_HOST = "172.17.x.x"
SAP_SYSNR = "00"
SAP_MANDT = "300"
connection = Connection.new( {
'user' => SAP_USER,
"passwd" => SAP_PASS,
"client" => SAP_MANDT,
"ashost" => SAP_HOST,
"sysnr" => SAP_SYSNR })
function = connection.get_function("BAPI_USER_GET_DETAIL")
fc = function.get_function_call
fc[:USERNAME]="INACTIVEUSER"
fc.invoke
# Works fine when called on an inactive user (where "valid to" date is set)
fc[:LOGONDATA][:GLTGB] # => #<Date: 2011-06-13 ((2455726j,0s,0n),+0s,2299161j)>
fc[:LOGONDATA][:GLTGB].to_s # => "2011-06-13"
# Metadata for field:
fc[:LOGONDATA].member_metadata :GLTGB
# => {:name=>"GLTGB", :type=>:RFCTYPE_DATE, :nucLength=>8, :ucLength=>16, :decimals=>0, :typeDescHandle=>#<FFI::Pointer address=0x00000000000000>}
# Now call for an ACTIVE user (where the :GLBTB entry is not yet populated)
fc[:USERNAME]="ACTIVEUSER"
fc.invoke
fc[:LOGONDATA][:GLTGB].to_s
# BOOM!
ArgumentError: invalid date
from /home/vagrant/.rvm/gems/ruby-2.2.5/gems/nwrfc-0.0.9/lib/nwrfc/datacontainer.rb:43:in `parse'
from /home/vagrant/.rvm/gems/ruby-2.2.5/gems/nwrfc-0.0.9/lib/nwrfc/datacontainer.rb:43:in `[]'
from (irb):70
from /home/vagrant/.rvm/rubies/ruby-2.2.5/bin/irb:11:in `<main>'
# Other fields which are set return correct data:
fc[:LOGONDATA][:LTIME].to_s # "2017-08-05 10:48:11 +0000"
I've ran into an issue where I'm referencing a field in a structure (which is of type date) that gives a error when it's not populated, but works fine when it's been set.
Am I using the library correctly? Or is this s bug?
I've ran the code below in IRB: