require "SAP/Rfc"
print "Host: "
$Host = gets
print "System Number: "
$Sysnr = gets
print "Client: "
$Client = gets
print "User: "
$User = gets
print "Password: "
$Password = gets
rfc = SAP::Rfc.new(:ashost => $Host.chop!,
:sysnr => $Sysnr.chop!.to_i,
:lang => "EN",
:client => $Client.chop!.to_i,
:user => $User.chop!,
:passwd => $Password.chop!,
:trace => 1)
itab = rfc.discover("RFC_READ_TABLE")
print "/nEnter table: "
$Table = gets
print "/n"
itab.query_table.value = $Table.chop!
itab.delimiter.value = "|"
rfc.call(itab)
$Fields = Array.new
$Data = Array.new
$Data_Fields = Array.new
$Data_Split = Array.new
itab.fields.hashRows {|field| $Fields.push(field) }
$Fields_Len = $Fields.length
itab.data.hashRows {|field| $Data.push(field.to_s.strip!) }
$Data_Len = $Data.length
for i in 0...$Data_Len
$Data_Fields = $Data[i]
$Data_Split = $Data_Fields.split("|")
for i in 1...$Fields_Len
print $Data_Split[i].to_s.strip, "|"
end
print "/n/n"
end
print "/nclose connection: ", rfc.close(), "/n"