With 7.31 EHP1 SAP has introduced new modules GetPayloadValueBean, PutPayloadValueBean and RemovePayloadValueBean. The modules usage is recently described by Beena Thekdi Insert value from Request message to Response message using GetPayloadValueBean and PutPayloadValueBean

The focus of this blog is to explain some new use cases of PutPayloadValueBean. As per SAP help: Adding PutPayloadValueBean in the Module Processor – Adding Modules to the Module Processor – SAP Library


Use PutPayloadValueBean to enrich the message with values from a module context. You can use this module in combination with GetPayloadValueBean to enrich a response message with information from the request. Normally you use GetPayloadValueBean to extract values from a message, then execute an adapter module (example, synchronous SOAP call) and finally use PutPayloadValueBean to enrich the response with stored values

Although, in SAP help it is described that PutPayloadValueBean can be used in combination with GetPayloadValueBean in case of synchronous communication interfaces, we can still use this module in asynchronous communications with below explained use cases

Case 1: Pass some static value “PutThisValue” to xml field /ns0:root/field. The trick is to use double quotes “” to treat it as a string rather than as a variable from module context

Module Type Module Key
AF_Modules/PutPayloadValueBean Local Enterprise Bean Payload
Module Key Parameter Name Parameter Value
Payload put:/ns0:root/field “PutThisValue”
Payload xmlns xmlns:ns0 = “http://yourxmlnamespaces

Case 2: Pass some static value but with xml fields “<Name>Praveen Gujjeti</Name><Company>IBM</Company>” to xml field /ns0:root/field. This way we can enrich basic xml structure at module level using this module

Module Type Module Key
AF_Modules/PutPayloadValueBean Local Enterprise Bean Payload
Module Key Parameter Name Parameter Value
Payload put:/ns0:root/field “<Name>Praveen Gujjeti</Name><Company>IBM</Company>”
Payload xmlns xmlns:ns0 = “http://yourxmlnamespaces

Check results yourself 🙂

Hope this information help for your integration requirements

– Praveen Gujjeti

To report this post you need to login first.

17 Comments

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

  1. Suseelan Hari

    Hi Praveen,

    Wonderful Thank you so much for sharing about putpayloadvaluebean. I appreciate all your efforts and involvement in SCN community.

    Keep sharing ! Keep Contributing ! Keep Motivating !

    Regards,

    Hari Suseelan

    (0) 
  2. Uday Suvvada

    Hi Praveen,

    Can we use this same config for Multiple Values(0.. Unbounded) case.

    Please let me know in case ifwe can.

    This is working for replace single field value.

    Thanks & Regards

    Uday Suvvada

    (0) 
    1. Praveen Gujjeti Post author

      Hi Uday,

      I don’t have a system to check. May be you can try with xpath array syntax

      put:/ns0:root/field[1]

      put:/ns0:root/field[2]


      ……

      put:/ns0:root/field[n]

      //BR,

      Praveen Gujjeti

      (0) 
  3. Vijita Aggarwal

    Hi Praveen,

    I am trying to use this in my SOAP receiver channel and get the below error :

    “Object not found in lookup of GetPayloadValueBean”

    I found in SDN that this is only available from SAP PI 7.31.  We are on PI 7.30 SP 10. But your blog says it is available from 7.3. Another thing, SAP help from the link you provided in your blog,  the help is available under

    Technology->SAP Netweaver Platform -> 7.3 EHP1

    Can you please help and confirm if we this is only available from EHP1. If that is the case we might have to look at another solution.

    Appreciate your help!

    Thanks,

    Vijita

    (0) 
    1. Praveen Gujjeti Post author

      Hi Vijita,

      Yes, it’s a typo in my blog. I will update this now as 7.31 EHP1.

      BTW, what is your scenario flow and is it sync or async? And what is your requirement

      Best Regards,

      Praveen Gujjeti

      (0) 
  4. Vijita Aggarwal

    Thanks Praveen for your quick response. My scenario is a simple synchronous scenario where we are calling a webservice on the receiver side.

    I had to send a payload value from request to response similar to what you explained in your blog, except I wouldn’t have to trick the system for Asynch use case.

    I wanted to use GetPayloadValueBean/PutPayloadValueBean to achieve this as it is just channel config and really easy option.But since we are on PI 7.30, I could not use this approach.

    I used the UDF instead to store the payload value in Dynamic Configuration objects. This method works and I am getting the expected result.  

    Thanks,

    Vijita

    (0) 
  5. Badari G

    Hi Praveen,

    It looks like the module evaluates only absolute XPATH (/root/node1/element1) and fails if I use relative XPATH (//element1).  I am thinking it is possibly a bug. Any thoughts?

    Regards,
    Badari
     

    (0) 
    1. Evgeniy Kolmakov

      Hi Badari!

      I guess it’s not a bug but implementation feature. The point is that in module bean your XPath expression is used also for appending nodes to document. So, path splitting is performed in code and “/” is used as separator.

      Regards, Evgeniy.

      (0) 
  6. Badari G

    Thank you for the response, Evgeniy!  Would you mind posting also the snippet where the given XPATH is being evaluated please?  I think that the implementation is somewhat counter-intuitive.  Evaluating the relative XPATH is such a basic functionality that’s missing in this module?!
     

    (0) 
    1. Evgeniy Kolmakov

      Hi Badari!

      Here is the method used for storing value to payload in module bean:

      It calls method appendTemplateIfEmptyReq() shown above. And that method, in turn, calls getParts() method of XPathWrapper class where your XPath expression is splitted into tokens using “/” as separator. So, if you set xpath as “//element”, you get empty token and it leads to error in further logic, I guess.

      Regards, Evgeniy.

      (0) 
  7. Badari G

    Thank you, Evgeniy.  I appreciate your response.  Yes, it looks like the XPATH is getting messed up even before being evaluated.

    Regards,
    Badari
     

    (0) 

Leave a Reply