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

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

    19-Dec-2015
  • Category

    Documents

  • view

    223
  • download

    2

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

Page 1: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

SAP .NET Connector: Case Study on Microsoft SAP BW Data Extract

Bill [email protected]

Page 2: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Agenda

• What is the SAP .NET Connector• Data Push Design Overview• Development Overview• Lesson Learned

Page 3: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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 also where you store all of your master data

ODS – Operational Data Store. This is where you store you detailed level records in BW.

RFC – Remote Function Call. This is a call to a function module 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 the computer boots, can be paused and restarted, and do not show any user interface.

Page 4: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

What is the SAP .NET Connector

• Terminology SQLXML – Enables developers to bridge the gap

between Extensible Markup Language (XML) and relational data. You can create XML views of your existing relational data and work with it as if it were an XML file for example.

SQLXML BULK LOAD – XML Bulk Load is a stand-alone COM object that allows you to load XML data into Microsoft SQL Server tables. Bulk load utility provides higher performance when you need to insert large amounts of XML data.

Page 5: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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 via open standards

The SAP .NET Connector offers developers to expose BAPIs and remotely-enabled function modules to any .NET application (inside-out). You now also can access .NET components from with a mySAP.com application (outside-in)

Page 6: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

What is the SAP .NET Connector

• SAP client solution, the SAP system is the server and the .NET application is the client that interacts with the RFC

• Examples of some uses for the SAP .NET Connector client application Windows form application that has a customized and

highly interactive user experience Console application to access information from the SAP

system as part of some NT batch processing

Page 7: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

What is the SAP .NET Connector

• RFC server allows your SAP system to execute .NET code as if the .NET code were another SAP system

• Examples of some uses for the SAP .NET Connector server application Getting information such as maps, stock prices or

weather from an external service to be used within a SAP report

Sending emails from your SAP system

Page 8: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

• Business case: Supply data that had been transformed in SAP BW to a non-SAP database

• Other solutions considered Create a custom ABAP to create flat files to be

consumed by the destination data warehouse Create a DTS package to extract and pump the data to

the 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

Page 9: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Data Push Design Overview

• Why we chose the SAP .NET Connector Flexibility Speed Cost Scalability Leverage development expertise on the internal

Microsoft SAP development team Demonstrate SAP BW ability to be a enterprise data

distribution tool within Microsoft using SAP openness tools

Page 10: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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

Page 11: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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

Page 12: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Data Push Design Overview

SAP ABAPProgram

Call RFC withdestination

SM 59Destination

information table

SAP BWLayer

Windows Service

External SQL Server

Windows 2003ServerLayer

SQL XMLBULK

INSERTXML

Schema

ConvertIncometable to

XML

SAP BW Window 2003 Server

Page 13: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Data Push Design Overview

• Process Flow Submit a ABAP program to run per the selection criteria

entered ABAP program executes a RFC that will either create the

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

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

Pass back any success or failure message to the ABAP program

Page 14: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Development Overview

• Project Overview• Metadata Definition• RFC Set Up

• ABAP Query over BW dataRFC call

• Windows Service Overview

• SQLXML BULK INSERT

Page 15: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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 pushData is stored in the BW info objects

0COMP_CODE0COMP_CODE data is stored in the BW

tables /BI0/MCOMP_CODE and /BI0/TCOMP_CODE

Page 16: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Project Overview

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

ABAP program will only pass the ‘Active’ records ABAP program will use a TCP/IP connection to

talk to the windows service

Page 17: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Meta data definition – SAP itab

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

ZBPUR_COMPANY_TYPE Short text:Structure of Company Table Interface Structure Field structure Number of fields: 2 Sum of field lengths: 44

Component Type Len TypName Text COMPANYCODE CHAR 4 /BI0/OICOMP_CODE

Company CodeCOMPANYCODETEXT CHAR 40 RSTXTMD Med.

Desc

Page 18: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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 structure Structure Field structure Number of fields: 2 Sum of field lengths: 100

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

Page 19: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Metadata Definition – SQL Table

/* Company Table build */IF @TableName = 'CompanyCode'BEGINSET @DropTableString = 'DROP TABLE ' + /* Build the name of the table. */ @TableNameCreateSET @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

Page 20: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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>

Page 21: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

RFC Set Up

TCP/IP Set up – SM59 RFC destination BW_NETCONNECT Connection type T TCP/IP connection

Activation Type SectionChose ‘Registered Server Program’

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

Gateway OptionsGateway 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

Page 22: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

ABAP - Query over BW data

* t_comp_code ITAB to hold data from the ABAP query and is passed

* to the RFC callDATA: t_comp_code TYPE STANDARD TABLE OF

zbpur_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 processingDATA: c_company_function(35) TYPE c VALUE 'Z_B_PUR_R_COMPANY_TABLE', c_company TYPE tablename VALUE

'CompanyCode'

Page 23: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

ABAP - Query over BW data

* Select all active company code records* and move the results into the ITAB t_comp_code SELECT t~comp_code t~txtmd FROM /bi0/tcomp_code AS t JOIN

/bi0/mcomp_code AS m ON t~comp_code = m~comp_code INTO TABLE t_comp_code WHERE m~objvers = 'A' AND m~changed = ''.* Call the RFC that will pass the data to the window servicePERFORM rfc_call TABLES t_comp_code USING c_company_function c_company.

Page 24: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

ABAP – RFC call

FORM rfc_call TABLES t_table “ Data from query USING _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 SM59 CALL FUNCTION _function DESTINATION c_dest EXPORTING table = wa_tables-tablenamecreate “ Table to be created server = p_serv “ Destination Server from sel. screen database = p_db “ Destination database from sel. screen IMPORTING return_code = return_text “ Message text TABLES table_name = t_table “ Data from ABAP query EXCEPTIONS communication_failure = 1 system_failure = 2. .

Page 25: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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

Page 26: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Windows Service Overview

• Windows Service receives the RFC call and process the incoming data

• Load predefined XML schema and load incoming data into external SQLServer via SQLXML interface using SQLXML BULK INSERT

Page 27: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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 file

objBL.ErrorLogFile = appPath + "error.xml";

Page 28: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

SQLXML BULK INSERT

BULK INSERT SettingobjBL.SGUseID = true;// XML Bulk Load assigns the values that are specified in the source

file to the identity columnobjBL.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 fragment objBL.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);

Page 29: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Lesson Learned

• Performance Results• Phase 2 Changes• Lagniappe• Useful Sites

Page 30: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Performance Results

• 15 tables total10 master data tables4 transactional tables1 audit table

• 1 year worth of data • Loaded 2K records per second• Total run time is about 20 minutes

Page 31: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Phase 2 Changes

• Leverage the BAPI or BADI to format the data

• Load data in parallel• Add more robust error messages• Automatically generate the XML schema

Page 32: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Lagniappe

• SQL XML BULK INSERT requires the data to be in a set format depending on how you have created your SQL tables, or it will fail. Here are some hints on how to debug the data format: Create a test excel spreadsheet, and load data

into the SQL tables using a DTS package BULK INSERT task

Watch out for how the data is stored in the SAP, and the format that the SQL table requires the data to be in

- Leading zeros could cause issues- Date time fields need to be adjusted

Page 33: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

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 in

batches instead of loading all of the records at once

Use varchar/nvarchar columns instead of text/ntext columns whenever possible. Use char/varchar columns instead of nchar/nvarchar if you do not need to store unicode data.

Page 34: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Useful Sites

• http://service.sap.com/CONNECTORS Requires a OSS log on

• http://www.microsoft-sap.com/• http://www.sapgenie.com/interfaces/netconnector.htm

Page 35: SAP.NET Connector: Case Study on Microsoft SAP BW Data Extract Bill Faison bfaison@microsoft.com.

Thank you for attending!Please remember to complete and return your evaluation form following this session.

Session Code: 412