Skip to Content
Author's profile photo Former Member

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:

Module.png

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:

/wp-content/uploads/2013/03/auditlog_196929.png

The response mapping:

RespMapping.png

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

http://help.sap.com/saphelp_nw73ehp1/helpdata/en/d7/d0ee447cfe43d6b44fbe7845781a14/content.htm?frameset=/en/09/14324ca86f4fa8b0ccbd4e5aaa7139/frameset.htm

http://help.sap.com/saphelp_nw73ehp1/helpdata/en/03/f9286f7b284928b1c41025d4ba1cf4/content.htm?frameset=/en/09/14324ca86f4fa8b0ccbd4e5aaa7139/frameset.htm

Assigned Tags

      25 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Prateek Raj Srivastava
      Prateek Raj Srivastava

      Thanks for sharing this Beena. This feature was long awaited and can have many use cases.

      Cheers,

      Prateek Raj Srivastava

      Author's profile photo Baskar Gopalakrishnan
      Baskar Gopalakrishnan

      Nice explanation and useful tip.  Thanks for sharing.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      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.

      Author's profile photo Samiullah Qureshi
      Samiullah Qureshi

      This is going be useful way to avoid BPM.

      Thanks for sharing Beena 🙂

      Regards,

      Sami.

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      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.

      Soap.png

      http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/12/21/putpayloadvaluebean--not-only-for-synchronous-communications

      Thanks in advance.

      Regards,

      Jaya

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      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

      doubt.JPG


      Regards

      Venkat

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      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.

      https://scn.sap.com/message/15027098#15027098

      Regards

      Venkat

      Author's profile photo Nipun Shedhani
      Nipun Shedhani

      Well, I was just in need of this, This one has simplified my interface now.

      Thanks Beena for sharing.

      Author's profile photo Former Member
      Former Member

      Excellent Blog Beena...Keep up the good work....

      Author's profile photo Sai Chand Dhanekula
      Sai Chand Dhanekula

      Nice Explanation Beena, keep sharing..

      Author's profile photo Former Member
      Former Member

      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.

      Author's profile photo Stenish Peter S
      Stenish Peter S

      Hi Jyotika,

           Try specifying the module name as "localejbs/AF_Modules/GetPayloadValueBean". Not simply "GetPayloadValueBean". I got the same error.

      Author's profile photo Former Member
      Former Member

      Hi Jyotika

      I am facing the same issue. Can you please tell me how did u resolve your problem.

      Thanks,

      Indrajit

      Author's profile photo Former Member
      Former Member

      Nice one...

      --Divyesh

      Author's profile photo Lalitha Devi Chintalapati
      Lalitha Devi Chintalapati

      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

      Author's profile photo Former Member
      Former Member

      Thank you. This blog was very informative and helpful.

      Author's profile photo Mark Bernabe
      Mark Bernabe

      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.

      Author's profile photo Deeksha Kulal
      Deeksha Kulal

      Hi mark.bernabe,

      I am facing the same issue. Did you get any solution for this?

       

      Thanks

      Author's profile photo Former Member
      Former Member

      Hi,

      Can this GetPayloadValueBean and PutPayloadValueBean be used in below case.

      1. Web service at client side is in synchronous mode.
      2. There in no unique identifier between request and response

      Has any one faced any performance issue in GetPayloadValueBean and PutPayloadValueBean

      TIA,

      Author's profile photo Srinivasan Ramanan
      Srinivasan Ramanan

      thank you this is still very helpful

       

      br

      Domenico