35
SAP .NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison [email protected]

Bi Dotnet Sapbw

Embed Size (px)

Citation preview

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 1/35

SAP .NET Connector: CaseStudy on Microsoft SAPBW Data Extract

Bill [email protected]

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 2/35

Agenda

What is the SAP .NET Connector

Data Push Design Overview

Development Overview

Lesson Learned

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 3/35

What is the SAP .NET Connector

Terminology SAP BW ± SAP data warehousing solution Info Object ± Building blocks of BW. This is where you

define your key figures and characteristics. It is alsowhere you store all of your master data

ODS ± Operational Data Store. This is where you storeyou detailed level records in BW.

RFC ± Remote Function Call. This is a call to a functionmodule in a system different from the caller¶s.

Windows Service - Formerly known as NT services,enable you to create long-running executable

applications that run in their own Windows sessions.These services can be automatically started when thecomputer boots, can be paused and restarted, and donot show any user interface.

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 4/35

What is the SAP .NET Connector

Terminology

SQLXML ± Enables developers to bridge the gapbetween Extensible Markup Language (XML) andrelational data. You can create XML views of your

existing relational data and work with it as if it were anXML file for example.

SQLXML BULK LOAD ± XML Bulk Load is a stand-aloneCOM object that allows you to load XML data intoMicrosoft SQL Server tables. Bulk load utility provides

higher performance when you need to insert largeamounts of XML data.

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 5/35

What is the SAP .NET Connector

An SAP product released late 2002

From the SAP website:

The SAP Connectors allow the integration of different

applications and technologies with SAP Systems viaopen standards

The SAP .NET Connector offers developers to exposeBAPIs and remotely-enabled function modules toany .NET application (inside-out). You now also canaccess .NET components from with a mySAP.com

application (outside-in)

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 6/35

What is the SAP .NET Connector

SAP client solution, the SAP system is the serverand the .NET application is the client thatinteracts with the RFC

Examples of some uses for the SAP .NETConnector client application

Windows form application that has a customized andhighly interactive user experience

Console application to access information from the SAP

system as part of some NT batch processing

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 7/35

What is the SAP .NET Connector

RFC server allows your SAP system toexecute .NET code as if the .NET code wereanother SAP system

Examples of some uses for the SAP .NETConnector server application

Getting information such as maps, stock prices orweather from an external service to be used within aSAP report

Sending emails from your SAP system

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 8/35

Business case: Supply data that had beentransformed in SAP BW to a non-SAP database

Other solutions considered

Create a custom ABAP to create flat files to beconsumed by the destination data warehouse

Create a DTS package to extract and pump the data tothe non-SAP database

Use MS SQL replication to extract and feed the data to

the non-SAP database Hub and Spoke

Data Push Design Overview

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 9/35

Data Push Design Overview

Why we chose the SAP .NET Connector

Flexibility

Speed

Cost Scalability

Leverage development expertise on the internalMicrosoft SAP development team

Demonstrate SAP BW ability to be a enterprise data

distribution tool within Microsoft using SAP opennesstools

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 10/35

Data Push Design Overview

Technologies used

SAP BW 3.0B

SAP .NET Connector 1.0

Window 2003

SQL 2000 SP3

SQL XML 3.0

Microsoft Visual Studio .NET

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 11/35

Data Push Design Overview

Skill sets needed

Database Design

SAP Basis

SAP Security

ABAP developer

RFC and TCP/IP knowledge

MS SQL and DTS

C# developer

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 12/35

Data Push Design Overview

SAP BW Window 2003 Server

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 13/35

Data Push Design Overview

Process Flow

Submit a ABAP program to run per the selection criteriaentered

ABAP program executes a RFC that will either create the

tables on the non-SAP database, or push the SAP datafrom the query that was run in the ABAP

RFC calls the Windows service, which will either call astored procedure to create tables, or push data into thetables it had just created using SQLXML BULK INSERT

Pass back any success or failure message to the ABAPprogram

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 14/35

Development Overview

Project Overview

Metadata Definition

RFC Set Up

ABAP

Query over BW data

RFC call

Windows Service Overview

SQLXML BULK INSERT

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 15/35

Project Overview

Detailed Example ± Company Code

Business Requirement and Data Analysis

Pass to non-SAP data warehouse company

code number and name

Full push of the data with each data push

Data is stored in the BW info objects0COMP_CODE

0COMP_CODE data is stored in the BW tables /BI0/MCOMP_CODE and /BI0/TCOMP_CODE

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 16/35

Project Overview

ABAP program will pull all company code data,and place it in a internal table, then pass thedata in the internal table to a RFC

ABAP program will only pass the µActive¶ records

ABAP program will use a TCP/IP connection totalk to the windows service

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 17/35

Meta data definition ± SAP itab

Structure for Company Table Interface* Defines the company code table for ABAP and RFC

ZBPUR_COMPANY_TYPEShort text:Structure of Company Table Interface

Structure

Field structureNumber of fields: 2Sum of field lengths: 44

Component Type Len TypName TextCOMPANYCODE CHAR 4 /BI0/OICOMP_CODE

Company CodeCOMPANYCODETEXT CHAR 40 RSTXTMD Med.

Desc

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 18/35

Metadata Definition ± SAP itab

Structure for Tables to be created* Used to hold the name of the tables will create* in the destination databaseZBPUR_CREATED_TABLE_TYPE

Short text:bw dnc created table structureStructure

Field structureNumber of fields: 2Sum of field lengths: 100

Component Type Len TypName TextTABLENAME CHAR 50 TEXT50 Text FieldTABLENAMECREATE CHAR 50 TEXT50 Text Field

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 19/35

Metadata Definition ± SQL Table

 /* Company Table build */IF @TableName = 'CompanyCode'BEGINSET @DropTableString = 'DROP TABLE ' +

 /* Build the name of the table. */@TableNameCreate

SET @CreateTableString = 'CREATE TABLE ' + 'dbo.' + /* Build the name of the table. */@TableNameCreate +

 /* Build a table fields */'(CompanyCode CHAR(4) NOT NULL,CompanyCodeText VARCHAR(40) NULL DEFAULT(" "),CONSTRAINT ' + @TableNameCreate + '_PK PRIMARY KEY (CompanyCode))'

 /* Check to see if the table exists, if yes delete it */IF exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME =@TableNameCreate) EXEC (@DropTableString)

 /* Create the table */EXEC (@CreateTableString)

 /* Error message to pass back to BWSET @ErrCode=@@ERRORRETURN (@ErrCode)

END

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 20/35

Metadata Definition ± XSD file

XML File - ZBPUR_COMPANY_TYPETable.xsd<?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:sql="urn:schemas-microsoft-com:mapping-schema">- Maps to RFC table structure name- FRODO is a place holder for the C# code to fill in the SQL table name from

RFC <xs:element name = "ZBPUR_COMPANY_TYPE" sql:relation="FRODO"><xs:complexType><xs:sequence>- Element name maps the RFC table field name, sql:field maps to the SQL

table<xs:element name="COMPANYCODE" sql:field="CompanyCode"type="xs:string" />

<xs:element name="COMPANYCODETEXT" sql:field="CompanyCodeText"type="xs:string" />

</xs:sequence>

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 21/35

RFC Set Up

TCP/IP Set up ± SM59RFC destination BW_NETCONNECTConnection type T TCP/IP connection

Activation Type Section

Chose µRegistered Server Program¶ 

Registered Server Program SectionProgram ID ± <Window Service program executable>

Gateway Options

Gateway Host - < Gateway Host Name>Gateway Service - < Gateway Service Name>

Logon Security TabClick on Actv., and enter in the name of the authorization to use the

destination

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 22/35

ABAP - Query over BW data

* t_comp_code ITAB to hold data from the ABAP query and ispassed

* to the RFC call

DATA: t_comp_code TYPE STANDARD TABLE OFzbpur_company_type.

* c_company_function is the RFC name defined with SE37

* c_company is the name we pass to the windows service to

* identify which table we are processing

DATA: c_company_function(35) TYPE c VALUE

'Z_B_PUR_R_COMPANY_TABLE',

c_company TYPE tablename VALUE'CompanyCode'

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 23/35

ABAP - Query over BW data

* Select all active company code records* and move the results into the ITAB t_comp_codeSELECT t~comp_code t~txtmdFROM /bi0/tcomp_code AS t JOIN

 /bi0/mcomp_code AS m

ON t~comp_code = m~comp_codeINTO TABLE t_comp_codeWHERE m~objvers = 'A'AND m~changed = ''.

* Call the RFC that will pass the data to the windowservice

PERFORM rfc_call TABLES t_comp_codeUSING c_company_function

c_company.

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 24/35

ABAP ± RFC call

FORM rfc_call TABLES t_table ³ Data from queryUSING _function ³ RFC name

  _tab_name. ³ Table identifier* Get the name of the table to created with date/time stampREAD TABLE t_tables INTO wa_tables

WITH KEY tablename = _tab_name.

* c_dest is the name of the TCP/IP connections defined in SM59CALL FUNCTION _function DESTINATION c_destEXPORTINGtable = wa_tables-tablenamecreate ³ Table to be createdserver = p_serv ³ Destination Server from sel. screendatabase = p_db ³ Destination database from sel. screen

IMPORTING

return_code = return_text ³ Message textTABLEStable_name = t_table ³ Data from ABAP query

EXCEPTIONScommunication_failure = 1system_failure = 2.

.

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 25/35

FUNCTION Z_B_PUR_R_COMPANY_TABLE.*"----------------------------------------------------------------------*"*"Local interface:*" IMPORTING*" VALUE(TABLE) TYPE TEXT50*" VALUE(SERVER) TYPE TEXT50

*" VALUE(DATABASE) TYPE TEXT50*" EXPORTING*" VALUE(RETURN_CODE) TYPE ZBPUR_DNC_RETURN_CODE_TYPE*" TABLES*" TABLE_NAME STRUCTURE ZBPUR_COMPANY_TYPE*"----------------------------------------------------------------------

ENDFUNCTION.

ABAP ± RFC call

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 26/35

Windows Service Overview

Windows Service receives the RFC call andprocess the incoming data

Load predefined XML schema and load

incoming data into external SQLServer viaSQLXML interface using SQLXML BULKINSERT

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 27/35

SQLXML BULK INSERT

 // Example of how to write the SQLXML BULK INSERT Code

SQLXMLBulkLoad3Class objBL = new SQLXMLBulkLoad3Class(); // Set the connectation string //  ServerName and DataBaseName come from the RFC 

objBL.ConnectionString ="Provider=SQLOLEDB.1;Data Source=" + ServerName + ";Initial Catalog=" + DataBaseName + "; Trusted_Connection=yes";

 // Write any error to a error fileobjBL.ErrorLogFile = appPath + "error.xml";

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 28/35

SQLXML BULK INSERT

BULK INSERT SettingobjBL.SGUseID = true;

 // XML Bulk Load assigns the values that are specified in the sourcefile to the identity column

objBL.KeepIdentity = true; // XML Bulk Load creates temporary files, one for each table that is

identified in the mapping schema //objBL.Transaction = true; //source data is not an XML fragmentobjBL.XMLFragment = false;

 // appPath is passed in from a .ini fileobjBL.TempFilePath = appPath;

 // Execute the BL // xsdfile is the predefined XML schema // dataStream is the data from BW

objBL.Execute(xsdfile, dataStream);

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 29/35

Lesson Learned

Performance Results

Phase 2 Changes

Lagniappe Useful Sites

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 30/35

Performance Results

15 tables total10 master data tables

4 transactional tables

1 audit table 1 year worth of data

Loaded 2K records per second

Total run time is about 20 minutes

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 31/35

Phase 2 Changes

Leverage the BAPI or BADI to format thedata

Load data in parallel

Add more robust error messages

Automatically generate the XML schema

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 32/35

Lagniappe

SQL XML BULK INSERT requires the datato be in a set format depending on howyou have created your SQL tables, or itwill fail. Here are some hints on how todebug the data format: Create a test excel spreadsheet, and load data

into the SQL tables using a DTS package BULKINSERT task

Watch out for how the data is stored in the

SAP, and the format that the SQL tablerequires the data to be in- Leading zeros could cause issues- Date time fields need to be adjusted

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 33/35

Lagniappe

When defining your Table definition,consider the following for performance Do not put constraints in your tables unless

you have to

If you have large datasets, commit the data inbatches instead of loading all of the records atonce

Use varchar/nvarchar columns instead of 

text/ntext columns whenever possible. Usechar/varchar columns instead of nchar/nvarchar if you do not need to storeunicode data.

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 34/35

Useful Sites

http://service.sap.com/CONNECTORS

Requires a OSS log on

http://www.microsoft-sap.com/

http://www.sapgenie.com/interfaces/netconnector.htm

8/8/2019 Bi Dotnet Sapbw

http://slidepdf.com/reader/full/bi-dotnet-sapbw 35/35

Thank you for attending!Please remember to completeand return your evaluation formfollowing this session.

Session Code: 412