Quantcast
Channel: SCN : Document List - Process Integration (PI) & SOA Middleware
Viewing all 571 articles
Browse latest View live

Communication Channel Administration in ABAP

$
0
0

Motivation

In any environment there maybe communication channels that should not be always started. Like those used for data loads or periodic activities (submitting tax, etc).  Without detailed knowledge of each of the interfaces in the environment it can be tricky and time consuming to determine which comunication channels should be started following a period of downtime. To remove some of that headache I wrote this report that can be imported into your SAP system and with a few tweaks you can use your environment. 

 

After writing the program I did a search in SCN on this topic and found a nice blog that summarises how this works in prinicple and provides some sample ABAP to achieve this. The SAP Help content in this space is also pretty clear.

 

http://scn.sap.com/community/pi-and-soa-middleware/blog/2011/05/24/startstop-a-communication-channel-from-an-abap-program-using-the-external-control-switch

 

User Guide

 

The configuration is the same in that you need to ensure that the communication channels you wish to manage are set to “External” in the communication channel manager.  Once complete you can then run the report. 


A basic selection screen allows you to perform one of three, pretty self-explanatory actions “Check”, “Start” and “Stop”.

 

image 1.png

Result for “Check” action. Note the colour coded icon for “Activation State”.

 

image 2.png

 

There are also fields for Channel State Text and a traffic light icon to represent this, but they are only populated if the channel is active.  You can refer to the XSD for the service for details of this and all the other fields.  The screen shot below shows a couple of channels in the active state with the channel status.

 

image 3.png

 

Result for “Start” Action

 

image 4.png

 

As communication channels have not yet finished changing status, hit refresh to see any updated statuses.

 

image 5.png

 

And it’s pretty much the same outcome for stopping a channel.

 

 

Initial Setup


First create a new ABAP program and copy the code from the attached text file. 


Now you need to setup an RFC destination to PI, more specifically to the ChannelAdminServlet.  You can copy your existing proxy connection to PI if you like. You need to set the path prefix to “/AdapterFramework/ChannelAdminServlet” and then update the path prefix and logon details.

 

image 6.png

 

I have a method to determine the HTTP destination name you configure in SM59 that you should replace with something that returns the name of the communication channel you just created in the above step.

 

image 7.png

 

Now you need to code the following method “get_comm_channels_config”.  The result must return a list of the communication channel names and the business component/service to be managed externally in PI.


image 8.png


See the type definition.


image 9.png


How you choose to manage this I will leave to your discretion.  For mine I used a custom maintenance table to list all the comm channels that can be started via external control.  You may even like to add name and service as selection criteria to filter any list you maintain.


Finally you need to create a GUI status called “DEFAULT” to enable the refresh button.


image 10.png


Once all the aboove steps are complete, the report should be good to go…

 

Caveat

If you have scheduled communication channels, you should adjust the schedule appropriately during periods of downtime.  As these comm channels require automatic control, you cannot use this process to manage them.



SAP Process Integration Act as Message Broker for Other SAP Products

$
0
0

In this document, it will demonstrate how SAP PI act as message broker for SAP BPM and SAP MII and common technical strategy.


1 .SAP Business Process Management (BPM) manages processes and process operations.

2 .SAP Manufacturing Integration and Intelligence (MII) used for Manufacturing Integration and also Intelligence.


Both of them have their other supported integration approaches. For SAP BPM, it support RFC,WS,XI protocols; for SAP MII, it support SQL action, WS action, XI action etc. Howeve, if need them integrate with other wilde Enterprise Applications (e.g. 3rd party WS, B2B product, Cloud  Application etc.) in one large scale integration landscape, its capabilities have some limitation to deal with such requirement smoothly.


Therefore, using a combined solution with SAP PI can make it acting as central message broker exposed to outside Enterprise Application. Then it make connected SAP Products( BPM or MII as examples) able to integrate with kinds of Enterprise Applicaitons via kinds of PI adapters.


For more technical details about how PI act message broker for BPM, please refer to the following guide.

1. PI Integrate with BPM

bpm.JPG

pdf.JPGGuide 1: How PI Act as Message Broker for BPM

 

 

For more technical details about how PI act message broker for MII, please refer to the following guide.

2. PI Integrate with MII


MII.JPG

pdf.JPGGuide 2: How PI Act as Message Broker for MII

Hybrid Integration Solution: SAP Process Integration Transfer into SAP Process Orchestration

$
0
0

Starting from SAP Process Orchestration, the new ONE Integration Solution came out. SAP Process Orchestration not only a composite system combine PI,BPM and BRM together, but also makes system technical integration transform into business integration from high level integration view.

POHybrid.JPG


1 .SAP Business Process Management (BPM) manages processes and process operations.

2 .SAP Process Integration (PI) is used for technical integration in order to manage the different technologies in the sub-systems and link themtogether.

3. SAP Business Rules Management (BRM) is a component which can model cross-system business logics centrally.


(Note: The usage of the sub-brand "SAP NetWeaver" has been reevaluated and the SAP NetWeaver prefix will be dropped from most of the components. This will be publicly announced at SAPPHIRE NOW in June 2014. New names will be SAP Process Orchestration, SAP Process Integration, SAP Business Process Management, and SAP Business Rules Management.)



Of course one business requirement can implement by Pure PI from technical point of view. However as Process Orchestration combine PI, BPM and BRM together as ONE integration solution, SAP PO just like a message broker to combine those 3 powerful SAP Products together and provide us multitudinous hybrid model.


Process Orchestration make integration task more possible paths, do not only limited in Process Integration. In the future, you can choose the best one solution which fit your integration landscape from develop task load, system performance load and operation load concerns etc.

In the following guides, one same business requirement scenario will be practice with detail procedures to let PI consultant adapt to PO consultant model and get the idea about how SAP PI integrate with SAP BPM and SAP BRM in SAP PO from technical view and Hybrid model.

 

DocumentSAP Process Orchestration Makes System Technical Integration Transform into Business Integration
pdf.JPG

 

Guide ONE:

How PI integrate with BPM in PO

pdf.JPG

 

Guide TWO:

How PI integrate with BRM in PO and Hybrid Model

ExcelTransformBean: Convert various Excel formats to XML easily

$
0
0

Introduction

There are already a handful of blogs on SCN dealing with Excel to XML conversion - so why another one??

 

Here is my wish list for a comprehensive solution:-

  • Able to read all kinds of Excel format (XLS and XLSX)
  • Behaves in a similar way as MessageTransformBean
  • Highly configurable - develop/deploy once, use multiple times
  • Able to handle XML special characters

 

In the reference section below are some of the more popular approaches, however below are some of the (non-exhaustive) limitations/drawbacks

  • XLSX files stores string contents in a separate sharedStrings.xml file in the zipped XLSX file
  • JExcel API does not support Excel 2007 XLSX formats
  • Limitations in handling formulas, formatting and special characters in cells

 

ExcelTransformBean is an attempt to provide a generic adapter module solution (a la MessageTransformBean) that is highly configurable and reusable. It is based on the Apache POI API. Utilizing the combined SS interface of the API, it uses a single logic to read all kinds of Excel files (XLS and XLSX.)

 

 

Source Code

The full source code can be found in the following public repository on GitHub.

GitHub repository for ExcelTransformBean

 

This module is based on Apache POI 3.9 library. In order for the Java project to compile and build successfully, the following JAR files need to be referenced/imported into the project.

  • poi-3.9-20121203.jar
  • poi-ooxml-3.9-20121203.jar
  • poi-ooxml-schemas-3.9-20121203.jar
  • xmlbeans-2.3.0.jar
  • dom4j-1.6.1.jar

 

The library files can be downloaded from Apache's website, direct link to the ZIP file is provided below.

Apache POI 3.9 ZIP file

 

 

Module Parameter Reference

Below is a list of the parameters for configuration of the module. Certain parameters will automatically inherit the default values if it is not configured.

 

Parameter NameAllowed valuesDefault valueRemarks
sheetNameThe name of the active Excel sheet to extract. Either sheetName or sheetIndex must be populated.
sheetIndexInteger values beginning from 0The index of the active Excel sheet to extract (starts from 0.) Either sheetName or sheetIndex must be populated.
skipEmptyRowsYES, NOYESEmpty rows to be skipped or not
rowOffsetInteger values beginning from 10Starting row to begin extracting content from (i.e. 0 = start from first row, 1 = start from second row.) If processFieldNames = 'fromFile' and rowOffset = 0, first line is always skipped
processFieldNames

fromFile, fromConfiguration, notAvailable

Required field. Determines the naming of each column of the rows, and the number of columns to extract:

  • fromFile = Column names and number of columns are determined from header line of the sheet
  • fromConfiguration = Column names and number of columns are determined from module fieldNames
  • notAvailable = Column names will be set as ColumnX, where X = 1,2,3,4. Number of columns will be determined from parameter columnCount
fieldNamesName of columns. Required field whenprocessFieldNames = 'fromConfiguration'
columnCountInteger values beginning from 1Number of columns for extraction. Required field whenprocessFieldNames = 'notAvailable'
recordNameRecordXML element name for row of record in output
documentNameRequired field. Document name of root element of XML output
documentNamespaceRequired field. Namespace of root element of XML output
formattingexcel, rawexcelControls how the cell contents are formatted in XML output
  • excel = Cells are displayed the same way as Excel formatting of corresponding cell
  • raw = Raw value of cells are displayed
evaluateFormulasYES, NOYESControls how cell contents with formulas are displayed in XML output
  • YES = Cells are displayed with result of formula evalution
  • NO = Cells are displayed with actual formula
emptyCellOutputsuppress, defaultValuesuppressControls how empty cells are displayed in XML output
  • suppress = Empty cells are not displayed (no corresponding XML tags for empty cells)
  • defaultValue = Empty cells will be displayed with default value
emptyCellDefaultValue<blank>If emptyCellOutput = 'defaultValue', all empty cells will be populated with value in this parameter
indentXMLYES, NONODetermines if XML output will be indented or not
debugYES, NONODisplays contents in Audit Log of each cell extracted. WARNING: Use this only for debugging in non-productive systems

 

 

Example Scenarios

Here are some example scenarios of the behavior of the conversion based on different configuration options.

 

Scenario 1

Excel 2007 XSLX file format.

Extract Sheet1 with column names determined directly from header line of file.

Special character & automatically converted

 

Module parameters

Parameter NameParameter Value
sheetNameSheet1
processFieldNamesfromFile
documentNameMT_Order
documentNamespaceurn:equalize:com

 

Result

Inputin1.png
Outputout1.png

 

Scenario 2

Excel binary XLS file format.

Extract sheet at index 0. Column names are provided from configuration.

Row offset provided to skip first two lines.

No formatting of cells, so raw values displayed.

 

Module parameters

Parameter NameParameter Value
sheetIndex0
processFieldNamesfromConfiguration
fieldNamesOrder,Date,Material,Quantity
rowOffset2
recordNameLine
documentNameMT_CustomOrder
documentNamespaceurn:equalize:com
formattingraw

 

Result

Inputin2.png
Outputout2.png

 

 

Scenario 3

Excel 2007 XSLX file format.

Extract sheet at index 0.

Column names are not available. Number of columns = 5.

Row offset provided to skip first line.

Empty rows are included.

Cells with formula are displayed with formula instead of result.

Empty cells are displayed with default value "space".

 

Module parameters

Parameter NameParameter Value
sheetIndex0
processFieldNamesnotAvailable
columnCount5
rowOffset1
documentNameMT_CustomOrder
documentNamespaceurn:equalize:com
skipEmptyRowsNO
evaluateFormulasNO
emptyCellOutputdefaultValue
emptyCellDefaultValuespace

 

Result

Inputin3.png
Outputout3.png

 

 

Reference

This article does not cover the steps for creating a custom adapter module. This can be found easily via an SCN search. It is also listed in the reference section of the article below regarding adapter module testing.

Standalone testing of Adapter Module in NWDS

 

Alternative methods for Excel conversion

PI/XI: Reading MS Excel's XLSX and XLSM files with standard PI modules - easily...

Excel Files - How to handle them in SAP XI/PI (The Alternatives)

A Simple approach in Reading Excel File

Easiest way to get the jar file for Java mapping

$
0
0

Document Objective: To get the required Java mapping .jar files.

 

There are some methods already discussed in this blog that I have seen on scn to get the Java mapping .jar files.

Sometime due to restricted access to the SAP installation server one is not able to get the file and have to request it from the Basis team.

 

The second method which tells how to get the files from Java Webstart local files makes us to navigate through a lot of folder.

 

I found one more method that I would like to share -

 

Below are the steps that one can follow and get the .jar file -

 

Step 1: Open the Java Control Panel

 

On the Java control panel, navigate to the General tab and in the Temporary Internet file part click on the view button.

 

1.jpg

 

 

 

Step 2: Getting the server link for the .jar files

 

Next we need to select Resources next to Show drop down list and below Name column find the .jar file name

 

Next we will copy the server path for the .jar file, so we can use the link and download the .jar file directly from the server using the login user id and password.

 

 

2.jpg

 

In above image we can see the .jar file and next to it the url for that.

 

We can use this url to download the .jar file.

 

 

 

P.S. For this method to work you must have opened your ESR atleast once so that the Java cache can log that in its cache.

A Simple approach in Reading Excel File

$
0
0

 

            Hi folks! Working with Adapter-modules has always been challenging and great to use for typical business requirements dealing with Excel files. Excel files carry most of the financial data in current business landscapes. Being one among those who faced such challenge, here I would like to share one of my recent works on Adapter module that deals with Excel files.

 

This blog explains the way an adapter module can be designed in a simple way and this is unique in the manner that it is generic in nature converting .xls and .xlsx files into XML for SAP PI to process.

 

  Here we go!  All you need to do is, just follow the below steps.


1.     Create the Data Type for the excel sheet that you want to read.


dt.jpg

 

2.    Techie Buds, please follow the below link to know basics of creating an Adapter module in SAP PI. 

 

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0b39e65-981e-2b10-1c9c-fc3f8e6747fa?overridelayout=true


3.          Add the below Jars to your module

    

           poi-3.9.jar

          poi-ooxml-3.9.jar

          xmlbeans-2.3.0.jar

4.    Add the below attached java code in your project


5.     Configure the Sender channel parameters as per your data structure.

cc.PNG


 

UDF : In my business scenario I created the below  UDF ,which maps the first occurrence of the field in XML (Cell Data) to Field 1 (Project Id) on the target side ,2nd occurrence(Cell Data[2]) to Field 2 (Project Engineer). This way all the data in the XML file will be mapped to the actual fields on the target side for further processing. Isn’t it a simple one?


mmping.PNG


Testing:

Let’s test a file of .xls and .xlsx by placing in the FTP server for PI to pick.

file1.PNG


ftpinp.PNG


Output XML file equivalent to EXCEL file read by the module , made available in Target FTP.

ftpout.PNG

XML File :

final.PNG


  How did this approach help me?

 

  • By using this module I converted my Actual Excel file to an intermediate XML file.
  • The XML file is just like any other XML that we use in File based scenarios.
  • Excel file based scenario is now turned to XML file based scenario using this scenario.
  • The Adapter module has become a reusable one, as most of the financial data will have similar format the same can be used.


Step by Step Dynamically choosing target folder using JAVA mapping with SFTP adapter.

$
0
0

Hello All,

 

Business Requirement: We had to route the file to different folder using company-code as routing condition available in the file name. Since there was no transformation required so it was basically a pass-through scenario. But since we had to fix the receiver directory during runtime we decided to use java mapping to set dynamic configuration Filename and Directory parameters. We have SFTP as sender and Reciver channels and we were using ICO for configuration.

 

Its basically a pass-through scenario with choosing the directory/Filename during Runtime.

 

So it gives an insight of three aspects:

  1. How to configure Pass-through scenario and still use Java Mapping.
  2. How  to put things together with ICO with SFTP adapter.
  3. How to work on java mapping using Eclipse Editor with new API's.

 

 

ESR Objects:

  • We need to create below mentioned objects
    • Sender Data Type (Dummy structure)
    • Sender Message Type
    • Sender Service Interface
    • Receiver Data Type(Dummy structure)
    • Receiver Message Type
    • Receiver Service Interface
  • Imported Archive

ImportedArchive.jpg

  • PFA Java Mapping Sample Code which can be edited as per requirement.(Step by Step explained in below section)

 

 

  • Operation Mapping.

operationMapping.jpg

Note: We need not worry about sender structure not matching the input File.

 

ID-ICO Configuration.

 

  • ICO Inbound Processing:

ICOInboundProcess.jpg

Note: We have to leave the SWCV of sender Interface blank otherwise we might get an error as Adapter engine expects the the file in sender Data Type.


  • ICO Receiver:

ICOReceiverDetermin.jpg

  • ICO Receiver Interfaces:

ICOInterfaceDetermine.jpg























 

 

  • ICO OutBound Processing

ICOOutboundProcess.jpg


  • ICO Sender Channel with Advanced module Parameter

SenderChannel.jpg

Note: We don't need to add anything in Module parameter for content conversion.Just need to leave with default entry.


  • ICO Receiver Channel with Advanced module Parameter

ReceiverChannel.jpg


Note: We don't need to add anything in Module parameter for content conversion.Just need to leave with default entry.


Java Mapping Using Eclipse Editor.


  • Step 1

Step1NewProject.jpg

  • Step 2

Step2NewProjectName.jpg

  • Step 3: Right Click on Project-> Properties -> Java Build Path -> Add External Jars.

Step3AddExternalJars.jpg

  • Step 4

Step4AddNewClass.jpg



  • Step 5

Step5NewClass.jpg


  • Step 6: Now paste the code provide and edit as per your requirement.


  • Step 7: Right Click on Package you are working --> Export


  • Step 8:

Step7JarCreation.jpg


  • Step 9:

Step9JarCreation.jpg

 

 

  • Just Press on Finish and import it through Imported Archive as mentioned above.

 

 

I  know this might not be a difficult one but now this gives us lot of flexibility with other scenarios.

  • PGP Encryption:Supposedly if we want encryption we can add pgp module parameters and do encryption in the receiver channel.
  • Complex Dynamic Filename configuration.

 

Hope this solves few problems.

 

Please share if it requires any changes.

 

thanks and regards

Praveen Tirumareddy.

 

 






PI.SFSF Integration.DOC - How to Model Successfactors SOAP and ODATA Entities using Eclipse Juno Tool.

$
0
0

Document Objective

 

Objective of this document is to providing information about “How to Model SFSF SOAP and ODATA Entities using Eclipse Juno Tool”.

 

Modelling consist mainly two activities:-

1. Generating automated XSDs for Entities

2. Generate Queries/Resource Path for data extractions.

 

Eclipse Version: Juno

SFSF BizX Entity Used for Demo : CompoundEmployee

 

This document provides an example of all the steps required in Juno. This is divided into following three steps :-

1. Installation of Juno.

2. Configuration of Juno.

3. Implementation of scenario in Juno.

 

Step I. Juno Installation. : - Install Juno from Below URL

 

http://www.eclipse.org/downloads/packages/release/juno/sr2

http://www.eclipse.org/downloads/packages/eclipse-classic-422/junosr2

Juno0.1.PNG

 

Step II. Juno Configuration.

 

Run Eclipse.exe.

Once Eclipse Juno is installed, Open Eclipse Juno.

Then Choose Help  and Install New Software.

Juno0.2.png

 

Choose Add.

Juno0.3.PNG

 

 

In the Add Repository window, specify the relevant details according to the description given in the table below.

URL: https://tools.hana.ondemand.com/juno

Juno0.4.PNG

 

Choose OK.

A list of plug-ins available for installation are populated in the table below.

Select SAP HANA Cloud Integration Tools and choose Next.

Juno0.5.PNG

 

Accept the license agreement and choose Finish. Eclipse SDK prompts for a restart.

Choose OK in the Software Updates window.

 

Step III. Configuration of Eclipse Juno : - Modelling:


1. Auto XSD Generation for Mapping - The SFQL when modeled using the operations modeler generates an XSD file which can be used mapping purposes.

2. Auto Query/Resource Path genaretion for Communication Channel. - It generated SFQL which can be further used in SFSF Communication Channel.

 

 

 

Creating a New Integration Flow and Project. Choose Integration Flow. Commonly known as "IFlows".

  Juno1.PNG

Juno2.PNG

 

Dummy IFlow will be created.

Juno3.png

 

 

Focus on Target Channel Arrow and Double Click.

Juno4.PNG

 

Channel Properties will be Open.

Choose AdapterType as Successfactors

Message Protocol as SOAP ( Note : For OData choose OData Message Protocol).

Juno5.PNG

 

Fill the neccessry information.

Eg. Address of SFSF DataCenter . In our case it is API5.

Company ID

User

Password

( Ask above information from SFSF Configuration Expert ).

Juno6.PNG

 

Juno7.PNG

 

From a big list of entities , Choose relevent entity to your interface.

Juno8.PNG

 

In our case It is CompoundEmployee.

Juno9.PNG

 

Select Field/tags to be partt of SFQL and XSD.

Based on your selection a XSD and query will be generated.

Juno10.PNG

 

Juno11.PNG

 

Juno12.PNG

 

Juno13.PNG

Below is the UseCase of genearted SFQL and XSD :-

 

SFQL

 

Juno15.png

 

XSD :

 

Juno16.png

 

 

Refer below SAP URLs for more information :-

 


Installation and
  Configuration Juno


http://help.sap.com/saphelp_nw-connectivity-addon100/helpdata/en/a5/940acc528043ccb90d9267e8e13f1e/frameset.htm


Creating a New Integration Flow and Project


http://help.sap.com/saphelp_nw-connectivity-addon100/helpdata/en/25/86a07e53614dbe9ac26c15f7702639/content.htm


Modelling


http://help.sap.com/saphelp_nw-connectivity-addon100/helpdata/en/89/8362021924433d8d7f2f231c436ee5/content.htm


Featured Content in Process Integration (PI) & SOA Middleware

$
0
0

RKT Workshop on SAP HANA Cloud Integration

We are organizing a RKT workshop for SAP HANA Cloud Integration (SAP HCI) in Bangalore on Nov. 20+21, 2014. Visit us and get deep insight on SAP HCI with solution details, use cases and hands-on exercises. Find more information and the registration link in the blog by Piyush GakharOct. 2014

Build your SAP TechEd && d-code agenda!

Have you already finalized your agenda for TechEd && d-code Las Vegas? The event in Las Vegas is now just one week ahead. Don’t miss the integration sessions @ TechEd && d-code in Las Vegas, October 20-24. Take the advantage to meet the integration experts in person and receive the newest highlights of our on-premise and also cloud-based integration platform. Learn in demo rich lectures and hands-on trainings how SAP integration technologies, like SAP HANA Cloud Integration and SAP Process Orchestration are being used for the integration of SAP's cloud pillars. Get insights into the current solutions and road maps and get a preview on prepackaged content for jump-starting your integration projects. Get on overview on relevant SAP Middleware-related sessions with the blog by Smadar Ludomirski and read the blog by Gunther Stuhec to know all important sessions to understand the new tool of the Integration Advisor and see how it will work in real. Oct 2014

SAP has released SP4 for B2B Add-on and Secure Connectivity Add-on

After SAP's announcement that B2B is now included in the SAP Process Orchestration license the Support Package 4 is now released with important enhancements. Get an overview on the major enhancements with the blog by Piyush Gakhar. Oct. 2014

Results of Global Process Integration Survey 2014

The blog by Holger Himmelmann reveals the results of the 2014 global SAP PI survey. Thanks to everyone who participated and shared their feedback!
See also the central blog International Focus Group for SAP Process Integration (IFG for SAP PI) that gives you the background of the first initiative of SAP user groups around the globe in the area of SAP PI. Oct 2014

http://scn.sap.com/profile-image-display.jspa?imageID=51093&size=72Reduce your integration efforts with the new solution "Integration Advisor"

The Integration Advisor is a new cloud based solution running on SAP HANA Cloud Integration (HCI) starting with its beta program in January 2015. This tool will tremendously improve and simplify the entire B2B integration project by bringing the different integration phases of business domain experts and integration experts together and by using crowd sourcing based intelligence. Read Gunther Stuhec's article to understand the new solution and have a look on his blog describing his believe how tomorrow's simplified environment for B2B integration will look like. Oct 2014

SFTP Adapter Module in SAP PI 7.0

$
0
0

We don't have SFTP adapter Module in SAP PI 7.0 so if there is any requirement to connect a SFTP server then either we need to purchase an external adapter or we could create a module in JAVA.

 

I was having a requirement of placing a file over SFTP server so to solve that I wrote a JAVA code for SFTP adapter module.

 

Hopefully this will help others to create modules for their requirement.

 

Parameter Configuration in PI receiver Channel:

hahahah.PNG

/**
* @author ashutosh.a.upadhyay
*
* To change the template for this generated type comment go to
* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
*/
package com.sftp;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;


import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import com.sap.aii.af.mp.module.Module;
import com.sap.aii.af.mp.module.ModuleContext;
import com.sap.aii.af.mp.module.ModuleData;
import com.sap.aii.af.mp.module.ModuleException;
import com.sap.aii.af.ra.ms.api.Message;
import com.sap.aii.af.ra.ms.api.MessageDirection;
import com.sap.aii.af.ra.ms.api.XMLPayload;
import com.sap.aii.af.service.auditlog.Audit;
import com.sap.aii.af.service.auditlog.AuditDirection;
import com.sap.aii.af.service.auditlog.AuditLogStatus;
import com.sap.aii.af.service.auditlog.AuditMessageKey;
/**
* @ejbHome <{com.sap.aii.af.mp.module.ModuleHome}>
* @ejbLocal <{com.sap.aii.af.mp.module.ModuleLocal}>
* @ejbLocalHome <{com.sap.aii.af.mp.module.ModuleLocalHome}>
* @ejbRemote <{com.sap.aii.af.mp.module.ModuleRemote}>
* @stateless
*/
public class SFTPAdapterModule implements SessionBean, Module {
private SessionContext myContext;

AuditMessageKey amk;

public void ejbRemove(){
}
public void ejbActivate(){
}
public void ejbPassivate(){
}
public void setSessionContext(SessionContext context){
  myContext = context;
}
public void ejbCreate() throws CreateException {
}

public ModuleData process(ModuleContext moduleContext,ModuleData inputModuleData)throws ModuleException {
  try {
  Object obj = inputModuleData.getPrincipalData();
  Message msg = (Message) obj;
  String SFTPHOST = (String) moduleContext.getContextData("SFTPHostorIP");
  String SFTPPORT = (String) moduleContext.getContextData("SFTPPort");
  String SFTPUSER = (String) moduleContext.getContextData("SFTPUserName");
  String SFTPPASS = (String) moduleContext.getContextData("SFTPpassword");
  String destDir =  (String) moduleContext.getContextData("TargetLocation");
  String fileName = (String) moduleContext.getContextData("SFTPFileName");
    
    if (msg.getMessageDirection()== MessageDirection.INBOUND)
    amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.INBOUND);
    else
    amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.OUTBOUND);
     
    XMLPayload xp = msg.getDocument();
   
 
  Hashtable mp = (Hashtable) inputModuleData.getSupplementalData("module-parameters");
  if (fileName ==""){
   fileName = (String) mp.get ("FileName");
  }
  if (destDir ==""){
    fileName = (String) mp.get ("Directory");
  }  
    Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"SFTP adapter module called....");
  
    if (xp != null){
     Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Connecting to SFTP....");
   byte by[] = convert(xp.getInputStream(),SFTPHOST,SFTPPORT,SFTPUSER,SFTPPASS, fileName, destDir);
     Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"File placed successfully");
     xp.setContent(by);
    }
  
    inputModuleData.setPrincipalData(msg);
    Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Principle data is set successfully.");
    }
    catch (Exception e){
  Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Module Exception Caught .");
  ModuleException me = new ModuleException(e);
  throw me;
    }
    return inputModuleData;
}


public byte [] convert(InputStream inputstream,String host,String port, String username,String password, String fileName, String dir) throws Exception {
Session session = null;
Channel channel = null;
ChannelSftp channelSftp = null;
String file ="";
  try
  {  
  Date date = new Date();
  SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
  String formattedDate = sdf.format(date);
  fileName = fileName+formattedDate;

  JSch jsch = new JSch();
  int portNo = Integer.parseInt(port);
  session = jsch.getSession(username,host,portNo);
  session.setPassword(password);
  java.util.Properties config = new java.util.Properties();
  config.put("StrictHostKeyChecking", "no");
  Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Establishing Connection...");
  session.setConfig(config);
  session.connect();
  Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Session Established");
  channel = session.openChannel("sftp");
  Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Connecting the channel.." );
  channel.connect();
  channelSftp = (ChannelSftp) channel;
  Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Hitting the directory" );
 
  channelSftp.put(inputstream,fileName); 
  Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"File placed.." );
     
  channelSftp.disconnect();
  Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Channel Disconnected..." );
    
  session.disconnect();
  sdf = new SimpleDateFormat("dd/MM/yyyy");
  formattedDate = sdf.format(date); 
  file = "<FileName> file placed to SFTP server at "+formattedDate;
 
  inputstream.close();
  Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Server Disconnected..." );
}
    catch (Exception e) {
    Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Exception in Convert Method.");
    channel.disconnect();
  session.disconnect();
}
return file.getBytes();
}
}

ExcelTransformBean Part 2: Convert simple XML to various Excel formats easily

$
0
0

Introduction

This is a continuation of the ExcelTransformBean adapter module. The first part ExcelTransformBean Part 1: Convert various Excel formats to simple XML easily covers Excel to simple XML conversion.

 

This second part focuses on simple XML to Excel conversion. Similar to the first part, this uses the combined SS interface of Apache POI's API, therefore it is able to write both XLS and XLSX files.

 

 

Source Code

The source code is shared with the first part. Refer to the corresponding section in the first article for details on accessing the source code from the GitHub repository.

 

 

Module Parameter Reference

Below is a list of the parameters for configuration of the module for XML to Excel conversion (conversionType = 'SimpleXML2Excel'.) Certain parameters will automatically inherit the default values if it is not configured.

 

Note: All fields in the simple XML structure must exists. If any field does not exist, this will cause the alignment of the columns to be incorrect. This is similar to the behavior of FCC or MTB's SimpleXML2Plain conversion. To ensure proper column alignments, use MapWithDefault when mapping the fields of the target structure.

 

Parameter NameAllowed valuesDefault valueRemarks
conversionTypeSimpleXML2ExcelRequired field. Determines conversion type.
excelFormatxls, xlsxxlsxDetermines output file format
sheetNameSheet1Name of sheet in output Excel file
addHeaderLine

none, fromXML, fromConfiguration

none

Determines if there will be a header line in the output file, and how it should be populated:

  • none = No header line
  • fromXML = Column names are determined from XML field names
  • fromConfiguration = Column names are determined from parameter fieldNames
fieldNamesName of columns. Required field whenprocessFieldNames = 'fromConfiguration'

 

 

Example Scenarios

Here are some example scenarios of the behavior of the conversion based on different configuration options.

 

Scenario 1

Default values for all optional parameters.

Excel 2007 XSLX file format with default Sheet1.

No header line.

 

Module parameters

Parameter NameParameter Value
conversionTypeSimpleXML2Excel

 

Result

Inputin1.png
Outputout1.png

 

Scenario 2

Excel binary XLS file format.

Active sheet name provided

Header line added with details from input XML fields.

Escape sequence &amp; automatically converted to special character &

 

Module parameters

Parameter NameParameter Value
conversionTypeSimpleXML2Excel
excelFormatxls
sheetNameMySheet1
addHeaderLinefromXML

 

Result

Inputin2.png
Outputout2.png

 

 

Scenario 3

Excel 2007 XSLX file format with default Sheet1.

Header line added. Column names are provided from configuration.

Certain fields are populated with blank values.

 

Module parameters

Parameter NameParameter Value
conversionTypeSimpleXML2Excel
addHeaderLinefromConfiguration
fieldNamesField1,Date,Field2,Quantity

 

 

Result

Inputin3.png
Outputout3.png

Step by Step Dynamically choosing target folder using JAVA mapping with SFTP adapter.

$
0
0

Hello All,

 

Business Requirement: We had to route the file to different folder using company-code as routing condition available in the file name. Since there was no transformation required so it was basically a pass-through scenario. But since we had to fix the receiver directory during runtime we decided to use java mapping to set dynamic configuration Filename and Directory parameters. We have SFTP as sender and Reciver channels and we were using ICO for configuration.

 

Its basically a pass-through scenario with choosing the directory/Filename during Runtime.

 

So it gives an insight of three aspects:

  1. How to configure Pass-through scenario and still use Java Mapping.
  2. How  to put things together with ICO with SFTP adapter.
  3. How to work on java mapping using Eclipse Editor with new API's.

 

 

ESR Objects:

  • We need to create below mentioned objects
    • Sender Data Type (Dummy structure)
    • Sender Message Type
    • Sender Service Interface
    • Receiver Data Type(Dummy structure)
    • Receiver Message Type
    • Receiver Service Interface
  • Imported Archive

ImportedArchive.jpg

  • PFA Java Mapping Sample Code which can be edited as per requirement.(Step by Step explained in below section)

 

 

  • Operation Mapping.

operationMapping.jpg

Note: We need not worry about sender structure not matching the input File.

 

ID-ICO Configuration.

 

  • ICO Inbound Processing:

ICOInboundProcess.jpg

Note: We have to leave the SWCV of sender Interface blank otherwise we might get an error as Adapter engine expects the the file in sender Data Type.


  • ICO Receiver:

ICOReceiverDetermin.jpg

  • ICO Receiver Interfaces:

ICOInterfaceDetermine.jpg























 

 

  • ICO OutBound Processing

ICOOutboundProcess.jpg


  • ICO Sender Channel with Advanced module Parameter

SenderChannel.jpg

Note: We don't need to add anything in Module parameter for content conversion.Just need to leave with default entry.


  • ICO Receiver Channel with Advanced module Parameter

ReceiverChannel.jpg


Note: We don't need to add anything in Module parameter for content conversion.Just need to leave with default entry.


Java Mapping Using Eclipse Editor.


  • Step 1

Step1NewProject.jpg

  • Step 2

Step2NewProjectName.jpg

  • Step 3: Right Click on Project-> Properties -> Java Build Path -> Add External Jars.

Step3AddExternalJars.jpg

  • Step 4

Step4AddNewClass.jpg



  • Step 5

Step5NewClass.jpg


  • Step 6: Now paste the code provide and edit as per your requirement.


  • Step 7: Right Click on Package you are working --> Export


  • Step 8:

Step7JarCreation.jpg


  • Step 9:

Step9JarCreation.jpg

 

 

  • Just Press on Finish and import it through Imported Archive as mentioned above.

 

 

I  know this might not be a difficult one but now this gives us lot of flexibility with other scenarios.

  • PGP Encryption:Supposedly if we want encryption we can add pgp module parameters and do encryption in the receiver channel.
  • Complex Dynamic Filename configuration.

 

Hope this solves few problems.

 

Please share if it requires any changes.

 

thanks and regards

Praveen Tirumareddy.

 

 






How to use Global Variable in SAP PI Mapping

$
0
0

What is Global Variable?

The variable which is accessible to whole program i.e. having global scope throughout a program is called as Global Variable. Here in PI we are actually referencing a definition w.r.t to JAVA as the base of our SAP PI graphical mapping is JAVA only.


What is the need of Global Variables in SAP PI mapping?

There are the cases where we need to pass\share some information or values in PI mapping among all the UDFs. Suppose for e.g. we have multiple UDFs in one graphical mapping which executes in one sequence. One UDF sets some parameters or variables based on any conditions that will be used by another UDF for sending alerts or for some internal validation in PI. These kinds of requirements can be solved by using Global Variables whose scope will be throughout the mapping or all mappings (the Information of deciding scope will be shared below)

How to define GLOBAL VARIABLE in Sap PI Mapping?

There are two ways to define a global variable in SAP PI Mapping.

 

Method 1: In the Mapping itself (as shown in below screenshot)

We have one ICON in the Message Mapping (Edit Java Sections) which allows us to declare Global Variables which are having scope to the same message mapping in which it is defined. All the UDFs which are created in that mapping can use those variables.

1.png

Now when you click on the ICON 3.png you will be getting a window where you can declare global variables and can initialize with a default value (as shown below)

 

2.png

 

Three variables are defined and are initialized as you see in the screenshot. Now these variuables can be used in UDFs.

Set it in one UDF like 2..pngand use it in aother as  4.png

 

 

 

Method 2:

 

 

In second options we will be creating a JAVA Mapping which will be imported in SWCV as Imported Archives and this allows us to use a Global Variable throughout all the mappings defined in the SWCV. So in this case the scope of our variable is increased to mappings not limited to UDFs.

 

 

The only thing we need to take care of that we need to initialize the global variables everytime when you are using it in UDF otherwise it will read the old values set by any other mapping or UDF. Also you need to import class name in import section of UDF and use variable as <ClassName>.<VariableName>

 

 

The Code is:

5.png

 

 

 

In Imported Achieves it will be like:

6.png

 

In Import Section of UDF, import your class like 7.png

 

In UDF set variable like this: 8.png

 

and use it like this  9.png

PI.SFSF Integration.DOC – Successfactors communication channel supports UDF based Lookups. [SFSF Lookup]

$
0
0

Document Objective: Objective of this document is to providing information about that “SFSF SOAP Channel supports for UDF based Lookups”.

 

This document provides an example on implementation of SFSF lookup UDF in PI Enterprise Service Repository.

 

 

Connectivity add on1.0
PatchLastest sca files :PICOASUF and PIADAPTERS.sca
Entity Type:SOAP
Entity Name:User
Operation TypeQuery
LookUp QuerySelect id from User where externalId in (<dynamicValues>)

 

 

 

Brief about Technical Scenario:

For each person_id_external Lookup Query will bring back the id from SFSF User Entity.

E.g. Input <external-Id > 346 and Output < id > would be USR-22.

 

 

Step I. Include following packages.

2.PNG

 

 

Step II. add UDF with following paramters.

3.png

 

Step III. UDF Code.

 

AbstractTrace trace = container.getTrace();

String Var_Username ="";

for (int inlen = 0; inlen < Var_ExternalID.length; inlen++)

{

Var_Username = Var_Username+","+"'"+Var_ExternalID[inlen]+"'";

}

Var_Username = Var_Username.substring(1,Var_Username.length());

 

try

  {

Payload SOAPOutPayload = null;

String SysName ="";

String BuisnessSysName ="";

BuisnessSysName = "SUCCESS_FACTORS_DEV";

Channel channel = LookupService.getChannel( BuisnessSysName,"Common_SF_SFAPI_Receiver");

SystemAccessor accessor = LookupService.getSystemAccessor(channel);

String SOAPxml ="<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:query
xmlns:ns0=\"urn:sfobject.sfapi.successfactors.com\"><ns0:queryString>Select id,externalId from User where externalId in ( "+Var_Username+")</ns0:queryString></ns0:query>";

 

InputStream inputStream =new ByteArrayInputStream(SOAPxml.getBytes());

XmlPayload payload = LookupService.getXmlPayload(inputStream);

SOAPOutPayload = accessor.call(payload);

InputStream inp = SOAPOutPayload.getContent();

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

Document document = builder.parse(inp);

document.getDocumentElement().normalize();

NodeList list = document.getElementsByTagName("id");

NodeList Elist = document.getElementsByTagName("externalId");

for (int temp =0; temp < list.getLength(); temp++)

{

Node node = list.item(temp);

Node Enode = Elist.item(temp);

if (node != null)

{

node = node.getFirstChild();

Enode = Enode.getFirstChild();

if (node != null)

{

result.addValue(node.getNodeValue()+"||"+Enode.getNodeValue());

}

}

}

}

catch (Exception e)

{

trace.addWarning("Error" + e);

  result.addValue(e);

}

 

Step IV: Communication Channel.

9.png

 

Step V : Testing and UDF Execution

4.PNG

5.PNG

6.png

Request Message to Successfactors

7.png

Response back from Successfactors

 

8.png

 

Please do write back your comments and Queries. 

Connecting ERP system to PI system via Netweaver Administrator

$
0
0

This document describes step by step with screenshots how to connect an ERP6.04 ABAP system to 7.10 PI system.

 

STEP1 - Login to your NWA via: http://<IP or Hostname of PI>:5SN00/nwa and navigate to configuration wizard (SN refers to System number) and execute FQDN:

Configuration Management-->Scenarios-->Configuration Wizard

You are recommended to execute FQDN-Hostname configuration at first. It registers FQDN of your PI to related areas:

1.png


STEP2 - Get certificates of both PI and ERP systems, from STRUST. You can save to your local as binary files. Then exchange them between the systems, via STRUSTSSO2. Add the certificates both to ACL and certificate list. Please keep in mind that those parameters should be set in both systems:

login/accept_sso2_ticket = 1

login/create_sso2_ticket = 2

2.png

 

 

STEP3 - Create RFC destinations in the satellite business system. All RFCs should be marked as "Unicode". The values will be used later in Netweaver Administrator to match the RFCs with the PI system.

After all RFCs will be created we can check them via transaction code SLDCHECK.

 

1st RFC: <PI_SID>_HTTPDESTINATION

4.png

Logon client is default PI client. In technical settings tab, fill the target host and service no (5SN00) information regarding to the PI system. Path prefix: /sap/xi/engine?type=entry

 

2nd RFC: INTEGRATION_SERVER_<PI_SID>

7.png

Unbenanntes Bild.png

Technical settings tab is same as the first RFC.

 

3rd RFC : LCRSAPRFC

8.png

Program ID: LCRSAPRFC_<PI_SID>

 

4th RFC :SAPSLDAPI

10.png

Program ID: SAPSLDAPI_<PI_SID>

 

STEP4 - Transaction Code : SLDAPICUST

Provide a PI system user name (SLD_CL_<SID_PI>) to send SLD datas to PI system. Give PI system and port in the related fields. Check the inputs from tcode SLDCHECK afterwards.

12.png

 

 

STEP5 - Transaction Code : RZ70

Schedule the background job, which sends ERP system data (satellite business system) to PI system. SLD Bridge refers to PI system.

13.png

 

 

STEP6 - Adding ERP ABAP system as a "Business System" to PI SLD. Login to sld:

http://<IP or Hostname of PI>:5SN00/sld

After scheduling RZ70 background job and execute it for the first time, we should be able to see ERP system under "Technical Systems". Now we will add it as a "Business System". Navigate to "Bus. System"-->Add new :

14.png

 

Select ERP ABAP system as "Technical system" from dropdown menu:

15.png

After completing this registration, check from business systems list whether your ERP ABAP system has been added successfully.

 

STEP7 - Transaction code : SXMB_ADM

Navigate to "Integration Engine Configuration" and choose your PI system as "Corresponding Integ. Server" :

17.png

 

"Specific configuration" :

18.png

 

 

STEP8 - Check your inputs from transaction code SLDCHECK once more :

19.png20.png

 

STEP9 - Login to your NWA via: http://<IP or Hostname of PI>:5SN00/nwa and navigate to configuration wizard (SN refers to System number):

Configuration Management-->Scenarios-->Configuration Wizard

Execute "NW PI - AS ABAP (Basic Configuration for Idoc, Proxy): Maintain" job. This job will approve the inputs we had entered before and register them in PI side. You'll be asked to enter administrative users of both PI and ABAP ERP system.

21.png

 

I've added some example screens to give an idea about the process.

During the execution, useful links and SAP notes will be recommended and advised. One can read and find useful information about integration structure within those links.

22.png

 

 

23.png

 

 

Some error and warning windows during the execution:

24.png

Reason: Logical name and client tables can not be written. You can skip.

 

25.png

Reason: SAP_ALL rights to PIAPPLUSER user. You can skip.

 

27.png

If you will have an IDX structure, you can edit it. Otherwise skip it.

 

26.png

Reason: You can skip this warning. We don't want to change the password.

 

After completion you'll see this window.

28.png


How to pick up files with filename dynamically specified in message content

$
0
0

Update 8 Jan 2015: Add Sync-Async bridge as a use case

 

Introduction

Typically, file based interfaces involve pickup of files for further processing. SAP's file based adapters (NFS, FTP, SFTP) provide the file name scheme/pattern to specify which files should be picked. Although placeholders, regex and wildcards are allowed, it is still a static definition.

 

Occasionally, there are requirements to dynamically pick up files based on the file name provided in the content of a message payload. This cannot be achieved with the standard adapters because:

  • Sender channels can only pick up based on static definitions
  • Receiver channels can only deliver files but not pick files

 

One approach to achieve this is to code a file IO operation in a mapping UDF. Although it is technically feasible, it violates EJB 2.1 specification. SAP's PI JavaDocs clearly documents this for the package com.sap.aii.mappingtool.tf7.rt (used for Function Libraries and UDFs.)

Note for Java mapping programs (user-defined functions and Imported Archives), the programming restrictions imposed on J2EE application providers and especially the restrictions imposed on J2EE EJB providers are valid. This means for example, you should not

 

  • load and use JDBC drivers (use instead the Lookup API),
  • use class loaders,
  • use the package java.io (writing to or reading from file system),
  • create and manage threads,
  • change system properties (using java.lang.System.setProperties()),
  • listen on, accept connections on, or multicast from a network socket.

For more on these restrictions, see chapter 25.1.2 of the EJB 2.1 specification.

 

An example of such violation is if the file IO operation moves the file after pickup. This mapping program is now stateful and introduces a side effect. Due to the side effect, failed messages cannot be reprocessed with a guarantee that the behaviour is still the same. The following blog describes in more detail why XI mappings should be free of side effects.

 

 

Approach

This blog details an approach to achieve such requirement using the Additional Files feature of the sender File (only NFS protocol) or SFTP adapter.

 

The basic idea is to have two interface scenarios as described below:

  • Scenario 1 - based on dynamically specified target filename to be picked up, create a trigger file in same directory
  • Scenario 2 - polls the directory for the trigger file, once trigger file is found, pick up additionally the target file

 

 

Configuration

Below are the design and configuration for the scenarios

 

Scenario 1

Based on incoming message containing filename to be picked up, create a trigger file in the directory with the same filename except having a different extension, i.e <filename>.trigger. The actual content of the trigger file does not matter. Graphical message mapping is used to change the filename and store it in a field of the target message. Variable substitution in receiver channel is configured so that the file is created based on the trigger filename in the target payload.

 

Message Mapping

Replaces source extension with trigger extension in filename to be picked up

map1.png

 

Receiver channel configuration

Filename is configured to be retrieved from payload content via variable substitution

receiver1.png

 

iFlow

iFlow setup with Operation Mapping specifying the change of extension

iflow_1.png

 

 

Scenario 2

Sender adapter will pickup the trigger file and adds the target file as an additional attachment. PayloadSwapBean is used to swap the attachment into the main document. Mapping is performed to change the extension of the main document since Dynamic Configuration will have the trigger file as its filename. The target file is then delivered to its final destination.

 

Sender channel configuration

Channel set to pick up trigger files along with the corresponding CSV files. ASMA is set for filename

sender_2.png

PayloadSwapBean in configured in the module chain to swap the CSV attachment into the main payload

swap.png

 

Message/Java Mapping

Mapping is performed to change back the filename extension from trigger filename to the original filename.

For non-XML target files, use Java mapping with Dynamic Configuration to change the filename extension

mapping.png

 

Receiver Channel Configuration

Receiver channel is set to create target file based on ASMA value

receiver2.png

 

iFlow

iFlow setup with Operation Mapping specifying the change of extension back

iflow2.png

 

 

Testing Example

 

Target CSV file that is to be picked up from the source directory

testfile.png

 

A message is sent on scenario 1 to specify pickup of the CSV file. Mapping changes the filename extension to the trigger file

sendfile.png

 

Trigger file is created in the directory with CSV file that is to be picked up

trigger.png

 

Trigger file is picked up with additional CSV file swapped into main payload

pick_trigger.png

 

The logs display that originally the trigger file is in the main payload, and the CSV file is the attachment. After the swap, the CSV file is the main payload and the trigger file is the attachment.

ori.png

swaplog.png

 

Finally, the CSV file is delivered to the intended final destination.

final.png

 

 

Use cases

Below are some example of use cases for such an approach:

  • Pick up specific file to move to different folder
  • Pick up specific file for further inbound processing
  • Pick up specific file to be attached in an email
  • Sync-Async bridge to indicate filename in request message and get file content in response message. Ensure that polling frequency for sender channel in scenario 2 does not exceed the timeout setting of original synchronous interface.

 

 

Reference

Below are some reference material for configuration of "Additional Files" in the sender adapter. Note that this is only available for NFS and SFTP sender adapters.

Sender File Adapter Frequently Asked Questions - Process Integration - SCN Wiki (Question 4)

Sending Additional Files from SAP Netweaver PI to Third party FTP location

Special character’s handling in PI/XI simplest ever.

$
0
0

We normally come across this very common issue where special characters are received from ECC and passes through PI successfully and at receiving system it fails as the receiver does not accept special characters.

 

Especially when we are dealing with Bank scenarios, the protocols at Bank’s end are very strict and the payments are rejected very frequently.

The major problem is that these characters do not get detected as they are not visible with naked eyes or in payload.

If you try opening payload in notepad then you will be able to figure out.

 

Normally when we try to deal with special characters we focus on the characters which are not acceptable, but while using this technique we normally miss some or the other character and the problem persists.

 

So to deal with special character problems, I have used a method which is fool proof and can anytime be used very easily and in very simple way anytime and in any version of PI/XI.

 

In this method we will be concentrating on the allowed characters list rather than not allowed ones.

It is a simple reusable java code which can be used to write and UDF and can be used for any input fields which need special character handling.

In this code we will match the input field character by character with the allowed list and if the character of input field matches the one from the allowed list, add them to the string buffer and return the list from the buffer in the end.

 

 

Capture.PNG

 

 

This is the best and simplest ever practice to deal with special characters in PI

PIP(Partner Interface Process) Codes: Consolidated List

$
0
0

The entire business supply chain domains for which PIPs are specified are divided into many clusters. Each cluster is further sub-divided into segments. Each segment consists of several PIPs.

PIPs include specification of partner business roles such as buyer, seller and so on, activities conducted between the roles and type, content, and sequence of documents exchanged by the roles while performing these activities. Also specified are the time, security, and authentication of these interactions.  The structure and content of the documents exchanged is based on the business dictionary and technical dictionary. The PIP is a compilation of this message type information into document type definitions (DTDs) and message guidelines.

Trading partners exchange documents that match the DTDs by using network protocols specified by RNIF.

The Below Codes may be useful for various information:-

 

4A1– Notify of the Strategy Forecast

4A3 – Notify Release Forecast Information

4A5 -- Forecast Replay

3A4 – Purchase order request

3A4R -- Purchase order response

3A8 -- Purchase Request

3A8R -- Purchase order Change Confirmation

3B2 -- ASN ( Advance Shipments Notifications)

3B3 -- Distributed Shipments Receipt

4B2 -- Notification of shipment Receipt

4C1 -- Distributed Inventory Receipt

3C3 -- Notify Invoice

3C6 -- Notify Remittances Advice

3C7 -- Self Building Invoice

5C1 -- Distributed Product List

7B1 -- Distributed Working Progress

 

 

If the codes starts with:

3*-- It mainly deals with Purchase Order related Interfaces at ECC level .

4*-- It mainly deals with Forecast Information in SCM.

5*-- Product Related Information.

7*-- Distribution information at SCM.

 

Example: 

 

 

3

 

 

A

 

 

8

 

 

R

 

 

 

Cluster

 

 

 

Quote

 

 

 

Order Entry

 

 

 

Request Purchase       Order

 

 

 

 

 

 

 

 

 

 

 

 

This completes the consolidated list of PIP codes.

FCC parameter reference for MessageTransformBean module

$
0
0

Update 2 Jan 2015: Correction for StructPlain2XML- should be xml.processFieldNames instead of xml.<StructureName>.processFieldNames


This document was moved from the following blog FCC parameter reference for MessageTransformBean module based on suggestion by Aaron Myers to allow for collaborative effort to maintain/update this reference list.

 

1) Conversion type: SimplePlain2XML

 

Parameter NameDefault value if parameter not configuredAllowed parameter valuesAdditional remarks
xml.skipEmptyFilefalse
xml.encodingUTF-8
xml.conversionTypeSimplePlain2XML
xml.structureTitlerow
xml.fieldFixedLengthsEither fieldFixedLengths or fieldSeparator must be populated
xml.fieldFixedLengthTypechar
xml.fieldSeparatorEither fieldFixedLengths or fieldSeparator must be populated
xml.endSeparatornl
xml.beginSeparator
xml.enclosureSign
xml.enclosureSignEndxml.enclosureSign
xml.enclosureSignEscape
xml.enclosureSignEndEscapexml.enclosureSignEscape
xml.enclosureConversionYES
xml.checkForXMLPredefinedEntitiesYES
xml.checkForISOControls
xml.lastFieldsOptionalNODeprecated and should not be used with missingLastFields or additionalLastFields
xml.missingLastFieldsignore
xml.additionalLastFields
xml.keepIncompleteFieldsNO
xml.addBeginSeparatorAsField
xml.addEndSeparatorAsField
xml.fieldContentFormattingtrim
xml.processFieldNames

notAvailable - means that no field name information is available.

 

fromFile - means that the field name information is located in the header line of the file to be converted.

 

fromFileWithBlankLine - corresponds to fromFile. After the header line there also follows a blank line or separator that is skipped.

 

fromConfiguration - means that no header information exits in the file to be converted, but it will be delivered by the present configuration.

 

notAvailable - means that no field name information is assumed to be in the configuration or in the file to be converted. In this case, the columns in the XML document are identified using a simple counter tag (<columnX> , X=0,1,2…).

Required parameter
xml.documentName
xml.documentNamespace
xml.documentNamespaceScoperoot
xml.fieldNamesRequired parameter if xml.processFieldNames = fromConfiguration

 

 

2) Conversion type: StructPlain2XML

<StructureName> is per the structure names defined in xml.recordsetStructure. For each structure name listed, configure the corresponding xml.<StructureName>.* parameters.

 

Parameter NameDefault value if parameter not configuredAllowed parameter valuesAdditional remarks
xml.skipEmptyFilefalse
xml.encodingUTF-8
xml.conversionTypeStructPlain2XML
xml.recordsetStructureRequired parameter
xml.recordsetStructureOrderasc
xml.allowEmptyRecordsetsYES
xml.recordsetNameRecordset
xml.recordsetNamespace
xml.recordsetNamespaceScoperoot
xml.recordsetBeginSeparator
xml.recordsetEndSeparator
xml.documentName
xml.documentNamespace
xml.documentNamespaceScoperoot
xml.recordsetsPerMessage*
xml.documentSkipFirstRows0
xml.keyFieldNameRequired parameter if there is a structure with * in xml.recordsetStructure
xml.keyFieldTypeRequired parameter if there is a structure with * in xml.recordsetStructure
xml.processFieldNamesfromConfiguration

notAvailable - means that no field name information is available.

 

fromFile - means that the field name information is located in the header line of the file to be converted.

 

fromFileWithBlankLine - corresponds to fromFile. After the header line there also follows a blank line or separator that is skipped.

 

fromConfiguration - means that no header information exits in the file to be converted, but it will be delivered by the present configuration.

 

notAvailable - means that no field name information is assumed to be in the configuration or in the file to be converted. In this case, the columns in the XML document are identified using a simple counter tag (<columnX> , X=0,1,2…).

xml.<StructureName>.fieldFixedLengthsEither fieldFixedLengths or fieldSeparator must be populated
xml.<StructureName>.fieldFixedLengthTypechar
xml.<StructureName>.fieldSeparatorEither fieldFixedLengths or fieldSeparator must be populated
xml.<StructureName>.endSeparatornl
xml.<StructureName>.beginSeparator
xml.<StructureName>.enclosureSign
xml.<StructureName>.enclosureSignEnd
xml.<StructureName>.enclosureSignEscape
xml.<StructureName>.enclosureSignEndEscape
xml.<StructureName>.enclosureConversionYES
xml.<StructureName>.checkForXMLPredefinedEntitiesYES
xml.<StructureName>.checkForISOControls
xml.<StructureName>.lastFieldsOptionalNODeprecated and should not be used with missingLastFields or additionalLastFields
xml.<StructureName>.missingLastFieldsignore

 

xml.<StructureName>.additionalLastFields
xml.<StructureName>.keepIncompleteFieldsNO
xml.<StructureName>.addBeginSeparatorAsField
xml.<StructureName>.addEndSeparatorAsField
xml.<StructureName>.fieldContentFormattingtrim
xml.<StructureName>.keyFieldValueRequired parameter if there is a structure with * in xml.recordsetStructure
xml.<StructureName>.keyFieldInStructureadd
xml.<StructureName>.fieldNamesRequired parameter if xml.<StructureName>.processFieldNames = fromConfiguration

 

 

3) Conversion type: SimpleXML2Plain

 

Parameter NameDefault value if parameter not configuredAllowed parameter valuesAdditional remarks
xml.skipEmptyFilefalse
xml.encodingUTF-8
xml.conversionTypeSimpleXML2Plain
xml.fieldFixedLengthsEither fieldFixedLengths or fieldSeparator must be populated
xml.fieldFixedLengthTypechar
xml.fieldSeparatorEither fieldFixedLengths or fieldSeparator must be populated
xml.endSeparatornl
xml.beginSeparator
xml.checkForXMLPredefinedEntitiesYES
xml.checkForISOControls
xml.addHeaderLineRequired parameter
xml.headerLineRequired parameter if xml.addHeaderLine = 3 or 4
xml.absoluteRowWidth0
xml.fixedLengthTooShortHandlingError

 

 

4) Conversion type: StructXML2Plain

<StructureName> is per the structure names defined in xml.recordsetStructure. For each structure name listed, configure the corresponding xml.<StructureName>.* parameters.

 

Parameter NameDefault value if parameter not configuredAllowed parameter valuesAdditional remarks
xml.skipEmptyFilefalse
xml.encodingUTF-8
xml.conversionTypeStructXML2Plain
xml.recordsetStructureRequired parameter
xml.<StructureName>.fieldFixedLengthsEither fieldFixedLengths or fieldSeparator must be populated
xml.<StructureName>.fieldFixedLengthTypechar
xml.<StructureName>.fieldSeparatorEither fieldFixedLengths or fieldSeparator must be populated
xml.<StructureName>.endSeparatornl
xml.<StructureName>.beginSeparator
xml.<StructureName>.checkForXMLPredefinedEntitiesYES
xml.<StructureName>.checkForISOControls
xml.<StructureName>.absoluteRowWidth0
xml.<StructureName>.fixedLengthTooShortHandlingError

 

 

References:

For details about the functionality & values related to each parameter, refer to the corresponding parameter listed in the FCC section of the File/FTP adapter below:-

Converting Text Format in the Sender File/FTP Adapter to XML

 

Converting XML in the Receiver File/FTP Adapter to Text Format

 

Wiki with step by step sample of configuring FCC on JMS adapter

How To...Content conversion module with J2EE JMS adapter - Process Integration - SCN Wiki

Simplify Java Mapping with Reusable Abstract Classes

$
0
0

Update 19 May 2014:JAR file also available for download at GitHub repository

 

Background

Whenever we need to develop Java mappings in PI, often it involves a lot of copy-paste of codes and doing the same tasks again and again. Most of this effort is to comply with the Java Mapping API provided in PI. In this article, I will introduce an approach that can simplify developments of Java Mapping in PI. A similar approach was previously introduced in the following article XI Java Mapping Helper (DOM) by Alessandro Guarneri. In this article, the design is based on the new API utilizing AbstractTransformation class from PI7.1 onwards. Hopefully this might also lower the entry barrier for those who are contemplating developing Java mappings but are new to it.

 

 

Concept & Design

The idea is to "package" commonly reused codes together, which then enables the developer to focus on the specific logic for a particular requirement. This approach is based on the Strategy Pattern using Abstract Classes.

 

In general, following are the sequence of steps required for a Java Mapping.

  1. Parsing of Input
  2. Generating the output content
  3. Convert output content to output stream

As mentioned above, steps 1 and 3 are always the same most of the time. The difference between mappings are often for step 2 to generate the output content. As such we can encapsulate the logic in steps 1 and 3 into an abstract base class.

 

Also, there is possibility of different type of input/output content (plain, XML, binary, etc), and each of these require specific logic for parsing and stream generation. Therefore there will be a second tier of abstract classes which controls the correct sequence of logic for each conversion type.

 

The following table lists the classes in this design.

ClassDescription
AbstractMappingBaseBase super class
AbstractDOM2DOMExtends AbstractMappingBase - Controls logic for DOM to DOM processing
AbstractDOM2PlainExtends AbstractMappingBase - Controls logic for DOM to Plain processing
AbstractPlain2PlainExtends AbstractMappingBase - Controls logic for Plain to Plain processing
AbstractPlain2DOMExtends AbstractMappingBase - Controls logic for Plain to DOM processing

 

Below is an example of the logic in AbstractPlain2DOM class. Firstly, the input data is parsed and stored in the array of String (representing each line of input payload). Then the output contents are generated in DOM format. Lastly, the DOM output is transformed to the output stream.

 

ArrayList<String> inputContents = parsePlainInput(input.getInputPayload().getInputStream());
Document outputDoc = getDocumentBuilder().newDocument();
generateOutput(inputContents, outputDoc);
transformDocumentToStream(outputDoc, output.getOutputPayload().getOutputStream(), indentOutputXML);

 

Each of the subclasses has an abstract generateOutput method. It is this method that needs to be implemented in a custom mapping class that extends the corresponding abstract class. Below is a table listing the input/output parameters of the abstract method for each of the classes.

ClassModifier & TypeMethod & Description
AbstractDOM2DOMabstract void

generateOutput (Document inDoc, Document outDoc)

Construct DOM output based on DOM input

AbstractDOM2Plainabstract StringBuilder

generateOutput (Document inDoc)

Generate String output based on DOM input

AbstractPlain2Plainabstract StringBuilder

generateOutput (ArrayList<String> inContents)

Generate String output based on input of String array

AbstractPlain2DOMabstract void

generateOutput (ArrayList<String> inContents, Document outDoc)

Generate DOM output based on input of String array

 

 

Example of Mapping Implementation

Now we go to the actual work to be done. In this example, I will develop the Java Mapping directly in ESR based on the technique shared by Sunil Chandra. Alternatively, this can be done in the normal way in Eclipse/NWDS - just need to remember to include the JAR file below in the build path.

 

Step 1

Import the JAR file into ESR as an Imported Archive (this can be skipped for further developments.)

archive.png

 

Step 2

Create Message Mapping with dummy source and target.

mm.png

 

Step 3

In the Functions tab, include the archive, and add the import for com.equalize.xpi.esr.mapping. If you are using DOM related functions, import org.w3c.dom as well.

arc.png  import.png

 

Step 4

Write code in "Attributes and Methods" section.

code.png

 

Essentially, there are only 2 things to do here. First of all, implement transform method of AbstractTransformation. The following code can be copied as-is.

 

@Override
public void transform(TransformationInput input, TransformationOutput output)  throws StreamTransformationException {  AbstractMappingBase map = new CustomMap();  map.process(input, output, this.getTrace());
}

 

Secondly, and more importantly is to code the logic for the output content. To do this, create a local CustomMap class that extends from one of the above abstract classes (AbstractPlain2Plain in this example). Then implement the generateOutput method. The following code just adds a prefix for each of the input lines - HD for first line, FT for last line and IT for everything in between.

 

// Local class with logic for output generation
class CustomMap extends AbstractPlain2Plain {  @Override  protected StringBuilder generateOutput(ArrayList<String> inContents) {    StringBuilder sb = new StringBuilder();    int count = 0;    for (String line : inContents) {      if (count == 0) {        sb.append("HD");      } else if (count == inContents.size()-1) {        sb.append("FT");      } else {        sb.append("IT");      }      sb.append(line);      sb.append("\n");      count++;    }    setPlainOutputEncoding("UTF-8");    return new StringBuilder(sb.toString());  }
}

 

Step 5

Test the mapping.

result.png

 

 

Conclusion

As you can see, the development of the Java mapping for any requirement has been significantly simplified. The developer no longer needs to handle the parsing and the stream conversion, and therefore can fully focus on the specific content generation.

 

Also, currently there are only 4 different mapping subclasses, handling DOM and plain text processing. This can be easily extensible in the future to include other types, i.e. SAX.

 

Source code and JAR

The Java source codes are available in the following GitHub repository. Also included are sample implementation source codes for each of the abstract class above.

PI_JavaMappingLib at engswee's GitHub

 

The JAR file (with source codes) are attached below. However, due to SCN file import limitations, it has been renamed as .TXT. To obtain the JAR file, please follow the steps below:

  1. Download the ZIP file.
  2. Extract contents of ZIP file.
  3. Remove .TXT extension of file (so that the extension becomes .JAR)

Update: JAR file is also available for direct download at GitHub

 

 

Reference

The following article Easy way to learn - Java Mapping using DOM - SAP PI 7.1+ by Ricardo Viana is a useful resource to learn DOM based processing.

Viewing all 571 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>