1 2 Previous Next 24 Replies Latest reply on Jan 22, 2019 3:52 AM by Seetharaman K

    unsual behaviour of workflow - problem in transforming

    Seetharaman K
      Share:|

      Hi

      i have a work flow in which a REST data comes in jason format. and then passing this to the  json to xml utility. now i need to transform this resultant xml to HTML to send to email body .

      unfortunately  am facing hell a lot of problem here . in short its not working below are the details

      <XML>

        <json>

          <rest-adapter-response>

            <header-lines>

      <set-cookie>sap-usercontext=sap-client=300; path=/</set-cookie>

      <content-length>9834</content-length>

      <sap-perf-fesrec>35838.000000</sap-perf-fesrec>

      <content-type>application/json</content-type>

            </header-lines>

            <metadata>

      <status>success</status>

            </metadata>

            <status-line>

      <reason>OK</reason>

      <code>200</code>

            </status-line>

            <message-body>

              <IDOCDATA>

      <STATUS>

      <MESSAGE>Amount is getting mismatched while posting invoice for PO4500033056</MESSAGE>

      <STATUS>Balance not zero: 0.05-  debits: 200.45  credits: 200.40</STATUS>

      <CREATION_DATE>2016-05-20</CREATION_DATE>

      </STATUS>

      <IDOC>0000000007214348</IDOC>

              </IDOCDATA>

              <IDOCDATA>

      <STATUS>

      <MESSAGE>Amount is getting mismatched while posting invoice for PO8100999900</MESSAGE>

      <STATUS>Balance not zero: 0.20-  debits: 191,143.20  credits: 191,143.00</STATUS>

      <CREATION_DATE>2016-05-25</CREATION_DATE>

      </STATUS>

      <IDOC>0000000007219189</IDOC>

              </IDOCDATA>

                  </message-body>

          </rest-adapter-response>

        </json>

      </XML>

       

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

        <xsl:template match="/">

          <xsl:text disable-output-escaping="yes">&lt;IDOCLIST&gt;</xsl:text>

          <xsl:text disable-output-escaping="yes">&lt;html&gt;&lt;body&gt;&lt;b&gt;</xsl:text>

          <xsl:value-of select="/XML/json" disable-output-escaping="yes" />

          <xsl:text disable-output-escaping="yes">&lt;/b&gt;&lt;/body&gt;&lt;/html&gt;</xsl:text>

          <xsl:text disable-output-escaping="yes">&lt;/IDOCLIST&gt;</xsl:text>

        </xsl:template>

      </xsl:stylesheet>

       

      i verified this transform also , using this site Free Online XSL Transformer (XSLT) - FreeFormatter.com  its cool .

      below is the  tree view of the above xslt

      ip of this transfomration is the o/p of the json to xml workflow which is a an XML

      o/p of this transformation is a body of the email which am going to sent itshould be something like this

       

      <IDOCLIST>

      <html>

      <body>

      <b>

      value i got from the xml

      </b>

      </body>

      </html>

      attached is the log , how ever belos is the smtp req and response

       

      [adapter request=

      <request-data>

        <smtpRequest>

          <from><![CDATA[baobot@xxxxx.com]]></from>

          <to>

            <address><![CDATA[baobot@xxxxx.com]]></address>

          </to>

          <subject>IDOC FAILURE</subject>

          <body /> -----> this is where the transformed content should have come but its not coming.

          <character-set />

          <content-type />

        </smtpRequest>

      </request-data>]

      18 Jan 2019 01:16:48,354 [Current Time=Fri Jan 18 01:16:48 IST 2019] [Process Name=:sample_module:Send Email] [Root Job Id=e4e37044e48bfb60:3e879be:1685d4c4042:-80001-1547754407229] [Job Id=e4e37044e48bfb60:3e879be:1685d4c4042:-80001-1547754407229/:sample_module:ERP-Failed-IDOC-Monitoring:start:call-process[2]]

      [adapter response=

      <smtp-response>

        <metadata>

          <status>success</status>

        </metadata>

      </smtp-response>]

        • 2. Re: unsual behaviour of workflow - problem in transforming
          Matthew Highcove

          The XSLT Transform Editor is intended to output XML. You are not creating an XML output, you are creating a text output in the shape of XML. The Transform Editor displays your result as XML because it interprets the string data, but other parts of BAO do not. They see that you have a string and they treat it as a string, which means later transforms cannot get data from it because it has no tags to parse.

           

          For BAO to use the contents of the transform in later activities, you must write a transform that outputs XML:

           

          803987_XSLT.png

           

          Please also note that you are using a "Value of" node to get the data from the adapter response. This will output the contents of the XML elements, with no whitespace between them, but not the elements themselves. If you want to preserve the XML structure you should use a "Copy Of" node.

          1 of 1 people found this helpful
          • 3. Re: unsual behaviour of workflow - problem in transforming
            Seetharaman K

            My intention is actually to generate  a html outpit from thos xml. To be specific for each idocdata node i wana create a <tr> <td> and enclose the value of the idoc node in it. And this entire for reach resuly should be comimg inside an html and body and table tags. So that my body of the emil will be some thing like below

            <html><body><table>

            <tr> <td>value of idoc 1<tr><td>

            <tr> <td>value of idoc 1<tr><td>

            And so on ...

            </table></body></html>

            But its very unfortunate that when i did such transformation email.body was again empty!!!!!!!

            I was frustrated so decided to extract somwthing atleast if not in row format.

            Hence the above transoformation.

            If u can help me in getting this intended transofrmation it will be of great use !!

            • 4. Re: unsual behaviour of workflow - problem in transforming
              Seetharaman K

              Matthew Highcove

              here is a latest update as per us suggestion

               

              this should ideally produce the output i was looking for

               

              <html><body><table>

              <tr> <td>value of idoc 1<tr><td>

              <tr> <td>value of idoc 1<tr><td>

              And so on ...

              </table></body></html>

               

              but again body tag of the adapter request produces this

               

              <body /> -----> this is where the transformed content should have come but its not coming.

              • 5. Re: unsual behaviour of workflow - problem in transforming
                Seetharaman K

                edit to my last reply

                <body /> -----> this shold not come but again this is what coming

                • 7. Re: unsual behaviour of workflow - problem in transforming
                  Ranganath Samudrala

                  When you want to copy a snippet of XML - meaning copy XML elements to create another XML, you would use COPY-OF and NOT VALUE-OF. VALUE-OF will copy only text data and will ignore elements.

                   

                  See attached sample. Even though it says JSON TO HTML, because I do not have JSON data, I am just using the XML you have shared in this discussion.

                   

                  This shows you need to understand the fundamentals of XSLT a bit better.

                  • 8. Re: unsual behaviour of workflow - problem in transforming
                    Seetharaman K

                    yes Ranga , i need to understand the fundmentals of xslt.  i know certain things conceptually . some handson i have . need to expertise on that in order to built a scalable solution in TSO. will get back in this thread in 5 mins !

                    • 9. Re: unsual behaviour of workflow - problem in transforming
                      Seetharaman K

                      still working on ,  may it it may take more time coz transferring this roar through email takes time.

                      • 10. Re: unsual behaviour of workflow - problem in transforming
                        Seetharaman K

                        ranga it was really help full for the question i asked , but i should have asked the actual question instead i asked solution for  something else which is not exactly the actual question .

                        your transformation includes all <IDOCDATA> nodes in to a <TR><TD> but i need only <IDOC>  , so  currently am trying to include a for each in your template

                        and  try something like

                        for each IDOCDATA apply a TR and TD and include the value of the IDOC alone .

                        my exception is output should be  :

                        1234555

                        7688778

                        8978988

                         

                        something like this ! am trying to modify your code so that i get my actual output , so far no luck. if you can jus guide me here , i will do it. am also trying.

                        • 11. Re: unsual behaviour of workflow - problem in transforming
                          Seetharaman K

                          this is what am trying , which is not giving the desired result. value of /IDOCDATA/IDOC ie the idoc number inside the IDOC node is what i want  inside these

                          TR and TD

                          • 12. Re: unsual behaviour of workflow - problem in transforming
                            Aryan Anantwar

                            Hi Seetharaman,

                             

                            I think you are not able to put your question correctly. please try to write your issue/query with clear details and expected results.

                            I tried below on your issue, hope this is what you are trying to do:

                            Your input XML:

                            <XML>

                              <json>

                               <rest-adapter-response>

                                <header-lines>

                            <set-cookie>sap-usercontext=sap-client=300; path=/</set-cookie>

                            <content-length>9834</content-length>

                            <sap-perf-fesrec>35838.000000</sap-perf-fesrec>

                            <content-type>application/json</content-type>

                                </header-lines>

                                <metadata>

                            <status>success</status>

                                </metadata>

                                <status-line>

                            <reason>OK</reason>

                            <code>200</code>

                                </status-line>

                                <message-body>

                                    <IDOCDATA>

                            <STATUS>

                            <MESSAGE>Amount is getting mismatched while posting invoice for PO4500033056</MESSAGE>

                            <STATUS>Balance not zero: 0.05-  debits: 200.45  credits: 200.40</STATUS>

                            <CREATION_DATE>2016-05-20</CREATION_DATE>

                            </STATUS>

                            <IDOC>0000000007214348</IDOC>

                                    </IDOCDATA>

                                    <IDOCDATA>

                            <STATUS>

                            <MESSAGE>Amount is getting mismatched while posting invoice for PO8100999900</MESSAGE>

                            <STATUS>Balance not zero: 0.20-  debits: 191,143.20  credits: 191,143.00</STATUS>

                            <CREATION_DATE>2016-05-25</CREATION_DATE>

                            </STATUS>

                            <IDOC>0000000007219189</IDOC>

                            </IDOCDATA>

                                </message-body>

                                </rest-adapter-response>

                              </json>

                            </XML>

                             

                            Applied below XSLT on this input XML:

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

                              <xsl:output indent="no" />

                              <xsl:template match="/">

                                <html>

                                  <body>

                                    <b>

                                      <table border="1">

                                        <tr>

                                          <th>

                                            <xsl:text disable-output-escaping="no">IDOC</xsl:text>

                                          </th>

                                          <th>

                                            <xsl:text disable-output-escaping="no">MESSAGE</xsl:text>

                                          </th>

                                          <th>

                                            <xsl:text disable-output-escaping="no">STATUS</xsl:text>

                                          </th>

                                          <th>

                                            <xsl:text disable-output-escaping="no">CREATION_DATE</xsl:text>

                                          </th>

                                        </tr>

                                        <xsl:for-each select="//IDOCDATA">

                                          <tr>

                                            <td>

                                              <xsl:value-of select="./IDOC/text()" disable-output-escaping="no" />

                                            </td>

                                            <td>

                                              <xsl:value-of select="./STATUS/MESSAGE/text()" disable-output-escaping="no" />

                                            </td>

                                            <td>

                                              <xsl:value-of select="./STATUS/STATUS/text()" disable-output-escaping="no" />

                                            </td>

                                            <td>

                                              <xsl:value-of select="./STATUS/CREATION_DATE/text()" disable-output-escaping="no" />

                                            </td>

                                          </tr>

                                        </xsl:for-each>

                                      </table>

                                    </b>

                                  </body>

                                </html>

                              </xsl:template>

                            </xsl:stylesheet>

                             

                            Output of this XSLT:

                            <html>

                              <body>

                                <b>

                                  <table border="1">

                                    <tr>

                                      <th>IDOC</th>

                                      <th>MESSAGE</th>

                                      <th>STATUS</th>

                                      <th>CREATION_DATE</th>

                                    </tr>

                                    <tr>

                                      <td>0000000007214348</td>

                                      <td>Amount is getting mismatched while posting invoice for PO4500033056</td>

                                      <td>Balance not zero: 0.05-  debits: 200.45  credits: 200.40</td>

                                      <td>2016-05-20</td>

                                    </tr>

                                    <tr>

                                      <td>0000000007219189</td>

                                      <td>Amount is getting mismatched while posting invoice for PO8100999900</td>

                                      <td>Balance not zero: 0.20-  debits: 191,143.20  credits: 191,143.00</td>

                                      <td>2016-05-25</td>

                                    </tr>

                                  </table>

                                </b>

                              </body>

                            </html>

                             

                            Graphical output in browser of generated HTML:

                             

                            HTH.

                             

                            Regards,

                            Aryan Anantwar

                            1 of 1 people found this helpful
                            • 13. Re: unsual behaviour of workflow - problem in transforming
                              Seetharaman K

                              for the below transformation i really do not aunderstnad the email op!! next to this i have embeded a mail screen shot also!! all "hello world"  should come one after another ,  but here !!  pls

                               

                              • 14. Re: unsual behaviour of workflow - problem in transforming
                                Seetharaman K

                                Aryan Anantwar

                                thanks a lot , yes i deviated from my actual problem. i will not repeat this .

                                meanwhile i tried your solution and while its working as a perfect html code , when it is renedered in a email body of the bult in SMTP - email work flow it did not not come:

                                i have already tested many html code by passing in the body argument of the built in email  workflow , it worked fine and have got colorful emails. but am not sure why this is not working.

                                1 2 Previous Next