cancel
Showing results for 
Search instead for 
Did you mean: 

ConversatioId in JAVA-mapping

Former Member
0 Kudos

Hello XI experts,

Can you please show me the way to create the ConversationId in message header in JAVA-mapping

the folowing code:

param.put(StreamTransformationConstants.CONVERSATION_ID,"111222");

is not working for me.

Thanks!

Accepted Solutions (0)

Answers (3)

Answers (3)

henrique_pinto
Active Contributor
0 Kudos

Artsiom,

what's the exact error you're getting in your java mapping using that code?

Also, did you implemented the setParameter() method properly?

Your mapping class should be something like this:


public class MyMapping implements StreamTransformation {

	private Map param = null;
	private AbstractTrace trace = null;

	public void setParameter(Map param) {
		this.param = param;
	}
	public void execute(InputStream in, OutputStream out)
		throws StreamTransformationException {
		<your code here...>
	}
}

Regards,

Henrique.

Former Member
0 Kudos

Hello Henrique,

The code JAVA_mapping is:

package mapping;

import java.io.*;

import java.util.*;

import com.sap.aii.mapping.api.*;

public class MM_EDW_ChangeDirectoryForCorrelation

implements StreamTransformation {

private static final DynamicConfigurationKey KEY_FILENAME =

DynamicConfigurationKey.create(

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

"FileName");

private Map param;

public void setParameter(Map param) {

this.param = param;

}

public void execute(InputStream in, OutputStream out)

throws StreamTransformationException {

// copy payload

copyPayload(in, out);

// access dynamic configuration

DynamicConfiguration conf =

(DynamicConfiguration) param.get(

StreamTransformationConstants.DYNAMIC_CONFIGURATION);

// read value

String fn = conf.get(KEY_FILENAME);

if (fn == null || fn.indexOf('.') == -1) {

throw new StreamTransformationException("Wrong FileName!");

}

param.put(

StreamTransformationConstants.CONVERSATION_ID,

fn.substring(0, fn.indexOf('.')));

}

private void copyPayload(InputStream in, OutputStream out)

throws StreamTransformationException {

int c;

try {

c = in.read();

while (c != -1) {

out.write(c);

c = in.read();

}

} catch (IOException e) {

throw new StreamTransformationException(e.getMessage());

}

}

}

No errors for this code, but after this mapping, no ConversationID field is created in MessageHeader. Do you know what can be the reason? Maybe it is possible only to change the value not to create?

Former Member
0 Kudos

whats your scenario - File? JDBC?

If you are processing EOIO and set a queue name in the file adapter, this can be used as the conversation ID.

sincerely,

--NM

Former Member
0 Kudos

Hello Naomi,

The scenario is file-to-file. The core problem is that I need to transfer the pairs of files(data files(.dat) and trigger files(.trg)) in a specific order: the data file should be transferred to target FTP server first. I was trying to use a directory for correlation (I was changing the directory variable in JAVA-mapping to filename without extension), but it was not working for some reasons (there are a couple of topics on this forum with the same problem of accesing the header values in BPM) and now I am trying to use a ConversationId for correlation, but I don't know how to change it.

Former Member
0 Kudos

Describe the steps in your BPM.

How do you create these files? why cant you send them with 2 sequential send steps in BPM and for these create file names and/or directories in the Java Map?

sincerely,

--NM

Former Member
0 Kudos

Hello Naomi,

The steps in BPM:

1. Fork step with 2 branches

1.1 recieve step for trigger file

1.2 recieve step for data file

2. send step for data file with transport aknolegement

3. send step for trigger file

Steps 1.1 and 1.2 are correlated on filename (not working for some reasons), so now I am trying to correlate on ConversationID, and trying to set it in JAVA-mapping, but it is not working.

Former Member
0 Kudos

I need this to set the ConversationId to the filename value to correlate later on ConversationId(FileName) in BPM. (the correlation on Filename or Directory is for some reasons not working).

Maybe there is a way to set the ConversationId in CommunicationChannel or somethere else besides JAVA-mapping?