Increment a number within a string

Hi!
How can I increment a number within a string ?
This code doesn' t provide the rigth result
DATA zahl TYPE I.
DO 10 TIMES.
zahl = zahl +  1.
write:/ 'HALLO zahl'.
ENDDO.

Hello,
Change the code like this.
DATA ZAHL TYPE I.
DATA: LV_ZAHL(8),
      CHAR(255).
DO 10 TIMES.
  ZAHL = ZAHL + 1.
  WRITE: ZAHL TO LV_ZAHL.
  CONCATENATE 'HALLO' LV_ZAHL INTO CHAR.
  CONDENSE CHAR NO-GAPS.
  WRITE:/ CHAR."'HALLO'NO-GAP,ZAHL NO-GAP.
ENDDO.
Regards,
Vasanth

Similar Messages

  • Separating character and number within the string

    I want to separate the character and the number within one string.
    For example,
    12345ABCD (the numbers and character may differ in lengths)
    I want to separate into two different string of 12435 and ABCD.
    Your help would be greatly appreciated.
    Thanks!

    here is an example:
    sample_separator.sql
    declare
      i        number := 0;
      j        number := 0;
      x        number := 0;
      vBasis   Varchar2(40) := '12345ABCD';
      vString1 Varchar2(40);
      vString2 Varchar2(40);
    begin
      for x in 1 .. length(vBasis) loop
        for i in 0 .. 9 loop
          if substr(vBasis,x,1) = to_char(i) then     
            vString1 := vString1 || substr(vBasis,x,1);
          end if;
        end loop;
        for j in 65 .. 90 loop
          if substr(vBasis,x,1) = chr(j) then
            vString2 := vString2 || substr(vBasis,x,1);
          end if;
        end loop;   
      end loop;
      dbms_output.put_line('vString1: '||vString1);
      dbms_output.put_line('vString2: '||vString2);
    end;
    /when run:
    SQL> @r:\sample_separator.sql;
    vString1: 12345
    vString2: ABCD
    PL/SQL procedure successfully completed.
    SQL> hope this helps.

  • I aGenerating a Sequence Number within a String

    Hi folks,
    I am trying to create a control file which I would be using for load records using SQL*Loader. I need to generate the Sequence Number and use the value for the column REQ_NUM. I have a file TEST.TXT which contains 30 records with STUDENT_ID. I would like to create a control file because I want to load all 30 rows with the same REQ_NUM.
    Here is what I have but I need to get the value of the Sequence Number.
    spool testing.ctl
    'load data infile 'TEST.TXT'
    select
    'append into table DUMMY_TABLE
    FIELDS TERMINATED BY '','' optionally enclosed by ''"''
    trailing nullcols
    (req_num CONSTANT "select req_num_seq.nextval from dual",
    student_id)'
    from   dual;
    spool off;
    exit 0;
    {code}
    Any help is greatly appreciated. I am on Oracle 9i.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Sorry to have made this complicated but all I want to do is my output of the SQL as something like this.
    Now, I have a Sequence out there that I was planning on using. Assuming that the Sequence is currently at 362, so when I run the SQL, I should get this output below. Makes sense ?
    append into TEST_TABLE                                                                                                        
    FIELDS TERMINATED BY ',' optionally enclosed by '"'                                                                           
    trailing nullcols                                                                                                             
    (req CONSTANT '363',                                                                                                          
    student_id)
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Trying to determine the last occurence of a number within a word string.

    Hi All,
    I am trying to find the last occurence of a number within a string. I have had a quick look at the Java Tutorial and know about lastIndexOf and substring. The thing is I have to test for the existance of the numbers 0-9 within a product code that typically looks like this:
    s1_14G12B
    s1_17G1BA
    s2_24GD
    The only part of the above strings that I am interested in is the letter(s) that follow the very last number, so in the case of those codes presented above, I would like to extract the following:
    B
    BA
    D
    I have written some code that performs a similar operation:
    public class FindPriceCode
      private String priceCode;
      private String[] numberValues = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
      public FindPriceCode()
        priceCode = "s2_71G4BA";
        for(int i=0; i<numberValues.length; i++)
          int location = priceCode.lastIndexOf(numberValues);
    System.out.println("Character " + numberValues[i] + " found at position: " + location);
    public static void main(String[] args)
    FindPriceCode myPriceCode = new FindPriceCode();
    ...finding the location of numberValues string within the given example code. I am now at a loss as to how I can determine the location of the last number occurence (moving right to left) and then build a substring from that number. Any help will be greatly appreicated.
    Thanks
    David

    Hello,
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class CutNumberTest extends JFrame implements ActionListener {
         private JTextField input= new JTextField(10);
         private JTextArea result=new JTextArea(10,10);
         char[]numbers=new char[]{'0','1','2','3','4','5','6','7','8','9'};
         public CutNumberTest() {
              super("CutNumberTest");
              setDefaultCloseOperation(DISPOSE_ON_CLOSE);
              JButton cutButton = new JButton("cut number");
              cutButton.addActionListener(this);
              JPanel topPanel=new JPanel();
              JLabel label=new JLabel("Please enter price-code:");
              topPanel.add(label);
              topPanel.add(input);
              topPanel.add(cutButton);
              getContentPane().add(topPanel, BorderLayout.NORTH);
              getContentPane().add(new JScrollPane(result));
              pack();
              setLocationRelativeTo(null);
         public void actionPerformed(ActionEvent e) {
              char[] code=input.getText().toCharArray();          
              int counter=code.length;
              boolean lastNumFound=false;
              while(!lastNumFound && --counter >= 0)
                   lastNumFound=isNumber(code[counter]);
              result.append(lastNumFound ? "result: "+input.getText().substring(counter+1)+"\n" : "No number found!\n");
         private boolean isNumber(char chr){
              boolean isNumber=false;
              int counter=-1;
              while(++counter < numbers.length && !isNumber)
                   isNumber=numbers[counter]==chr;
              return isNumber;
         public static void main(String[] args) {
              new CutNumberTest().setVisible(true);
    }//copy/paste:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class CutNumberTest extends JFrame implements ActionListener {
         private JTextField input= new JTextField(10);
         private JTextArea result=new JTextArea(10,10);
         char[]numbers=new char[]{'0','1','2','3','4','5','6','7','8','9'};
         public CutNumberTest() {
              super("CutNumberTest");
              setDefaultCloseOperation(DISPOSE_ON_CLOSE);
              JButton cutButton = new JButton("cut number");
              cutButton.addActionListener(this);
              JPanel topPanel=new JPanel();
              JLabel label=new JLabel("Please enter price-code:");
              topPanel.add(label);
              topPanel.add(input);
              topPanel.add(cutButton);
              getContentPane().add(topPanel, BorderLayout.NORTH);
              getContentPane().add(new JScrollPane(result));
              pack();
              setLocationRelativeTo(null);
         public void actionPerformed(ActionEvent e) {
              char[] code=input.getText().toCharArray();          
              int counter=code.length;
              boolean lastNumFound=false;
              while(!lastNumFound && --counter >= 0)
                   lastNumFound=isNumber(code[counter]);
              result.append(lastNumFound ? "result: "+input.getText().substring(counter+1)+"\n" : "No number found!\n");
         private boolean isNumber(char chr){
              boolean isNumber=false;
              int counter=-1;
              while(++counter < numbers.length && !isNumber)
                   isNumber=numbers[counter]==chr;
              return isNumber;
         public static void main(String[] args) {
              new CutNumberTest().setVisible(true);
    Regards,
    Tim

  • Findind out the number of lines within a string - using buffered reader

    Hi All,
    Want to know the number of lines within a string..Sample code is there for reference..could u help me out how to have the number of lines in a string without java comments (i.e string within /**------*/ and // should be eliminated)
    public class ReadLines {
         public static void main(String[] args) throws Exception{
              ReadLines rl = new ReadLines();
              rl.readLines();
         void readLines() throws Exception{
              String str = "/** This is a test message\n"+
                   "* for testing\n"+
                   "*/\n"+
                   "import java.io.*\n"+
                   "// this is again comment\n"+
                   "public class ReadLines {\n"+
              BufferedReader reader = new BufferedReader(new StringReader(str));
              String line = "";
              int count = 0;
              while ((line = reader.readLine())!= null )
                   //line = reader.readLine();
                   count++;
              System.out.println(count);
    }Thanks
    MK

    Hi
    What you need to do is parse the file in such a way that you read /*, */ and // as tokens. By that I mean rather than read a line at a time (although I'm sure you could), read it character by character. So every time you reach a new line character then increment the counter. But there are two casaes when you don increment the counter they are:
    If you encounter a / followed by * then keep reading but if you encounter a newline character then DONT increment the counter ONLY continue counting when you read a * followed by a / (as this is the end of the comment)
    If you encounter / followed by another / then do not count that particular line and go to the next line and continue counting from there.
    Where I've written 'continue counting' this is subject to the lines that follow not conforming to the above two cases.
    I hope this helps.

  • Increment the number with date/time string. when ever the next date come's it should reset again with initial number

     i want to store the number of records in a file. Every time when ever i run the program the record will be incremented well i using forloop with count value 1 as a constant .in the for loop i am using autoincrement with the  feedback node . to view the number i have attached the indicatator .the number will be increment every time . i am using number to time time stamp  that is connected to get date/time string. from that we can view the date string and time string . so , my issue is when ever i close the code again it is coming with intial value . i should get from that number only where ever i close the code . after the date completed again it should come from intial value . i am attaching the code so that u guys can solve my problem.
    Attachments:
    record.doc ‏34 KB

    here you can see.......the file path in case structure in that i have included my requirement of increment the number 
    -> if the case is true then it goes in ok file path and the no of records string will pass in the file by seeing these code u will get the clarity
    my requirement is the number of records should increase ........ whnever the program runs...that i made it. by the next day again it should begain with the intial value.........that is my requirement. i hope u understand .
    suggest me how can i use the  intial  value .......
    Attachments:
    code.vi ‏35 KB

  • Find number within string

    Hi guys/gals,
    Im looking to be able to find a number (any number) within a text string, what i ultimately want to do is crop the number out of the string to just be left with a number value, the only problem is the string could be any length and the number doesnt necessarily start at any point from the last character
    I have items on the stage named 'image0', 'textfield2', 'button500' etc, as you can see the prefix before the number isnt a fixed length so I couldnt use substr and set an index, and since the number could be any number i couldnt set the index as a certain value before the end of the string. (ie it might return '500' or 'ld2' or 'ge0' in the examples given before)
    I was looking into how to use IndexOf, but I dont really know how to make it so that it finds any number rather than a specific one
    can anyone help me out?
    Thanks

    One way to do this is by using regular expressions.  In the example below, the str string has anything that is not a number removed.
    var str:String = "button500";
    var regex:RegExp = /\D/g; // matches anything that is not a digit
    var numStr:String = str.replace(regex, "");
    trace(numStr);

  • Get number of character within a String by number of pixels

    How can i get the number of character within a String
    by a width value...
    for example..
    i have a String = "1234567890abcdefghi.........."
    and when i give the width "10"
    i will get the String "12".
    or the number of charcter..
    or somthingggggggggggggggg
    please help..
    Shay

    i solved this...
    by doing somthing similar..
    i made a for loop on all character
    and evrey time i am get a sub string from the 0 till the loop index..
    and i am chashing the last string
    so when a sub width is greater the the requested width
    i am returning the lst cashed result
    thanks.. all..

  • How to get a set of character within a string?

    Hi,
    I need to cut a set of character within a string. I have tried everthing but I need help.
    Example.
    Database Version 11.2.0.3
    create table tst_string (message varchar2(600));
    insert into tst_string values ('ANR0166I Inventory file expiration finished processing for node OSOGBO, filespace OSOGBO\SystemState, copygroup BACKUP and object type GROUP BASE with processing statistics: examined 43, deleted 43, retrying 0, and failed 0. (SESSION: 1506, PROCESS: 2)');
    insert into  tst_string values ('ANE4175I Starting Full VM restore of VMware Virtual Machine ''mfujiwara'' target node name=''VC1_DC1'', data mover node name=''VC1_DC1_DM3''  (SESSION: 3780)');
    commit;
    select * from tst_string;
    MESSAGE
    ANR0166I Inventory file expiration finished processing for node OSOGBO, filespace OSOGBO\SystemState, copygroup BACKUP and object type GROUP BASE with processing statistics: examined 43, deleted 43, retrying 0, and failed 0. (SESSION: 1506, PROCESS: 2)
    ANE4175I Starting Full VM restore of VMware Virtual Machine 'mfujiwara' target node name='VC1_DC1', data mover node name='VC1_DC1_DM3'  (SESSION: 3780)
    ## I want get
    # From first line following values:
    node OSOGBO
    filespace OSOGBO\SystemState
    examined 43
    deleted 43
    retrying 0
    failed 0
    # From second line
    mfujiwara
    VC1_DC1
    VC1_DC1_DM3Any help can be useful...
    Thanks in advance.

    Hi Frank,
    It looks like message can be seen as delimited lsit of sub-messages, where a number of different characters (perhaps ',' amd ':') may serve as delimiters. Each sub-message may or consist (entirely or in part) of something you want to display.Yes. In my first case where is "ANR0166I" I want get the characteres before "," (e.g "OSOGBO," I want get "OSOGBO") excluding "(SESSION: 1506, PROCESS: 2)"
    Would a user-define PL/SQL function be okay for you?Yes.. no problem.
    I'm not good with shell script, but will try show what I want using SHELL commands:
    See this example:
    ### I create a file named "tst_string"
    $ vi tst_string
    ANR0166I Inventory file expiration finished processing for node OSOGBO, filespace OSOGBO\SystemState\NULL\System State\SystemState, copygroup BACKUP and object type GROUP BASE with processing statistics: examined 43, deleted 43, retrying 0, and failed 0. (SESSION: 1506, PROCESS: 2)
    ## So I used a function sed to get my desired values. The command bellow is poor, but My point is the result.
    $ cat tst_string | sed 's/ANR0166I.*node //g' | sed 's/, filespace//g' | sed 's/, copygroup BACKUP and object type GROUP BASE with processing statistics: //g' | sed 's/. (SESSION.*//g' | sed 's/, deleted//g' | sed 's/, retrying//g' | sed 's/, and failed//g'
    OSOGBO OSOGBO\SystemState\NULL\System State\SystemState 43 43 0 0The result was:
    NODE     FILESPACE                              Examined     Deleted     Retrying        Failed      
    OSOGBO      OSOGBO\SystemState\NULL\System State\SystemState     43           43      0           0I will go check the links wich you mentioned.
    Thanks

  • Increment a number without using sequence in Mapping

    Hi,
    Is there anyway to increment a number without using oracle sequence generator in OWB? I am using version 10.2.0.4.
    Please let me know.
    Thanks,
    Siva

    Perhaps it would help if you were more specific on what you wanted to do. I mean, there are many ways to generate sequences of numbers in Oracle. For example:
    select level as seq_num from dual connect by level < 100;
    to get the integers from 1 to 100. If you are dealing with order of rows within subsets of a query, take a look into analytic functions like rank().
    But "Ways to increment a number"? Sure:
    create function increment( x in number) returns number is begin if x is not null then return x+1; else return null; end if; end;
    Now call your increment function!
    Not sure what you are trying to accomplish, and can't help much without knowing.
    Sorry.

  • Searching for a substring within a string

    can someone reccomend a simple way to search for a substring within a string and count the number occurences of that substring.
    The substring and the string will be provided as command line parameters.
    Thanks
    gg

    A simple way would be to use the indexOf methods in String:
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
    Not sure what this has to do with event handling though :-P

  • Number-chars in string to int?

    Are there any string method that converts number-chars within a string to integers?

    String line = "12345";
    int i = Integer.parseInt(line);
    the other way aroundint i = 12345;
    String line = String.valueOf(i);just a little remark.. :)

  • Increment the number in Expression

    Hi,
    I am trying to increment the number in a expression transformation,instead of using sequence generator.
    Can you please let me know how to achieve this?
    Regards,
    Siva

    Hi Siva
    I mean you can use the SQL syntax for incrementing a sequence within an expression operator. Then you must ensure you configure the mapping to use Set Based only code generation and execution mode. So you can do something like the following in your expression;
    case when acol=2 then myseq.nextval else 0 end
    Cheers
    David

  • OBIEE - Find position of the last occurrence of a charcter within a string.

    Hi,
    I have a requirement in 11.1.1.6.9 to be locate the position of the last occurrence of a character within a string.
    i.e. Given the following, I would want to locate the last "/":
    This/is/an/exampleI would like to return a value of 11. Now, there could be any number of "/" so I can't always locate the nth one - it must be the last one.
    Anyone any ideas?
    Thanks,
    John

    Your requirement is not complete. just in case you want to extract the last part 'example' just use substring and replace to trim up to required part.
    You may have to go for the same for multiple times.
    ETL is the best to handle this than BI.
    BTW: Check this How to use locate function if multiple occurences of same character
    Edited by: Srini VEERAVALLI on May 10, 2013 10:25 AM
    Good that given link is helped you to solve it ;)
    Edited by: Srini VEERAVALLI on May 13, 2013 7:47 AM

  • Is there any way to link page number with the reference page number within text in InDesign CC and CS6?

    Is there any way to link page number with the reference page number within text in InDesign CC and CS6?

    You should ask in InDesign
    The Cloud forum is not about using individual programs
    The Cloud forum is about the Cloud as a delivery & install process
    If you will start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

Maybe you are looking for

  • Photoshop CS6 Crashing Daily

    Hello all, I'm having Photoshop CS6 (fully updated as of 5/1/2013) crashing daily for the past week. Computer is a Mac Pro mid-2010 8 Core with 32 GB of RAM. Anything anyone can assist with would be most helpful! Console log of Thread error: Process:

  • Not receiving email from my work email address.

    Hey Everyone, Normally it would be a blessing but I cannot send emails to my icloud/me account from my work email address. This was working last Thursday morning but then stopped working towards the afternoon. I have tried sending a test email with a

  • Do you have examples of CSV Format XML that can handle relationshiptypes?

    Hi, I have created a Windows Computer extended class that, for the sake of the example, has an additional property ServerNameRow , and a relationship (selected via Single Instance Picker control) BusinessUnitCustomersListPickerClass_Relationship. (Th

  • Email login page

    Every time I login to my email account I have to re-enter my username and password. I always tick the "remember me" box but it never remembers. Am I missing something?

  • Remove failed grid upgrade

    RHEL 4 64bit 11.1.0.6 Hi, I had a failed grid upgrade. I have fixed numerous error, and would like to try again. I have allready run ./rootupgrade.sh, but getting error : [*root@avgrac01 ~]# unset ORACLE_HOME* *[root@avgrac01 ~]# /u01/app/11.2.0/grid