HOWTO: SCRIPTING LANGUAGE SUPPORT FOR SAP SERVICES - RUBY

Similar documents
Easy Lookup in Process Integration 7.1

MDM Import Manager - Taxonomy Data (Attribute Text Values) Part 3

MDM Syndicator: Custom Items Tab

Integration of Web Dynpro for ABAP Application in Microsoft Share Point Portal

SDN Community Contribution

SDN Community Contribution

Creating Multiple Methods/Operations and Exposing BAPI as a Webservice

Using Radio Buttons in Web Template

ecatt Part 6 System Data Container

Exception Handling in Web Services exposed from an R/3 System

POWL: Infoset Generation with Web Dynpro ABAP

Material Listing and Exclusion

Graphical Mapping Technique in SAP NetWeaver Process Integration

Material Master Archiving in Simple Method

How to Reference External JAR Files in Web Dynpro DC in SAP NW Portal 7.3

Financial Statement Version into PDF Reader

Creating Custom SU01 Transaction Code with Display and Password Reset Buttons

Validity Table in SAP BW/BI

Standalone BW System Refresh

Step By Step: the Process of Selective Deletion from a DSO

Creating, Configuring and Testing a Web Service Based on a Function Module

How to Create and Execute Dynamic Operating System Scripts With XI

How to Create and Schedule Publications from Crystal Reports

Open Text DocuLink Configuration - To Access Documents which are Archived using SAP

Explore to the Update Tab of Data Transfer Process in SAP BI 7.0

Displaying SAP Transaction as Internet Application in Portal

How to Create Top of List and End of List of the ALV Output in Web Dynpro for ABAP

SDN Community Contribution

Developing Crystal Reports on SAP BW

SUP: Personalization Keys and Synchronize Parameter

Database Statistics During ODS Activation

Step By Step Procedure to Implement Soap to JDBC Scenario

Add /Remove Links on ESS Home Page in Business Package 1.5

DB Connect with Delta Mechanism

Adding Files as Attachments to SAP Interactive Forms in the Java Environment

Step by Step Method for File Archival in BW

A Step-by-Step Guide on IDoc-ALE between Two SAP Servers

Creating Rules in Process Composer and using them in Process

List of Values in BusinessObjects Web Intelligence Prompts

This article explains the steps to create a Move-in letter using Print Workbench and SAPScripts.

Extracting Missing Fields of Data Source Which Are Present In Their Extract Structure

Step by Step Procedure for DSO Creation

Replacement Path: Explained with an Illustrated Example

SAP QM-IDI Interface. SDN Contribution. Applies to: Summary. Author Bio. SAP QM Interfaces

Step-By-Step guide to Virtual InfoCube Implementation

E-Sourcing System Copy [System refresh from Production to existing Development]

Information Broadcasting Part 3 Scheduling the First Report

Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

How to Default Variant Created for Report Developed In Report Painter/Writer

How to use Boolean Operations in the Formula as Subsidiary for IF Condition

Data Flow During Different Update Mode in LO Cockpit

How to Create Tables in MaxDB using SQL Studio

Linking Documents with Web Templates

How to Configure User Status in mysap SRM

Process Chain Log Deletion

SDN Community Contribution

ios Ad Hoc Provisioning Quick Guide

Printer Landscape Made Easy!!

MDM Syndication and Importing Configurations and Automation

Purpose of Goods Receipt Message indicator in Purchase Orders

Limitation in BAPI Scheduling Agreement (SA) Create or Change

Federated Portal for Composite Environment 7.1

Table Row Popup in Web Dynpro Component

How to Integrate SAP xmii Services with Web Dynpro Java

BAPI Execution in offline Adobe Form

Recreating BIA Indexes to Address the Growth of Fact Index Table

Currency Translation in SAP BI Step by step Guide

SMT (Service Mapping Tool)

SAP BusinessObjects Translation Manager Functionality and Use

Setting up Connection between BW and R/3 for Data Load

Upload Image file from system in Web dynpro view

Template Designer: Create Automatic PDF Documents for Attachment or Print Purpose

External Driver Configuration for Process Integration 7.0

How to Create Business Graphics in Web Dynpro for ABAP

Implying Security on Business Object XI 3.1 Universe having SAP BW as Source

Open Hub Destination - Make use of Navigational Attributes

Step by Step Guide for PI Server Start and Stop Procedure

Freely Programmed Help- Web Dynpro

SAP BI BO Unit/Currency Logic for Unknown Units Case Study

SAP PI/XI: Generating Sequence Number Between Multiple Instances of Mapping Execution

Universal Worklist - Delta Pull Configuration

How to Create View on Different Tables and Load Data through Generic Datasource based on that View

SDN Community Contribution

Solution to the Challenges in Pivoting

Programmatical Approach to User Management in Enterprise Portal

Creation of Key Figures with Higher Decimal Place Precision

Maintaining Roles and Authorizations in BI7.0 - RSECADMIN

Server Connectivity and Data Load from Non SAP System to BW

Config Tool Activities

Errors while Sending Packages from OLTP to BI (One of Error at the Time of Data Loads through Process Chains)

How to Upload a File into the Knowledge Management (KM) Repository using KM API.

About ITAB Duplicate_Key (SAP lrsaods) Runtime Error

SDN Community Contribution

Generate Export Data Source

Changing the Source System Assignments in SAP BW Objects without Affecting the Data Modeling

Fetching User Details from the Portal and Displaying it in Web Dynpro with Authentication in the Portal

Methods of Selecting BOM Variant Parts in Variant Configuration

SYNDICATING HIERARCHIES EFFECTIVELY

Loading the Data for Time Dependent Hierarchy in SAP BI

Material Master Extension for New Plant

Transcription:

SDN Contribution HOWTO: SCRIPTING LANGUAGE SUPPORT FOR SAP SERVICES - RUBY Applies To SAP NetWeaver; Ruby 1.8.2; SAP::Rfc 0.19 Ruby Extension. Summary This article gives an introduction to usage of SAP services in Ruby scripts. These concepts are applicable to any scripting language. There are also additional documents concerning Python, PHP and Perl support. The article does not consider security aspects, since they are subjects of different documents. Created: 14 July 2006 Version: 1.0.0 Author Bio Vasil Bachvarov (vasil.bachvarov@sap.com) has been working for SAP AG since January, 2005. He has developed demo applications and tests for the Composite Applications Framework project, Guided Procedures and does research in the area of scripting language integration with SAP software. Currently considered languages are PHP, Ruby, Ruby and Perl. Vasil is a graduate student at the Technical University of Darmstadt, Germany, major Informational and Communicational Technology. He has about 6 years experience in software development. 2006 SAP AG 1

Table of Contents HOWTO: Scripting Language Support for SAP Services - Ruby... 1 Applies To... 1 Summary... 1 Author Bio... 1 Table of Contents Motivation... 2 Motivation... 3 Writing a Ruby Scripting Application, Utilizing RFCs... 3 Example Ruby Application with RFC Access... 3 Preparatory Steps... 3 Importing the saprfc library... 3 Opening an RFC Connection... 3 Discovering the Required Function... 3 Making the Function Call... 3 Closing the RFC Connection... 4 Writing a Ruby Application, Consuming SAP Enterprise Services... 4 Example of a Ruby Application with Enterprise Service Access... 4 Preparatory Steps... 4 Creating the SOAP::RPC::Proxy Object... 4 Adding the Method Definition... 4 Executing the Web Method... 4 Conclusion... 5 Related Content... 5 Scripting Languages Support for SAP Services... 5 RFC Consumption in Ruby... 5 Web Services Consumption in Ruby... 5 NetWeaver Development... 5 Disclaimer and Liability Notice... 6 2006 SAP AG 2

Motivation SAP systems are accessible from the outer world through different interfaces. There are RFC connectors for Java,.NET, the RFC Library for native applications, etc. Another option is accessing SAP enterprise services via web service calls. The connectivity of a scripting language to a SAP system could be achieved by using a special connector, written as an extension to a language s engine (for RFC connectivity), or by using standard web service libraries (for enterprise services connectivity). This document explains the necessary steps to create a SAP-enabled scripting application in Ruby, using these interfaces and connectors. Ruby samples are available within the text. Writing a Ruby Scripting Application, Utilizing RFCs For this purpose one needs a specific SAP connector for Ruby. In the following an example of a Ruby application, utilizing RFC is shown. Assumption: This document assumes that an appropriate Ruby scripting environment is already installed and configured. Example Ruby Application with RFC Access Preparatory Steps We need to install a Ruby extension that will allow us to use the RFC API in the scripts. An RFC connector for Ruby is available at http://raa.ruby-lang.org/project/saprfc/ and is called SAP::Rfc. Please, follow the installation notes in its documentation in order to install it on your system. Importing the SAP::Rfc library To have access to the SAP::Rfc functions import the SAP::Rfc library: require "SAP/Rfc" Opening an RFC Connection To open an RFC connection, pass the connection parameters to the SAP::Rfc module: rfc = SAP::Rfc.new(:ashost => "ashost1", :sysnr => 0, :lang => "EN", :client => "100", :user => "jsmith", :passwd => "drowssap", :trace => 0) If error occurs an exception will be thrown. Discovering the Required Function We have to discover the remote function and get a reference to it before we can make the call. This will automatically retrieve all the necessary parameter definitions of the function. In case of an error an exception will be thrown. iface = rfc.discover("rfc_function1") Making the Function Call 1. Import the input parameters: 2006 SAP AG 3

iface.myparam1.value = param1 iface.myparam2.value = param2 2. Execute the function: rfc.call(iface) 3. Export the output parameters: rtn = iface.outparam1.value Closing the RFC Connection rfc.close() Writing a Ruby Application, Consuming SAP Enterprise Services Enterprise services can be consumed, using Ruby s built-in SOAP library. Example of a Ruby Application with Enterprise Service Access In the next example we ll use the SOAP::RPC::Driver class to create a web service proxy object. Preparatory Steps First we have to create a SAP enterprise service, which will be consumed, which is out of the scope of this document. Please, refer to the SAP NetWeaver Developer s Guide for more information. Please note, as of release 6.40 and higher all remote enabled functions can be called via this method. We will use the SOAP::RPC::Proxy class to connect to the web service via the automatically generated client stubs. Creating the SOAP::RPC::Proxy Object The proxy object can be created with the following code: my_service = SOAP::RPC::Driver.new( 'http://mysapserver:50000/myservice/config1?style=document', 'urn:myservicevi') Adding the Method Definition With the following code one can add a new method definition to the object: my_service.add_method('mymethod', 'myparam1', 'myparam2') Executing the Web Method The execution of the method is as simple as calling an automatically generated method stub of the proxy object: return my_service.mymethod(param1, param2) In case of error an exception is thrown from the method, so error handling is possible. 2006 SAP AG 4

Conclusion SAP service consumption in Ruby scripts can be implemented by calling enterprise services or RFCs. Enterprise services are compliant with the standard web services and therefore can be executed using builtin Ruby library for web service calls. RFCs are available in Ruby scripts thanks to the SAP::Rfc extension module, which exposes the RFC library functions to the Ruby application. Related Content Scripting Languages Support for SAP Services I. SAP Developer Network (http://sdn.sap.com). RFC Consumption in Ruby II. SAP::Rfc Connection Module for Ruby (http://raa.ruby-lang.org/project/saprfc/). Web Services Consumption in Ruby III. Solving the WSDL Import Problem for SAP Enterprise Services (SAP Notes 766953 and 738912). IV. Ruby Web Site (http://www.ruby-lang.org/). NetWeaver Development V. SAP NetWeaver Developer s Guide (https://www.sdn.sap.com/irj/sdn/developersguide). 2006 SAP AG 5

Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document. 2006 SAP AG 6