It’s been a long time since my last Ruby blog…so I wanted to something nice…instead of emulate any SAP transaction, it was time for me to engage with new SAP technologies, and Gateway really looks promising…so…what’s Gateway?

 

Gateway is based on OData, which allows us to perform CRUD operations on WebService like applications…in other words…it’s just awesome technology -;) If you want to find out more, please refer to this homepage on SCN “SAP NetWeaver Gateway Demo System”.

 

So…we can access Gateway using many technologies, for example JavaScript or Java for Blackberry. But for sure, I wanted to go beyond those awesome examples, and searched for other ways to consume Gateway data…on the OData SDK List I found a Ruby gem called Ruby_OData, which works awesome for services like Netflix OData, but didn’t work to well for SAP Gateway services…

 

As you may know…here on SCN, we’re like family, so we like to work together on some nice project, so as you can see here…that’s what we did -;)

SAP NETWEAVER GATEWAY DEMO SYSTEM

image

With the gem working, I knew I wanted to blog about it…build a small Ruby application to show how easy is to use the Ruby_OData gem…but of course…having a DOS style black window wasn’t very likely…so I decide to use Camping once again -:) and of course…Camping is not very classy…and I think it’s not even maintained anymore…so if you’re looking for something nicer, you can use Sinatra instead -;)

 

As I love to say…”Enough talk! Let’s go to the source code!”

 

Camping_Gateway.rb

 

To run this example, we need to provide only 3 simple parameters:

Client = 800

Username = GW@ESW

Password = ESW4GW

 

image

 

image

 

I know what you’re going to tell me after you read the source code…why I’m taking the work of reading the date, putting them on an array and looping that? I know I just could read the field from the model and all that…but…for some reason that I still need to discover…the filtering doesn’t work as I expected…for example…I should be able to pass a filter to only select the CITYTO = ‘ NEW YORK’, but it doesn’t work even when I don’t have any errors…so my approach here (and that’s for another blog), it to have all the information stored internally to be able to do the filtering after calling the Gateway service…so…if you’re an SAP Gateway expert…please let me how to make the filter work -:( Because, I know that if I pass the VALUE, SCHME_ID and SCHEME_AGENCY_ID it’s going to work, but only for 1 record…I want a better filter -;)

 

Hope you enjoy this one…and see you soon with more Gateway coolness!

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Michelle Crapo
    I got to play with it at Innojam.  At my work we are not on a high enough enhancement pack.   Bummer.

    Now I get to bookmark another blog for later use.

    Thank you!

    Michelle

    (0) 
    1. Alvaro Tejada Galindo Post author
      Michele:

      I know I didn’t state it directly on my blog, but if you take a look at http://www.sdn.sap.com/irj/sdn/gateway?rid=/webcontent/uuid/1051f6d9-e87a-2e10-d188-e2786c7878b1 you’re going to realize that some ready made Gateway services are available to consume…I’m using one of them, which is the Flight Example…I’m just using the Consumption Model http://gw.esworkplace.sap.com/sap/opu/sdata/sap/DEMO_FLIGHT/ to pass it to the Ruby gem and get all the information that I need…isn’t Gateway awesome? We can play with it without having to wait for our own server.

      Greetings,
      Blag.

      (0) 
      1. Michelle Crapo
        Yes!   I was wondering about that.  I thought maybe it was “special” access you had.  Normally you wouldn’t advertise username and password!

        And if I would have really looked at your code I would have seen the URL.

        What is it they say?  The stupid question is the one never asked.

        Thank you!

        Michelle

        (0) 
        1. Alvaro Tejada Galindo Post author
          >>Normally you wouldn’t advertise username and password!

          LOL…you’re right -;)

          >>And if I would have really looked at your code I would have seen the URL.

          True, but next time I need to make sure I’m posting all the information -;)

          Greetings,
          Blag.

          (0) 

Leave a Reply