Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Insert a Value from Request to Response in HCI

Hi HCI Experts,

I'm trying to build a scenario in HCI that would insert a value from a request message to a response message. In PI, this can be achieved using GetPayloadValueBean and PutPayloadValueBean. I'm looking into Content Modifier, Externalized Parameters or Variable which are all standard message transformers/objects in HCI. However, I'm getting no luck so far when trying to deploy the iFlow.

So far I've tried using the Write Variables. Here's my iFlow:

It's not working. It's either the Variable is not working / getting saved or I messed up with the Content Modifier. How do you fill up the message in the Body tab of the Content Modifier? The example in the guide is too simple. What if we need to assign the Variable's value in an existing field of a message payload such as my case?

What I did so far is copy pasted the whole message payload (this is the actual response message of the 1st Request-Reply from COD) and assigned the placeholder of the variable in one of the fields.

Has anyone ever done this scenario with success?

Again, appreciate any inputs.

Thanks in advance.

Mark

replied

Hello Mark,

Mapping step wont replace the headers and Properties directly in runtime.I mean ${header.H1} willnot be replaced with value of H1 directly,you need to write CustomFunction( UDF in SAP PI terminology) like below and call those in Message Mapping.

If you are using WriteVariable select the type as Property and set the value for that,later call it in mapping using below script.

If you are using Content Modifier,set the Property and later call it using below script.

To Retrieve the Header Value in Message Mapping:

import com.sap.it.api.mapping.*

def String getHeader1(String header,MappingContext context)

{

  String HeaderValue = context.getHeader(H_headerName);

  HeaderValue= HeaderValue.toString();

  return HeaderValue;

}


To Retrieve the Property Value in Message Mapping:


import com.sap.it.api.mapping.*


def String getProperty(String propertyName,MappingContext context)

{

  String PropertyValue= context.getProperty(Prop_propertyName);

  PropertyValue= PropertyValue.toString();

  return PropertyValue;

}

Regards,

Sriprasad Shivaram Bhat

2 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question