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

Similar documents
Graphical Mapping Technique in SAP NetWeaver Process Integration

Material Master Archiving in Simple Method

Easy Lookup in Process Integration 7.1

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

Step by Step Method for File Archival in BW

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

SDN Community Contribution

Using Radio Buttons in Web Template

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

Message Prioritization in Advanced Adapter Engine

Step by Step Guide for PI Server Start and Stop Procedure

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

Creating Custom SU01 Transaction Code with Display and Password Reset Buttons

External Driver Configuration in Process Integration 7.1 Using JSPM

MDM Syndicator: Custom Items Tab

External Driver Configuration for Process Integration 7.0

Step By Step Procedure to Implement Soap to JDBC Scenario

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

DB Connect with Delta Mechanism

Replacement Path: Explained with an Illustrated Example

Validity Table in SAP BW/BI

List of Values in BusinessObjects Web Intelligence Prompts

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

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

Process Chain Log Deletion

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

Using Nested Exception Aggregation in BEx Reports- Scenario

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

Linking Documents with Web Templates

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

Step by Step Procedure for DSO Creation

POWL: Infoset Generation with Web Dynpro ABAP

How to Download Multiple Files in ZIP using WebDynpro Java

Creation of Key Figures with Higher Decimal Place Precision

SDN Community Contribution

Upload Image file from system in Web dynpro view

Data Extraction & DS Enhancement in SAP BI Step by Step

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

How to Create and Schedule Publications from Crystal Reports

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

Limitation in BAPI Scheduling Agreement (SA) Create or Change

Material Listing and Exclusion

Creating Multiple Methods/Operations and Exposing BAPI as a Webservice

Administrating ABAP+JAVA and SLD Problems of SAP PI 7.1

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

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

ecatt Part 6 System Data Container

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

Developing Crystal Reports on SAP BW

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

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

Freely Programmed Help- Web Dynpro

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

SDN Community Contribution

Data Flow During Different Update Mode in LO Cockpit

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

How to Perform Value Mapping A Walkthrough

Custom Password Reset Tool in SAP Enterprise Portal Using Web Dynpro for Java

BPM Multi Line Container in Integration Process

How to Display Result Row in One Line While Reporting On Multiproviderer

Step-By-Step guide to Virtual InfoCube Implementation

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

Standalone BW System Refresh

Recreating BIA Indexes to Address the Growth of Fact Index Table

SUP: Personalization Keys and Synchronize Parameter

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

Universal Worklist - Delta Pull Configuration

Programmatical Approach to User Management in Enterprise Portal

B2B Integration Using Seeburger AS2 Adapter with PI 7.1 Ehp1

Displaying SAP Transaction as Internet Application in Portal

Financial Statement Version into PDF Reader

SAP Net Weaver 400s BI 7.0For more information, visit the Business Intelligence homepage.

Federated Portal for Composite Environment 7.1

How to Configure User Status in mysap SRM

How to Display Traffic Lights for Exceptions in BI Web Reports

Step by Step Guide on How to Use Cell Definition in BEx Query

Database Statistics During ODS Activation

Purpose of Goods Receipt Message indicator in Purchase Orders

Virus Scan with SAP Process Integration Using Custom EJB Adapter Module

BAPI Execution in offline Adobe Form

SAP Biller Direct Step by Step Configuration Guide

Web Dynpro: Coloring Table Conditionally

Download SAP Query Output to Local/ Network Folders in Background

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

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

SEEBURGER BICMD for SAP Exchange Infrastructure - Configuration Guide

Table Row Popup in Web Dynpro Component

Creating Rules in Process Composer and using them in Process

SDN Community Contribution

Information Broadcasting Part 3 Scheduling the First Report

Printer Landscape Made Easy!!

Server Connectivity and Data Load from Non SAP System to BW

HOWTO: SCRIPTING LANGUAGE SUPPORT FOR SAP SERVICES - RUBY

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

Open Hub Destination - Make use of Navigational Attributes

Config Tool Activities

How to Create and Execute Dynamic Operating System Scripts With XI

Customized Transaction to Trigger Process Chain from Failed Step

Currency Translation in SAP BI Step by step Guide

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

Transcription:

SAP PI/XI: Generating Sequence Number Between Multiple Instances of Mapping Execution Applies to: SAP XI 3.0, PI 7.0 and 7.1. Summary The paper discusses about how to obtain sequence number between multiple executions of the same or different mappings in a lightweight fashion. Author: Sudip Kumar Paul Company: Accenture Created on: 15 October 2010 Author Bio Sudip Kumar Paul is an SAP certified Net weaver (SAP XI/PI) consultant at Accenture. He has more than 6 years of experience in SAP Net weaver, Java/J2EE and middleware technologies and more than 5 years in SAP XI/PI. Was part of Netweaver team at SAP. 2010 SAP AG 1

Table of Contents Introduction... 3 The Problem... 3 The Solution... 3 Architectural Explanation... 3 How to use:... 4 Using in Java and XSLT mapping... 8 Code Snippet... 9 Jar... 9 Related Content... 10 Disclaimer and Liability Notice... 11 2010 SAP AG 2

Introduction Let s run through a very common scenario which consultants come across while dealing with the transformation or mapping step in SAP XI/PI. If there is a scenario where it requires executing mapping more than once and with each run you should be able to obtain a number which is next in sequence. This requires the last sequence information to be remembered till the point the mapping gets executed again. To make the problem more understandable lets look at a business scenario. Example: Business scenario Payment runs (TCODE: F110) happens in a SAP FI system and the payment information needs to be send across to a third party say in a file( or some other format). Now every day when there is a payment run there file generated should contain a sequence number identifying the file so that the third party application can process these files in the correct order. The Problem The problem is SAP PI/XI as such does provide any mean to have number ranges or generate sequence between multiple executions of mappings. It only provides a mean to have a sequence within a mapping execution. Now the question is how to do this in SAP XI/PI without doing any of the heavyweight steps like RFC, DB or web service look-up? The Solution Architectural Explanation The solution involves introducing some kind of data source which can be accessed from the mapping runtime. Then the idea is to have access to a file data source (Properties file in this case) through an API interface which can then be reused. The java class NumberGenerator (see below for the code snippet) uses the mapping runtime to persist the sequencing information in native file system of the SAP J2EE server node instance in the form of properties file. The same information is re-read and updated during consecutive execution of mappings. The architecture looks as follows, 2010 SAP AG 3

How to use: The steps illustrated below shows how to use this functionality with an XI/PI graphical mapping using a User Defined Function. 1. Create an Import Archive object in the appropriate namespace. 2. Import the Jar file containing the API implementation. 2010 SAP AG 4

3. Create a reusable function library which can be used in the graphical mapping and refer the imported archive as shown. 2010 SAP AG 5

4. Declare the import statement for this class here for using it in the mapping and select the created archive containing the api 2010 SAP AG 6

5. Create function in the reusable function library. In this case it is getsequencenumber. The function has two arguments, strsequenceidentifier: This is an identifier which identifies the sequence. e.g. in the business which is mentioned as an example above there should be an identifier for the file no, and the same should be used when this particular sequence is required. ( In step 6 I use FILE_NO as an identifier). strlength: The range of the sequence can be specified by this. e.g. if the range required is from 0-999 then 3 should be specified as length here. Similarly for 0-99999, 5 should be specified as length. 6. Add the function library to the mapping in which this is required. 2010 SAP AG 7

7. This can be tested as follows by executing the mapping in the test tool multiple times. Every time this is executed the next value in sequence is obtained. See the field SequenceNo in the target. First Execution Second Execution Using in Java and XSLT mapping If this required to be used in a java mapping or an XSLT mapping then this can be directly imported via the import statement in the code. 2010 SAP AG 8

Code Snippet public static String getsequencenumber(string formatname,string strlength) int ilength = 0; Properties properties = new Properties(); File propertiesfile = new File("Sequence.properties"); if(strlength!= null && strlength.length() > 0) ilength = Integer.parseInt(strLength); else return "Error:Specify length"; try propertiesfile.createnewfile(); properties.load(new FileInputStream(propertiesfile)); catch (IOException e) e.printstacktrace(); return "Error:File not read"; //get the current value of sequence String number = properties.getproperty(formatname); if (number == null) number = "0"; //increment the sequence String counter = String.valueOf(Integer.parseInt(number) + 1); //compare if the format value length exceed it limits if(counter.length() > ilength) //start the counter again counter = "1"; //set the current value of sequence properties.setproperty(formatname, counter); // Write properties file. try //store the values in file properties.store(new FileOutputStream(propertiesfile), null); catch (IOException e) return "Error:File not updated"; return counter; Jar 2010 SAP AG 9

Related Content https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/20ab7ccf-e78a-2a10-71b4-80fc764bafb0 http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2171 http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2781 2010 SAP AG 10

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. 2010 SAP AG 11