Inserting a PCL string in java Document for paper source control

Got a printer issue here.
I need to set the source printer tray from within the document using PCL because I am printing to a network printer and the driver that is being used always defaults the source tray to the printer default.
I am inserting the String right at the beginning of the document like so:
document.insertString(0, "\u001B&l2H", null);
The "\u001B" is the ASCII escape character used by the control sequence and the "&l2H" is the PCL code for the Manual tray. This does insert the string into the document but when the ,prn file is created (print to file) it does not use the inserted value.
The document type is text/html and I am 'Printing to file' using:
aJobAttrs.add(new javax.print.attribute.standard.Destination(new java.net.URI("file:///C:/temp/out.prn"))); as suggested in another forum. The .prn file that is persisted however still sets the tray to the printer default (&l7H).
Anyone go any suggestions?
Ps The MediaTray.MANUAL does not work because the network print driver overwrites it.

No, I does not set the print tray on the .prn file persited by the code. It would appear that the default tray (&l7H) is not overwritten with the tray I set in my document.
It may have something to do with the escape characters?

Similar Messages

  • Tools for extracting strings from java code for internationalization

    For legacy code with lots and lots of strings what method is typically used to extract strings for internationalization?
    Am I right in thinking you couldnt simply grep for strings, it could get pretty complitcated, especially with escape characters, escaped quotes etc.,
    -SK

    When dealing with legacy code, it is nice to have an application that queries you as it extracts the strings. You have a choice whether to accept the string as a localizable entity or not.
    There are several tools that do this...including some IDEs like JBuilder. Although it isn't a fully supported or robust tool, Sun has a utility for extracting strings in Java source files:
    http://java.sun.com/products/jilkit/.
    Regards,
    John O'Conner

  • JAVA APPLET FOR COUPON PRINT CONTROL

    I need to create a coupon control applet for my website that will require clients to submit to a squeeze form and then control the quantity of coupons printed to that IP address. The app will also need to manage the overall quantities printed of any one coupon. This exact system is being employed by smartsource.com currently.
    Thanks in advance for your response.
    Greg

    gregme wrote:
    I need to create a coupon control applet for my website that will require clients to submit to a squeeze form and then control the quantity of coupons printed to that IP address. The app will also need to manage the overall quantities printed of any one coupon. This exact system is being employed by smartsource.com currently.
    Thanks in advance for your response.
    Greg...and what, exactly, is your question?
    PS- All-capital titles make kittens sad.
    And, while I'm at it: [How To Ask Questions The Smart Way|http://catb.org/~esr/faqs/smart-questions.html]
    Edited by: kevinaworkman on Jan 7, 2010 10:15 AM

  • PDF  Document for cost object controlling

    Hi Sap Gurus ,
                    please any body sent cost object  controling pdf document to me.please help me .
    Thanks & Regards
    Sri

    HI
    Below links has some details relating to PC-COC
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/COPCIS/COPCIS.pdf
    VVR

  • Check for Items Source Control Status in Project Explorer

    Is there a way to check what items in the Project Explorer are not currently under source code control? Perhaps through property nodes? I didn't see anything that looked like it could be done this way, but I would like to know if there are items in my project that are not in source control that should be in source control.

    Hi zenthoef,
    I do not believe there is any way to tell which files are not currently under source code control through LabVIEW. My only thought is that you could make a call into the source code control API. However most likely the API is not open to external calls and it would depend on what source code control you are using. 
    <Brian A | Applications Engineering | National Instruments> 

  • How to get an xml string into a Document w/o escaping mark-up characters?

    Hi,
    I am using one of the latest xerces using Java. I am pretty sure I am using xerces-2.
    I have an existing Document and I am trying to add more content to it. The new content itself is xml string. I am trying to insert this xml string into the document using document.createTextNode. I am able to insert, but somewhere it is escaping the mark-up characters (<,>,etc). When I convert the document into String, I can see, for example, <userData> instead of <userData>.
    There is an alternative option to accomplish this by creating a new document with this xml string, get the root element, import this element into my document. Execution time for this procedure is very high - means, this is very bad in terms of time-wise performance.
    Can any help on how to accomplish this (bringing an xml string into a document without escaping mark-up characters) in time-efficient way.

    So you want to treat the contents of the string as XML rather than as text? Then you have to parse it.
    Or if your reason for asking is just that you don't like the look of escaped text, then use a CDATA section to contain the text.

  • LSMW me51n, how to create one PR document for all the records in the  file

    HI all,
    I need to create LSMW for t-code me51n -Create Purchase Requisition. I`m using Bapi BUS2105, method CREATEFROMDATA, idoc message type PREQCR, basic type PREQCR03. The problem is that the LSMW is creating different idoc and different PR document for every record in the source file. My requirement is to create one PR document for one source file (Every source file is different Purchase Requisition) . I`m trying to do this with writing some code(global functions ) in the 'Mapping and conversion rules'  events - BEGINOF_TRANSACTION_, ENDOF_TRANSACTION__..., but i`m not very sure what exactly i`m doing .
    Please help me resolve this problem, any help will be appreciated .
    Best regards, Emil Milchev.

    Thank you for you answer.
    But I have found faster way of doing it - two source structures, one HEADER and ONE ITEM.
    HEADER: one empty text field and identificator for it.
    ITEM: everything else.
    Then everything was just fine, i`ve mapped the different IDOC segments by PREQ_ITEM fields (equal values in the source file : 10-10-10..., 20-20-20,.... etc.) and put all required fields for my LSMW
    SOURCE FIELDS:
    Z_ME51N_V2 - MASS_UPLOAD - CREATE create
    Source Fields
    UPFILE                    upload file
                IDENT                          C(010)    ident
                                               Identifing Field Content: header
                TEXT                           C(001)
                UPFILE2                   123
                    IDENT                          C(010)    ident
                                                   Identifing Field Content: item
                    BSART                          C(004)    Document type
                    BANFN                          C(010)    Purchase requisition number
                    BNFPO_FOR_MAP                  N(005)    Item number of purchase req. for MAPPING acc.
                    BNFPO                          N(005)    Item number of purchase requisition
                    KNTTP                          C(001)    Account assignment category
                    PSTYP                          C(001)    Item category in purchasing document
                    MATNR                          C(018)    Material Number
                    WERKS                          C(004)    Plant
                    LGORT                          C(004)    Storage Location
                    MENGE                          N(013)    Purchase requisition quantity
                    EKGRP                          C(003)    Purchasing group
                    KONNR                          C(010)    Number of principal purchase agreement
                    KTPNR                          N(005)    Item number of principal purchase agreement
                    LIFNR                          C(010)    Desired Vendor
                    FLIEF                          C(010)    Fixed Vendor
                    AFNAM                          C(012)    Name of requisitioner/requester
                    PREIS                          AMT4(011) Price in purchase requisition
                    ABLAD                          C(025)    Unloading Point
                    WEMPF                          C(012)    Goods Recipient
                    PS_POSID                       C(024)    Work Breakdown Structure Element (WBS Element)
                    KOSTL                          C(011)    COST_CTR v bapito ?
                    NAME1                          C(040)    Name1 - Name of an address
                    NAME2                          C(040)    Name2 - Name of an address 2
                    STREET                         C(060)    Street
                    DELIVERY_DATE                  C(008)    Date on which the goods are to be delivered
                    TEXT                           C(132)    item text
    STRUCTURE RELATIONS :
    Structure Relations
    E1PREQCR              Header segment                                               <<<< UPFILE  upload file
               E1BPEBANC             Transfer Structure: Create Requisition Item                  <<<< UPFILE2 123
               E1BPEBKN              Transfer Structure: Create/Display Requisition Acct Assgt    <<<< UPFILE2 123
               E1BPEBANTX            BAPI Purchase Requisition: Item Text                         <<<< UPFILE2 123
               E1BPESUHC             Communication Structure: Limits                              <<<< UPFILE2 123
               E1BPESUCC             Communication Structure: Contract Limits                     <<<< UPFILE2 123
               E1BPESLLC             Communication Structure: Create Service Line                 <<<< UPFILE2 123
               E1BPESKLC             Create Comm. Structure: Acct Assgt Distr. for Service Line   <<<< UPFILE2 123
               E1BPESLLTX            BAPI Services Long Text                                      <<<< UPFILE  upload file
               E1BPMERQADDRDELIVERY  PO Item: Address Structure BAPIADDR1 for Inbound Delivery    <<<< UPFILE2 123
                   E1BPMERQADDRDELIVERY1 PO Item: Address Structure BAPIADDR1 for Inbound Delivery    <<<< UPFILE2 123
               E1BPPAREX             Ref. Structure for BAPI Parameter EXTENSIONIN/EXTENSIONOUT   <<<< UPFILE2 123
    MAINTAIN FIELD MAPPING AND... :
    the MAPPING between two IDOC`s segments:
    In first segment:
    E1BPEBANC                      Transfer Structure: Create Requisition Item
             Fields
                 PREQ_NO                      Purchase requisition number
                                     Source:  UPFILE2-BANFN (Purchase requisition number)
                                     Rule :   Transfer (MOVE)
                                     Code:    E1BPEBANC-PREQ_NO = UPFILE2-BANFN.
                 PREQ_ITEM                    Item number of purchase requisition
                                     Source:  UPFILE2-BNFPO (Item number of purchase requisition)
                                     Rule :   Transfer (MOVE)
                                     Code:    E1BPEBANC-PREQ_ITEM = UPFILE2-BNFPO.
    In second segment :
    E1BPEBKN                       Transfer Structure: Create/Display Requisition Acct Assgt
               Fields
                   PREQ_NO                      Purchase requisition number
                   PREQ_ITEM                    Item number of purchase requisition
                                       Source:  UPFILE2-BNFPO_FOR_MAP (Item number of purchase req. for MAPPING
                                       Rule :   Transfer (MOVE)
                                       Code:    E1BPEBKN-PREQ_ITEM = UPFILE2-BNFPO_FOR_MAP.
    After that everything was OK .

  • ACCOUNTING DOCUMENT FOR CONTROLLING DOCUMENT

    Hi Experts,
    I would like to know which table provides me the accounting document for the related Controlling document.
    ie. If i gives a controlling document for a table as an input in SE16 i should get the related accounting document . please help...
    Thanks and regards,
    Anand. K

    GLPCP Plan Line Items
    GLPCT Totals Table
    GLPCA Actual Line Items
    GLPCO  Object Table for Account Assignment Elements
    GLPCC   Transaction Attributes
    Regards,
    Sangram
    Moderator: Irrelevant

  • Search for a String within a document (Word, txt, doc) using JSP, JAVA

    Hi
    I have created a little application that uses combination of JSP and HTML. Users of this application can upload documents which are then stored on the server. I need to develop functionality where I can allows users to search for a string within a document. More precisely, user would type in some string in a text box and application will search all uploaded documents for that string and return the downloadable links to those documents that contains that string. I have never done this before. I was wondering if someone could get me started on this or point me to some thread where this idea is already discussed. Any Jave code exists for searching through documents??
    Thanks for your help
    Riz

    http://www.ibm.com/developerworks/java/library/j-text-searching.html
    http://en.wikipedia.org/wiki/Full_text_search
    Type these parameter in yahoo:+efficient text search
    you will need something like openoffice library to read microsoft word document.

  • How to search for upper/lower case using string using JAVA!!!?

    -I am trying to write a program that will examine each letter in the string and count how many time the upper-case letter 'E' appears, and how many times the lower-case letter 'e' appears.
    -I also have to use a JOptionPane.showMessageDialog() to tell the user how many upper and lower case e's were in the string.
    -This will be repeated until the user types the word "Stop". 
    please help if you can
    what i have so far:
    [code]
    public class Project0 {
    public static void main(String[] args) {
      String[] uppercase = {'E'};
      String[] lowercase = {'e'};
      String isOrIsNot, inputWord;
      while (true) {
       // This line asks the user for input by popping out a single window
       // with text input
       inputWord = JOptionPane.showInputDialog(null, "Please enter a sentence");
       if ( inputWord.equals("stop") )
        System.exit(0);
       // if the inputWord is contained within uppercase or
       // lowercase return true
       if (wordIsThere(inputWord, lowercase))
        isOrIsNot = "Number of lower case e's: ";
       if (wordIsThere(inputword, uppercase))
         isOrIsNot = "number of upper case e's: ";
       // Output to a JOptionPane window whether the word is on the list or not
       JOptionPane.showMessageDialog(null, "The word " + inputWord + " " + isOrIsNot + " on the list.");
    } //main
    public static boolean wordIsThere(String findMe, String[] theList) {
      for (int i=0; i<theList.length; ++i) {
       if (findMe.equals(theList[i])) return true;
      return false;
    } // wordIsThere
    } // class Lab4Program1
    [/code]

    So what is your question? Do you get any errors? If so, post them. What doesn't work?
    And crossposted: how to search for upper/lower case using string using JAVA!!!?

  • Java API for running entire ".sql" files on a remote DB ( mySQL or Oracle)?

    Hi,
    Would anyone happen to know if there's a java API for executing entire ".sql" files (containing several different SQL commands), on a remote database server ?
    It's enough if the API works with MySQL and/or Oracle.
    Just to demonstrate what i'm looking for:
    Suppose you've created sql file "c:/test.sql" with several script lines:
    -- test.sql:
    insert into TABLE1 values(3,3);
    insert into TABLE1 values(5,5);
    create table TABLE2 (name VARCHER) ENGINE innoDB; -- MYSQL specific
    Then the java API should look something like:
    // Dummy java code:
    String driver="com.mysql.jdbc.Driver";
    String url= "jdbc:mysql://localhost:3306/myDb";
    SomeAPI.executeScriptFile( "c:/test.sql", driver, url);
    Thanks.

    No such a API, but it's easy to parse all sqls in a file, then run those command:
    For instance:
    import java.sql.*;
    import java.util.Properties;
    /* A demo show how to load some sql statements. */
    public class testSQL {
    private final static Object[] getSQLStatements(java.util.Vector v) {
    Object[] statements = new Object[v.size()];
    Object temp;
    for (int i = 0; i < v.size(); i++) {
    temp = v.elementAt(i);
    if (temp instanceof java.util.Vector)
    statements[i] = getSQLStatements( (java.util.Vector) temp);
    else
    statements[i] = temp;
    return statements;
    public final static Object[] getSQLStatements(String sqlFile) throws java.
    io.IOException {
    java.util.Vector v = new java.util.Vector(1000);
    try {
    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.
    FileReader(sqlFile));
    java.util.Vector batchs = new java.util.Vector(10);
    String temp;
    while ( (temp = br.readLine()) != null) {
    temp = temp.trim();
    if (temp.length() == 0)
    continue;
    switch (temp.charAt(0)) {
    case '*':
    case '"':
    case '\'':
    // System.out.println(temp);
    break; //Ignore any line which begin with the above character
    case '#': //Used to begin a new sql statement
    if (batchs.size() > 0) {
    v.addElement(getSQLStatements(batchs));
    batchs.removeAllElements();
    break;
    case 'S':
    case 's':
    case '?':
    if (batchs.size() > 0) {
    v.addElement(getSQLStatements(batchs));
    batchs.removeAllElements();
    v.addElement(temp);
    break;
    case '!': //Use it to get a large number of simple update statements
    if (batchs.size() > 0) {
    v.addElement(getSQLStatements(batchs));
    batchs.removeAllElements();
    String part1 = temp.substring(1);
    String part2 = br.readLine();
    for (int i = -2890; i < 1388; i += 39)
    batchs.addElement(part1 + i + part2);
    for (int i = 1890; i < 2388; i += 53) {
    batchs.addElement(part1 + i + part2);
    batchs.addElement(part1 + i + part2);
    for (int i = 4320; i > 4268; i--) {
    batchs.addElement(part1 + i + part2);
    batchs.addElement(part1 + i + part2);
    for (int i = 9389; i > 7388; i -= 83)
    batchs.addElement(part1 + i + part2);
    v.addElement(getSQLStatements(batchs));
    batchs.removeAllElements();
    break;
    default:
    batchs.addElement(temp);
    break;
    if (batchs.size() > 0) {
    v.addElement(getSQLStatements(batchs));
    batchs.removeAllElements();
    br.close();
    br = null;
    catch (java.io.FileNotFoundException fnfe) {
    v.addElement(sqlFile); //sqlFile is a sql command, not a file Name
    Object[] statements = new Object[v.size()];
    for (int i = 0; i < v.size(); i++)
    statements[i] = v.elementAt(i);
    return statements;
    public static void main(String argv[]) {
    try {
    String url;
    Object[] statements;
    switch (argv.length) {
    case 0: //Use it for the simplest test
    case 1:
    url = "jdbc:dbf:/.";
    if (argv.length == 0) {
    statements = new String[1];
    statements[0] = "select * from test";
    else
    statements = argv;
    break;
    case 2:
    url = argv[0];
    statements = getSQLStatements(argv[1]);
    break;
    default:
    throw new Exception(
    "Syntax Error: java testSQL url sqlfile");
    Class.forName("com.hxtt.sql.dbf.DBFDriver").newInstance();
    //Please see Connecting to the Database section of Chapter 2. Installation in Development Document
    Properties properties = new Properties();
    Connection con = DriverManager.getConnection(url, properties);
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    //Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    // stmt.setMaxRows(0);
    stmt.setFetchSize(10);
    final boolean serializeFlag = false;//A test switch to serialize/deserialize the resultSet
    ResultSet rs;
    for (int i = 0; i < statements.length; i++) {
    if (statements[i] instanceof java.lang.String) {
    String temp = (java.lang.String) statements;
    switch (temp.charAt(0)) {
    case 'S':
    case 's':
    case '?':
    System.out.println(temp);
    rs = stmt.executeQuery(temp);
    if (serializeFlag) {
    // serialize the resultSet
    try {
    java.io.FileOutputStream fileOutputStream = new
    java.io.FileOutputStream("testrs.tmp");
    java.io.ObjectOutputStream
    objectOutputStream = new java.io.
    ObjectOutputStream(fileOutputStream);
    objectOutputStream.writeObject(rs);
    objectOutputStream.flush();
    objectOutputStream.close();
    fileOutputStream.close();
    catch (Exception e) {
    System.out.println(e);
    e.printStackTrace();
    System.exit(1);
    rs.close(); //Let the CONCUR_UPDATABLE resultSet release its open files at once.
    rs = null;
    // deserialize the resultSet
    try {
    java.io.FileInputStream fileInputStream = new
    java.io.FileInputStream("testrs.tmp");
    java.io.ObjectInputStream objectInputStream = new
    java.io.ObjectInputStream(
    fileInputStream);
    rs = (ResultSet) objectInputStream.
    readObject();
    objectInputStream.close();
    fileInputStream.close();
    catch (Exception e) {
    System.out.println(e);
    e.printStackTrace();
    System.exit(1);
    ResultSetMetaData resultSetMetaData = rs.
    getMetaData();
    int iNumCols = resultSetMetaData.getColumnCount();
    for (int j = 1; j <= iNumCols; j++) {
    // System.out.println(resultSetMetaData.getColumnName(j));
    /* System.out.println(resultSetMetaData.getColumnType(j));
    System.out.println(resultSetMetaData.getColumnDisplaySize(j));
    System.out.println(resultSetMetaData.getPrecision(j));
    System.out.println(resultSetMetaData.getScale(j));
    System.out.println(resultSetMetaData.
    getColumnLabel(j)
    + " " +
    resultSetMetaData.getColumnTypeName(j));
    Object colval;
    rs.beforeFirst();
    long ncount = 0;
    while (rs.next()) {
    // System.out.print(rs.rowDeleted()+" ");
    ncount++;
    for (int j = 1; j <= iNumCols; j++) {
    colval = rs.getObject(j);
    System.out.print(colval + " ");
    System.out.println();
    rs.close(); //Let the resultSet release its open tables at once.
    rs = null;
    System.out.println(
    "The total row number of resultset: " + ncount);
    System.out.println();
    break;
    default:
    int updateCount = stmt.executeUpdate(temp);
    System.out.println(temp + " : " + updateCount);
    System.out.println();
    else if (statements[i] instanceof java.lang.Object[]) {
    int[] updateCounts;
    Object[] temp = (java.lang.Object[]) statements[i];
    try {
    for (int j = 0; j < temp.length; j++){
    System.out.println( temp[j]);
    stmt.addBatch( (java.lang.String) temp[j]);
    updateCounts = stmt.executeBatch();
    for (int j = 0; j < temp.length; j++)
    System.out.println((j+1)+":"+temp[j]);
    for (int j = 0; j < updateCounts.length; j++)
    System.out.println((j+1)+":" +updateCounts[j]);
    catch (java.sql.BatchUpdateException e) {
    updateCounts = e.getUpdateCounts();
    for (int j = 0; j < updateCounts.length; j++)
    System.out.println((j+1)+":"+updateCounts[j]);
    java.sql.SQLException sqle = e;
    do {
    System.out.println(sqle.getMessage());
    System.out.println("Error Code:" +
    sqle.getErrorCode());
    System.out.println("SQL State:" + sqle.getSQLState());
    sqle.printStackTrace();
    while ( (sqle = sqle.getNextException()) != null);
    catch (java.sql.SQLException sqle) {
    do {
    System.out.println(sqle.getMessage());
    System.out.println("Error Code:" +
    sqle.getErrorCode());
    System.out.println("SQL State:" + sqle.getSQLState());
    sqle.printStackTrace();
    while ( (sqle = sqle.getNextException()) != null);
    stmt.clearBatch();
    System.out.println();
    stmt.close();
    con.close();
    catch (SQLException sqle) {
    do {
    System.out.println(sqle.getMessage());
    System.out.println("Error Code:" + sqle.getErrorCode());
    System.out.println("SQL State:" + sqle.getSQLState());
    sqle.printStackTrace();
    while ( (sqle = sqle.getNextException()) != null);
    catch (Exception e) {
    System.out.println(e.getMessage());
    e.printStackTrace();

  • Java Mapping for JDBC Interface

    Hi,
    please help on java mapping for my jdbc interface.
    my java code for jdbc is:
    Created on May 7, 2008
    TODO To change the template for this generated file go to
    Window - Preferences - Java - Code Style - Code Templates
    package XiMappingDB2.com.xi.test;
    @author miracle
    TODO To change the template for this generated type comment go to
    Window - Preferences - Java - Code Style - Code Templates
    Created on May 2, 2008
    To change the template for this generated file go to
    Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    package com.xi.test;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.util.HashMap;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.MappingTrace;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.StreamTransformationException;
    @author kotla
    To change the template for this generated type comment go to
    Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    public class NameMerge implements StreamTransformation  {
         private Map param = null;   
         private MappingTrace trace = null;
         public void setParameter(Map param){       
         this.param = param;
         if (param == null) { 
         this.param = new HashMap();
         public void execute(InputStream input, OutputStream output)      
         throws StreamTransformationException {
         AbstractTrace trace = null;     
         String RESULT = new String();
         trace =      
         (AbstractTrace) param.get(             
         StreamTransformationConstants.MAPPING_TRACE);
         try {          
        //Create DOM parser
        DocumentBuilderFactory factory =   
        DocumentBuilderFactory.newInstance();     
        DocumentBuilder builder = factory.newDocumentBuilder();
         //Parse input to create document tree
         Document doc = builder.parse(input);
                    trace.addInfo(doc.toString());
          //          Map the elements          
        Node root = doc.getFirstChild(); // gets the root element
         NodeList children = root.getChildNodes();
          for (int item = 0; item < children.getLength(); item++) {
          if (children.item(item) instanceof Element) {
          root = (Element) children.item(item);
          NodeList ch = root.getChildNodes();
          RESULT = RESULT.concat(ch.item(0).getNodeValue() + " ");
          trace.addInfo(RESULT); }
          catch (Exception e) {           
               trace.addDebugMessage(e.getMessage());      
       //Return the output document
       String document_exit = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:Person2 xmlns:ns0=\"urn:xxxxx.com:test:mapping:lookups\"><RESULT>" 
       + RESULT               
       + "</RESULT></ns0:Person2>";
         insertDB(RESULT);
       try
            output.write(document_exit.getBytes());
             catch (IOException e1) {
            trace.addDebugMessage(e1.getMessage());
    public void insertDB(String DETAILS){
        Statement stmt = null;
        Connection conn = null;
        try {
          conn = getConnection();
          conn.setAutoCommit(false);
          stmt = conn.createStatement();
          stmt.execute("insert into KUMAR(DETAILS) values ('"DETAILS"')");
          //System.out.println ('"DETAILS"');
          conn.commit();
          stmt.close();   
          conn.close();
        } catch (Exception e) {
          System.err.println("Error: " + e.getMessage());
          e.printStackTrace();
      public Connection getConnection() throws Exception {
        String driver = "com.ibm.db2.jcc.DB2Driver";
        String url = "jdbc:db2://172.17.4.24:50000/SAMPLE";
        String username = "miracle";
        String password = "sairam";
        Class.forName(driver);
        Connection conn = DriverManager.getConnection(url, username, password);
        return conn;
    but we are getting the following error:Linkage error occurred when loading class JavaDatabaseApp/XiMappingDB2/com/xi/test/NameMerge (http://FILE2JDBC_US, 7d7b3141-f4d1-11dc-b25e-d5d5c0a80198, -1)
    Start of test
    LinkageError at JavaMapping.load(): Could not load class: JavaDatabaseApp/XiMappingDB2/com/xi/test/NameMerge
    java.lang.NoClassDefFoundError: JavaDatabaseApp/XiMappingDB2/com/xi/test/NameMerge (wrong name: XiMappingDB2/com/xi/test/NameMerge) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:539) at java.lang.ClassLoader.defineClass(ClassLoader.java:448) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingLoader.findClass(RepMappingLoader.java:175) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at com.sap.aii.ibrep.server.mapping.ibrun.RepJavaMapping.load(RepJavaMapping.java:136) at com.sap.aii.ibrep.server.mapping.ibrun.RepJavaMapping.execute(RepJavaMapping.java:50) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170).
    please solve this issue.

    Uday,
    May be you have uploaded class file into external definitions.
    You need to Zip the class file into .jar  and then upload into external definitions of integration repository
    Regards,
    Kiran Bobbala

  • Inserting an element into an XML document

    I am simply looking insert a new element into an existing XML Document using JDOM. Here is my code so far:
    public class UserDocumentWriter {
         private SAXBuilder builder;
         private Document document;
         private File file = new File("/path/to/file/users.xml");
         private Element rootElement;
         public UserDocumentWriter() {
              builder = new SAXBuilder();
              try {
                   document = builder.build(file);
                   rootElement = document.getRootElement();
              } catch (IOException ioe) {
                   System.err.println("ERROR: Could not build the XML file.");
              } catch (JDOMException jde) {
                   System.err.println("ERROR: " + file.toString() + " is not well-formed.");
         public void addContact(String address, String contact) {
              List contactList = null;
              Element contactListElement;
              Element newContactElement = new Element("contact");
              newContactElement.setText(contact);
              List rootsChildren = rootElement.getChildren();
              Iterator iterator = rootsChildren.iterator();
              while (iterator.hasNext()) {
                   Element e = (Element) iterator.next();
                   if (e.getAttributeValue("address").equals(address)) {
                        contactListElement = e.getChild("contactlist");
                        contactListElement.addContent(newContactElement);
                        writeDocument(document);
         public void writeDocument(Document doc) {
              try {
                   XMLOutputter output = new XMLOutputter();
                   OutputStream out = new FileOutputStream(file);
                   output.output(doc, out);
              } catch (FileNotFoundException ntfe) {
                   System.err.println("ERROR: Output file not found.");
              } catch (IOException ioe) {
                   System.err.println("Could not output document changes.");
         }However, the problem is, the newly added element will always be appended to the end of the last line, resulting in the following:
    <contactlist>
                <contact>[email protected]</contact><contact>[email protected]</contact></contactlist>Is there anyway in which I can have the newly added element create it's own line for the purpose of tidy XML? Alternatively is there a better methodology to do the above entirely?

    Your question is not very clear.
    Do you want to know How to insert an element into an XML document?
    Answer: I can see you already know how to do it. You have added the element using addContent()
    or do you want to know How to display the XML in a tidy format?
    Answer: to view the XML in a properly formatted style you can you the Format class. A very basic way of viewing the XML would be:
       * Prints the Document to the specified file.
       * @param doc
       * @param filename
       * @param formatting
      public static void printDocToFile(Document doc, String strFileName,
          boolean formatting)
        XMLOutputter xmlOut = null;
        if (!formatting)
          xmlOut = new XMLOutputter();
        } else
          Format prettyFormat = Format.getPrettyFormat();
          prettyFormat.setOmitEncoding(false);
          prettyFormat.setOmitDeclaration(false);
          xmlOut = new XMLOutputter(prettyFormat);
        try
          if (doc != null)
            FileWriter writer = new java.io.FileWriter(strFileName, true);
            xmlOut.output(doc, writer);
            writer.flush();
            writer.close();
          } else
            System.out.println("Document is null.");
        catch (Exception ex)
          System.out.println(ex);
      }

  • Error in Java Mapping for Single XML conversion

    We are working on ABAP Proxy --> SAP PI 7.1 --> SOAP (Synchronous Scenario).
    (ECC -> PI -> Legacy CRM)
    Client has provided a WSDL with Single Node of XML and asking us to pass the whole structure as an single string along with all the nodes of data structure. To perform mapping we are using Java Mapping.
    Message which we are getting after Java Mapping:
    Input
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_SOReject_Sender xmlns:ns0="http://MTSINDIA/TC/SalesOrderReject">
       <ITEM>
          <sSlsOrderCode>1001</sSlsOrderCode>
          <sDlrCode>A250</sDlrCode>
          <sRejectReason>Z2</sRejectReason>
          <nCircleCode>2</nCircleCode>
       </ITEM>
    </ns0:MT_SOReject_Sender>
    Output
    <?xml version="1.0" encoding="UTF-8"?><MT_Trg xmlns:ns="urn:Test_File_to_File"><stringinp>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;ns0:MT_SOReject_Sender xmlns:ns0="http://MTSINDIA/TC/SalesOrderReject"&gt;&lt;ITEM&gt;&lt;sSlsOrderCode&gt;1001&lt;/sSlsOrderCode&gt;&lt;sDlrCode&gt;A250&lt;/sDlrCode&gt;&lt;sRejectReason&gt;Insufficient Stock Balance&lt;/sRejectReason&gt;&lt;nCircleCode&gt;2&lt;/nCircleCode&gt;&lt;/ITEM&gt;&lt;/ns0:MT_SOReject_Sender&gt;</stringinp></MT_Trg>
    Is ther any way from which we can convert &gt; as u201C>u201D and &lt; as u201C<u201D.  Required result is as follows
    Required Output
    <?xml version="1.0" encoding="UTF-8"?><MT_Trg xmlns:ns="urn:Test_File_to_File"><stringinp><?xml version="1.0" encoding="UTF-8"?><ns0:MT_SOReject_Sender xmlns:ns0="http://MTSINDIA/TC/SalesOrderReject"><ITEM><sSlsOrderCode>1001</sSlsOrderCode><sDlrCode>A250</sDlrCode><sRejectReason>Insufficient Stock Balance</sRejectReason><nCircleCode>2</nCircleCode></ITEM></ns0:MT_SOReject_Sender></stringinp></MT_Trg>
    We are using following Java Code for the same.
    import java.io.BufferedReader;
              import java.io.FileInputStream;
              import java.io.FileOutputStream;
              import java.io.InputStream;
              import java.io.InputStreamReader;
              import java.io.OutputStream;
              import java.util.Map;
              import javax.xml.parsers.DocumentBuilder;
              import javax.xml.parsers.DocumentBuilderFactory;
              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.Element;
              import org.w3c.dom.Document;
              import org.w3c.dom.Text;
              import com.sap.aii.mapping.api.*;
              import com.sap.aii.mapping.api.StreamTransformation;
    public class SingleStr implements StreamTransformation{
          * @author user
          * To change the template for this generated type comment go to
          * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
                    public static void main(String args[]) throws Exception {
                FileInputStream inFile =
                 new FileInputStream("C:/Documents and Settings/user.HR0102WILT00033/Desktop/Input.XML");
                FileOutputStream outFile =
                 new FileOutputStream("C:/Documents and Settings/user.HR0102WILT00033/Desktop/Output.XML");
                 SingleStr xml = new SingleStr();
                xml.execute(inFile, outFile);
                System.out.println("Success");
               public void setParameter(Map param) {
                Map map = param;
               public void execute(InputStream in, OutputStream out)
                throws com.sap.aii.mapping.api.StreamTransformationException {
                try {
                 //************************Code To Generate The XML Parsing Objects*****************************//    
                 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                 DocumentBuilder db = dbf.newDocumentBuilder();
                 TransformerFactory tf = TransformerFactory.newInstance();
                 Transformer transform = tf.newTransformer();
                 //Document doc = db.parse(in);
                 Document docout = db.newDocument();
                 Element root = docout.createElement("MT_Trg");
                 root.setAttribute("xmlns:ns","urn:Test_File_to_File");
                 docout.appendChild(root);
                 Element stringinp = docout.createElement("stringinp");
                 root.appendChild(stringinp);
                 BufferedReader inpxml = new BufferedReader(new InputStreamReader(in));
                 StringBuffer buffer = new StringBuffer();
                 String line="";
                 while ((line = inpxml.readLine()) != null)
                 buffer.append(line);
                 String inptxml=buffer.toString();
                 Text srcxml = docout.createTextNode(inptxml);
                 stringinp.appendChild(srcxml);
                 DOMSource domS = new DOMSource(docout);
                 transform.transform((domS), new StreamResult(out));
                 } catch (Exception e) {
                   System.out.print("Problem parsing the file: " + e.getMessage());
                   e.printStackTrace();
    Please help!!

    We are using following Java Code for the same.
    import java.io.BufferedReader;
              import java.io.FileInputStream;
              import java.io.FileOutputStream;
              import java.io.InputStream;
              import java.io.InputStreamReader;
              import java.io.OutputStream;
              import java.util.Map;
              import javax.xml.parsers.DocumentBuilder;
              import javax.xml.parsers.DocumentBuilderFactory;
              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.Element;
              import org.w3c.dom.Document;
              import org.w3c.dom.Text;
              import com.sap.aii.mapping.api.*;
              import com.sap.aii.mapping.api.StreamTransformation;
    public class SingleStr implements StreamTransformation{
               public static void main(String args[]) throws Exception {
                FileInputStream inFile =
                 new FileInputStream("C:/Documents and Settings/user.HR0102WILT00033/Desktop/Input.XML");
                FileOutputStream outFile =
                 new FileOutputStream("C:/Documents and Settings/user.HR0102WILT00033/Desktop/Output.XML");
                 SingleStr xml = new SingleStr();
                xml.execute(inFile, outFile);
                System.out.println("Success");
               public void setParameter(Map param) {
                Map map = param;
               public void execute(InputStream in, OutputStream out)
                throws com.sap.aii.mapping.api.StreamTransformationException {
                try {
                 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                 DocumentBuilder db = dbf.newDocumentBuilder();
                 TransformerFactory tf = TransformerFactory.newInstance();
                 Transformer transform = tf.newTransformer();
                 //Document doc = db.parse(in);
                 Document docout = db.newDocument();
                 Element root = docout.createElement("MT_Trg");
                 root.setAttribute("xmlns:ns","urn:Test_File_to_File");
                 docout.appendChild(root);
                 Element stringinp = docout.createElement("stringinp");
                 root.appendChild(stringinp);
                 BufferedReader inpxml = new BufferedReader(new InputStreamReader(in));
                 StringBuffer buffer = new StringBuffer();
                 String line="";
                 while ((line = inpxml.readLine()) != null)
                 buffer.append(line);
                 String inptxml=buffer.toString();
                 Text srcxml = docout.createTextNode(inptxml);
                 stringinp.appendChild(srcxml);
                 DOMSource domS = new DOMSource(docout);
                 transform.transform((domS), new StreamResult(out));
                 } catch (Exception e) {
                   System.out.print("Problem parsing the file: " + e.getMessage());
                   e.printStackTrace();
    Please help!!

  • Image not displayed in pdf generated using Java API for Forms service

    Hi,
    I am creating a pdf document using Java API for Forms Service.
    I am able to generate the pdf but the images are not visible in the generated pdf.
    The image relative path is coming in the xml as defined below. The images are stored dynamically in the Livecycle repository each time a request is fired with unique name before the xml is generated.
    <imageURI xfa:contentType="image/png" href="../Images/logo.png"></imageURI>
    Not sure if I need to specify specify specific URI values that are required to render a form with image.
    The same thing is working when I generate pdf document using Java API for Output Service.
    As, I need to generate interactive form, I have to use Forms service to generate pdfs.
    Any help will be highly appreciated.
    Thanks.

    Below is the code snippet:
                //Create a FormsServiceClient object
                FormsServiceClient formsClient = new FormsServiceClient(myFactory);
                //Specify URI values that are required to render a form
                URLSpec uriValues = new URLSpec();
                                  // Template location contains the whole rpository path for the form
                uriValues.setContentRootURI(templateLocation);
               // The base URL where form resources such as images and scripts are located.  Whole Image path is passed in BaseUrl in the http format.
                      String baseLocation = repositoryPath.concat(serviceName).concat(imagesPath);   
                                  uriValues.setBaseURL(baseLocation);                                        
                // Set run-time options using a PDFFormRenderSpec instance
                PDFFormRenderSpec pdfFormRenderSpec = new PDFFormRenderSpec();
                pdfFormRenderSpec.setCacheEnabled(new Boolean(true));           
                pdfFormRenderSpec.setAcrobatVersion(com.adobe.livecycle.formsservice.client.AcrobatVersio n.Acrobat_8);
                                  //Invoke the renderPDFForm method and write the
                //results to a client web browser
                String tempTemplateName =templateName;
                FormsResult formOut = formsClient.renderPDFForm(tempTemplateName,
                                              inXMDataTransformed,pdfFormRenderSpec,uriValues,null);
                //Create a Document object that stores form data
                Document outputDocument = formOut.getOutputContent();
                InputStream inputStream = outputDocument.getInputStream();

Maybe you are looking for

  • Process empty file : file (fcc) to rfc

    Hi Experts, I have a scenario where. I have to process files and send it to rfc.. file to rfc scenario... now basically.. when the file is empty the content conversion does not produce any payload and throws error.. can u pls help me in this?

  • Where can I view all the presentation variables

    Hi, I have a question..... how can we see all the presentation variables defined ( created ) in answers/dashboards..? like if we want to see all the repository variable/session variables..we can see those in BI Admin Tool... from >manage>variable...

  • Digital Scrapbooking - Changing page sizes  Elements 4

    I downloaded a "paper" from a disgital scrapbooking web site, to be used as a background for creating a digital scrapbook page. The paper was 12 X 12 in. Is there a way for me to convert it to a 8 X 11.5 in. in the Elements workplace? I tried to resi

  • Voice deployment design help required

    Hi All, We have a scenario in which I need to design a voice deployment solution. The scenario is that we have multiple CUCM v9 clusters interconnected with a CUCM Session manager in Europe. In Asia we have more number of clusters (Cisco CM clusters,

  • When is the release date for the 5th generation iPod touch

    When is the release date for the 5th generation iPod touch?