Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
stefan_grube
Active Contributor
19,495

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 PutPayloadValueB...

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:

stefan.grube/blog/2009/06/19/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:

ModuleTypeModule Key
AF_Modules/DynamicConfigurationBeanLocal Enterprise BeanDC1
AF_Modules/RequestResponseBeanLocal Enterprise BeanRRB
sap.com/com.sap.aii.af.soapadapter/XISOAPAdapterBeanLocal Enterprise BeanSOAP
AF_Modules/DynamicConfigurationBeanLocal Enterprise BeanDC2
AF_Modules/ResponseOnewayBeanLocal Enterprise BeanROB

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 KeyParameter NameParameter Value
DC1key.1write strDocNum Value
DC1value.1module.strDocNum
DC2key.1read strDocNum Value
DC2value.1module.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

30 Comments
rhviana
Active Contributor
0 Kudos

Hey Stefan,

Nice blog thanks for contribution !

See ya

Former Member
0 Kudos

Hello Stefan,

Thanks for sharing the details.

I had created a document on a similar subject few days back - Dynamic Configuration Usages in SAP PI. You may find it interesting.

Regards.

Former Member
0 Kudos

Hello Stefan,

Thanks for sharing!

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

Dynamic Configuration values names are same...

Best regards,

Fabian Engel

stefan_grube
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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:

could you please help me to correct this?

Thanks

Navneet

stefan_grube
Active Contributor
0 Kudos

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?

Former Member
0 Kudos

Thank you so much Stefan, I removed all beans from RFC and it worked perfectly.. :smile:

Thanks

Navneet.

adam_sosnowski
Explorer
0 Kudos

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

stefan_grube
Active Contributor
0 Kudos

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

adam_sosnowski
Explorer
0 Kudos

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.

adityavempati
Participant
0 Kudos

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

adityavempati
Participant
0 Kudos

I got this. Thank you once again.

Regards,

Aditya

adityavempati
Participant
0 Kudos

Hi Stefan,

I have a similar scenario and facing issue while creating response IDoc. Could you please check IDoc AAE receiver channel in ResponseOnewayBean

Regards,

Aditya

former_member226216
Participant
0 Kudos

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 Kudos
Thanks for this Stefan! I'll try this out as suggested by Praveen 🙂
Former Member
0 Kudos
Excellent blog, Stefan.
Former Member
0 Kudos
Thank you Stefan !! It works in PO 7.5 as well.
Former Member
0 Kudos
Thanks for such informative blog Stefan!

I tried implementing this in REST adapter, the value is getting stored but is not getting fetched. Is it because of the REST adapter?



Thanks,

Pankaj
stefan_grube
Active Contributor
0 Kudos
The parameters should be:

key.1 & value.1

key.2 & value.2
Former Member
0 Kudos
Thanks Stefan! Able to post the stored value now.

 

Regards,

Pankaj
Former Member
0 Kudos
Hello Stefan,

Thank you for helpful blog!

One question

Are you sure that namespace should be used there?













DC1 key.1 write strDocNum Value
DC1 value.1 module.strDocNum

I tried with multiple keys and it works for REST adapter with the following configuration only













DC1 key.1 write strDocNum Value1
DC1 value.1 module.Value1














DC1 key.2 write strDocNum Value2
DC1 value.2 module.Value2

Thank you!
stefan_grube
Active Contributor
Hi Olga,

 

Thank you for sharing your experience with REST adapter.

I have not worked with REST adapter so far and this information is very useful for me.

 

Regards

Stefan
lm_allen
Explorer
0 Kudos

The module parameter is mentioned in SAP note 974481, example 6 & 7

Patrick_Schaaf
Explorer
0 Kudos

Hi Stefan, Hi all,

I have an Sync Interface called from ERP Proxy -> REST Receiver with Request / Response Mapping. I need to pass a value from the request to the response. I have tried it with your hints, but it fails. Apparently the Module is able to write, but not to read. Any help is welcome.

I have also tried to put the Rest Adapter Bean into the middle with the same result. Also I have used RRB with ROB Bean, but as the Interface is already Sync i guess it is not needed.

stefan.grube 

Any Idea?

stefan_grube
Active Contributor
The parameters should be:

key.1 & value.1

key.2 & value.2

 

The REST module should be in the middle
Patrick_Schaaf
Explorer
0 Kudos
Thanks, that worked. I thought "value" is dynamic and should be replaced with the value of the dynamic object. Also i thought that key.2 & value.2 should be also "1" as the module should read the parameter written within DC1.

 
stefan_grube
Active Contributor
0 Kudos
My fault, you can use key.1 and value.1 for DC1 and DC2 both.

But you can use different numbers as well.
olga_gerlich
Explorer
0 Kudos

Hi Stefan!

I have to copy the value which can have dynamic amount of itself. DynamicConfigurationBean saves only last value. How can I save and read all values?

My input:

<Structure>
<Position>
<code>1</code>
</Position>
<Position>
<code>2</code>
</Position>
</Structure>​

 

Only "2" is saved

My UDFs are identical to yours.

Module in SFSF interface

stefan_grube
Active Contributor
0 Kudos
It is not possible to save multiple entries in the dynamic configuration.
I recommend concatenating your values into a single string with a delimiter that is not part of any string like this: 1|2
0 Kudos
Hi Stefan,

 

my request mapping is passthrough, can you let me know how can i acheive this?

 

Regards,

Keerthana
Labels in this area