Showing posts with label SAP PI. Show all posts
Showing posts with label SAP PI. Show all posts

Thursday, August 2, 2012

SAP PI - Dynamic File Name generation



In some cases the requirements of the file being dropped by PI requires to be certain specific formats. For e.g. Date or sequence numbers required. Even though there is a date stamp privided by the File adapter, it is not very flexible in terms of format. Thus the below method is quite helpful. Everything happens in the message mapping.

There is one config required in the File Receiver in the Integration Directory:




The next thing to configure is the message mapping in the ESR, create a UDF in the message mapping as follows:


The reason why I am imported the Seeburger functions are because in this particular case, the file name required a sequence number which increments for each customer. Thus it creates a seeburger variable and gets the next sequence number. Also this UDF should be called once only in the mapping. It should basically have the following code to make the file name be as per what you define:

 DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMdd");
String timestamp = dateformat.format(new Date());

String filename1= "OTI_I_18_"+customerGLN + "_" + customerNumber +"_" +".txt";

conf.put(key, filename1);

The above should do the trick for a special date formatted file name.

MDM ECC integration



After configuring PI to use standard integration from MDM to ECC, there are some config required in ECC so that the MDM objects gets processed correctly. The below are conversion rules on the MDM idocs:

1) Go to transaction SALE
2) Navigate to Modelling and Implementing Business Processes > Converting Data between sender and receiver

3)  Click on Create Rules

The list of Rules you need to create are as per the following Screenshot:



4) Go back to Menu and Click on Maintain Rules
5) Edit the following rules:
















The above are all the config required for your MDM Idocs run correctly in ECC. The Alpha routine only adds leading zeros to the fields (e.g. KUNN2). The reason for this is because MDM tends to remove the leading zeros when saving.

Thanks. Hope you enjoyed the blog.

Regards,
Gawshan.