Comments

  • 1-8 of 8
  • Venkatesh Reddy

    Can you please me out.

  • Venkatesh Reddy

    Hi,

    There is an alternate way to upload file into UCM if it is related to Financials Cloud, I.e. ERP Connector(Import Data into Financials Cloud Application).

    Regards

    Venkat

  • Venkatesh Reddy

    Hi Hemanth,

    Please find the attachment for the javascript file, which we used for xml to json conversion.

    Thanks,

    Venkat

  • Venkatesh Reddy

    No, still facing the issue.

    Regards,

    Venkat

  • Venkatesh Reddy

    Hi Akaushal,

    We are providing the phone number as string in the xml schema.

    Regards,

    Venkat

  • Venkatesh Reddy

    Hi Hemanth,

    We are using ICS version: 17.3.3.0.0

    Regards,

    Venkat

  • Venkatesh Reddy

    Please refer below mentioned code for reference of how we used the data inside CDATA section in an integration:

    In XSLT file we have to edit so that we have to map fields. once done with the xslt, import the iar file into ICS.

    example:

       <!--User Editing allowed BELOW this line - DO NOT DELETE THIS LINE-->

       <xsl:param name="GetReportData" xml:id="id_17"/>

      <xsl:variable name="var" select="$GetReportData/nssrcmpr:NewOperationResponse/result/DATA_DS"/>

       <xsl:template match="/" xml:id="id_15">

          <nstrgmpr:SalesOrderResponse xml:id="id_16">

            <xsl:for-each select="$var/G_1">

                <SalesOrder>

                   <order_number>

                      <xsl:value-of select="USER_ID"/>

                   </order_number>

                </SalesOrder>

             </xsl:for-each>

          </nstrgmpr:SalesOrderResponse>

       </xsl:template>

    </xsl:stylesheet>

    Let me know in case you have any queries.

    Regards,

    Janardhan

  • Venkatesh Reddy

    Hi Hemanth,

    Have to construct an JSON request query string  in order to invoke the target system.

    The expected URL part  is having  value:

    {%22Kind%22:%201,%22ActorCSID%22:%2063,%22ProdConceptID%22:%20113,%22Addresses%22:%20[{%22Kind%22:%202,%22Name1%22:%20%22Test%20sender%22,%22Street1%22:%20%22Test%20Address%22,%22PostCode%22:%20%226400%22,%22City%22:%20%22S%C3%B8nderborg%22,%22Phone%22:%20%2223249480%22,%22Mobile%22:%20%2204799999999%22,%22Attention%22:%20%22test%22,%22CountryCode%22:%20%22DK%22},{%22Kind%22:%201,%22Name1%22:%20%22John%20Doe%22,%22Street1%22:%20%22Test%20address%201%22,%22Street2%22:%20%22Test%20address%202%22,%22PostCode%22:%20%226400%22,%22City%22:%20%22S%C3%B8nderborg%22,%22CountryCode%22:%20%22DK%22}],%22Lines%22:%20[{%22PkgWeight%22:%205000,%22GoodsTypeKey1%22:%20%22A%22,%22Pkgs%22:%20[{%22ItemNo%22:%201}]}]}

    which is encoded format of actual json:

    {"Kind": 1,"ActorCSID": 63,"ProdConceptID": 113,"Addresses": [{"Kind": 2,"Name1": "Test sender","Street1": "Test Address","PostCode": "6400","City": "Sønderborg","Phone": "23249480","Mobile": "04799999999","Attention": "test","CountryCode": "DK"},{"Kind": 1,"Name1": "John Doe","Street1": "Test address 1","Street2": "Test address 2","PostCode": "6400","City": "Sønderborg","CountryCode": "DK"}],"Lines": [{"PkgWeight": 5000,"GoodsTypeKey1": "A","Pkgs": [{"ItemNo": 1}]}]}

    Here we are constructing the JSON from the request from source system which is an XML.

    Converting XML to JSON using function call over ICS. In this Process we are getting  string values over resulted JSON response.

    Below is the Code using for conversion: (xml toJson)

    function strxml2json(p1){

        //var xml = <person id="1234" age="30"><name>John Doe</name></person>;

        var xml = new XML(p1);

        //console.log(xml);

        var t1 = typeof(p1);

        var t2 = typeof(xml);

        //console.log("p1 type: " + t1 + " xml type: " + t2 );

        //console.log("test", xml, "   its children: ", xml.children());

        var json = xml2json(xml);

        //console.log(json);

        return json;

    }

    /*  This work is licensed under Creative Commons GNU LGPL License.

        License: http://creativecommons.org/licenses/LGPL/2.1/

       Version: 0.9

        Author:  Stefan Goessner/2006

        Web:     http://goessner.net/

    */

    function xml2json(node) {

    //var X

    var X = {  toObj: function(xml) {

             var o = {};

             if (xml.nodeKind()=="element") {   // element node ..

                 var attributes = xml.attributes();

                 for (var i in attributes){

                     var a = attributes[i]

                     o["@"+a.localName()] = X.escape(a.text().toString());

                 }

                 xml.normalize();

                 var children = xml.children();

                 //console.log("document: " , xml , "  ", children);

                 if (children.length() > 0) { // element has child nodes ..

                   var textChild=0, cdataChild=0, hasElementChild=false;

                   for(var n in children){

                       var child = children[n];

                       if (child.nodeKind()=="element") {

                           hasElementChild = true;

                       //} else if ((child.nodeKind()=="text") && child.text().toString().match(/[^ \f\n\r\t\v]/)) {

                       } else if (child.nodeKind()=="text") {

                           textChild++; // non-whitespace text

                       } else if (child.nodeKind()== "cdata") {

                           cdataChild++; // cdata section node

                       }

                   }

                   if (hasElementChild) {

                      //if (textChild < 2 && cdataChild < 2) { // structured element with evtl. a single text or/and cdata node ..

                         //X.removeWhite(xml);

                          for(var n in children){

                              var child = children[n];

                              if (child.nodeKind()=="text") {

                                  var txt = child.text().toString();

                                  if(txt.length > 0){

                                      o["#text"] = X.escape(text);

                                  }

                              } else if (child.nodeKind()== "cdata"){ // cdata section node

                                  var txt = child.text().toString();

                                  if(txt.length > 0){

                                      o["#cdata"] = X.escape(txt);

                                  }

                              } else {

                                  var childName = child.localName();

                                  if (o[childName]) {

                                      if (o[childName] instanceof Array)

                                          o[childName].push(X.toObj(child));

                                      else

                                          o[childName] = [o[childName], X.toObj(child)];

                                  } else { // first occurence of element..

                                      o[childName] = X.toObj(child);

                                  }

                              }

                          }

                      /*                     

                      } else { // mixed content

                         if (!xml.attributes.length)

                            o = X.escape(X.innerXml(xml));

                         else

                            o["#text"] = X.escape(X.innerXml(xml));

                      }

                      */

                   }

                   else if (textChild) { // pure text

                      if (!xml.attributes().length())

                         o = X.escape(xml.text().toString());

                      else {

                          var txt = xml.text().toString();

                          if(txt.length > 0){

                              o["#text"] = X.escape(txt);

                          }

                      }

                   }

                   else if (cdataChild) { // cdata

                       o = X.escape(xml.text().toString());

                      /**

                       if (cdataChild > 1)

                         o = X.escape(xml.text());

                      else

                         for (var n=xml.firstChild; n; n=n.nextSibling)

                            o["#cdata"] = X.escape(n.nodeValue);

                      */

                   }

                }

                if ((xml.attributes().length()==0) && (xml.children().length()==0))

                    o = null;

             }

             /*

             else if (xml.nodeKind()=="document") { // document.node

                o = X.toObj(xml.documentElement);

             }

             */

             else

                console.error("unhandled node type: " + xml.nodeKind());

             return o;

          },

    toJson: function(o, name, ind) {

             var json = name ? ("\""+name+"\"") : "";

             if (o instanceof Array) {

                for (var i=0,n=o.length; i<n; i++)

                   o[i] = X.toJson(o[i], "", ind+"\t");

                json += (name?":[":"[") + (o.length > 1 ? ("\n"+ind+"\t"+o.join(",\n"+ind+"\t")+"\n"+ind) : o.join("")) + "]";

             }

             else if (o == null)

                json += (name&&":") + "null";

             else if (typeof(o) == "object") {

                var arr = [];

                for (var m in o)

                   arr[arr.length] = X.toJson(o[m], m, ind+"\t");

                json += (name?":{":"{") + (arr.length > 1 ? ("\n"+ind+"\t"+arr.join(",\n"+ind+"\t")+"\n"+ind) : arr.join("")) + "}";

             }

             else if (typeof(o) == "string")

                json += (name&&":") + "\"" + o.toString() + "\"";

             else

                json += (name&&":") + o.toString();

             return json;

          },

     

         innerXml: function(node) {

             var s = ""

             if ("innerHTML" in node)

                s = node.innerHTML;

             else {

                var asXml = function(n) {

                   var s = "";

                   if (n.nodeType == 1) {

                      s += "<" + n.nodeName;

                      for (var i=0; i<n.attributes.length;i++)

                         s += " " + n.attributes[i].nodeName + "=\"" + (n.attributes[i].nodeValue||"").toString() + "\"";

                      if (n.firstChild) {

                         s += ">";

                         for (var c=n.firstChild; c; c=c.nextSibling)

                            s += asXml(c);

                         s += "</"+n.nodeName+">";

                      }

                      else

                         s += "/>";

                   }

                   else if (n.nodeType == 3)

                      s += n.nodeValue;

                   else if (n.nodeType == 4)

                      s += "<![CDATA[" + n.nodeValue + "]]>";

                   return s;

                };

                for (var c=node.firstChild; c; c=c.nextSibling)

                   s += asXml(c);

             }

             return s;

          },

    escape: function(txt) {

             //console.log("escape:  " , txt)

             return txt;

             return JSON.stringify(txt);

             return txt.replace(/[\\]/g, "\\\\")

                       .replace(/[\"]/g, '\\"')

                       .replace(/[\n]/g, '\\n')

                       .replace(/[\r]/g, '\\r');

          },

          removeWhite: function(e) {

             e.normalize();

             for (var n = e.firstChild; n; ) {

                if (n.nodeType == 3) {  // text node

                   if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node

                      var nxt = n.nextSibling;

                      e.removeChild(n);

                      n = nxt;

                   }

                   else

                      n = n.nextSibling;

                }

                else if (n.nodeType == 1) {  // element node

                   X.removeWhite(n);

                   n = n.nextSibling;

                }

                else                      // any other node

                   n = n.nextSibling;

             }

             return e;

          }

         };

       var n1 = node;

       var n2 = X.toObj(n1);

       var n3 = { };

       n3[node.localName()] = n2;

       var n4 = JSON.stringify(n3, null, 3);

       return n4;

    }

    Thanks,

    Janardhan