cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to set referencing message from UDF?

Former Member
0 Kudos

Hi to all, I have a simple question but I didn't find an answer in other sdn thread.

Is it possible to set the ReferenceMessageID in a UDF? if not, How can I do it?

Your help would be appreciated

Regards

Emiliano

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can get the RefMsgId value from the DynamicConfiguration object, but I'm not sure you can set it (even if it is possible, you must check it won't create any inconsistencies in XI messages store or related) ...

Why do you need to set this explicitly, cuz XI is in charge of this field, at least in usual situation ?

Chris

S0003991129
Explorer
0 Kudos

ok I'll try to explain the scenario.

I have two async messages. One from a System A to System B, and the second

goes from System B to System A.

The both scenarios are async. I would if it is possible to reference one message to

the other in order to easly see them on the runtime workb or other monitor.

Maybe it is possible to set those header message parameters from custom Adapter module?

Thanks

Emiliano

Former Member
0 Kudos

Okay, I get it ... You are trying to implement some sort of correlation/link between your 2 interfaces using the RefMsgId !

Do you know how are you going to pass message id of the first interface to the second one in order to set its ref msg id ?

Chris

Former Member
0 Kudos

I can read the msg ID of the first msg(SysA-->SysB) and write it in the payload. A program running in

the system B will read the msgId from payload and will pass it to the paylod of the second msg(SysB-->SysA).

I wonder how I can write this msgId of the first message into the refmsgid parameter of the second one....

course if it possible....I am quite sure that it is possible by inbound adapter module processor(SysB --> SysA)...anyway I would not to use a custom module processor.

Thanks

Emiliano

Former Member
0 Kudos

A simple plan could be creating a table to store this msgid (that will become the ref msg id for the other intf), your first msg mapping would store its msg id in this table and then it could be read using db lookup in your mapping for the other flow. This table could have a key field for correlation (like doc nr) and a field for msgid of intf A2B

More complex and "professional" solution could be created for sure

Chris

Former Member
0 Kudos

Thanks Chris, that could be a solution to take into account.

Emiliano

Former Member
0 Kudos

You could also work with BPM, using correlation feature, it might do the trick without storing values in custom table (though the ref msg id still needs to be retrieved before coming back to the BPM) ...

In the "response" msg, can you adapt the piece of code responsible for its creation in order to pass the msg id received in the input document ? It would be things much easier

Chris

Former Member
0 Kudos

Yes, I can use the code to manage the ref msg, but I don't know how

to set that value on the parameter "RefMsgId" in the Header of the "response" message.

I can write the RefMsgId in the payload of the "response" msg, and then

using the Api of the module adapter(

Message msg = (Message)inputModuleData.getPrincipalData()

) I can set that parameter(

Message.setRefToMessageId()

).

Is it possible to do it using a UDF?

Emiliano

Former Member
0 Kudos

Maybe, but not sure, you can set it thru the DynamicConfiguration object in your UDF, like :

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System”,

“RefToMessageId”);

conf.put(key, newRefToMessageId);

I'm not sure about RefToMessageId's original namespace

Chris

Former Member
0 Kudos

Thank you Chris, I'll try it and I'll keep you informed.

Emiliano

henrique_pinto
Active Contributor
0 Kudos

The problem is that even though you may be able to set it at mapping, mapping runtime occurs at interface determination step, which is after the receiver determination, where XI evaluates the proper receiver of the message. So, the field must be filled before receiver determination step, hence you need adapter module.

In this blog, I comment on sync/async scenarios without BPM: /people/henrique.pinto/blog/2007/08/02/syncasync-scenarios-without-bpm

The setRefToMessageId() method may even work, but I was successfull setting the CorrelationId. For this, you should use setCorrelationId() method in the adapter module. More info here: http://help.sap.com/saphelp_nw70/helpdata/EN/17/50d440e14f8431e10000000a1550b0/frameset.htm

Regards,

Henrique.

henrique_pinto
Active Contributor
0 Kudos

Also, to set non-adapter specific message atributes (xi message header, not dynamic configuration) use something like this in UDF (I'm not sure it'll work though, you'll have to try it):

> String id = null;

> ...

> (retrieve msg id value from payload)

> ...

> container.getTransformationParameters().put(StreamTransformationConstants.REF_TO_MESSAGE_ID, id);

Regards,

Henrique.

Former Member
0 Kudos

Thanks for the replay.

I just tried the last code but without any result. It wasn't possible to set the refidmsg attribute....

I think the unique solution is to use a module processor, anyway let me know if you have any other workaroud.

Thanks all

Emiliano