Skip to Content
author's profile photo Former Member
Former Member

Convert Inputstructure into String and store into DB2

Hello All

My requirement is I want to convert total input structure into string then stored into database single field as clob. Can anyone suggest me how will i retive input structor, is there any user defined function will i write or is there any inbuilt functionality in SAP PI. Plese suggest me

Thanks&Regards,

VenkatK

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 30, 2008 at 02:52 AM

    HI,

    Converting source structure to single target node is possible with simple concat API also.

    How many fields are there on source side??? ...if the no of fields are more and it feels complicated to conatc each an every field then you can go for XSLT mapping also..

    I doubt if you will require any UDF for this. If the occurance of input structure is Unbounded then before passing the field to concat api....use mapwithDefault api.

    Input1 -


    > Concat }----


    > target node.

    Input2 -->mapWithDefault -


    >

    I hope this will help you.

    Please let us know if there are any specific requirments, you may even share the source and expected target structure

    Thanks

    Swarup

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      You can use xslt mapping for this.

      <xsl:text disable-output-escaping="yes">

      <![CDATA[<![CDATAhttp://<?xml version='1.0' encoding='UTF-8'?>]></xsl:text>

      <xsl:copy-of select="."/>

      <xsl:text disable-output-escaping="yes"><!CDATA[]]]></xsl:text>

      <xsl:text disable-output-escaping="yes"><![CDATA>]></xsl:text>

      Thanks,

      Beena.

  • Posted on Jul 29, 2008 at 04:22 PM
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 04, 2008 at 11:54 AM

    Hi,

    Check my wiki page [Java Mapping- Convert the Input xml to String|https://wiki.sdn.sap.com/wiki/display/XI/JavaMapping-ConverttheInputxmlto+String]

    Thanks

    SaNv...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 29, 2008 at 08:32 PM

    Hello All,

    Can anyone suggest me on this issue.

    Thanks&Regards,

    VenkatK

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 30, 2008 at 03:28 AM

    Hi Venkat,

    Please paste your source structure. The target structure i believe is a single varchar field in the DB.

    Regards,

    Shamly.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 31, 2008 at 04:48 AM

    Hi Venkat,

    U can do the same using java mapping,where the entire structure that is the input stream is read as string and then u can store it in the DB as clob..let me know if u would like to see the code..so i can give u the snippet of java mapping.

    Regards,

    Mohd Tauseef I

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Venkat,

      u want all the details to be stored in a clob in the DB right?

      try this code

      have a dummy data type with a field dummy

      write this code in NWDS, inport the jar file in the imported archive and use it in interface mapping.

      public class className implements StreamTransformation

      {

      private Map map;

      private Document document;

      private String Data = "";

      public void setParameter(Map param)

      {

      map = param;

      }

      public void execute(InputStream in, OutputStream out) throws StreamTransformationException

      {

      DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();

      try

      {

      // create DOM structure from input XML

      DocumentBuilder builder = factory.newDocumentBuilder();

      document = builder.parse(in);

      NodeList list = document.getElementsByTagName("Dummy");

      //int count = list.getLength();

      Node node = list.item(0);

      node = list.item(0);

      if (node != null)

      {

      // if found, look for the value of DUMMY

      node = node.getFirstChild();

      if (node != null)

      {

      Data = node.getNodeValue();

      //Create the output DOM

      }

      }

      Document docOut = builder.newDocument();

      // create the root element <MT_SOURCE>

      Element MessageType_Target = docOut.createElement("MT_SOURCE");

      docOut.appendChild(MessageType_Target);

      Element DataNode = docOut.createElement("Data");

      PayloadNode.appendChild(DataNode);

      Text titleText = docOut.createTextNode(Data);

      TransformerFactory tf = TransformerFactory.newInstance();

      Transformer transform = tf.newTransformer();

      transform.transform(new DOMSource(docOut), new StreamResult(out));

      }

      catch (Throwable t)

      {

      throw new StreamTransformationException("error", t);

      }

      }

      }

      This is using DOM parser,same can also be done using SAX

      Hope it helps 😉

      Edited by: Mohd Tauseef Ibrahim on Aug 1, 2008 6:26 AM

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.