cancel
Showing results for 
Search instead for 
Did you mean: 

One Sender, two receivers: 1 passthrough, 1 mapping

0 Kudos

Hi there,

Scenario:

Single message routed to:

a) file - passthrough without mapping

b) receiver (R/3) - mapping

Message is an email attachment - might be XML or PDF (distinguishable by FileName attribute delivered by splitter module). XML schema is known.

Using dummy interfaces, I was able to resolve passing data to file.

But I am left with dummy sender interface.

Is it possible to add another receiver in iFlow to achieve the following ?

- if FileName is *XML

- assume message is not DUMMY but based on XML schema

- perform mapping

- deliver to r/3

I believe I could do it in two steps: create another scenario in which previously stored file would be processed further, but I'd like to stay with 1 scenario if possible.

Thanks,

Bart

Accepted Solutions (1)

Accepted Solutions (1)

former_member190293
Active Contributor
0 Kudos

Hi Bartosz!

I would create outbound interface with XML message type. Since you choose receiver according to FileName, it doesn't matter if non-XML payload comes to Receiver determination. Thus, in first case you just set receiver interface (even dummy) and receiver communication channel for that interface and in second - you will be able to select appropriate Operation mapping for your source interface/XML message type.

Regards, Evgeniy.

0 Kudos

I am not following.

Are You saying, that message validation (outbound message) is done at receiver determination step ?

This way I can create service interface with XML message type, feed it with XML and PDF data, and depending on receiver I could pass both as dummy (and save to files) and additionaly one as XML via SOAP together with mapping ?

former_member190293
Active Contributor
0 Kudos

What do you mean saying "message validation"? If you're talking about validation against XSD Scheme in adapter - I guess you don't use it because in this case you wouldn't be able to send both xml and non-xml messages.

Messaging system itself doesn't perform any validations. It evaluates condition expression, if any, at Receiver determination step and passes the payload "as is" to Operation mapping. If you use message mapping, input payload is parsed according to source message type structure. If you use java or XSLT, you apply the transformation logic yourself.

Regards, Evgeniy.

0 Kudos

Right now, what have is:

1. SOAP -> Dummy outbound service interface -> Dummy inbound service interface -> File

What I tried:

1. All payload: SOAP -> Dummy outbound interface -> Dummy inbound service interface -> File

2. XML payload: SOAP -> Dummy outbound interface -> Specific inbound service interface (with mapping)-> File (*)

(*) - here I couldn't create mapping, because outbound interface is dummy and there is no way to do mapping.

Now, let's assume the following:

1. All payload: SOAP -> Specific outbound interface based on XSD (**) -> Dummy inbound service interface -> File

2. XML payload: SOAP -> Specific outbound interface based on XSD -> mapping -> Specific inbound interface -> R/3

(**) - by validation I meant checking incoming message against XSD.

Will the incoming payload be validated against XSD in step 1 ?

If I understand You correctly, it will not be validated unless operation mapping is involved and mapping is provided only in step 2 ?

former_member190293
Active Contributor
0 Kudos

Hi Bartosz!

What exactly is the FileName attribute in your case? Is it Dynamic Configuration attribute?

Regards, Evgeniy.

0 Kudos

It's a Context Object - works fine with File adapter.

Tried to use outbound service interface based on XSD schema, and it died on PDF payload:

Transmitting the message to endpoint using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.aii.adapter.xi.routing.RoutingException: Unable to parse XML message payload to extract operation for receiver determinationorg.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

Not sure, why it needs payload to use context object in determination.

former_member190293
Active Contributor
0 Kudos

Ok, in this case you could use Extended Receiver determination.

Regards, Evgeniy.

0 Kudos

Will have to read the docs, never done that before.

Will report progress.

Thanks, Bart

former_member190293
Active Contributor
0 Kudos

Just a very simple java mapping to read DC attribute "FileName" and set Receiver according to that.

former_member190293
Active Contributor
0 Kudos

Something like this:

public class ED_GetReceiver extends AbstractTransformation {

@Override
public void transform(TransformationInput in, TransformationOutput out)throws StreamTransformationException {
try {
DynamicConfiguration dc = in.getDynamicConfiguration();
DynamicConfigurationKey fileKey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
String srcFileName = dc.get(fileKey).trim();

String outMsg = "<ns1:Receivers xmlns:ns1=\"http://sap.com/xi/XI/System\"><Receiver><Service>" + 
(srcFileName.endsWith(".pdf") ? "BS_FOR_PDF" : "BS_FOR_XML") + "</Service></Receiver></ns1:Receivers>";

out.getOutputPayload().getOutputStream().write(outMsg.getBytes("UTF-8"));
}
catch (Exception e) {
throw new StreamTransformationException(e.getMessage());
}
}
}

Regards, Evgeniy.

0 Kudos

"Will report progress"... right.

Well, better late than never.

Thanks for suggestions and java code.

Java receiver determination worked in a separate test flow, just to check if it generally works.

Had other issues which stopped me from a fully working solution - used external component for extracting attachments and creating separate messages from them. In this flow it just didn't work. Started getting pending messages, which were not delivered at all. Eventually gave up, went with SOAP -> File. File -> R/3

Answers (5)

Answers (5)

0 Kudos

I wasn't able to pick any interface up because I've configured technical system as Standalone and couldn't assign Software Component to it.

Changed that, now I can see values.

But... another issue...

My outbound interface is dummy, as I do not know the structure of XML data.

To add another receiver for XML with known structure I need to create operation mapping.

The point is I am not able to create OM for a dummy service interface and thus add mapping in receiver determination.

former_member190293
Active Contributor
0 Kudos

Hi Bartosz!

If you've used Business Component as receiver, did you assign any inbound interfaces for it?

Regards, Evgeniy.

0 Kudos

Added another communication component in the ICO-Receiver tab.

Set condition: "FileName CP *.xml"

Moved to ICO-Receiver interfaces tab, selected newly added receiver, but I can't pick any inbound service interfaces.

Inbound service is currently used in another flow and it does work in that setup.

Why can't I pick up any inbound interfaces from newly added receiver ?

former_member190293
Active Contributor
0 Kudos

Hi Bartozs!

In general I 'm agree with Gagandeep, but you can face some issues.

Your receiver determination can raise exception in case of non-XML payload. In this case you should apply SAP Note 1354905.

In receiver determinaton you use condition for receiver in case of XML payload and default receiver for cases when condition is not true (for non-XML payloads). You set the rule to use default receiver when no condition matches your source data.

Regards, Evgeniy.

gagandeep_batra
Active Contributor
0 Kudos

Hi,

Yes you can achieve this using put the condition at Interface or receiver determination step in ICO

Regards

GAgan