cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Inputstructure into String and store into DB2

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Swarup / Shamly

My input structure is nearly 60 fields. Sample Structure

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

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<SOAP-ENV:Body>

<create xmlns="urn:MySoapServices">

<PurchaseOrder>

<BuyerDetails>

<Organization>University of Washington</Organization>

<Authorized_Person>

<FisrtName>Cease</FisrtName>

<LastName>Wayne</LastName>

</Authorized_Person>

<Street>Savery Hall</Street>

<City>Seattle</City>

<State>Wa</State>

<Zip>98195</Zip>

<Contact_Numbers>

<Phone>888-846-6638</Phone>

<Fax>212-629-1158</Fax>

</Contact_Numbers>

<Email>hidekiu.washington.edu</Email>

</BuyerDetails>

<SupplierDetails>

<Organization>Thomas Industrial Network</Organization>

<Authorized_Person>

<FisrtName>Cease</FisrtName>

<LastName>Wayne</LastName>

</Authorized_Person>

<Street>5 Penn Plaza, 10th Floor</Street>

<City>New York</City>

<State>NY</State>

<Zip> 10001</Zip>

<Contact_Numbers>

<Phone>888-846-6638</Phone>

<Fax>212-629-1158</Fax>

</Contact_Numbers>

</SupplierDetails>

<PurchaseOrderInformation>

<Order_Number>4556</Order_Number>

<Order_Delivery_Date>10-10-2006</Order_Delivery_Date>

<PO_Type>Finished</PO_Type>

<status>PO sent</status>

</PurchaseOrderInformation>

<Address>

<Shipping_Address>

<Organisation>University of Washington</Organisation>

<Authorized_Person>

<FisrtName>Cease</FisrtName>

<LastName>Wayne</LastName>

</Authorized_Person>

<Street>Savery Hall</Street>

<City>Seattle</City>

<State>Wa</State>

<Zip>98195</Zip>

<Email>hidekiu.washington.edu</Email>

</Shipping_Address>

<Billing_Address>

<Organisation>University of Washington</Organisation>

<Authorized_Person>

<FisrtName>Cease</FisrtName>

<LastName>Wayne</LastName>

</Authorized_Person>

<Street>Savery Hall</Street>

<City>Seattle</City>

<State>Wa</State>

<Zip>98195</Zip>

<Email>hideki</Email>

</Billing_Address>

</Address>

<Payment_Terms>

<Purchase_Order>

<PO_Number>456</PO_Number>

<Payment_Type>Bank</Payment_Type>

<Payment_Type_PO>

<Bank>

<BankName>Citibank</BankName>

<AccountNumber>654987456</AccountNumber>

<BranchCode>564</BranchCode>

</Bank>

<Credit_Card>

<Payment_Type_CC>VISA</Payment_Type_CC>

<CC_Number>1234 4567 7890 0123</CC_Number>

<CC_Expire_Date>10-12-2012</CC_Expire_Date>

</Credit_Card>

</Payment_Type_PO>

</Purchase_Order>

<Currency>USD</Currency>

</Payment_Terms>

<Purchase_Items>

<Item>

<Part_Name>6 foot wide 5 foot high cabinet</Part_Name>

<Quantity>9</Quantity>

<Description>Cabinets of systems</Description>

</Item>

<Item>

<Part_Name>6 foot wide shelves</Part_Name>

<Quantity>6</Quantity>

<Description>Shelves for books</Description>

</Item>

</Purchase_Items>

</PurchaseOrder>

</create>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

I need to store whole XML structure (Including XML version) into Database single field as a clob. not field values. Please help me out from this issue.

Former Member
0 Kudos

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.

Answers (5)

Answers (5)

santhosh_kumarv
Active Contributor
0 Kudos

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...

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Mohd,

Can you guide me step by step with detail description.

Thanks&Regards

venkatk

Edited by: venkat k on Aug 1, 2008 2:15 AM

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Venkat,

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

Regards,

Shamly.

Former Member
0 Kudos

Hello All,

Can anyone suggest me on this issue.

Thanks&Regards,

VenkatK

former_member190389
Active Contributor
0 Kudos