on 2023 Feb 16 1:27 PM
Request clarification before answering.
Hi Pavel,
the settings in the REST sender adapter writes the id into the message header id2 with namespace http://sap.com/xi/XI/System/REST, in the file variable substitution you can either read from pre-defined message headers or the message payload as described here https://help.sap.com/docs/SAP_NETWEAVER_750/5cf7d2de571a45cc81f91261668b7361/446a316af5a23672e100000...
With the prefix message: you can only refer to the message header that are listed in the docu, to read from payload you need to use the prefix payload:
Not sure if Priyanka's approach works, you may try it out. From what I see you have two options:
1. Option: map the value of the id2 message header to the payload, and use variable substitution from the payload
2. Option: map the value of the id2 message header concatenated with the file suffix to the message header FileName with namespace http://sap.com/xi/XI/System/File and in the receiver channel use the adapter-specific message header setting instead of the variable substitution, i.e., select the Use Adapter-Specific Message Attributes flag and select the File Name flag, in this case regardless of what you have specified in the file name schema it will be overwritten with the specified file name, if you have chosen Add timestamp then it will add a timestamp to your file, if the value of id2 is unique anyway you can choose create
For both options you need an UDF to read the id2 header in a message mapping, for the second option you also need an UDF to write message headers
here are functions that you can use, for the getASMA function you need to pass the REST namespace to the first argument, and the constant id2 to the second attribute, the returned value needs to be then passed to the first argument writeASMA if you go for the second option, namespace would be then the file NS and attribute would be FileName, hope this helps
Alex
@LibraryMethod(title="getASMA", description="get adapter specific message attribute", category="UDFPool", type=ExecutionType.SINGLE_VALUE)
public String getASMA (
@Argument(title="") String namespace,
@Argument(title="") String attribute,
Container container) throws StreamTransformationException{
Map<String, Object> all = container.getInputHeader().getAll();
DynamicConfiguration dynConf = (DynamicConfiguration)all.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( namespace, attribute);
String value = dynConf.get(key);
return value;
}
@LibraryMethod(title="writeASMA", description="write adapter specific message attribute", category="UDFPool", type=ExecutionType.SINGLE_VALUE)
public String writeASMA (
@Argument(title="") String value,
@Argument(title="") String namespace,
@Argument(title="") String attribute,
Container container) throws StreamTransformationException{
Map<String, Object> all = container.getInputHeader().getAll();
DynamicConfiguration dynConf = (DynamicConfiguration)all.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( namespace, attribute);
dynConf.put(key,value);
return value;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
34 | |
21 | |
8 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.