SAP Exchange Infrastructure Defined Functions Accessing Adapter-Specific Attributes

Accessing Adapter-Specific Attributes

Use

Sender adapters can write adapter-specific attributes to the message header; these can then be evaluated at configuration time (see: Adapter-Specific Message Attributes in the Message Header ). Java mapping programs can also change the attributes after the message has arrived (see also: Java Mapping of Adapter-Specific Attributes ).

To change the adapter-specific attributes of the message header by using message mappings, you access the required classes of the mapping API by using a mapping runtime constant.

Integration

To access the classes DynamicConfiguration and DynamicConfigurationKey by using the mapping runtime constant DYNAMIC_CONFIGURATION, use the method getTransformationParameters() of the container object .

Example

The following program code for a user-defined function changes the value of the file adapter parameter FileName .

package com.hello;
import com.sap.aii.mapping.api.*;
import com.sap.aii.mappingtool.tf7.rt.*;
import java.util.*;

public class HelloWorld {
	public void init(GlobalContainer container) throws StreamTransformationException {
	}
	
	public String putASMA(String namespace, String attributename, String attributevalue, Container container)
			throws StreamTransformationException {
		Map map = container.getTransformationParameters();
		DynamicConfiguration conf = (DynamicConfiguration) map.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
		DynamicConfigurationKey key = DynamicConfigurationKey.create(namespace, attributename);
		conf.put(key, attributevalue);
		return "";
	}
	
	public String getASMA(String namespace, String attribute, Container container)
			throws StreamTransformationException {
		Map map = container.getTransformationParameters();
		DynamicConfiguration conf = (DynamicConfiguration) map.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
		DynamicConfigurationKey key = DynamicConfigurationKey.create(namespace, attribute);
		String value = conf.get(key);
		return value;
	}
	
	public String Example(String namespace, String attribute, Container container)
			throws StreamTransformationException {
		DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters()
				.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
		DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
		String valueOld = conf.get(key);
		if (valueOld != null) {
			String valueNew = valueOld.replaceAll("input", "output");
			conf.put(key, valueNew);
		}
		return "";
	}
	public void cleanUp(GlobalContainer container) throws StreamTransformationException {
	}
}

访问特定于适配器的属性
采用
发送方适配器可以将特定于适配器的属性写入消息头; 然后可以在配置时评估这些(请参阅:消息头中的适配器特定消息属性)。 Java 映射程序还可以在消息到达后更改属性(另请参阅:适配器特定属性的 Java 映射)。

要使用消息映射更改消息头的特定于适配器的属性,您可以使用映射运行时常量访问映射 API 的所需类。

一体化
要使用映射运行时常量 DYNAMIC_CONFIGURATION 访问类 DynamicConfiguration 和 DynamicConfigurationKey,请使用容器对象的 getTransformationParameters() 方法。

例子
以下用户定义函数的程序代码更改了文件适配器参数 FileName 的值。

SAP Exchange Infrastructure Defined Functions Accessing Adapter-Specific Attributesicon-default.png?t=M276https://help.sap.com/docs/SAP_NETWEAVER_701/6f32f7136c4b101499aac9e4a5643c40/4303612cdecc6e76e10000000a422035.html?locale=en-US

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SAP爱好者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值