Insert value from Request message to Response message using GetPayloadValueBean and PutPayloadValueBean
There is very frequent requirement for the scenario like
1. Asynchronous interface like Idoc/ File will call the synchronous interface like RFC/web service
2. Merge some of the values from Idoc/ FIle request message with response message and send this message to create another file
It was impossible to achieve above scenario without BPM earlier. Then comes Async-sync bridge using RequestResponse and ResponseOneway beans to achieve async-sync scenario.
However still it was not possible to merge the values from request message with response message without BPM as there is no provision in PI to store the values of any field within PI.
That’s not the case now:
One can use GetPayloadValueBean and PutPayloadValueBean to achieve this.
I will not focus on async-sync bridge using RequestResponse and ResponseOneway beans as this is already well described on scn.
To continue with above scenario, we will take an example where
1. Asynchronous Request message sends SAP username and Reference username
2. Fetch SAP Id using SAP username using synchronous RFC call
3. Merge SAP Id and Reference Username and send it in response file
We can achieve this as follows:
1. Create File to RFC synchronous scenario with
Request message having 2 fields SAP username, Reference Username
Response message having 2 fields SAP Id and Reference Username
2. Configure async-sync bridge in sender file adapter using RequestResponse and ResponseOneway beans
3. In RFC adapter, configure GetPayloadValueBean, RemovePayloadValueBean and PutPayloadValueBean as follows:
We need value of Reference username to be merged with SAP Id. However we don’t pass this field to RFC. Then how can we store it?
For this purpose, I added one field in RFC structure in PI.
a. export xsd of RFC request structure
b. Edit xsd and add field WEBREFERENCEUSER
c. Import xsd in external definition and use it as the target message in request message mapping
The Operation mapping will have same RFC interface imported from SAP. We will use external definition only in message mapping.
Now, we use GetPayloadValueBean and store the value of WEBREFERENCEUSER in module context. It is like a variable which will hold the value of field (same as container variable in BPM). In above example, it is defined as test.
Define parameter as get:/ns1:BAPI_USER_GET_DETAIL/WEBREFERENCEUSER and value of parameter as test.
The parameter xmlns is used to define the namespace ns1. The multiple namespaces can be defined separated by space.
We can define multiple parameters to store multiple values.
So we have successfully stored the value for request message.
However we don’t want to pass WEBREFERENCEUSER to RFC call as there is no such field in RFC structure. So we remove the element before calling RFC using RemovePayloadValueBean.
parameter name : remove:/ns1:BAPI_USER_GET_DETAIL/WEBREFERENCEUSER
Same module key will be used as that of GetPayloadValueBean.
Then we call the RFC so we need to put GetPayloadValueBean and RemovePayloadValueBean before adapter’s module call.
Next, we need to retrieve the value stored earlier. So now we add PutPayloadValueBean after adapter’s module:
parameter name – put:/ns1:BAPI_USER_GET_DETAIL.Response/ADDRESS/ADDR_NO
parameter value – test —-> same module context where the value of request message was stored earlier
Here as well Same module key will be used as that of GetPayloadValueBean.
We can add a new field to Response structure or use existing one.
Then response mapping will map the value as required.
Below are the message log details:
The response mapping:
This is the response:
<?xml version=”1.0″ encoding=”UTF-8″?>
<ns1:mt_test_in xmlns:ns1=”http://abc.com/test”>
<id>0000067833</id>
<name>TestReferenceUser</name>
</ns1:mt_test_in>
Reference links:
http://help.sap.com/saphelp_nw73ehp1/helpdata/en/09/14324ca86f4fa8b0ccbd4e5aaa7139/content.htm
Thanks for sharing this Beena. This feature was long awaited and can have many use cases.
Cheers,
Prateek Raj Srivastava
Nice explanation and useful tip. Thanks for sharing.
Thanks to both of you.
As pointed by Prateek, there are many usecases. One can be this:
The RemovePayloadValueBean can be used to remove some nodes from ouput.
This can be used for mapping requirements like same source needs to be passed to target after removing some fields. So now this can be achieved using adapter module.
This is going be useful way to avoid BPM.
Thanks for sharing Beena 🙂
Regards,
Sami.
Nice feature. Thanks for sharing Beena. Now we can avoid custom mapping developments/BPM's as I explained in my blog:
http://scn.sap.com/community/pi-and-soa-middleware/blog/2010/03/04/usage-of-dynamic-configuration-in-synchronous-scenarios
Regards,
Praveen Gujjeti
Hi Praveen,
I have used the below blog and creted a scenario(Soap to File) in 7.31 dual stack. I have configured the module in sender soap channel. Scenario is sucessfully executing but I'm not able to find the exact functionality of the module "PutPayload value bean".
My intention is to use this module is that it has to enrich the basic xml structure. But still I'm able to see the original payload in the Soap channel.
Please guide me if there is any configuration chnages.
http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/12/21/putpayloadvaluebean--not-only-for-synchronous-communications
Thanks in advance.
Regards,
Jaya
Hi Jaya,
As per your snap shot I can see that you have used GetPayloadValueBean in module configuration, but you should be using PutPayloadValueBean.
Probably I have to correct this typo mistake in my blog. I am updating this now
Regards,
Praveen Gujjeti
Hi Praveen,
I tried in by giving the PutPayload value bean in module. But still I'm not able to resolve my issue.
Regards,
Jaya
I remember that there is some exception for SOAP sender adapter (search forum), where in if we configure some standards/custom modules it will have no effect. May be you can configure the module in receiver file channel to see it's effect.
check this link for SOAP Adapter: Module Processor (SAP Library - SAP NetWeaver Exchange Infrastructure)
"â—Ź In the sender adapter, you cannot add your own modules."
Regards,
Praveen Gujjeti
Hi Praveen Gujjeti ,
As per our project requirement we are working on Synchronous interface (RFC<-->SOAP) .Target system might return fault exception as well .In either case we need to capture one of the source field value .When I use two put values(one for normal response other for fault response) I'm getting below error.
Transmitting the message using connection RFC_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.lang.NullPointerException: while trying to invoke the method org.w3c.dom.Node.appendChild(org.w3c.dom.Node) of a null object loaded from local variable 'template_parent'
Configuration screenshot
Regards
Venkat
Hi Venkat,
I think the issue you are facing is pretty straight forward. Since you get only either a proper response or a fault response always, hence one of the put statement will obviously fail since it can't point to XPATH which doesn't exist in response.
Regards,
Praveen Gujjeti
Hi Praveen,
Thanks for your response .I understood my Issue ,I posted here to know any tweaks for my situation .
Below link contains complete background to my issue.
Regards
Venkat
Well, I was just in need of this, This one has simplified my interface now.
Thanks Beena for sharing.
Excellent Blog Beena...Keep up the good work....
Nice Explanation Beena, keep sharing..
Hi Beena,
Thanks for the very informative blog. I was trying to implement something very similar to the above, but I am getting the following error in my channel:
Message processing failed. Cause: com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of GetPayloadValueBean.
Any idea how this error can be resolved?
Thanks,
Jyotika.
Hi Jyotika,
Try specifying the module name as "localejbs/AF_Modules/GetPayloadValueBean". Not simply "GetPayloadValueBean". I got the same error.
Hi Jyotika
I am facing the same issue. Can you please tell me how did u resolve your problem.
Thanks,
Indrajit
Nice one...
--Divyesh
Hi Beena,
Iam a begginer. Iam trying to do this scenario. Its a File-JDBC Sync Scenario.
In which adapter we need to use this parameters and If possible could you please provide me a sample scenario.
Thanks
Lalitha
Thank you. This blog was very informative and helpful.
Hi Beena,
Do these modules work for response with multiple occurences (i.e. BAPI_USER_GET_DETAIL.response/ADDRESS that is 0..unbounded) ? I have a similar scenario but my response can be more than 1. When I used the modules, the PutPayloadValueBean only worked on the 1st occurence.
Any idea about this?
Thank you.
Hi mark.bernabe,
I am facing the same issue. Did you get any solution for this?
Thanks
Hi,
Can this GetPayloadValueBean and PutPayloadValueBean be used in below case.
Has any one faced any performance issue in GetPayloadValueBean and PutPayloadValueBean
TIA,
thank you this is still very helpful
br
Domenico