XSLT mapping calls Java class, with hardcoded values-problem at Transport

Hi All,
I know the subject may be  misguiding, but i need some suggestions how to handle the following scenario.
From my XSLT mapping, i am calling a java function which performs a data connection to an oracle database and then returns some values, whcih i have mapped in the mapping.
The problem is, i have hardcoded the Connection parameters....
and now that we transport these objects to production, the connection parameters will change.
I thought of two solutions
1) i create a new java class for Production system
2) i define the parameters as input arguemnts to my method, whcih is called from XSLT mapping
But in both cases, if theres any chg in future, there will a dependancy on one of the objects to be changed and sent again.
What is the suggested way? is there nothing like a property file(like in EP), where you define dependant parameters...and the file is only changed.
XI Gurus, please suggest me the correct way to handle.....
Thanks a lot.
Mona

Mona,
This is what i do..
1) Parametrize ur current calling class,
2) define a separate class called dbConnect.java there, you have all your parameters that way when there is a change your main program is untouched, and you just need to change the dbconnect.
The call from your current class will be just like
dbConnect.Runsql("sql as a string");
the runSql can then internally call
dbConnect().connect(); //that should do the connection opening.
then create a prepared statement from your string input and call the db.......
this is the implementation that would be best suited for your scenario, you can further parametrize the method to where you can add the database params from the calling xml..so all that needs to be done when the machine is changed or any param is changed is ..modify the xml........not too bad was that.....
Regards
Ravi

Similar Messages

  • Java Error in RFC Lookup in XSLT Mapping usinf Java helper class

    Hi All,
    I am doing RFC Lookup in XSLT Mapping using Java Helper class.
    The Lookup works fine when called one RFC at a time However my requirement is I want to do 2 Lookups.
    Both Lookups works when done individually however when I call both lookups in one mapping I get following error "javax.xml.transform.TransformerException: DOMSource whose Node is null."
    Following is the code I have written in XSLT for the lookup:
         <xsl:template name="Lookup_1">
              <xsl:param name="STDPN"/>
                   <rfc:RFC_READ_TABLE>
                        <QUERY_TABLE>KNA1</QUERY_TABLE>
                        <OPTIONS><item><TEXT>
                                  <xsl:value-of select="$STDPN"/>
                             </TEXT></item>
                        </OPTIONS>
                        <FIELDS>
                             <item>
                                  <FIELDNAME>KUNNR</FIELDNAME>
                             </item>
                        </FIELDS>
                   </rfc:RFC_READ_TABLE>
              </xsl:variable>
              <xsl:variable name="response" xmlns:lookup="java:urn.mt.pi" select="lookup:execute($request, 'BS_D, 'cc_RfcLookup', $inputparam)"/>
              <xsl:element name="STDPN">
                   <xsl:value-of select="$response//DATA/item/WA"/>
              </xsl:element>
         </xsl:template>
         <xsl:template name="Lookup_2">
              <xsl:param name="BELNR"/>
                   <xsl:variable name="Query">AGMNT = '<xsl:value-of select="$BELNR"/>'</xsl:variable>
                   <xsl:variable name="request1">
                        <rfc:RFC_READ_TABLE>
                             <QUERY_TABLE>ZTABLE</QUERY_TABLE>
                             <OPTIONS><item><TEXT>
                                  <xsl:value-of select="$Query"/>
                                  </TEXT></item>
                             </OPTIONS>
                             <FIELDS>
                                  <item>
                                       <FIELDNAME>KUNAG</FIELDNAME>
                                  </item>
                             </FIELDS>
                        </rfc:RFC_READ_TABLE>
                   </xsl:variable>
                   <xsl:variable name="response1" xmlns:lookup="java:urn.mt.pi" select="lookup:execute($request1, 'BS_D','cc_RfcLookup', $inputparam)"/>
                   <xsl:element name="BELNR">
                        <xsl:value-of select="$response1//DATA/item/WA"/>
                   </xsl:element>
         </xsl:template>
    My Question: Am I doing anything wrong? Or Is it possible to call multiple lookups in one XSLT?
    Thanks and Regards,
    Atul

    Hi Atul,
    I had the same problem like you had.
    The main Problem is that with the example code the request variable is created as NodeList object. In XSLT a variable is somekind of a constant and can't be changed. As the request object is empty after the first request the programm fails at the following line:
    Source source = new DOMSource(request.item(0));
    So I've created a workaround for this problem.
    In the call of the template I've put the request as a parameter object at the template call:
    <xsl:with-param name="req">
    <rfc:PLM_EXPLORE_BILL_OF_MATERIAL xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
      <APPLICATION>Z001</APPLICATION>
      <FLAG_NEW_EXPLOSION>X</FLAG_NEW_EXPLOSION>
      <MATERIALNUMBER><xsl:value-of select="value"/></MATERIALNUMBER>
      <PLANT>FSD0</PLANT>
      <VALIDFROM><xsl:value-of select="//Recordset/Row[name='DTM-031']/value"/></VALIDFROM>
      <BOMITEM_DATA/>
    </rfc:PLM_EXPLORE_BILL_OF_MATERIAL>
    </xsl:with-param>
    With this change the request will be provided as a String object and not as a NodeList object.
    Afterwards the RfcLookup.java has to be changed to the following:
    package com.franke.mappings;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Source;
    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.Node;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.lookup.Channel;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.lookup.RfcAccessor;
    import com.sap.aii.mapping.lookup.LookupService;
    import com.sap.aii.mapping.lookup.XmlPayload;
    * @author Thorsten Nordholm Søbirk, AppliCon A/S
    * Helper class for using the XI Lookup API with XSLT mappings for calling RFCs.
    * The class is generic in that it can be used to call any remote-enabled
    * function module in R/3. Generation of the XML request document and parsing of
    * the XML response is left to the stylesheet, where this can be done in a very
    * natural manner.
    * TD:
    * Changed the class that request is sent as String, because of IndexOutOfBound-exception
    * When sending multiple requests in one XSLT mapping.
    public class RfcLookup {
         * Execute RFC lookup.
         * @param request RFC request - TD: changed to String
         * @param service name of service
         * @param channelName name of communication channel
         * @param inputParam mapping parameters
         * @return Node containing RFC response
         public static Node execute( String request,
                 String service,
                 String channelName,
                 Map inputParam)
              AbstractTrace trace = (AbstractTrace) inputParam.get(StreamTransformationConstants.MAPPING_TRACE);
              Node responseNode = null;
              try {
                  // Get channel and accessor
                  Channel channel = LookupService.getChannel(service, channelName);
                  RfcAccessor accessor = LookupService.getRfcAccessor(channel);
                   // Serialise request NodeList - TD: Not needed anymore as request is String
                   /*TransformerFactory factory = TransformerFactory.newInstance();
                   Transformer transformer = factory.newTransformer();
                   Source source = new DOMSource(request.item(0));
                   ByteArrayOutputStream baos = new ByteArrayOutputStream();
                   StreamResult streamResult = new StreamResult(baos);
                   transformer.transform(source, streamResult);*/
                    // TD: Add xml header and remove linefeeds for the request string
                    request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+request.replaceAll("[\r\n]+", ""); 
                    // TD: Get byte Array from request String to send afterwards
                    byte[] requestBytes = request.getBytes();
                   // TD: Not used anymore as request is String
                    //byte[] requestBytes = baos.toByteArray();
                    trace.addDebugMessage("RFC Request: " + new String(requestBytes));
                    // Create input stream representing the function module request message
                    InputStream inputStream = new ByteArrayInputStream(requestBytes);
                    // Create XmlPayload
                    XmlPayload requestPayload =LookupService.getXmlPayload(inputStream);
                    // Execute lookup
                    XmlPayload responsePayload = accessor.call(requestPayload);
                    InputStream responseStream = responsePayload.getContent();
                    TeeInputStream tee = new TeeInputStream(responseStream);
                    // Create DOM tree for response
                    DocumentBuilder docBuilder =DocumentBuilderFactory.newInstance().newDocumentBuilder();
                    Document document = docBuilder.parse(tee);
                    trace.addDebugMessage("RFC Response: " + tee.getStringContent());
                    responseNode = document.getFirstChild();
              } catch (Throwable t) {
                   StringWriter sw = new StringWriter();
                   t.printStackTrace(new PrintWriter(sw));
                   trace.addWarning(sw.toString());
              return responseNode;
         * Helper class which collects stream input while reading.
         static class TeeInputStream extends InputStream {
               private ByteArrayOutputStream baos;
               private InputStream wrappedInputStream;
               TeeInputStream(InputStream inputStream) {
                    baos = new ByteArrayOutputStream();
                    wrappedInputStream = inputStream;
               * @return stream content as String
               String getStringContent() {
                    return baos.toString();
              /* (non-Javadoc)
              * @see java.io.InputStream#read()
              public int read() throws IOException {
                   int r = wrappedInputStream.read();
                   baos.write(r);
                   return r;
    Then you need to compile and upload this class and it should work.
    I hope that this helps you.
    Best regards
    Till

  • How to display value from java class with output generated with toplink

    i hava a requirement of displaying (distance ie calculated in java class) with output generated by query.
    ie if output is like
    school name (distance)
    physical address
    here the school name and physical address are retrived from database.

    Hi,
    ValueHolders are used by the JSF internal framework. To work with an object (attributes) in a managed bean you don't need to make it returning a value holder.
    Create a POJO, provide accessor methods and register it as a managed bean. Access it from JSF with EL
    Frank

  • How to call java class file from jsp

    hi
    we need to call java classes (which are written separately in .java file )from jsp file. we need it for our project if anyone knows about please reply us.
    bye
    siva sankari

    you can call the methods in a lot of ways. you could use scriptlets with the
    <%@ page import="package.class"%> and then inside instantiate an object
    <%
         MyClass mc = new MyClass(parameters if any);
         mc.theMethodYouWantToCall();
    %>or as Madathil has stated,
    or use the JSP tags
    <jsp:useBean id="anyname" class="classname"/>and then use the getProperty tag
    or even Custom Tags

  • Parameterized queries running much slower than ones with hardcoded values

    Very often there is a huge performance difference when using parameters in a query, compared to running the same code after replacing the parameters with hardcoded values: the parameterized version of the code runs much slower!
    The case is not parameter sniffing as it is not a (compiled) stored proc, but code executed directly from the editor and the performance issue has been observed in different versions of SQL Server (2000 and 2005).
    How is this explained and how can the parameterized queries have similar performance with the hardcoded ones?
    Also, why does this happen in some cases and not always?
    Finally, the same is sometimes the case with stored procs: a very slow running proc speeds up tremendously when running its code directly, instead of calling the procedure --and even faster, according to the previous, when its parameters are replaced with
    hardcoded values 

    >>The case is not parameter sniffing as it is not a (compiled) stored proc, but code executed >>>directly
    from the editor ?>>>and the performance issue has been observed in different >>>versions of SQL Server (2000 and 2005).
    Something like below?
    --SQL Server creates 3 execution plan rather only one
    DBCC FREEPROCCACHE
    GO
    SELECT *
    FROM Sales.SalesOrderHeader
    WHERE SalesOrderID = 56000
    GO
    SELECT * FROM
    AdventureWorks.Sales.SalesOrderHeader WHERE
    SalesOrderID = 56001
    GO
    declare @i int
    set @i = 56004
    SELECT *
    FROM Sales.SalesOrderHeader
    WHERE SalesOrderID = @i
    GO
    select  stats.execution_count AS exec_count, 
    p.size_in_bytes as [size], 
    [sql].[text] as [plan_text]
    from sys.dm_exec_cached_plans p
    outer apply sys.dm_exec_sql_text (p.plan_handle) sql
    join sys.dm_exec_query_stats stats ON stats.plan_handle = p.plan_handle
    GO
    ----This time only (we get parameterization)
    DBCC FREEPROCCACHE
    GO
    EXEC sp_executesql N'SELECT  SUM(LineTotal) AS LineTotal
    FROM Sales.SalesOrderHeader H
    JOIN Sales.SalesOrderDetail D ON D.SalesOrderID = H.SalesOrderID
    WHERE H.SalesOrderID = @SalesOrderID', N'@SalesOrderID INT', 56000
    GO
    EXEC sp_executesql N'SELECT  SUM(LineTotal) AS LineTotal
    FROM Sales.SalesOrderHeader H
    JOIN Sales.SalesOrderDetail D ON D.SalesOrderID = H.SalesOrderID
    WHERE H.SalesOrderID = @SalesOrderID', N'@SalesOrderID INT', 56005
    GO
    select  stats.execution_count AS exec_count, 
    LEFT([sql].[text], 80) as [plan_text]
    from sys.dm_exec_cached_plans p
    outer apply sys.dm_exec_sql_text (p.plan_handle) sql
    join sys.dm_exec_query_stats stats ON stats.plan_handle = p.plan_handle
    GO
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Call Java Class and Methods from ABAP

    Hi
    I install de JCo, But how i can call java class and methods from ABAP?. somebody has an example?
    The tutorial say that's is possible,  but don't explain how do that?
    Thanks.
    Angel G. Hurtado

    If you need only simple java program, you do not need to install JCo. The following codes can call java class.
    DATA: COMMAND TYPE STRING VALUE 'C:\j2sdk1.4.2_08\bin\java',
          DIR TYPE STRING VALUE D:\eclipse\workspace',
          PARAMETER TYPE STRING VALUE 'Helloworld'. "here the name of your java program
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
       EXPORTING
         APPLICATION = COMMAND
         PARAMETER = PARAMETER
         DEFAULT_DIRECTORY = DIR
       MAXIMIZED =
         MINIMIZED = 'X'     "If you need the DOS window to be minimized
      EXCEPTIONS
        CNTL_ERROR = 1
        ERROR_NO_GUI = 2
        BAD_PARAMETER = 3
        FILE_NOT_FOUND = 4
        PATH_NOT_FOUND = 5
        FILE_EXTENSION_UNKNOWN = 6
        ERROR_EXECUTE_FAILED = 7
        OTHERS = 8.
    Tell me if it works.
    Nuno.

  • Link java class with custom taglib in Nitrox

    Hi,
    I am creating a set of Nitrox custom libraries for my company, and I need a tag with the following behavior:
    The tag insert window has to contain a select combo with information retrieved from a file or a database.
    So, my questions are:
    1) How can I call java classes from tlei or tagedit files?
    2) What does it mean the following tag?
    <editor-class>com.m7.wide.struts.tags.tagedit.StrutsSelectTagEditor</editor-class>
    3) What does it mean this other tag?
    <default-bundle>com.m7.wide.struts.resources.html-resources</default-bundle>
    4) Do you have any online documentation about tagedit files and the related classes?
    I am using Eclipse 3.1 and Nitrox 3.0.0 M2
    Thanks in advance,
    Alberto

    The Workshop Java API for tag customization is not public for the time being, sorry for the inconvenience.

  • How to call java class from pl/sql procedure ?

    Hello everyone,
    My query is..
    There is one pl/sql stored procedure which is doing some business logic and storing data in some columns of one table, suppose the table name is 'ABC' .. and the rest of columns of table ABC are getting updated using java class. Now my problem is whenever I insert data in ABC using store proc.. i have to call that java class so that it will update the rest columns ( why java class for updating the columns in ABC is ..because that logic cant be done from pl/sql proc.. it has to be done using java )
    and the other thing is.. oracle is in one machine and java is in another .. :(
    hope ..u can help me out !!
    Thank in advance !!

    but that updation have to be done from java code only.. we are using GIS tools .. have to create some shape files and update the column with that shape file.. so creation of shape file has to be done from java code only..
    so how to call java class file which is on another machine and oracle in another..

  • Call java class by using servlet

    i written simple servlet with doGet(0. I need call java class when i run servlet
    my requirement is when i start the server i will call servlet it will redirect to another page.
    but before that servlet will run java class. which i have written externally.
    i need to run java class by using servlet then it will redirect to another page.
    could you give the proper solution

    You don't call classes - you call methods.
    There's nothing special about servlets except the requirement that they implement HttpServlet. Servlets and other classes they interact with all get compiled into WEB-INF/classes on the server.
    To forward a request to, say, "other.jsp" you do:
    getServletContext().getRequestDispatcher("/other.jsp").forward(request,response);

  • Calling java classes from plsql procedures

    I'm attempting to call java classes from plsql procedures which will create cmsdk users, folders, groups etc, however when I attempt to load a java class into the oracle schema using the command:
    loadjava -user user/password@database -resolve classname.class
    It generates error messages to the effect that classes (cmsdk classes) required by the class cannot be found. The class is loaded and marked with the status "invalid". Is it therefore necessary for me to load the cmsdk packages into the schema?
    Cheers
    David

    Using CMSDK Java API within the database has never been supported
    (see Problems loading IFS's java class into database
    When we needed to invoke CMSDK code from our PL/SQL code, we used one of two approaches:
    (1) use advanced queues to send requests to an external Java program (the CMSDK code, running outside the database) and receive the results back (asynchronous choice); or
    (2) make an HTTP request to a Java servlet (the CMSDK code, running in some Java web container like iAS) and get the response back in some custom format (XML or something) (synchronous choice).
    It seems to me that the CMSDK Java API was designed to be used only in middle-tier, not in database tier.
    Regards,
    Daniel.

  • Assign Object to class with characteristic values ?

    Hi All,
    I want to assign object to class with characteristic values. I found CL20N transaction for performing the same. Is there any BDC , BAPI to upload the same.
    Thanks & Regards,
    Navneeth K.

    Hi,
    try as below
        CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
          EXPORTING
            classtext            = 'X'
            classtype            = w_classtype  "Class type
            language             = sy-langu
            object               = w_object     "Object Matnr + Batch
            objecttable          = 'MARA'     "As requirement
            change_service_clf   = 'X'
            inherited_char       = ' '
            change_number        = ' '
          TABLES
            t_class              = t_class
            t_objectdata         = t_objectdata
            i_sel_characteristic = i_sel_characteristic
            t_no_auth_charact    = t_no_auth_charact.
        IF sy-subrc <> 0.
        ENDIF.
    *     Create with reference-----------------------
          w_objectkeynew = wa_inputfile-to_matnr.
          CALL FUNCTION 'BAPI_OBJCL_CREATE'
            EXPORTING
              objectkeynew    = w_objectkeynew
              objecttablenew  = 'MARA'
              classnumnew     = w_classnum
              classtypenew    = w_classtype
            TABLES
              allocvaluesnum  = t_allocvaluesnum
              allocvalueschar = t_allocvalueschar
              allocvaluescurr = t_allocvaluescurr
              return          = t_lreturn.
    "or
    BAPI_OBJCL_CHANGE              Classification BAPI: Change Assignment
    Prabhudas

  • B1if Call Java Class

    I am attempting to call a java class using the Call Java Class atom. 
    Java Class Name: full name of the java class to be called (boldjar must be available in the B1i base pathbold)
    Where is the B1i base path?
    I have created a simple java class the implements Callable that simply returns 1.
    The exception I get com.sap.b1i.xcellerator.XcelleratorException: XCE001 Nested exception: com.sap.b1i.bizprocessor.BizProcException: BPE027 Could not get an instance for 'Callable'-class
    I have pasted the jar file in just about every path I can think of and still get this exception.
    Does anyone have a simple example of what the class should look like?  The callable interface only has a single function named call which does not take parameters.  How do we create a class that accepts parameters?

    Well I found this under Control Center -> Development -> BPC Reference
    User defined Java-Classes for the Call-Atom via the 'Callable' interface
    com.sap.b1i.bizprocessor.Callable
    This interface must be implemented by classes intended to be called by the B1iBizProcessor via the Call-Atom. Instances of these classes are subject of internal pooling if they do not indicate after a usage that they should be destroyed. In order to be able to create them internally in a generic way, they have to implement a parameterless initializer !!!
    I just searched the entire BizStore for com.sap.b1i.bizprocessor.Callable but was unable to find it. 
    I also searched Google for com.sap.b1i.bizprocessor.Callable and it only come up with my posts.
    I also searched the SAP Partner Portal, and SAP SDN with no avail.
    Is this functionality only for internal SAP use?

  • Calling java class from jsp page

    Dear Friends.
    I wrote jsp page and java class.
    Am calling java class from jsp page. after processing result,
    I have to refresh jsp page from java class.
    processing time may take 5 minutes or 1 minute etc. that depends on user.
    Can It be possible ? if possible , How ?

    Ok, I get a very strange error now:
    org.apache.jasper.JasperException: Unable to compile class for JSPerror: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
    What is this??? Anyone?

  • Calling java class from abap function moduile

    Is it possible to call java class from function module.
    i am a java guy. my need is to call a java class from a  function module in the backend. which in turn performs certain functions.
    i would be highly obliged if someone could let me know if this is possible.
    regards
    Srikumar V

    Hi Srikumar ,
    you can call a java webservice in ABAP .
    u can call the webservice and via that u can trigger the java class..
    Regards
    Renu

  • Can anyone help i want to call java class using visual basic

    I want to call java class using visual basic and send some arguments to the main class

    Hi,
    I don't know VB, but you can surely launch a command line like :
    javaw.exe mypackage.MyMainClass myArgument1
    Regards

Maybe you are looking for

  • Why can't I see the individual .jpegs in iphoto library?

    First off, I would like to apologize to the group in advance if these question have been asked 1000 times!!! I didn't see an answer when I searched the forum!! #1 Can someone tell me why I can't see all of the individual .jpegs in the Iphoto Library

  • Replacement for 'Apple Notes'?

    Hi all I've been using Apple's built-in 'Notes' app on Mavericks as well as my iPod Touch and I love it because it's easy and fast for me to create notes that I can look at later. However, I just bought an Android tablet and iCloud isn't available fo

  • How can I get again Mac O S X 10.5.8 in my computer

    My computer is not reading Mac O S X 10.5.8,.: by mistake stopped a update and nowis not working ,only shows the apple and the circle rolling and after that a blue screen.

  • I guess there is some feature missing...

    Hello~ Happy New Year for all of u~ well, today i just wanted to click some event 'done' and i could not find it, if i am not wrong, there used to be a feature in which i could check the 'status' be it 'done' or some others that i dont remember well

  • Download files through web Dynpro

    Hai All,   Now i am working in web Dynpro2.0.9. "IWDResource" property is used to download and upload files in web Dynpro. "IWDResource" is not supported by web Dynpro2.0.9.what is the alternative way for to download files other than using "IWDResour