cancel
Showing results for 
Search instead for 
Did you mean: 

How can Request output value be mapped to Response output field ???

former_member399424
Participant
0 Kudos

Hi Experts,

I have a syncronous scenario ( Webservice to RFC) & where in I have two mappings one for request & other for response.

I need to map one of the target field of response mapping with the value of target field from request mapping.

Please let me know how can i acheive this.

Regards,

FM

Accepted Solutions (1)

Accepted Solutions (1)

nabendu_sen
Active Contributor
0 Kudos

Hi FM,

Check this code to pass value from Request Mapping to Response Mapping. I have used this in one of my projects.

UDF1 in Request Mapping: ('Unique' is the Input Field with All Values of The Context defined in UDF)


public void StoreFieldValue(String[] Unique, ResultList result, Container container) throws StreamTransformationException{


DynamicConfigurationKey keyA[] = new DynamicConfigurationKey[Unique.length];

for(int i = 0; i<Unique.length; i++)

{

  try

  {

  DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

  keyA[i] = DynamicConfigurationKey.create("http:/"+"/DCUsage.com", "keyA[" + Integer.toString(i) + "]" );

  conf.put(keyA[i],Unique[i]);

  result.addValue("");

  result.addContextChange();

  if(i == Unique.length-1)

  {

  DynamicConfigurationKey keyCount = DynamicConfigurationKey.create("http:/"+"/DCUsage.com","keyCount" );

  conf.put(keyCount,Integer.toString(Unique.length) );

  }

  }

  catch (Exception e)

  {

  e.printStackTrace( );

  }

}


UDF2 in Response Mapping: (All Values of The Context defined in UDF)


public void RetrieveFieldValue(ResultList result, Container container) throws StreamTransformationException{

int count = 0;

DynamicConfiguration conf = null;

try

{

  conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

  DynamicConfigurationKey keyCount = DynamicConfigurationKey.create("http:/"+"/DCUsage.com","keyCount" );

  String countStr = conf.get(keyCount);

  count = Integer.parseInt(countStr.trim());

}

catch (Exception e)

{

  e.printStackTrace( );

}

DynamicConfigurationKey keyA[] = new DynamicConfigurationKey[count];

for(int i = 0; i<count; i++)

{

  try

  {

  keyA[i] = DynamicConfigurationKey.create("http:/"+"/DCUsage.com", "keyA[" + Integer.toString(i) +"]" );

  String str = conf.get(keyA[i]);

  result.addValue(str);

  result.addContextChange();

  }

  catch (Exception e)

  {

  e.printStackTrace( );

  }

}



Use 1st UDF can be used in between any Field to Field transformation logic, it is not returning any value.


Regards,

Nabendu.

former_member399424
Participant
0 Kudos

Hi Nabendu,

Thanks for your response.

I am working on PI 7.31 Java only stack, so i am not sure whether the above works or not as some where i read the for Java only stack dynamic configuration functionality in synchronous messages can't be used fully by using Integrated Configuration.

Please let me know for any other option.

Regards,

FM

former_member399424
Participant
0 Kudos

Dear All,

Thanks for your inputs..

We are able to acheive the above using simple Dynamic Configuration.

UDF at request mapping..

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/SOAP", "fieldName");    

conf.put(key1,var1);

return "";

UDF at Response Mapping..

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey Variable  = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/SOAP", "fieldName" );

String string1 = conf.get(Variable);
return string1;

Regards,

Farooq

Answers (1)

Answers (1)

former_member184720
Active Contributor
0 Kudos

Did you check the below blog?