Splitting String values

Dear Legends,
I have a text field that I need to split.
Requirement is I need to split on 30th letter.
But If 30th letter ends in the middle of the word then give the whole word before space.
So If I have following text then it should split equally:
"Very popular for the beach in France, It is stylish and useful. Being so light and soft they are easy to pack for holidays and carry to the beach. They dry quickly and can also be re-used."
First, It should split after
1 to 30 letters
Second 31 to 60
Very popular for the beach in
France, It is stylish and useful.(30 letters but include Everything before space)
Being so light and soft they are(30 letters but include Everything before space)
easy to pack for holidays and carry(30 letters but include Everything before space)
to the beach. They dry quickly and
can also be re-used.
Also it needs to be dynamically count in values till at least 300 words.
All your help is much appreciated.
Kind regards,
Aamir

Hi Aamir,
I had to do something similar on a 'pre-printed' form however I also had to account for the no. of lines that can be printed on the page dimensions. Here's a 'part' of the code that should do the splitting job:
WhilePrintingRecords;
local stringvar s := {String_Field_in_database};
local stringvar array arr := split(s," ");
local numbervar i;
numbervar lcount;
lcount := 1;
local numbervar fixed := 30;
local booleanvar nl := false;
for i := 1 to ubound(arr) do
    If i = 1 then
        local stringvar nstring := nstring + trim(arr[i]) + " ";
        local numbervar rem := fixed - len(nstring);
    else if i <> 1 and i <> ubound(arr) then
        if len(arr[i]) <= rem then
            nstring := nstring + trim(arr[i]) + " ";
            rem := (fixed*lcount) - (len(nstring)+lcount);      
            stringvar s := nstring;
            numbervar t := rem;
        else
            nstring := rtrim(nstring) + chr(13) + trim(arr[i]) + " ";
            lcount := lcount + 1;
            nl := true;
            rem := (fixed)- len(arr[i] + " ");
    else if i = ubound(arr) then
        if len(arr[i]) <= rem then
            nstring := nstring + trim(arr[i]);
            rem := fixed - len(nstring);
        else
            nstring := nstring + chr(13) + trim(arr[i]);
            rem := fixed - len(arr[i] + " ");
nstring;
Hope this helps.
-Abhilash

Similar Messages

  • Splitting string values in query

    all,
    i cant remember this but my problem is like i have a collection of string values passed to my query like "X234234:X23466:X03287:X457675" , so my query should be able to split each data value and use in the filter as below,
    select * from emp where EmpID in ("X234234:X23466:X03287:X457675")
    so how do i split every individual value and pass in the filter?
    thank you.

    Gor_Mahia wrote:
    onedbguru
    I'll revisit and marks acordingly i.e helpful but the other solution worked for me...thank you.It may have worked for you, but TABLE(XMLSEQUENCE is deprecated functionality so should be avoided.
    That's what happens when you take a 'correct' answer on face value rather than actually reading up on it and understanding if it really is a correct answer.
    The issue you have described is the "Varying IN list" issue which is commonly asked here, and Tom Kyte's blog on it is a suitable reference for dealing with it.
    Other methods are described in the FAQ: {message:id=9360009}
    You would be better to re-visit the solutions and pick one that is better, that doesn't use deprecated functionality.

  • Is there any function to split string value into diff junks

    Hi guys i have a string value as below
    14507|||Subterranean Masquerade||||||Subterranean Masquerade
    you can say ||| is a field delimiter.
    i want to split each field identified by ||| delimiter and store in a collection table.
    is there any easy way to that?
    Thanks
    Asif

    actually i want to use DIY$ dynamic view and what i did.
    1) I created a object type as xyz_row_type with 4 attributes.
    2) then i created a collection type xyz_tab_type of xyz_row_type
    3) now i want to create a function which will return me xyz_tab_type
    i am using a utl_file.get_line(file_name,f_line_txt)
    each line has the four elements delimited by '|||' shown below
    14522|||Lessig|||Minna|||Lessig, Minna
    i want to split each element for each attribute of xyz_row_type.
    How can i do this?

  • Split String value into internal table at Carriage return

    Hi All,
    I have given a string type context ( text edit  box ) to the user to enter the values. The data can have carriage returns also.
    My Requirement is that I want to split the data at carriage returns and store it in my tables.
    I tired with a constant value of '%CR_LF' as available in CL_ABAP_CHAR_UTILITIES but to no good result.
    Can the Experts suggest some solution?/??
    Thankx in advance.
    Regds,
    Srini

    Hi Srini,
    Have you looked at your string containing the text in the debugger to verify that you really have <CR>+<LF> (i.e. reflecting CL_ABAP_CHAR_UTILITIES=>CR_LF, which should be easily visible when looking at the hex codes of the string)? Maybe it's just a <LF> (i.e. CL_ABAP_CHAR_UTILITIES=>NEWLINE). Might be good to do a REPLACE first using a regular expression for identifying the line feeds and then doing the SPLIT.
    Cheers, harald
    p.s.: If you still cannot get it to work, provide some more details of what you're doing...

  • HELP URGENT:; Splitting strings in servlets

    hi ...
    I am trying to access the below servlet from another servlet in iplanet . I have to access a file and arrange the '|' delimited data in the file in a table format like in html ...
    I have used my own function inside the servlets which splits a string based on character ...But I always get
    Internal error: exception thrown from the servlet service function (uri=/servlet/ReportsDataServlet): java.lang.NullPointerException, Stack: java.lang.NullPointerException
    at ReportsDataServlet.split(ReportsDataServlet.java:82)
    at ReportsDataServlet.doPost(ReportsDataServlet.java:56)
    at ReportsDataServlet.doGet(ReportsDataServlet.java:14)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:919)
    at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:483)
    The sample code is shown below....I get the same error when i tries with stringokenizer as well....Pls help me fix this.....
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, Se
    rvletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    cont=getServletContext();
    out.println("<html><head><title>Reports Data</title></head><body bgcolor=DBD0E2>");
    String repType = request.getParameter("Rep");
    String mon = request.getParameter("month");
    String day = request.getParameter("day");
    String year = request.getParameter("year");
    String repName = repType+"."+mon+"-"+day+"-"+year+".txt";
    BufferedReader in = new BufferedReader( new FileReader("/home/lnayar/baais/xmlServlet/"+rep
    Name));
    String st;
    st = in.readLine();
    cont.log(st);
    int c =0;
    out.println("<table border=\"3\" cellpadding=\"0\" cellspacing=\"0\" width=\"800\"><tr><td>L
    ATA</td><td>WC CLLI</td><td>WC NAME</td><td>ADSL_LOCATION</td><td>ATM FLAG</td><td>ATM RELIEF DATE</td><t
    d>FRAME FLAG</td><td>FRAME RELIEF DATE</td><td>GOLD FLAG</td><td>GOLD RELIEF DATE</td><td>OVERLAY INDICAT
    OR</td><td>COUNT</td></tr>");
    while (st != null)
    c++;
    st = in.readLine();
    StringTokenizer stt = new StringTokenizer(st);
    out.println("<tr>");
    while (stt.hasMoreTokens())
    //out.println("<td>"+stt.nextToken("|")+"</td>");
    out.println("<td>hello</td>");
    out.println("</tr>");
    while (st != null)
    c++;
    st = in.readLine();
    out.println("<tr>");
    Enumeration en = split(st,"|");
    while(en.hasMoreElements())
    out.println("<td>"+en.nextElement()+"</td>");
    out.println("</tr>");
    cont.log("out while");
    out.println("</table>");
    out.println("</body></html>");
    public Enumeration split (String str, String delim)
    Vector v = new Vector();
    int pos_1;
    int pos_2;
    //Set initial delimiter positions...
    pos_1 = 0;
    pos_2 = 0;
    //Start chopping off bits from the string
    //until left boundary reaches the length of string
    while ( pos_1 <= str.length() )
    pos_2 = str.indexOf(delim, pos_1);
    if ( pos_2 < 0 )
    pos_2 = str.length();
    String sub = str.substring (pos_1, pos_2);
    pos_1 = pos_2 + 1;
    v.addElement(sub);
    return v.elements();
    d deeply appreciate if soeone could take a look at the code and tell me exactly where i am going wrong ..... Its URGENT ...
    Thx
    klv

    But there is the while statement which filters null
    values..Which is useless in your case, because you proceed to change the value of st to something else which you don't check for null.
    At any rate, what you have to do is this:
    1. Look at the stack trace to find the line number where the error occurs.
    2. Look at that line in your code.
    3. Look at each object variable in that line. Find out how it became null and fix that.

  • Function module to split strings

    Hi,
    I have a string value ' DBTABLE-FIELDNAME'. I need to split this into 2 strings - The first one is the database table name and the second one is the fieldname. So, the character '-' is the point where the split needs to be done. How can this be achieved. Any FM that I could use?
    Thanks for your help!
    Regards,
    Divyaman Singh Rawat

    Use FM 'STRING_SPLIT'
    REPORT ZEXAMPLE.
    DATA: V_HEAD(10), V_TAIL(10).
    PARAMETERS: P_STR(20),
                P_DEM.
    CALL FUNCTION 'STRING_SPLIT'
         EXPORTING
              DELIMITER = P_DEM
              STRING    = P_STR
         IMPORTING
              HEAD      = V_HEAD
              TAIL      = V_TAIL
         EXCEPTIONS
              NOT_FOUND = 1
              NOT_VALID = 2
              TOO_LONG  = 3
              TOO_SMALL = 4
              OTHERS    = 5.
    IF SY-SUBRC EQ 0.
      WRITE:/ 'HEAD:', V_HEAD,
            / 'TAIL:', V_TAIL.
    ELSE.
      WRITE:/ 'ERROR SPLITTING STRING'.
    ENDIF.
    Regards,
    Joy.

  • Is there any native method for converting String value to Hungarian notat..

    Hello. there.
    This might be very simple question. but I'm just curious about this.
    I am wondering if Java API offer the any native method for converting uppercased string value to lowercase which obey the Hungarian notation.
    What I'm going to do is using Reflection for excuting RFC function on SAP. I was found it is very similar to JDBC Programming.
    Please refer to blow codes.
    //mTable
    JCoTable mTable = function.getTableParameterList().getTable(rtnTblNm);
        for (int i = 0; i < mTable.getNumRows(); i++) {
         mTable.setRow(i);
         HashMap tmpData = new HashMap ();
              for (int j=0; j < mTable.getNumColumns(); j++) {
                     // I want to set key String [userNo] instead of  [USER_NO] here.
              tmpData.put(mTable.getMetaData().getName(j).toLowerCase(), mTable.getString(j));
              result.add(tmpData);
    } Basically, The idea was from ibatis framework [com.ibatis.common.beans.classInfo] dropcase();
    Any idea would be very helpful for me. Thank you.
    Edited by: hosung.seo on Aug 30, 2009 10:42 PM
    Edited by: hosung.seo on Aug 30, 2009 10:50 PM

    ejp wrote:
    Hungarian notation is a representation of logical/arithmetic expressions in postfix form. Not what you're talking about.
    So your title is very confusing to the people here who know what it means, which is probably all of them, because people read threads based on their title.From now on, I will pay more attention when I post an question.
    If the titile as " +Is there any native method for converting String value to camelcase?"+ would be easier to what i'm pointing at.
    As I mentioned in above sorce code, converting [USER_NO] to [userNo] isn't relevant Hungarian notation. yes, it was ambiguous. Agree! :)
    But some answer wasn't fit to converting case or recognizing "underscore" delimiter. I was expecting toCamelCase() such as blew. Thanks.
        public static String toCamelCase(String name) {
            String lowerName = name.toLowerCase();
            String[] pieces = lowerName.split("_");
            if (pieces.length == 1) {
                return lowerName;
            StringBuffer result = new StringBuffer(pieces[0]);
            for (int i = 1; i < pieces.length; i++) {
                result.append(Character.toUpperCase(pieces.charAt(0)));
    result.append(pieces[i].substring(1));
    return result.toString();

  • Regarding ssis - split multi value column into multiple records

    Hi,
    I have one scenario
    Table
    Col1. Col2
    1. A,b,c,df,ghf
    2. C,b
    3. B
    Output should be
    Col1. Col2
    1. A
    1. B
    1. C
    1. Df
    1. Ghf
    2. C
    2. B
    3. B
    please help

    Try the below:
    Create TVF as below:
    CREATE FUNCTION [dbo].[split]
    ( @String NVARCHAR(4000), @Delimiter NCHAR(1) )
    RETURNS TABLE
    AS
    RETURN
    With Split(stpos, endpos)
    AS (
    SELECT 0 AS stpos, CHARINDEX(@Delimiter, @String) AS endpos
    UNION ALL
    SELECT endpos + 1, CHARINDEX(@Delimiter, @String, endpos + 1)
    FROM Split
    WHERE endpos > 0
    SELECT 'Id' = ROW_NUMBER() OVER (ORDER BY (SELECT 1)),
    'Data' = SUBSTRING(@String, stpos, COALESCE(NULLIF(endpos,0), LEN(@String)+1)-stpos)
    FROM Split
    Test script:
    create Table Test_Table(id int, data varchar(4000))
    Insert into Test_Table Values(1,'a,F,c, G'),(2,'LASD,wer,yy')
    Select A.id,upper(Left(b.Data,1)) + lower(Right(b.data, Len(b.data) - 1)) From Test_Table A
    Cross Apply dbo.split(A.data,',') B
    Drop table Test_Table

  • Input a string value

    What is the simplest method to accept an input of string value? Is buffering or string tokenizer required to perform this?

    vinayv wrote:
    What is the simplest method to accept an input of string value? Is buffering or string tokenizer required to perform this?It depends what you're doing. StringTokenizer isn't used to get an input value, it's used to separate it out into tokens. It's also deprecated in favor of String.split.
    You might want to use BufferedReader's readLine method. Or you might want to use Scanner's next, nextLine, nextInt, etc. It depends on how you're consuming and parsing input. You might even want to check out the Console class introduced in version 6.
    Start here, and play around with the above until you find what best suits your needs.
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • Split String FM

    Hello,
    Does anyone know a standard string FM that split string at an absolut place and consider if the N place is blank or not ?
    My meaning is likely:
    str = 'test one two three'.
    I would like to split str at the 10th place but because it's in a middle of word split it in the 8th place ..
    str1 = 'test one'
    str2 = 'two three'
    and not
    str1 = 'test one t'
    str2 = 'wo three'
    I know that VB has few methods like that, I'm hope abap has it also ..
    Thanks in advance,
    Rebeka

    Hi Rebeka,
                    Please check the following code. This would help. FM 'TEXT_SPLIT' does it correctly.
    DATA: text(50) TYPE c VALUE 'test one two three',
    text1(20) TYPE c,
    text2(20) TYPE c.
    CALL FUNCTION 'TEXT_SPLIT'
      EXPORTING
        LENGTH             = 10
        TEXT               = text
       AS_CHARACTER       =
    IMPORTING
       LINE               = text1
       REST               = text2
    check sy-subrc = 0.
    write :   text1 ,
              text2.
    Reward points if useful.
    Regards
    Abhishek

  • Parameters To Include Null Or Empty String Values

    I have a table that has both Nulls & Empty Strings that I want to use as a Dynamic Parameter.  Even though there is an indication of the Null/Empty String value when the parameter prompt comes up, selecting the value of Null/Empty String results in no records being returned.  I have a formula to display the values in the report (where I substitute "Unknown" for the Null/Empty String values), but I am not able to do a parameter on that formula.
    I guess in general, this is a situation of needing to be able to use a Dynamic Parameter based on a formula field.
    Thanks for any assistance!  
    Edited by: Dragon77 on Apr 2, 2010 9:39 AM

    I'd use a SQL Command as the data source for the list of values. Something like this... (MS SQL Server)
    SELECT DISTINCT
    CASE WHEN t.StringField IS NULL OR  t.StringField LIKE ''
         THEN 'Unknown' ELSE  t.StringField END AS  StringField
    FROM TableName AS t
    ORDER BY  StringField
    Then use a formula like this in the selection criteria.
    IF {?Parameter} = "Unknown"
    THEN (ISNULL ({TableName.StringField}) OR {TableName.StringField} LIKE "")
    ELSE {TableName.StringField} = {?Parameter}
    HTH,
    Jason

  • How to get string value from xml in JSF??

    In JSF How to get string value from xml, .ini and properties file. I want to get string value from xml or text to JSF

    Just use the appropriate API's for that. There are enough API's out which can read/parse/write XML, ini and properties files. E.g. JAXP or DOM4J for xml files, INI4J for ini files and Sun's own java.util.Properties for propertiesfiles.
    JSF supports properties files as message bundle and resource bundle so that you can use them for error messages and/or localization.

  • How to get string value from database table using Visual Studio 2005?

    Hi,
    Im developing plugin in illustrator cs3 using visual studio 2005. I need to get the values eneterd in database. Im able to get the integer values. But while getting string values it is returning empty value.
    Im using the below code to get the values from database table
    bool Table::Get(char* FieldName,int& FieldValue)
        try
            _variant_t  vtValue;
            vtValue = m_Rec->Fields->GetItem(FieldName)->GetValue();
            FieldValue=vtValue.intVal;
        CATCHERRGET
        sprintf(m_ErrStr,"Success");
        return 1;
    Im using the below code to get the values.
    AIErr getProjects()
        char buf[5000];
        int i;   
        std::string  catName;
        ::CoInitialize(NULL);
        Database db;
        Table tbl;
        errno_t err;
        err = fopen(&file,"c:\\DBResult.txt","w");
        fprintf(file, "Before Connection Established\n");
        //MessageBox(NULL,CnnStr,"Connection String",0);
        if(!db.Open(g->username,g->password,CnnStr))
            db.GetErrorErrStr(ErrStr);
            fprintf(file,"Error: %s\n",ErrStr);
        fprintf(file, "After Connection Established\n");
    if(!db.Execute("select ProjectID,ProjectName from projectsample",tbl))
            db.GetErrorErrStr(ErrStr);
            fprintf(file,"Error: %s\n",ErrStr);
        int ProjectID;
        int UserID;
        int ProjectTitle;
        char ProjectName[ProjectNameSize];
        if(!tbl.ISEOF())
            tbl.MoveFirst();
        ProjectArrCnt=0;
        for(i=0;i<128;i++)
            buf[i]='\0';
            int j=0;
        while(!tbl.ISEOF())
            if(tbl.Get("ProjectID",ProjectID))
                fprintf(file,"Project ID: %d ",ProjectID);
                ProjectInfo[ProjectArrCnt].ProjectID = ProjectID;
                sprintf(buf,"%d",ProjectID);
                //MessageBox(NULL, buf,"f ID", 0);
                j++;
            else
                tbl.GetErrorErrStr(ErrStr);
                fprintf(file,"Error: %s\n",ErrStr);
                break;
            //if(tbl.Get("ProjectTitle",ProjectName))
            if(tbl.Get("ProjectName",ProjectName))
                MessageBox(NULL,"Inside","",0);
                fprintf(file,"ProjectTitle: %s\n",ProjectName);
                //catName=CategoryName;
                ProjectInfo[ProjectArrCnt].ProjectName=ProjectName;
                //sprintf(buf,"%s",ProjectName);
                MessageBox(NULL,(LPCSTR)ProjectName,"",0);
            else
                tbl.GetErrorErrStr(ErrStr);
                fprintf(file,"Error: %s\n",ErrStr);
                break;
            ProjectArrCnt++;
            //MessageBox(NULL, "While", "WIN API Test",0);
            tbl.MoveNext();
        //MessageBox(NULL, ProjectInfo[i].ProjectName.c_str(),"f Name", 0);
        ::CoUninitialize();
        //sprintf(buf,"%s",file);
        //MessageBox(NULL,buf,"File",0);
        fprintf(file, "Connection closed\n");
        fclose(file);
        for(i=0;i<ProjectArrCnt;i++)
            sprintf(buf,"%i",ProjectInfo[i].ProjectID);
            //MessageBox(NULL,buf,"Proj ID",0);
            //MessageBox(NULL,ProjectInfo[i].ProjectName.c_str(),"Project Name",0);
        return 0;
    In the above code im geeting project D which is an integer value. But not able to get the project name.
    Please some one guide me.

    As I said in the other thread, this really isn't the place to ask questions about a database API unrelated to the Illustrator SDK. You're far more like to find people familliar with your problem on a forum that is dedicated to answering those kinds of questions instead.

  • Getting string values from DB query

    I am using the following code:
    <%@ page import="java.sql.*" %>
    <%
        String userName = request.getParameter("usernameField");
        String password = request.getParameter("passwordField");
        String connectionURL = "jdbc:mysql://localhost:3306/babbemployees?user=DBUser;password=MyPassword";
        Connection connection = null;
        Statement statement = null;
        ResultSet rs = null;
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        connection = DriverManager.getConnection  (connectionURL, "DBUser", "MyPassword");
        statement = connection.createStatement();
        String queryString = "SELECT * FROM tbemployees where userID='"+userName+"'";
        rs = statement.executeQuery(queryString);   
        String isAuthenticated;
        if (userName == rs.getString("userID") && password == rs.getString("password")[0])
            isAuthenticated = "AUTHENTICATED";
        else
            isAuthenticated = "NOT AUTHENTICATED";
        rs.close();
    %>
    <html>
        <body>
        <h1><%= isAuthenticated %></h1>
        <hr>
        </body>
    </html>I am trying to get a String value for rs.getString() but for some reason this is not working out. Is there anything I can do to get the values for the queries in a String value?
    Thanks,
    Harlin

    When a ResultSet is returned to you, it is always positioned before the first row.
    You need to insert a rs.next(); after your executeQuery().

  • How do I know if I can convert a String value to an int value or not?

    Hi,
    I want to know how to make the judgment that if I can convert a String value to an int value or not? Assume that I don't know the String is number or letters
    Thank you

    Encephalopathic wrote
    Again, why?One of the problems (have been dued) in my codelab asks us to write a class as follow
    Write a class definition of a class named 'Value' with the following:
    a constructor accepting a single integer paramter
    a constructor with no parameters
    a method 'setVal' that accepts a single parameter,
    a boolean method, 'wasModified' that returns true if setVal was ever called for the object.
    a method 'getVal' that returns an integer value as follows: if setVal has ever been called, it getVal returns the last value passed to setVal. Otherwise if the "single int parameter" constructor was used to create the object, getVal returns the value passed to that constructor. Otherwise getVal returns 0.
    The setVal(int y) returns nothing, so how do I know whether it has been called or not?
    Thank you

Maybe you are looking for

  • Dunning wizard doesn't work for the patners who have already dunned

    Hello everyone, I have a problem with dunning wizard, I have 2 dunning level : Level 1, 1 day Level 2, 2 days I launch once dunning yesterday, all parteners who have invoices no paid pass to level1 Today, I lauche again the wizard, there are no resul

  • Valuation type in case of stock transport order

    Hi, We are spilt valuation. now we are doing stock transport order and it is asking for valuation type. while we dont want to enter valuation type in STO. as which material is to sent to plant, we know at that time of delivery. but during making STO

  • ITunes Has Disabled My CD/DVD Drive - can anyone help ?

    Hi, I recently bought a 5th Generation iPod Video 30gb, and have some issues with the iTunes software. I am running a fairly new (4/5 months old) Packard Bell PC with Windows XP Home and have Sonic RecordNow CD burning software. Here's the problem...

  • Error in RSCRM_BAPI

    I am using RSCR_BAPI to get the query data in flat file. When I restrict the query with fiscal year/period it is giving zero bytes file. Any suggestions would be highly appreciated.

  • Time Capsule port mapping is broken for L2TP Servers behind NAT config.

    I'm hoping that someone here can refute the below bug assertion... am I missing something? There is a bug with Apple’s Time Capsule/Airport Express Base Station (TC/AEBS) rendering L2TP servers on the LAN unusable: When TC/AEBS is used as a router pr