Reading strings

Hello Abapers,
This is the issue: I'm need logic for the following:
let's say I have product# 00000TA12345
I need to get only: TA12345
but if the product starts with a number, let's say:  0000056789,
I need to get the same: 0000056789.
How can I handle this? Any ideas?
Please advise. Thanks in advance.
Ol

Hello,
Data: string like mara-matnr
Data: number likr mara-matnr.
Do you type this code:
IF string ca sy-abdce.
overlay string with ' '.
number = string.
else.
number = string.
endif.
regards
DLC

Similar Messages

  • Easily read strings while tracking the number of bytes read?

    Hi all,
    I'm after a way to easily parse and read strings from a file, while also being able to check (at any point) how many bytes have currently been read from that file.
    I currently use the following for the string processing:
    BufferedReader in = new BufferedReader(new FileReader(filename));
    String str = null;
    while ((str = in.readLine()) != null)
      // process the string
    }That's all fine, but the files I'm reading can be very large (multi GB) so obviously it can take a while to read them. During this time I pop up a progress bar, and attempt to track the progress of the read. The files I'm working with just now come with a header on the first line that states how many "somethings" (that I happen to be looking for) will appear in the file. I can use that number to set the maximum value for the progress bar, and update its current value as I find them.
    However... I'm also about to start working with files that don't contain this information. I've thought of two ways of knowing how much work has to be done in advance of the read so the maximum value for the progress bar can be set:
    1) Quickly count the number of lines in the file without doing any processing. This works, but can still take some time for large files, even with more efficient reading algorithms.
    2) Use File.length() to set the maximum to be the number of bytes that will read.
    I'd like to use 2), but can't work out a way to use simple String based file parsing (as in the code above), but also be able to know how many bytes have been read so far. Using this code means I don't have to worry about end of line terminators, charset encoding, etc - the Reader does it for me.
    Any suggestions?
    Thanks

    import javax.swing.*;
    Component parent; // might be null, or your JFrame
    String message; // message to display in the progress bar
    BufferedReader br = new BufferedReader(new InputStreamReader(new ProgressMonitorInputStream(parent, message, new FileInputStream(file)), charset));

  • Read string

    Hi, I just want to read string through rs232 from my test boards and it can work property in high execution status ( display the string in the front panel) but if i run the vi automatically , it didn't display the string in front panel.
    how can i do and sort out.
    thanks

    Hi srt,
    Since the info is displayed while you highlight the execution, it would indicate that maybe you are reading your serial port too quickly.
    What you could do is place you read serial port within a loop which has a delay (wait = 50 ms) and you exit the loop when the serial buffer is empty.  How do you index the length of the buffer you are reading?  Maybe with a small timeout you don't actually ready the data from the port.  Placing the reading serial port in a loop with some delay (at least 10ms) and using "Bytes at Serial Port" to index the number of bytes to read and exit only if "Bytes at Serial Port" = 0 should solve this.
    By the way, I used to work at a company whose name was SRT. 
    JLV

  • To read string from another file

    Dear friends
    I am working on a project where i need to read log files which are there on my C drive.
    I got a folder and from that i need to read string from another folder and name them as URL,TS etc..so any body have any idea about this...

    I have no idea what you're even trying to do. Can you try explaining your problem more clearly and in more detail?

  • Problem with reading String from Xlsx file.

    Hi! I am trying to read string and numerical data from an xlsx file and trying to display its contents in a word file. I tried converting it to a .lvm file too. On using the "Read From Spreadsheet" tool, I get random characters as output. On using " Read From Measurement File" tool, I am getting an error saying "Error 100 occurred at Read From Measurement File->Untitled 1". What do I do? At the end I need to display the output, row by row, in a Microsoft Word file. I am so lost. Please Help.
    Solved!
    Go to Solution.

    bsvare wrote:
    labview currently does not read directly from an xlsx file. If you convert the xlsx to an xls file first, then you can use the read from spreadsheet tool to load the data from the file.
    Hey, I tried doing that. It still just gave the values 0.00 in all the cells of the indicator array. Plus my file has string in it also. The data type in the spreadsheet was "general". Here in the tool, it is "Double". I changed the tool data type to string and spreadsheet to text but I only got gibbrish for my efforts.
    Thanks anyway!

  • Reading String within the single quotes

    Hi All,
    Can you please let me know, how to read a String within the sinle quote in line.
    I have to read a report into internal table and again from that I need to read a string within the single quote. Please help me in this.
    Thanks in Advance,
    Raghu

    I have the following code:
    REPORT  test.
    DATA:  v_test(05) TYPE c.
    v_test = ‘TTT’.
    I am getting this errror:
    Field “TTT” is unknown.  It is neither kin on e of the specified tables nor defined by a “DATA” statement.
    For some reason, my single quote is not being recognized from my keyboard.  I noticed that my emotion icons are not being displayed either (example:  I type and i do NOT get the smiley face on my end).
    Is there a button that I pressed that caused that?

  • Reading strings and integers from a text file

    I want to read the contents of a text file and print them to screen, but am having problems reading integers. The file contains employee's personal info and basically looks like this:
    Warren Laing
    32 //age, data type is int
    M //gender, data type is String
    Sharon Smith
    44
    F
    Here's what I've done so far. The method should continue reading the file until there's no lines left. When I call it from main, I get a numberFormatException error. I'm not sure why because the data types of the set and get methods are correct, the right packages have been imported, and I'm sure I've used Integer.parseInt() correctly (if not, pls let me know). Can anyone suggest why I'm getting errors, or where my code is going wrong?
    many thanks
    Chris
    public void readFile() throws IOException{
    BufferedReader read = new BufferedReader(new FileReader("personal.txt"));
    int age = 0;
    String input = "";
    input = read.readLine();
    while (input != null){
    setName(input);
    age = Integer.parseInt(input);
    setAge(age);
    input = read.readLine();
    setGender(input);
    System.out.println("Name: " + getName() + " Age: " + getAge() + " Gender: " + getGender());
    read.close();

    To answer your question - I'm teaching myself java and I haven't covered enumeration classes yet.
    With the setGender("Q") scenario, the data in the text file has already been validated by other methods before being written to the file. Anyway I worked out my problems were caused by "input = read.readLine()" being in the wrong places. The code below works fine though I've left out the set and get methods for the time being.
    Chris
    public static void readFile()throws IOException{
    String name = "";
    String gender = "";
    int age = 0;
    BufferedReader read = new BufferedReader(new FileReader("myfile.txt"));
    String input = read.readLine();
    while(input != null){
    name = input;
    input = read.readLine();
    gender = input;
    input = read.readLine();
    age = Integer.parseInt(input);
    input = read.readLine();
    System.out.println("Name: " + name + " Gender: " + gender + " Age: " + age);
    read.close();

  • Error converting a read string to type Double.

    I'm trying to read data stored in a text file, a mixture of strings and data.
    Using MyReader As New FileIO.TextFieldParser(source)
    Do
    intSampleCnt = intSampleCnt + 1
    strSample(intSampleCnt) = MyReader.ReadLine ' Reads a string like "filename.txt"
    dblOggLength(intSampleCnt) = CDbl(Val(MyReader.ReadLine)) ' <= Crash occurs here. Reads a number like 9.87654321
    ' additional code...
    Loop Until intSampleCnt = 10
    End Using
    Big problem: *I'm* not getting the error so I can't reproduce it. OTHER users are telling me they are getting the following error:
    System.InvalidCastException: Bringing the line "0.Au" to type "Double" is invalid. ---> System.FormatException: Input string had invalid
    format.
    No idea where "0.Au" is coming from. It's not in my file. Originally, I simply read the line and assigned it to the dblVariable (which worked for me). When users started reporting the error, I tried using:
    dblVar = CDbl(MyReader.ReadLine)
    When that failed, I tried:
    dblVar = CDbl(Val(MyReader.ReadLine))
    I must be on the wrong track. No idea why others are getting errors but not me. Any ideas? Thx.

    The first suggestion will set things up for you but you need to play with this
    Another suggestion is to place the culture code as the first line in the file i.e. to get the current culture code then change how data is written to the file
    System.Globalization.CultureInfo.CurrentCulture.Name
    Then read the file i.e
    Source text file
    fr-BE
    Somename 1 1000,56
    AnotherName 9,99
    Code
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim FileName As String = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "France.txt")
    Dim style As NumberStyles = NumberStyles.Number Or NumberStyles.AllowDecimalPoint
    Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture(IO.File.ReadAllLines(FileName)(0))
    Dim number As Decimal
    Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(FileName)
    MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
    MyReader.Delimiters = New String() {vbTab}
    Dim currentRow As String()
    While Not MyReader.EndOfData
    Try
    currentRow = MyReader.ReadFields()
    If Not currentRow.Length = 1 Then
    If Decimal.TryParse(currentRow(1), style, culture, number) Then
    Console.WriteLine("Converted '{0}' to {1}", currentRow(1), number)
    Else
    Console.WriteLine("Unable to convert '{0}'", currentRow(1))
    End If
    End If
    Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
    ' You decide how to handle issues
    End Try
    End While
    End Using
    End Sub
    Results
    Converted '1000,56' to 1000.56
    Converted '9,99' to 9.99
    Detect Decimal separator
    System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • How to Read string from keyboard input??

    Hi,
    I am writing an application that requires the user to input string
    text. I have declared a variable String[] SData. The user will enter
    several words in a line of string, and I want to be able to split
    these and assign it to different variables, e.g. A= SData[1]
    My problem is how do you assign the SData to what is being inputted?
    I was using SData = System.in.read()
    But I got a type compatibility error.
    Is there another way I can get user input into a string?
    Does anyone have any ideas? Any help would be greatly appreciated.
    Thank you.

    Is there another way I can get user input into a
    string?
    KeyboardInput
    Adapted from Jacquie Barker's "Beginning Java Objects" (2002)
    pp. 324 - 325
    To use, in main():
    KeyboardInput k = new KeyboardInput();
    k.readLine();
    To get the input stored in k,
    k.getKeyboardInput();
    import java.io.*;
    class KeyboardInput
    //User input is saved in this string
    private static String keyboardInput;
    public String readLine()
    char in;
    // Clears previous input
    keyboardInput = "";
    try
    // Read one integer and cast it into a character.
    // Keeps going until a newline character is read.
    do
    in = (char) System.in.read();
    keyboardInput = keyboardInput + in;
    } while ( in != '\n' );
    catch (IOException e)
    // Reset the input
    keyboardInput = "";
    System.out.print("\n\nError in reading keyboardInput: \n" +
    e + "\n\n");
    // Strips off any leading and/or trailing whitespace
    keyboardInput = keyboardInput.trim();
    // Return the complete String;
    return keyboardInput;
    } // End String readLine()
    public String getKeyboardInput()
    return keyboardInput;
    } // End String getKeyboardInput()
    } // End class KeyboardInput

  • Network-Shared Variable - read string with CVI

    I need to read an NSV string with CVI.  I have been digging into accessing and writing NSV with CVI, but they are all scalar value.  What should I do with strings, clusters and arrays?

    'm an employee at National Instruments and I wanted to make sure you didn't miss the Network Variable API that is provided with LabWindows/CVI, the National Instruments C development environment. The the Network Variable API will allow you to easily communicate with the LabVIEW program over Shared Variables (http://zone.ni.com/devzone/cda/tut/p/id/4679). While reading these links, note that a Network Variable and a Shared Variable are the same thing - the different names are unfortunate...
    The nice thing about the Network Variable API is that it allows easy interoperability with LabVIEW, it provides a strongly typed communication mechanism, and it provides a callback model for notification when the Network/Shared variable's properties (such as value) change.
    You can obtain this API by installing LabWindows/CVI, but it is not necessary to use the LabWindows/CVI environment. The header file is available at C:\Program Files\National Instruments\CVI2010\include\cvinetv.h, and the .lib file located at C:\Program Files\National Instruments\CVI2010\extlib\msvc\cvinetv.lib can be linked in with whatever C development tools you are using.
    Thomas N.
    Applications Engineer
    National Instruments

  • Reading String input?

    So the other day I thought I might go ahead and try to make a few simple programs to see if anything I have learned is soaking in. I did a few math ones, which were easy enough, but then I tried to do a password program. It was easy enough to write, but the thing is I could only do it with numbers. Although thats alright, I was aiming to do one with Strings rather than ints. Thing is I have no idea how to take the input of a String like an int would (readInt). Heres my short password program involving just ints if it helps any:
    package OtherStuff;
    import acm.program.ConsoleProgram;
    import java.util.*;
    public class stringPassword extends ConsoleProgram {
    public void run() {
         int password = 2256;
              while (true) {
                   int input = readInt("Enter a password: ");
                   if (input == password) {
                        println("Password accepted");
                        break;
                   if (input != password) {
                        println("Password not accepted\n");
    }So all in all, how can I take the input of a String and use it in the same way I use ints in the code above?

    jverd wrote:
    ldilley wrote:
    jverd wrote:
    ldilley wrote:
    jverd wrote:Reference values, actually.The values stored in reference variables are memory addresses.They may be implemented as such, but it's not required by the spec. The JLS has no concept of a memory address.Required or not, it is what it is. Nobody was questioning specification requirements; albeit the JLS does make mention of addresses of objects. I come from a C background and the concept of memory addressing is how I describe it. Terminology tends to bleed over if you use multiple languages. Regardless, you are wanting to debate about semantics. Let us not digress from the OP's inquiry.It was specifically for the OP's benefit that I brought it up. I've seen too much confusion from people blurring the lines between specification and implementation, and trying to apply concepts from other languages beyond where there's any similarity or any usefulness in doing so.
    A reference is simply an opaque value that is used to locate and object. The fact that it's an address is irrelevant. What is it an address of? In current Sun JVMs, I believe it's an address of a pair of pointers. One might say something like, "If you're familiar with addresses or pointers in other languages, you can think of a Java reference as the memory address of the object, even though that's not strictly speaking what it is." I don't see any value in telling a noob that it IS an address though.Making mention of memory addresses is certainly not beyond similarity or usefulness in the scope of this context if that is what you are implying. I do not believe it is irrelevant (I see from many of your posts that you like this word) to help Cypher understand what is going on conceptually. The "cubby holes" visualization of memory certainly helped me in my programming courses. The fact is, there are many people who can use the Web(tm) proficiently without knowing the related RFCs. The same applies to the JLS and programming with Java. It may help if you want to be a pedantic Java lawyer. However, knowledge of this document is definitely not required to use the language productively. So, inversely, I do not see the value in being overly concerned with semantics and the details of the JLS as it could be too restrictive and confuse "noobs".
    In fact, there are several college-level textbooks that explain reference variables in terms of memory addresses. "Java Programming: From Problem Analysis to Program Design" by D. S. Malik is one such book. So, again, this is certainly not irrelevant by any means.
    Regards,
    Lloyd D.

  • VISA READ STRING and GRAPH

    I have some basic questions:
    1. I have Serial communication from PXI to device. When I read the string of 26characters, continously, on Hypertermianl. It is fast enough. But when I read in the VI program, simple VISA read.
    The reading is very slow. The VISA read one character at a time and take time to make a string of 26characters. Visa read is very slow, Why?
    The baud rate is 1152K and rate is 32 updates per second, which is super fast in hyperterminal but very slow in Labview VI.
    2. Second I  need the extract the some data from my string at different positions on a string of 26 characters. I already made the subVI for reading it but since the VISA read is slow to read it gives wrong values from the string.
    So I thought I can make an array and ask the subvi to read the the second (i.e n-1 value) 26 characters which are ready rather than first one which is being formed. But there is no arrays for string.How can I do that? also my concern is if I read n-1 value, it is not real time value.
    :8 -0582                                n value Visa read slowly
    :000000 -0076U 0008 -0582   n-1 value
    :000000 -0074U 0008 -0582  n-2 value
    :000000 -0075U 0008 -0582  n-3 value
    3. I will extract the 74, 76, 77 etc say the value as AA. I want to plot the graph of value AA versus Seconds? How can generate Seconds on my X-axis?
    Attachments:
    TSS1-porem-final4.vi ‏16 KB

    Thank you for suggestion!
    Now I am receiving data continuosly.
    1. As mentioned previously, I wish to plot the heave value on real time basis, I saw the shipping example, modified my VI.
    The plot is not correct, as the heave value increases and decreases linearly but there is strange graph.
    2. Also I have one more question, actually if I want to find out the heave value, device once moved up 10cm and brought back to 0 level again. Its not instant as the design of the device says it takes 2 secs to get back to the zero state again. The heave is read from 10, 9, 8,7 6, 5, etc. It takes 10 steps to come back to normal value, zero value.
    I just need to plot the 0 and 10cm or may be  next might be -5cm, I need to capture the final data. How can i do that?
    Attachments:
    TSS1-porem-final4-1.vi ‏16 KB
    MRU-TEST3-1.vi ‏20 KB

  • Reading String Data

    Am quite new to java and having trouble with the syntax.
    Using package java.net, I am trying to read the output of an http client. I can echo the ouptut to screen but prefer not to do that.
    I tried the following but it sometimes raises an eInvalidPointer exception, and the compiler indicates that the string array resp may not be initialized.
    Would appreciate an idea of the best way to read the returned data from this http client.
    import java.net.*;
    import java.io.*;
    import java.util.*;
    class GetAvgLatency{
    public static void connectAndGet( String targetURL ){
    String dataLine;
    String[] resp;
    try{
    URL url = new URL( targetURL );
    //Open a connection to the URL and get a URLConnection object.
    URLConnection urlConnection = url.openConnection();
    //Use the connection to get an InputStream object.
    // Use the InputStream object to instantiate a DataInputStream object.
         BufferedReader htmlPage =
         new BufferedReader(new InputStreamReader(url.openStream()));
    //Use the DataInputStream object to read and store the received data one line at a time.
    int i = 0;
    while((dataLine = htmlPage.readLine()) != null){
         resp[ i ] = dataLine;
         i++;
    } //end while loop
    } //end try
    catch(UnknownHostException e){
    System.out.println(e);
    System.out.println("Must be online to run properly.");
    } //end catch
    catch(MalformedURLException e){System.out.println(e);}
    catch(IOException e){System.out.println(e);}
    } //connectAndGet
    public static void main(String[] args){
    String TheHost;
    int imax = 100;
    long t0, t1, deltaT;
    long sum = 0;
    float avg;
    // if ( args == null )
    TheHost = "Http://icmicronjwc/scripts/runisa.dll?eroicaLT:pgloadtest1";
    // else     
    //      TheHost = args[ 0 ];
    System.out.println( "Testing " + TheHost );
    System.out.println( "" );
    for ( int i = 0; i < imax; i++ ){
    t0 = System.currentTimeMillis();          
    connectAndGet( TheHost );
    t1 = System.currentTimeMillis();          
    deltaT = t1 - t0;
    System.out.print( i + " " + deltaT + " " );
    sum += deltaT;
    System.out.println( "" );
    System.out.println( "" );
    avg = sum/imax;
    System.out.println( "average app latency for " + imax +
    " requests is " + avg + " ms" );
    } //end main
    } //end class HttpTest
    tks,
    jwc

    You should create your array this way : String[] resp = new String[10]. If not, the compiler complains that it is not initialized.
    But this methods is not good. To store your strings, you should use a Vector, LinkedList or whatever you want, because you don't know how many lines you are going to store :
    Vector resp = new Vector();
    while((dataLine = htmlPage.readLine()) != null){
    resp.add(dataLine);
    i++;
    } //end while loop

  • Xml reading Strings

    Hi there,
    Im struggling to find a way to read XML data from a sting, the xml parse doesnt accept strings only files, inputssoures ect..
    Is there a way to do this,
    Also how can i send a file over SOAP?
    Thanks
    Robert

    Thanks DrClap,
    that was the problem, having not worked with StAX before I didn't know it could behave like this :(
    So I had a look at the documentation and tried setting the IS_COALESCING property but it seems the implementation of StAX that we have doesn't support this :( and doesn't have the methods isCoalescing :( and I don't have enough influence to change that.
    So I have had to set up my looping through events like the following pseudo code :
    if event != CHARACTERS && stringBuffer.length > 0
    process characters
    make stringBuffer empty
    do some event processing
    if event == CHARACTERS
    add the characters to the string buffer
    If there is a better way of doing this I'd like to know but at least I have something that works at the moment.
    Thanks
    Rob

  • Reading String (Name-Value) from text file into XML

    Hi,
    I have a requirement for reading a text file and converting each entry of that text file into XML format. I have not came across such thing yet so looking for some ideas. I am using SQL Server 2005 and here is a sample entry from my source text file,
    Jun 4 14:31:00 zzzz64x02 fff:
    INPUT(ty=XYZ,Prefix=15063,dn=78787878787878,sgk=100.139.201.48,xxn=87878,ani=656565656565,ogrp=F7ZX05,ogtxt=NNNNN,ogx=NNNNN,oci=0xe00ac,ogi={NOA=INT,BC=1,SIG-TYPE=ZIP});
    PROCESS(ty=0x100000,cu=32880,Name=XOXOXOX,pc=88017,pd=24,dd=880175,pk=880175,rd=115472,ca=BGD,reg=RW,cdp=1,ai=245359,grp=2648,sl=9);
    OUTPUT(ty=XXXX,ret=0,rl=
    {i=1,su=99999,rizID=61084,skid=06,truckgp=1084,dd=8801,dn=78787878787878}
    I will get multiple entries like this in my source text file which I have to convert into XML (using TSQL).
    Any help will be useful.
    Regards.
    'In Persuit of Happiness' and ..... learning SQL.

    And I'm telling you that this is a bad option. You would use the vaccum cleaner to wash the dishes, would you?
    If you for some reason would do this task in SQL Server, you would implement it as a CLR stored procedure, but from what you have said I don't understand why you would do this server-side at all.
    What's wrong with the current C# solution?
    Erland Sommarskog, SQL Server MVP, [email protected]
    Got it.  I was just looking for the available options, nothing wrong with my C# solution. And yes, I don't use vacuum cleaner to wash dishes.
    'In Persuit of Happiness' and ..... learning SQL.

Maybe you are looking for