XI/PI Dynamic Change File Receiver File Name

Dynamic Change File Receiver File Name

在实际的业务需求中,有很多需要动态的改变写出的文件名称,比如根据一些判断逻辑,写不同的文件名称等等,

方法有几种,可以用在ID端用XPATH方式,下面列举其中一种办法,UDF方式,

在Message Mapping 时自定义函数,代码如下:

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

DynamicConfigurationKey key = DynamicConfigurationKey.create(

"http://sap.com/xi/XI/System/File",

"FileName"); //如果想改变Directory,那FileName 换一下就可以了

String valueNew = "";

String valueOld = conf.get(key);//获得原文件名称,

//if (valueOld != null) { // 判断原文件名是否存在

valueNew = "test";//valueOld.replaceAll("input","output");//改为新的文件名称

conf.put(key, valueNew);

//}

return a;

clip_image002

这些开始mapping ,只要对非数据字段(非叶子结点)mapping即可,

clip_image004

这时IR端的开发就完成了,下面是ID端,ID端很简单了 Adapter-Specific Attributes,

clip_image006

根据这个思路你可以改变Directory ,File Type 等内容

原文地址:https://www.cnblogs.com/byfhd/p/1507098.html