Skip to Content
Author's profile photo Alvaro Tejada Galindo

Tasting the mix of Ruby, Sinatra and SAP

I’m pretty sure that by now you have realized that I love Scripting Languages. That means that once in a while I love to play with a new language or a new web framework. This time I came to play with Sinatra a very amazing framework.

I must say that the documentation is very poor…even when a Sinatra book is in the making.

I have said a lot of times that I’m going to learn Rails but somehow…everytime I start I drop it a couple of days before…why? Surely because of Sinatra and Camping which much easier to learn and even can offer the same things as Rails.

But I’m sure that you don’t want to know about my private programming life…So let’s get into some code…


Ruby/Sinatra and SAP – SE16 Emulation

eos end end get ‘/login_view’ do body do <<-eos

eos end end get ‘/show_table’ do $output = “” for i in 0…$Fields_Len $Fields_Fields = $Data_Names[i].to_s $output += “” end $output += “” for i in 0…$Data_Len $output += “” $Data_Fields = $Data[i] $Data_Split = $Data_Fields.split(“|”) for i in 0…$Fields_Len $output += “” end $output += “” end $output += “


” body $output end post ‘/login’ do $host,$sysnr,$client,$user,$password = params[:host],params[:sysnr], params[:client],params[:user], params[:password] “#{do_login}” redirect ‘/login_view’ end post ‘/table_view’ do $table = params[:table] “#{get_table}” redirect ‘/show_table’ end helpers do def do_login $rfc = => $host, :sysnr => $sysnr.to_i, :lang => “EN”, :client => $client.to_i, :user => $user, :passwd => $password, :trace => 1) end def get_table $itab = $“RFC_READ_TABLE”) $itab.query_table.value = $table $itab.delimiter.value = “|” $$itab) $Fields = $Data = $Data_Fields = $Data_Split = $Data_Names = $itab.fields.hashRows {|field| $Fields.push(field) } $Fields_Len = $Fields.length $ {|field| $Data.push(field[‘WA’].to_s.strip!) } $Data_Len = $Data.length $itab.fields.hashRows {|field| $Data_Names.push (field[‘FIELDNAME’].to_s.strip)} end end 

Now…Some pictures…





Hope you like it -:)

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Good post Alvaro,

      Short, informative and sweet. 🙂

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author

      I'm so glad to hear that you like it -:) I believe that small frameworks are the way to go -;)