Skip to Content

Calling Graphical mapping via Java mapping in sap pi 7.31

Aug 23, 2017 at 05:57 AM


avatar image

Hi Experts,

I need to call a graphical mapping via Java mapping and get the graphical output in java mapping.

If it is possible, Please help me on this

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Muniyappan Marasamy Aug 23, 2017 at 08:17 AM

As Evgeniy said this is not possible to call graphical map from java map.

But you can achieve this using below blog.

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi Muni,

Thanks for sharing the blog.

I'm stuck up with the below errors. is not abstract and does not override abstract method getOutputAttachments() in class TransformationOutputImpl extends TransformationOutput {


capture.png (10.0 kB)

I tried using java map first and calling message map. it is working. you need to implement your login in method "YourExtBussLogicMethod"

i put the trace to verify this. it is working.

This is the code i am using in method "Attributes and Methods". converting inputstread to by ByteArrayOutputStream can be done in many ways. google search and use the best approach.

       InputAttachments inputAttachments;
	InputHeader inputHeader;
	InputParameters inputParameters;
	DynamicConfiguration dynamicConfiguration;
	OutputAttachments outputAttachments;
	OutputHeader outputHeader;
	OutputParameters outputParameters;

	public void transform(TransformationInput in, TransformationOutput out)
			throws StreamTransformationException {

getTrace().addInfo("Java Map start");
		try {
			dynamicConfiguration = in.getDynamicConfiguration();
			inputAttachments = in.getInputAttachments();
			inputHeader = in.getInputHeader();
			inputParameters = in.getInputParameters();
			outputAttachments = out.getOutputAttachments();
			outputHeader = out.getOutputHeader();
			outputParameters = out.getOutputParameters();
			InputStream is = (InputStream) in.getInputPayload()
			 * **************************** GuideLines for Java Mapping
			 * *********
			 * *********************************************************** You
			 * can have java mapping code INLINE if it is few lines. And if it
			 * is a big and complex code, then I recommend to isolate java
			 * mapping logic and develop it separately as a NORMAL java program.
			 * Import it as 'imported archive' and refer it in graphical mapping
			 * And then call the externally developed public method here
			 * Recommendation for external method signature: public
			 * ByteArrayOutputStream YourExtBussLogicMethod(InputStream is, ...)
			 * *
			 * *****************************************************************
			 * ****************************************************************
			 * BEGIN ************************************************* PATTERN 1
			 * (JM - GM) *************************************************
			// Java Mapping: YourExtBussLogicMethod(is) code is nothing but your
			// java mapping logic. You can also have INLINE code here
			ByteArrayOutputStream baos = YourExtBussLogicMethod(is);
			InputStream newInputStream = new ByteArrayInputStream(baos
			InputPayloadImpl payloadInObj = new InputPayloadImpl(newInputStream);
			TransformationInputImpl transformInObj = new TransformationInputImpl(
			// Graphical mapping called here
			super.transform(transformInObj, out);
		} catch (Exception e) {
			throw new StreamTransformationException(e.getMessage());

	class InputPayloadImpl extends InputPayload {
		InputStream in;

		public InputPayloadImpl(InputStream in) { = in;

		public InputStream getInputStream() {
			return in;

	class TransformationInputImpl extends TransformationInput {
		InputPayload payload;

		public DynamicConfiguration getDynamicConfiguration() {
			return dynamicConfiguration;

		public TransformationInputImpl(InputPayload payload) {
			this.payload = payload;

		public InputAttachments getInputAttachments() {
			return inputAttachments;

		public InputHeader getInputHeader() {
			return inputHeader;

		public InputParameters getInputParameters() {
			return inputParameters;

		public InputPayload getInputPayload() {
			return payload;

	class OutPayloadImpl extends OutputPayload {
		OutputStream ou;

		public OutPayloadImpl(OutputStream ou) {
			this.ou = ou;

		public OutputStream getOutputStream() {
			return ou;

	class TransformationOutputImpl extends TransformationOutput {
		OutputPayload payload;

		public TransformationOutputImpl(OutputPayload payload) {
			this.payload = payload;

		public void copyInputAttachments() {

		public OutputAttachments getOutputAttachments() {
			return outputAttachments;

		public OutputHeader getOutputHeader() {
			return outputHeader;

		public OutputParameters getOutputParameters() {
			return outputParameters;

		public OutputPayload getOutputPayload() {
			return payload;
public ByteArrayOutputStream YourExtBussLogicMethod(InputStream is)
			throws Exception {

	String in = null;
		BufferedReader br = new BufferedReader(new InputStreamReader(is));
		StringBuilder sbr = new StringBuilder();
		while(( in =br.readLine())!=null){
		String outputmessage = sbr.toString();
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		DataOutputStream out = new DataOutputStream(byteArrayOutputStream);
		return byteArrayOutputStream;


i used below udf in one of the message mapping field.

container.getTrace().addInfo("This is from Message map UDF"); return var1;

my mapping output


mapping.jpg (44.0 kB)

Thanks Muni.

Solved my problem.

Evgeniy Kolmakov Aug 23, 2017 at 06:59 AM

Hi Vinoth!

I guess it's not possible. And why do you have such a strange requirement?

Regards, Evgeniy.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Evgeniy,

I have a graphical mapping which is not mapped for handle multiple details record. So Now I have a requirement to process multiple records.

If I execute with multiple records, I'm getting context issue.

So, I'm planning to loop a graphical mapping with single record via java mapping.


Vinoth S

Raghuraman S Aug 23, 2017 at 07:47 AM

Hello Vinoth,

Why your calling Graphical in java mapping.

Instead sequence it in operation mapping like first java mapping then graphical mapping

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Raghu,

I designed multi mapping in OM. that is 0..unbound scenario and my graphical mapping doesn't build for handle unbound scenario. So I want to execute graphical mapping for each message separately and club it in java mapping and then send to target.


Hello vinoth,

Requirment is not clear.

Your trying to merge messages using Java mapping?