Dynamic File name using ASMA (Adapter Specific Message Attributes) in PI/XI

2023-12-14 05:38

本文主要是介绍Dynamic File name using ASMA (Adapter Specific Message Attributes) in PI/XI,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

转自:http://www.saptechnical.com/Tips/XI/ASMA/Index.htm

 

There has been an added feature from SP14 onwards to handle the Message Attributes dynamically using AdapterSpecificMessageAttibutes (e.g. Filename). This feature has been demonstrated with one of the example below using File adapter.  

Business case:

There was a requirement in one of our interfaces to get the   same file name that sender places in his FTP and get the same name as file name with the added time stamp separated by the “_ “(underscore) symbol on the target side.

Ex: Source side file name (DynamicPO.txt has to be converted to DynamicPO_<timestamp>.xml).  

Technical challenge:

Time stamp can be added at the end of the file name by specifying the Add Timestamp parameter .But our requirement is to put underscore between filename and time stamp which is not possible in the former case. To achieve this we can make use of ASMA and modify the file name according to our requirement.  

Procedure:

Design Part (IR):

Prerequisites:

All the required Interface objects have already been created,In the current case the message structures are:  

Source Structure

 

Target Structure

<!-- [if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:137.25pt; height:150.75pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image001.png" o:title=""/> </v:shape><![endif]-->

<!-- [if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" style='width:139.5pt;height:154.5pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image003.png" o:title=""/> </v:shape><![endif]-->

Message mapping:  

  • Create an UDF and include the piece of code that captures the Filename and Timestamp from source side via ASMA. 

  • Modify them according to our requirement by adding the <Timestamp> at the end of <filename>.

  • Map the UDF to any of the top level node so that the modified filename will be available for the target communication channel.

UDF code: 

<!-- [if gte vml 1]><v:shape id="_x0000_i1027" type="#_x0000_t75" style='width:378pt;height:266.25pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image005.png" o:title=""/> </v:shape><![endif]-->  

Code:

try {

String filename    = "";

String timestamp = "";

DynamicConfiguration conf1 = (DynamicConfiguration) container

    .getTransformationParameters()

    .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

DynamicConfigurationKey key2 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","SourceFileTimestamp");

filename = conf1.get(key1);

timestamp = conf1.get(key2);

filename = filename.replaceAll( ".txt" ,"_" );

filename = filename+timestamp+".xml";

conf1.put(key1,filename);

return filename;

}

catch(Exception e)

{

     String exception = e.toString();

       return exception;

}

Configuration Part (ID):

à In the sender side communication channel, Mention *.txt as file name to pick all the txt files that will be placed in the source directory.

<!-- [if gte vml 1]><v:shape id="_x0000_i1028" type="#_x0000_t75" style='width:242.25pt;height:78pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image007.png" o:title=""/> </v:shape><![endif]-->  

à Click on Advanced tab and check the Option “SetAdapterSpecificMessageAttributes ” in addition to that check the attribute that are required to be captured during run time. In our case File Name and Source File Time Stamp are required to be checked as shown in the below picture.

<!-- [if gte vml 1]><v:shape id="_x0000_i1029" type="#_x0000_t75" style='width:214.5pt;height:118.5pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image009.png" o:title=""/> </v:shape><![endif]-->             

--> In the receiver communication channel Mention ‘ * ‘as File Name Scheme.

<!-- [if gte vml 1]><v:shape id="_x0000_i1030" type="#_x0000_t75" style='width:270.75pt;height:55.5pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image011.png" o:title=""/> </v:shape><![endif]-->

à Click on Advanced tab and check the Option “SetAdapterSpecificMessageAttributes ” in addition to that check the attribute “File Name ” which will carry the modified value in the UDF in mapping as shown below.

<!-- [if gte vml 1]><v:shape id="_x0000_i1031" type="#_x0000_t75" style='width:3in;height:118.5pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image013.png" o:title=""/> </v:shape><![endif]-->

à Create the Remaining IR objects as usual, save and activate them.  

Execution:

Now it’s the time to test the interface .Place the “.txt ” file in the source directory and execute scenario. After successful execution you will see the “.xml ” file (as my scenario is FCC to xml ) created by the name that in way it has been modified in the UDF using Dynamic Configuration .

Sender system

Receiver System

<!-- [if gte vml 1]><v:shape id="_x0000_i1032" type="#_x0000_t75" style='width:3in;height:51.75pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image015.png" o:title=""/> </v:shape><![endif]-->

<!-- [if gte vml 1]><v:shape id="_x0000_i1033" type="#_x0000_t75" style='width:255pt;height:59.25pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image017.png" o:title=""/> </v:shape><![endif]-->

 

<!-- [if gte vml 1]><v:shape id="_x0000_i1034" type="#_x0000_t75" style='width:153pt;height:51pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image019.png" o:title=""/> </v:shape><![endif]-->

<!-- [if gte vml 1]><v:shape id="_x0000_i1035" type="#_x0000_t75" style='width:324pt;height:215.25pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image021.png" o:title=""/> </v:shape><![endif]-->

Runtime Workbench:  

The checking of options ASMA in communication channel allows sender file attributes to be available in RWB as shown in the figure to see them Go to   sxmb_moni à click on the message à Inbound message à SOAP Header à Dynamic Configuration .  

File name and timestamp in SXMB_MONI (Before Modification ) :

<!-- [if gte vml 1]><v:shape id="_x0000_i1036" type="#_x0000_t75" style='width:342pt;height:144.75pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image023.png" o:title=""/> </v:shape><![endif]-->

Go to sxmb_moni à click on the message à Call Adapter à SOAP Header à Dynamic Configuration .

File name in SXMB_MONI (After modification Modification using Dynamic Configuration):

<!-- [if gte vml 1]><v:shape id="_x0000_i1037" type="#_x0000_t75" style='width:425.25pt;height:204.75pt'> <v:imagedata src="file:///C:\DOCUME~1\SAPTEC~1\LOCALS~1\Temp\msohtml1\03\clip_image025.png" o:title=""/> </v:shape><![endif]-->

这篇关于Dynamic File name using ASMA (Adapter Specific Message Attributes) in PI/XI的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/491313

相关文章

vue+elementui--$message提示框被dialog遮罩层挡住问题解决

最近碰到一个先执行this.$message提示内容,然后接着弹出dialog带遮罩层弹框。那么问题来了,message提示框会默认被dialog遮罩层挡住,现在就是要解决这个问题。 由于都是弹框,问题肯定是出在z-index比重问题。由于用$message方式是写在js中而不是写在html中所以不是很好直接去改样式。 不过好在message组件中提供了customClass 属性,我们可以利用

BD错误集锦5——java.nio.file.FileSystemException 客户端没有所需的特权

问题:在运行storm本地模式程序时,java.nio.file.FileSystemException  客户端没有所需的特权   解决方式:以管理员身份运行IDEA即可。

BD错误集锦1——[Hive]ERROR StatusLogger No log4j2 configuration file found. Using default configuration:

错误描述:在使用IDEA进行jdbc方式连接到hive数据仓库时,出现以下错误:                ERROR StatusLogger No log4j2 configuration file found. 问题原因:缺少log4j2.xml文件   <?xml version="1.0" encoding="UTF-8"?><Configuration><Appender

iOS:编译时出现no such file or directory:xxx以及use twice...filenames are used to distinguish private dec

简    注册  登录   添加关注 作者  婉卿容若 2016.04.29 11:22 写了21870字,被16人关注,获得了14个喜欢 iOS:编译时出现"no such file or directory:xxx"以及"use twice...filenames are used to distinguish private

论文阅读--Efficient Hybrid Zoom using Camera Fusion on Mobile Phones

这是谷歌影像团队 2023 年发表在 Siggraph Asia 上的一篇文章,主要介绍的是利用多摄融合的思路进行变焦。 单反相机因为卓越的硬件性能,可以非常方便的实现光学变焦。不过目前的智能手机,受制于物理空间的限制,还不能做到像单反一样的光学变焦。目前主流的智能手机,都是采用多摄的设计,一般来说一个主摄搭配一个长焦,为了实现主摄与长焦之间的变焦,目前都是采用数字变焦的方式,数字变焦相比于光学

vue dist文件打开index.html报Failed to load resource: net::ERR_FILE_NOT_FOUND

本地正常。打包好的dist文件打开index.html报Failed to load resource: net::ERR_FILE_NOT_FOUND 解决办法: 在webpack.prod.conf.js 中output添加参数publicPath:’./’ 在webpack.base.conf.js里 publicPath: process.env.NODE_ENV === ‘pro

github 报错 git fatal: unable to write new index file

错误一:git fatal: unable to write new index file主要原因就是服务器磁盘空间不够导致的,增加服务器空间就OK了在百度上面搜索没得到什么有效信息,在gooogle上搜索得到很多有效信息 Finding large directories with something like the following helped clean up some log fi

在WinCE的C#编程中,需要静态调用C++的动态库,需要添加using System.Runtime.InteropServices

using System.Runtime.InteropServices;         [DllImport("Win32DLL.dll", EntryPoint = "WriteREG_SZToRegTCHAR")]         private static extern bool WriteREG_SZToRegTCHAR(int iFlag, string regKeyP

【Orange Pi 5与Linux编程编程】-POSIX消息队列

Linux系统中的POSIX消息队列编程 文章目录 Linux系统中的POSIX消息队列编程1、POSIX 消息队列2、Linux 中的 POSIX 消息队列命名3、POSIX 消息队列调用3.1 mq_open, mq_close3.2 mq_timed_send、mq_send、mq_timed_receive、mq_receive3.3 mq_notify3.4 mq_unlink3

STM32CubeIDE提示找不到头文件(No such file or directory)的解决办法

0 前言 最近在使用STM32CubeIDE时,发现为工程添加了头文件路径,但编译的时候还是报错,提示找不到头文件: 1 解决办法 1.1 为工程添加头文件路径 右键我们的工程,然后添加头文件路径(最好是相对路径): 1.2 为源文件夹添加头文件路径 右键我们包含了头文件的源文件夹,也将头文件路径添加进去(最好是相对路径): 最后编译就可以通过了: 2 更好的解决办法 这样