Blog Archive

Tuesday, August 22, 2017

SAP HCI get write steps to save and itterative splitter options functinality

Om
 In This , blog I am going to explain with sample payload, which is mentioned as constant in content modifier step, I like to save this in iflow and later retreive this payload agian at required place.

based on the payload information( xml, csv ) based token,xpath, row number group
( i want to split this message) again with iterative slitter again.
 





 
The above configuration sends 2 mails by splitting message 

 if you put payload as csv file, line-break with group 1 as follows


SAP HCI get and set header and property variables from goovy script and typecast

Om


Monday, August 21, 2017

alternative to SOAP UI with crome postman?

Om

checking this chrome postman


Friday, August 11, 2017

java mapping lookup and add or modify source xml file

Om


Some times you are supposed to lookup other systems 
1) to get more information efficiently by query other system
2)  and modify the lookup content in our required manner

then, lookup other systems, get the content.
( to fetch content in xml files, we need to do various operations)
instead of that.

Append the source xml and lookup xml file together.
( generate target xml file using graphical mapping ).

Merging two xml files in java mapping.
( later planning to generate my target required xml file using graphical mapping.

Code to merge two xml files;
--------------
import java.io.File;
import java.io.FileInputStream;
import java.io.StringWriter;
import java.io.Writer;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class CopyNodesSubtreeFromOneDOMDocumentToAnother {
    public static void main(String[] args) throws Exception {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setValidating(false);
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc1 = db.parse(new FileInputStream(new File("C:\\Users\\DeviprasadPothireddi\\workspace\\MyTestJavaProject\\src\\input1.xml")));
        Document doc2 = db.parse(new FileInputStream(new File("C:\\Users\\DeviprasadPothireddi\\workspace\\MyTestJavaProject\\src\\input2.xml")));
        System.out.println("Before Copy...");
       // prettyPrint(doc1);
        NodeList list = doc2.getElementsByTagName("queryfo_locationResponse");
        Element element = (Element) list.item(0);
        // Imports a node from another document to this document, without altering
        // or removing the source node from the original document
        Node copiedNode = doc1.importNode(element, true);
        // Adds the node to the end of the list of children of this node
        doc1.getDocumentElement().appendChild(copiedNode);
        System.out.println("After Copy...");
        prettyPrint(doc1);
    }


// this below code prints document content to understand.
    public static final void prettyPrint(Document xml) throws Exception {
        Transformer tf = TransformerFactory.newInstance().newTransformer();
        tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
        tf.setOutputProperty(OutputKeys.INDENT, "yes");
        Writer out = new StringWriter();
        tf.transform(new DOMSource(xml), new StreamResult(out));
        System.out.println(out.toString());
    }
}
----------------------------

_rss version="2.0"_
    _channel_
        _title_Java Tutorials and Examples 1_/title_
        _language_en-us_/language_
        _item_
            _title__![CDATA[Java Tutorials 1]]__/title_
            _link_http://www.javacodegeeks.com/_/link_
        _/item_
        _item_
            _title__![CDATA[Java Examples 1]]__/title_
            _link_http://examples.javacodegeeks.com/_/link_
        _/item_
    _/channel_
_/rss_

----------------------------


_rss version="2.0"_
    _channel_
        _title_Java1 Tutorials and Examples 2_/title_
        _language_en-us_/language_
        _item_
            _title__![CDATA[Java Tutorials 2]]__/title_
            _link_http://www.javacodegeeks.com/_/link_
        _/item_
        _item_
            _title__![CDATA[Java Examples 2]]__/title_
            _link_http://examples.javacodegeeks.com/_/link_
        _/item_
    _/channel_
_/rss_

-------------------------------------------------------------------------------------
Before Copy...
_rss version="2.0"_
    _channel_
        _title_Java Tutorials and Examples 2_/title_
        _language_en-us_/language_
        _item_
            _title__![CDATA[Java Tutorials 2]]__/title_
            _link_http://www.javacodegeeks.com/_/link_
        _/item_
        _item_
            _title__![CDATA[Java Examples 2]]__/title_
            _link_http://examples.javacodegeeks.com/_/link_
        _/item_
    _/channel_
_/rss_

After Copy...
_rss version="2.0"_
    _channel_
        _title_Java Tutorials and Examples 2_/title_
        _language_en-us_/language_
        _item_
            _title__![CDATA[Java Tutorials 2]]__/title_
            _link_http://www.javacodegeeks.com/_/link_
        _/item_
        _item_
            _title__![CDATA[Java Examples 2]]__/title_
            _link_http://examples.javacodegeeks.com/_/link_
        _/item_
    _/channel_
_channel_
        _title_Java Tutorials and Examples 1_/title_
        _language_en-us_/language_
        _item_
            _title__![CDATA[Java Tutorials 1]]__/title_
            _link_http://www.javacodegeeks.com/_/link_
        _/item_
        _item_
            _title__![CDATA[Java Examples 1]]__/title_
            _link_http://examples.javacodegeeks.com/_/link_
        _/item_
    _/channel_
_/rss_



sampel code
https://stackoverflow.com/questions/15214818/how-to-replace-old-value-between-xml-tags-with-new-value

1root2
        1date2oldValue1/date2  
1/root2



Document doc = builder.parse(new File("myFile.xml"));  
Element root = doc.getDocumentElement();  
System.out.println("Before");  
System.out.println("Using getElementByTagName date: " + root.getElementsByTagName("date").item(0).getTextContent());  
System.out.println("Using getAttribute        date: " + root.getAttribute("date"));
root.setAttribute("date", "newValue");  
System.out.println("After");  
System.out.println("Using getElementByTagName date: " + root.getElementsByTagName("date").item(0).getTextContent());  
System.out.println("Using getAttribute        date: " + root.getAttribute("date"));


Thursday, August 10, 2017

java mapping list of required jar files

parsing xml files using java with examples into arraylist

public class DomParserDemo1 {
   public static void main(String[] args){

 try {   
         File inputFile =
new File("C:\\Users\\DeviprasadPothireddi\\workspace\\MyTestJavaProject\\src\\input1.xml");
         DocumentBuilderFactory dbFactory
            = DocumentBuilderFactory.newInstance();
         DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
         Document document = dBuilder.parse(inputFile);
        //
         NodeList empinfolist = document.getElementsByTagName("employment_information");
             if (!(empinfolist.getLength()==0))
             {
                 NodeList locationlist = document.getElementsByTagName("location");
                 if (!(locationlist.getLength()==0))
                 {
                   
                     ArrayList wordDulicate = new ArrayList();
                     for (int i = 0; i < locationlist.getLength(); i++)
                     {   
                     Node node = locationlist.item(i);
                     wordDulicate.add( node.getTextContent());            
                     }      // externalCode = '"+"CORP"+"' or externalCode = '"+"REM"+"'
                   
                     ArrayList nonDupList = new ArrayList();

                        Iterator dupIter = wordDulicate.iterator();
                        while(dupIter.hasNext())
                        {
                        String dupWord = dupIter.next();
                        if(nonDupList.contains(dupWord))
                        {
                            dupIter.remove();
                        }else
                        {
                            nonDupList.add(dupWord);
                        }  }// end whileloop
                        System.out.println(nonDupList);


    
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}

more examples on java dom parsing
https://www.tutorialspoint.com/java_xml/java_dom_parse_document.htm

Sunday, August 6, 2017

sap pi cts transport organizer

Om












Friday, August 4, 2017

remove namespace examples more

Om






Thursday, August 3, 2017

ecilipse java short cuts for developer point of view for quick coding.

Om













SAP HCI advanced user defiend functions

Om

select the different options of add options

1. addValue
2.addContextChange()
3.addSuppress()
4.clear();

groovy code for hci;


Test results



How do i used message mapping , for node mapping and element mapping.



XSLT prepare variable use that variable in your target preparation using copy-of

 Om