cancel
Showing results for 
Search instead for 
Did you mean: 

Sort the contexts of XML response in passthrough

ramu_g4
Participant
0 Kudos

Hi Experts,

We are working on SAP PI 7.31 dual stack where the scenario is SOAP to Proxy synchronous, in which the request comes from Webservice as SOAP and response is triggered from SAP ECC via Proxy. The data structure is same for request for both source & target and response data structure also same for both source & target here. Hence, we have developed the interface using pass-through scenario where no mappings are involved. The interface developed works fine with single line item in request but Web service team requested the response XML message should be sorted out based on contexts in case of multiple line items in request. For example as of now the response for multi-line items[here two line items where first material does not exist and for second material quote created successfully] which looks like below:

<ACK>

<MESSAGE>Added Material Does not exists</MESSAGE>

</ACK>

<ACK>

<MESSAGE>Quotation created successfully</MESSAGE>

<QUOTATION_NO>0020003692</QUOTATION_NO>

</ACK>

But above is creating issue on Predix side. They need successfully created Quote messages to appear on top in response message and other next like below:

<ACK>

<MESSAGE>Quotation created successfully</MESSAGE>

<QUOTATION_NO>0020003692</QUOTATION_NO>

</ACK>

<ACK>

<MESSAGE>Added Material Does not exists</MESSAGE>

</ACK>

Please guide me on how to achieve this in pass-through scenario, if not possible in pass-through then in case of graphical mappings which node functions or UDF to be used to achieve the above.

Thanks,

Ramu G.

Accepted Solutions (1)

Accepted Solutions (1)

former_member190293
Active Contributor
0 Kudos

Hi Ramu!

Is there any other status texts available in your response? If yes and text is something like: "Something went wrong", sorting the nodes becomes useless.

You can use MessageTransformBean in your pass-through scenario with XSL transformation like this:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template match="/*">

        <MT_Message>

            <xsl:copy-of select="ACK[starts-with(MESSAGE/text(), 'Quotation')]"/>

            <xsl:copy-of select="ACK[not (starts-with(MESSAGE/text(), 'Quotation'))]"/>

        </MT_Message>

    </xsl:template>

</xsl:stylesheet>

Source:

<?xml version="1.0" encoding="UTF-8"?>

<MT_Message>

     <ACK>

          <MESSAGE>Added Material Does not exists</MESSAGE>

     </ACK>

     <ACK>

          <MESSAGE>Quotation created successfully</MESSAGE>

          <QUOTATION_NO>0020003692</QUOTATION_NO>

     </ACK>

     <ACK>

          <MESSAGE>Something went wrong</MESSAGE>

     </ACK>

</MT_Message>

Result:

<?xml version="1.0" encoding="utf-8"?>

<MT_Message>

     <ACK>

          <MESSAGE>Quotation created successfully</MESSAGE>

          <QUOTATION_NO>0020003692</QUOTATION_NO>

     </ACK>

     <ACK>

          <MESSAGE>Added Material Does not exists</MESSAGE>

     </ACK>

     <ACK>

          <MESSAGE>Something went wrong</MESSAGE>

     </ACK>

</MT_Message>

Regards, Evgeniy.

ramu_g4
Participant
0 Kudos

Hi Evgeniy,

Thanks for your response.

-Ramu.

Answers (2)

Answers (2)

Ryan-Crosby
Active Contributor
0 Kudos

Hi Ramu,

I would say that's not a particularly helpful set of response messages as it does not indicate which item was successful vs. which item failed because the material did not exist.  If item number data were included in the response information then the receiving application could easily discern context and sort the output as required.

Regards,

Ryan Crosby

former_member182412
Active Contributor
0 Kudos

Hi Ramu,

Use can use below logic in message mapping.

Test:

Regards,

Praveen.

ramu_g4
Participant
0 Kudos

HI Praveen,

The response data structure in ESR looks like below:

Would the above logic work for the same?

Thanks,

Ramu G.