Recently I worked on a scenario with two Idocs that are used as asynchronous request and response messages for ERP and a synchronous webservice.

For this scenario, I used SOAP adapter with async-sync brigde with help of RequestResponseBean and ResponseOnewayBean.

I wanted to populate fields in the response Idoc from the request Idoc. Here I had the challenge that the required values were only available in the Idocs, but not part of the request and response message of the web service, so I could not use the option with GetPayloadValueBean and PutPayloadValueBean, as it is described in this blog of Beena Thekdi:

Insert value from Request message to Response message using GetPayloadValueBean and PutPayloadValueBean

I wanted to use the dynamical header fields of the PI message to store the vales. Unfortunately, the SOAP adapter removes dynamic header field from request message, so the response message would not be able to access them. So I needed to find a way to keep the values.

I found the solution with the DynamicConfigurationBean that allows copying values form dynamical header fields to the module context and back. All adapter modules within the same module chain of the communication channel can access the parameter values in the module context.

I have already described this feature in this blog:

Unknown use case of DynamicConfigurationBean: Store file name to JMS header without mapping

Now the module chain of my SOAP adapter receiver channel looks like this:

Module Type Module Key
AF_Modules/DynamicConfigurationBean Local Enterprise Bean DC1
AF_Modules/RequestResponseBean Local Enterprise Bean RRB
sap.com/com.sap.aii.af.soapadapter/XISOAPAdapterBean Local Enterprise Bean SOAP
AF_Modules/DynamicConfigurationBean Local Enterprise Bean DC2
AF_Modules/ResponseOnewayBean Local Enterprise Bean ROB

I will not go into the configuration for RequestResponseBean and ResponseOnewayBean, as this is described in other blogs.

The module parameters for the DynamicConfigurationBean are following. In my scenario, I used the dynamic value “Value” with namespace “strDocNum”.

Those values might not be the best choices, however it works anyway.

Module Key Parameter Name Parameter Value
DC1 key.1 write strDocNum Value
DC1 value.1 module.strDocNum
DC2 key.1 read strDocNum Value
DC2 value.1 module.strDocNum

For the graphical mapping tool, it is necessary to create user-defined functions to store the values in the dynamical header fields and read them from there. Here are the functions that are used in my scenario:

PutDocNum is used in the request mapping

PutDocNum

public String PutDocNum(String docnum, String username, Container container) throws StreamTransformationException{

DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey keySource1 = DynamicConfigurationKey.create(“strDocNum“,”Value“);

if (conf != null) {

  conf.put(keySource1, docnum);

}

return username;

GetDocNum is used in the response mapping

Note: as the value DocNum was not part of the target message, the UDF was tied to another target field called username.

GetDocNum

public String GetDocNum(Container container) throws StreamTransformationException{

DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

if (conf != null) {

    DynamicConfigurationKey keySource1 = DynamicConfigurationKey.create(“strDocNum“,”Value“);

    return conf.get(keySource1);

} else

    return “”;

Here is the link to the online help, the parameter value module.nn is still not mentioned:

Adding DynamicConfigurationBean in the Module Processor

To report this post you need to login first.

15 Comments

You must be Logged on to comment or reply to a post.

  1. Fabian Engel

    Hello Stefan,

    Thanks for sharing!

    Is your example config coincidental of an E-Invoice Mexico Project? 🙂

    Dynamic Configuration values names are same…

    Best regards,

    Fabian Engel

    (0) 
    1. Stefan Grube Post author

      Hi Fabian, You are right, I took this example while I did an implementation for E-Invoicing Mexico. The original solution comes with a ccBPM. I could not use it as my customer has PI 7.31 Java only. After my experience I recommend not use ccBPM for this scenario at all, as the async-sync bridge with adapter module is the superior solution. Regards Stefan

      (0) 
  2. Navneet Vewahare

    Hi Stefan,

    Thanks for the blog, I am able to use this feature in my requirement but I need to save multiple values. when I am executing the interface only last value saved is coming in all the fields. please take a look at the sequence and parameters:

    Capture11.PNG

    Capture122.PNG

    could you please help me to correct this?

    Thanks

    Navneet

    (0) 
    1. Stefan Grube Post author

      You only need the DynamicConfigurationBean twice. By the way: I think you do not need those beans for the RFC adapter, because the RFC adapter does not delete the dynamic header fields. Could you check this and confirm?

      (0) 
  3. Adam Sosnowski

    Just for information:
    This trick does not work with all Adapter types. At least it does not work with HTTP_AAE (as of PO 7.50 SP03). The reason is, that the Supplemental Data (module context) gets deleted by Adapter Module sap.com/com.sap.aii.adapter.http/HttpAdapterBean.


    Since this is the place where the DynamicConfigurationBean stores the data with its “write” action, all data stored by the bean vanishes.

    Regards,
    Adam

    (0) 
    1. Stefan Grube Post author

      Hi Adam, good to know. I tested this with PI 7.11 and PI 7.31 SOAP adapter only. So I cannot assure if that works for any other adapter or for any other PI release. Do you know, if it works with the SOAP adapter in PO 7.5? Regards Stefan

      (0) 
      1. Adam Sosnowski

        Hi Stefan,

        yes, I had to switch from HTTP_AAE to SOAP receiver channel to make it work.

        Regards,

        Adam

        PS: There may be a way of preserving the context data of the request message for the response message without using DynamicConfigurationBean and it should work for any standard adapter module. It involves writing a tiny wrapper adapter module following the the approach presented here: Adapter Module: ExceptionCatcherBean
        I didn’t try it, since it was only my fallback solution, but it should work.

        (0) 
  4. Aditya Vempati

    Hi Stefan,

    Many thanks for this blog.

    Could you please let me know if these UDFs are used in request or response mappings?

    And to just let you know – in my scenario, I have to send the request IDoc number in the response IDoc. I can get either success or fault response from target system. I have three mappings in total – Request IDoc to SOAP mapping, SOAP response to response IDoc mapping and SOAP fault to response IDoc mapping.

    Regards,

    Aditya

    (0) 
  5. Andrey Petin

    Hello Stefan.

    I am facing the problem being described.

    It would be good to use your approach but I have to save random number of values. I mean, there is 1..unbounded node in source message, and I have to save values of “ID” element from each node.

    OK, it is possible to write them into DC with UDF: keys will be Id1, Id2, .. IdN, namespace will be unique for these keys.

    But is it possible to configure DynamicConfigurationBean so that all keys from certain namespace would be saved in module data and be available in response message?

    (0) 

Leave a Reply