About string function

Hi Experts,
in my scenario there is a value that is comming from source need to be substring depending on some condition eg: Electrical:Cable as per the req we need only Cable this could be achived by using the substring function but if there is a null value comming from the source then it should write a null at the target
but when we are using substring function to get the value eg Cable it works fine but when there is a null value it throws a error  on substring function
can anyone provide the inputs as the req is critical
Thanks
Sampath

Hi venkat,
Use the Below UDF(SubString). It works fine, even when the input given is null.
SourceField->UDF->TargetField
public static String SubString(String sInput, int iStartIndex, int iNoOfChars) {
          int iLen = 0;
          int iEndIndex = 0;
          try {
               iLen = sInput.length();
               iEndIndex = iStartIndex + iNoOfChars;
               if (iStartIndex > iLen)
                    return "";
               if (iEndIndex > iLen)
                    iEndIndex = iLen;
          } catch (Exception e) {
               return "";
          return sInput.substring(iStartIndex, iEndIndex);
Regards,
Swetha.

Similar Messages

  • [OT] User-Defined string Functions  Oracle PL/SQL

    Ladies and Gentlemen,
    I am pleased to offer the following string functions Oracle PL/SQL:
    GETALLWORDS(): Inserts the words from a string into the table.
    GETWORDCOUNT(): Counts the words in a string.
    GETWORDNUM(): Returns a specified word from a string.
    OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
    OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
    PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
    STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
    STRFILTER(): Removes all characters from a string except those specified.
    RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RAT() is case-sensitive. RAT similar to the PL/SQL function INSTR.
    ATC(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (including overlaps). The search performed by ATC() is case-insensitive. ATC similar to the PL/SQL function INSTR.
    RATC(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RATC() is case-insensitive. RATC similar to the PL/SQL function INSTR.
    AT2(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (excluding overlaps). The search performed by AT2() is case-sensitive. AT2 similar to the PL/SQL function INSTR.
    REPLICATE(): Returns a character string that contains a specified character expression repeated a specified number of times.
    ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).
    Plus, there are versions for MS SQL SERVER, SYBASE ASA, DB2, MS SQL SERVER 2005 SQLCLR.
    More than 8000 people have already downloaded my functions. I hope you will find them useful as well.
    For more information about string UDFs Oracle PL/SQL please visit the
    http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,29233
    Please, download the file
    http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,29233
    With the best regards.

    >
    I am using the Oracle Data Provider in vs2012. I am having trouble calling a function that returns an object type defined.
    >
    Returning a collection like that is a bad idea to begin with. That isn't scaleable and wastes memory.
    Either return a REF CURSOR and let the client FETCH the rows or use a PIPELINED function and let the client query it like they would a table.
    Here is an example similar to yours that uses a PIPELINED function.
    create or replace
        package pkg2
          as
            CURSOR emp_cur is (SELECT empno, ename, job, mgr, deptno FROM emp);
            type pkg_emp_table_type is table of emp_cur%rowtype;
            function get_emp(
                             p_deptno number
              return pkg_emp_table_type
              pipelined;
      end;
    create or replace
        package body pkg2
          as
            function get_emp(
                             p_deptno number
              return pkg_emp_table_type
              pipelined
              is
              begin
                  for v_emp_rec in (SELECT empno, ename, job, mgr, deptno
                                    FROM emp where deptno = p_deptno) loop
                    pipe row(v_emp_rec);
                  end loop;
              end;
      end;
    select * from table(pkg2.get_emp(20));
           EMPNO ENAME      JOB              MGR     DEPTNO
            7369 DALLAS     CLERK2          7902         20
            7566 DALLAS     MANAGER         7839         20
            7788 DALLAS     ANALYST         7566         20
            7876 DALLAS     CLERK           7788         20
            7902 DALLAS     ANALYST         7566         20

  • System table that stores info about any function module

    Hi All,
    I know that table TFDIR stores primary information about any function module.
    Could anyone tell me where the code of that function module gets stored in?
    Also.. If I want to write an ABAP code to read the function module code then what is the best possible solution?
    I want to read a function module code if that contains specific string.
    Can anyone help me  with that?
    Thanks in advace and any answer will be appreciated.
    Regards
    Jignesh
    Edited by: Jignesh Patel on Jun 12, 2008 12:22 PM

    Hi Jignseh,
    The codes are not stored in any table, they are stored as cluster.
    To read the code, you can use READ REPORT.
    But there you must provide the Include Name
    For Example , If you want to read the code of READ_TEXT,
    READ REPORT 'LSTXDU01'.
    You can get this include name inside include LSTXDUXX
    Use "GET_INCLUDES" to get all include names
    Edited by: Swastik Bharati on Jun 12, 2008 12:28 PM

  • Oracle course to learn more about BI functions

    Hi,
    Do you know if there is any Oracle course specific about BI functions?
    Aggregate Functions
    Running Aggregate Functions
    String Functions
    Math Functions
    Calendar Date/Time Functions
    Conversion Functions
    System Functions
    Operators
    Expressions
    Literals
    I know how to build simple reports, but when it comes to use the above functions, I find it difficult.
    Maybe somebody can suggest a good book too?
    Thanks and Regards
    G.

    http://download.oracle.com/docs/cd/E10415_01/doc/bi.1013/b31770.pdf
    Page No 366 about Aggregated functions
    Running Aggregate Functions - 374
    String Functions - 378
    Math Functions - 384
    Calendar Date/Time Functions - 390
    Conversion Functions - 398
    System Functions - 402
    I Hope this works for you..

  • Search and replace string function

    Hello, I am using the "search and replace string" function and it does nt seem to work consistently for me.   I am using it in a situation where I am taking an array of strings, converting this into a spreadsheet string then deleting all of the commas.  Has anyone experienced the same behavior? I have searched through other posts and found other simular faults but none of the fixes worked for this. I can post the code it needed.
    Thanks,
    Andrew

    I agree that commas are often not desirable, especially if your software should also work in countries where comma is used as a decimal seperator.
    Where are the commas coming from? Does (1) each element of the original array have one (or more), do you (2) use comma as seperator if you convert it to a spreadhseet string?
    For (1), you might just strip out the comma for each element right in the loop. For case (2) you would simply use a different separator to begin with, of course.
    Btw: you are abusing a WHILE loop as a FOR loop, because you have a fixed number of iterations. Please replace it with a FOR loop. If you use a FOR loop, LabVIEW can manage memory much more efficiently, because it can allocate the entire output array before the loop starts. For While loops, the total number of iterations is not known to the compiler. (Of course a real program would also stop the loop if an error occurs. In this case you would need to stay woth the WHILE loop. )
    Do you have a simple example how the raw array elements look like. How many commas are there?
    LabVIEW Champion . Do more with less code and in less time .

  • Error in XSLT mapping while using string functions

    Hi All,
    While using tokenize() and substring-before() functions in XSLT mapping,we are getting an error.The error message is Unexpected symbol "" So while using string functions in XSLT mapping do we have to use any header functions.
    Please through light on syntax etc.,of string functions in XSLT.
    Thanx in advance,
    Lokesh Dhulipudi
    Edited by: LOKESH DHULIPUDI on Dec 27, 2007 7:32 AM

    Hi,
    Hope you have gone thru this help:
    http://w3schools.com/xsl/default.asp
    Rgds, Moorthy

  • Wrong use of "Scan From String" function in a while loop?

    Hi,
    I've got a "Scan From String" function inside a while loop. On the first iteration it converts correctly the number passed by the input string (for example 4) But on the second one it has only spaces (one or more \s) as input string.
    I expected to obtain a zero as output (as it does always that it can not make any conversions, as I am supposed to) but indeed, i subtracts 1 from the previous number (according to the number indicated as example I would obtain a 3 as output)
    What's wrong with this?
    Does the function fails on this case?
    The rest of the diagram o the VI is expected to manage a 0 on that situation, like others in which the conversion is not made.
    Andres.

    I have simplified the VI evading calls to other VIs and trying to reproduce the mistake.
    The type of string I introduce to reproduce the mistake is:
    clock 3 (30) clock (40)
    Forgetting to introduce a number between the second "clock" and the following parenthesis, I would manage it programmatically with code that isn't included.
    Then "Scan From String" is supposed to do not make a conversion. But it leaves a 2 as output (in this example)
    I have realised, unbelievable but true, that it has matter with the number I substract to the output number (if it were 2, I would obtain 1 as output and so on)
    Excluding that, I got the conversion made before as output, 3, on the second time that "Scan From String" executes. But, how can this func
    tion as bad?
    I am using LV4 on an old PC. I have tried to reproduce it with LV6 and it works. But it isn't desirable for me, I would have to convert a lot of VIs and surely I will find a lot of errors due to the conversion (I have already tried)
    Attachments:
    EXTCLOCK.VI ‏26 KB

  • Documentation about this function module

    ineed Documentation about this function module RP_ANSAL_FROM_PERNR

    Hi Avinash,
    Have a look at the function group program documentation.It gives an idea of what the function module does.
    Short text
    Annual Salary Functionality (ANSAL)
    Description
    This function group contains different functionality for calculating the annual salary, and calculating a period salary from the annual salary.
    The function group evaluates different tables and features:
    Tables
    T503      defines whether an employee is paid on an
              hourly basis or per period
    T510W     defines the time unit
    T511      determines the relevant module from the annual
              salary wage type, rounding, etc.
    T539J     defines the valid wage types for calculating 
              the annual salary
    Features
    ANSAL     defines the annual salary wage type
    PFREQ     number of periods per year
    Old U510F -> use T510F ?
    Thanks
    Lakshman

  • Essbase MDX - string functions are not working!

    Hi all!
    this MDX code works fine (LEN function):
    With
    member Scenario.MS1 as 'Len([Account].currentmember.member_name)'
    select { Scenario.MS1} on columns from http://Planing.Budget
    this code raises error (UPPER or any string function):
    With
    member Scenario.MS1 as 'Upper([Account].currentmember.member_name)'
    select { Scenario.MS1} on columns from http://Planing.Budget
    The administration tool I am using is for version 11.1.1.3 ..
    why? O_o
    Edited by: serzzzh on 14.10.2009 22:54

    Unless maybe if you're using J2ME and have very tight memory requirements (are you?) either an array or a Vector should be fine to hold 8000 strings.
    So I'm guessing, either:
    1) you're using J2ME, have a device with tight memory, in which case you probably need a redesign, either to move data off the device and into an online service or the like, or possibly to use the record db system that's in one of the J2ME profiles (although 8000 seems like a lot of stuff to put in such a small form factor device).
    2) the strings are in fact enormous, in which case array-or-vector isn't the issue
    3) there's some other problem. maybe you have a runaway recursive method or something.

  • Have a question about  using functions  in JSP 2.0

    Hello,
    Does someone try to create functions in JSP2.0?
    the following codes is from http://developer.java.sun.com/developer/technicalArticles/javaserverpages/JSP20/
    Code Sample:math.jsp
    <%@ taglib prefix="my" uri="http://jakarta.apache.org/tomcat/jsp2-example-taglib %>
    <HTML>
    <HEAD>
    <TITLE>Functions</TITLE>
    </HEAD>
    <BODY>
    <H3>Add Numbers</H3>
    <P>
    <FORM action="math.jsp" method="GET">
       X = <input type="text" name="x" value="${param["x"]}">
       <BR>
       Y = <input type="text" name="y" value="${param["y"]}">
       <input type="submit" value="Add Numbers">
    </FORM>
    <P>
    The sum is: ${my:add(param["x"],param["y"])}
    </BODY>
    </HTML>Compute.java
    package jsp2.examples.el;
    import java.util.*;
    public class Compute {
       public static int add(String x, String y) {
          int a = 0;
          int b = 0;
          try {
            a = Integer.parseInt(x);
            b = Integer.parseInt(y);
          }catch(Exception e) {}
          return a + b;
    }I put function tags in C:\Tomcat\webapps\jsp-examples\WEB-INF\jsp2\jsp2-example-taglib.tld
      <function>
            <description>add x and y</description>
            <name>add</name>
            <function-class>jsp2.examples.el.Compute</function-class>
            <function-signature>int add(java.lang.String,java.lang.String)</function-signature>
        </function>But get the error messages:
    The server encountered an internal error () that prevented it from fulfilling this request.
    org.apache.jasper.JasperException: /jsp2-tutorial/math.jsp(11,22) equal symbol expected
    Am I missing somethig?
    Thanks.

    Well, i think the code is perfectly fine , what you should look after : is there any servlet.jar exist in the jre/lib/ext on you java sdk ,you can determine whether EL 2 works by trying some jsp 2 examples provide with tomcat 5 alpha version .
    If it works , then it is not the alternative servlet.jar issue , most probably is your configuration errors.
    I have try my custom function and it worked well under tomcat 5 after resolving the earlier servlet.jar issue.
    By the way you don't have to put your tld file as described , simply place it under your /WEB-INF and edited your tomcat 5 web.xml to like my example given below .
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
    <display-name>Display Name of the application</display-name>
    <description>
    application name
    </description>
    <jsp-config>
    <taglib>
    <taglib-uri>
    your tld file
    </taglib-uri>
    <taglib-location>
    /WEB-INF/your tld file.tld
    </taglib-location>
    </taglib>
    </jsp-config>
    </web-app>
    Please give it a try and let me know whether it works , I will provide more assistance if required.

  • Contains (String function) is not working in switch condition .

    Hi All ,
    I have a interface in which there are two projects.
    1 notification interface
    2 DFW interface .
    Project 1 Has Mediator in it where I am checking a Filter condition on DESTINATION PARTNER ID as below
    contains($in.request/inp1:TSOHoldCommon/inp1:Destination_Partner_ID,'DFW')
    as you all know this is the string function(containd) I have used.
    But there is a problem I am facing , when i use the same condition in DFW INTERFACE in all the switch conditions i have used .
    So now the problem is in switch condition used in BPEL of DFW INTERFACE.
    I have a asign statement after this condition,and i am getting assign pending so flow is faulting.
    please help me in this regard or give me any suggestions for fixing this .
    BPEL VERSION 1.1
    SOA 11.1.1.6

    Please post the error log which you are getting in EM.
    Thanks,
    Ashutosh

  • Split string function in oracle ...

    Hello,
    Little question, is there any split string function available in Oracle.
    SQL> select more_info
    2 from dba_advisor_findings;
    MORE_INFO
    Allocated Space:4390912: Used Space:4237403: Reclaimable Space :153509:
    select more_info as Allocated_Space,
    more_info as Used_Space,
    more_info as Reclaimable_Space
    from dba_advisor_findings
    Allocated_Space Used_Space Reclaimable_Space
    4390912 4237403 153509
    Thanks,
    Manish Gupta

    I explored more on SUBSTR and INSTR string functions ... and below is the solution
    select substr(more_info,instr(more_info,':',1,1)+1,instr(more_info,':',1,2)-instr(more_info,':',1,1)-1) as "Allocated_Space",
    substr(more_info,instr(more_info,':',1,3)+1,instr(more_info,':',1,4)-instr(more_info,':',1,3)-1) as "Used_Space",
    substr(more_info,instr(more_info,':',1,5)+1,instr(more_info,':',1,6)-instr(more_info,':',1,5)-1) as "Reclaimable_Space"
    from dba_advisor_findings;
    Allocated_Space
    Used_Space
    Reclaimable_Space
    4390912
    4237403
    153509
    Thanks...

  • NEED INFORMATION ABOUT "MAX_TEST" FUNCTION MODULE

    HI ABAPERS,
                      I need information about "MAX_TEST" function module . this function module is used in 4.6 version , now system have been shifted to 6.0.....here in 6.0 version this function module is not prasent.can any one tell me which new function module we can use in place of this function module, without changing the functionality........
             Thanks in advance
    regards,
    SUNIL

    The module is not very sophisticated. Profficiency in Java or ABAP will be a great bonus here. There are plenty of good materials regarding XI on SDN. I suggest to start with step-by-step guides and master all basic integration scenarios
    http://wiki.sdn.sap.com/wiki/display/XI/Step-by-Step+Guides
    Opportunities in industry are not bad also, cause PI is rather popular among customers. The best thing is that it fits any type of customer's business. Integration is demanded almost everywhere.

  • About CallByteMethodA Function

    Hi you all:
    I have some problem about CallByteMethodA function.
    This is what my java code looks like:
    public void setDS_INFO_mac(byte[] mac) {
    for( int i = 0; i < mac.length; ++i ) {
    this.ds_info.mac[i] = mac;
    This is what my c code looks like:
    jobject objref;
    jclass cls = NULL;
    jfieldID fid = NULL;
    jmethodID mid = NULL;
    jbyte dsMac[6];
    jbyteArray returnArray = 0;
    /* code not pertaining to this question snipped. */
    mid = env->GetMethodID(cls, "setDS_INFO_mac", "([B)V" );
      for( int j = 0; j < 6; ++j ) {
          dsMac[j] = search_Info[i].ds_info.mac[j];
    returnArray = env->NewByteArray(6);
    if( returnArray != NULL ) {
    env->SetByteArrayRegion(returnArray, 0, 6, (jbyte*)dsMac);
    env->CallByteMethodA(objref, mid, (jvalue*)returnArray);
    env->DeleteLocalRef(returnArray);
    This is not working.
    and, some about run time exception as follows:
    Exception in thread "main" java.lang.NullPointerException
    at CFGINFO.setDS_INFO_mac(DSCIStructure.java:97)
    at DSCIJNInterface.dsc_EnumSearch(Native Method)
    at MainApp.searching(MainApp.java:105)
    at MainApp.main(MainApp.java:46)
    Any idea what I'm doing wrong?

    You are missing error checking code. Many calls to the JNI interface require that you check the method return value. Many calls also require that java exceptions must be checked for after the call.

  • Supplementary characters and string functions

    I am using AL32UTF8 as my database character set and plan to store Japanese supplementary characters in the DB character set itself. Do I need to use any special string functions for these supplementary Japanese characters.

    With the AL32UTF8 character set, supplementary characters like any other characters, except that they are the widest (4 bytes). You just need standard multibyte processing.
    With AL16UTF16 (NCHAR), and depending on your needs, you may want to use certain SQL function variants that have 4 in their name: LENGTH4, INSTR4, SUBSTR4, LIKE4.
    When retrieving AL32UTF8 supplementary characters through JDBC or OCI in UTF-16 mode, you have to take care of the fact that one AL32UTF8 supplementary character becomes 2 UTF-16 code units (a surrogate pair). This is important for buffer allocations, length calculations, and any code that can split strings into substrings.
    -- Sergiusz

Maybe you are looking for