Increment a Char Variable

How do you increment a character variable?
Eg.
DATA: L_VAR1(3) TYPE C,
          L_INC(3) TYPE C.
L_VAR1 = '080'
L_INC = '001'.
Then I need in a particular Loop run, L_VAR1 to vary from 080, 081, 082...120.
If I increment it with L_VAR1 = L_VAR1 + L_INC.
The next value stored is 81 and not 081.
Please provide Inputs in2 this.
Thanks

Hi..
Since u need a numeric value. Declare with Type N.
Eg:
DATA: L_VAR1(3) TYPE N,
L_INC(3) TYPE N.
L_VAR1 = '080'
L_INC = '001'.
Then:
L_VAR1 = L_VAR1 + L_INC.  "This will work.
<b>
REWARD IF HELPFUL.</b>

Similar Messages

  • Increment CHAR variable

    Hi,
    I'm a beginner in ABAP and I have a question..
    Is possible increment a char variable?
    for example I have varible:
    R001 and i want increment this variable till RZZZ..
    There is some solution or some function that i could use to do this?
    Thanks so much.

    Hi,
    please find starting & ending sequence numbers from R000 RZZZ
    000     001     002     003     004     005     006     007     008     009     00A     00B     00C     00D     00E     00F     00G     00H     00I     00J     00K     00L     00M     00N
    00O     00P     00Q     00R     00S     00T     00U     00V     00W     00X     00Y     00Z     010     011     012     013     014     015     016     017     018     019     020     021
    022     023     024     025     026     027     028     029     030     031     032     033     034     035     036     037     038     039     040     041     042     043     044     045
    046     047     048     049     050     051     052     053     054     055     056     057     058     059     060     061     062     063     064     065     066     067     068     069
    070     071     072     073     074     075     076     077     078     079     080     081     082     083     084     085     086     087     088     089     090     091     092     093
    094     095     096     097     098     099     01A     01B     01C     01D     01E     01F     01G     01H     01I     01J     01K     01L     01M     01N     01O     01P     01Q     01R
    01S     01T     01U     01V     01W     01X     01Y     01Z     02A     02B     02C     02D     02E     02F     02G     02H     02I     02J     02K     02L     02M     02N     02O     02P
    ZUM     ZUN     ZUO     ZUP     ZUQ     ZUR     ZUS     ZUT     ZUU     ZUV     ZUW     ZUX     ZUY     ZUZ     ZVA     ZVB     ZVC     ZVD     ZVE     ZVF     ZVG     ZVH     ZVI     ZVJ
    ZVK     ZVL     ZVM     ZVN     ZVO     ZVP     ZVQ     ZVR     ZVS     ZVT     ZVU     ZVV     ZVW     ZVX     ZVY     ZVZ     ZWA     ZWB     ZWC     ZWD     ZWE     ZWF     ZWG     ZWH
    ZWI     ZWJ     ZWK     ZWL     ZWM     ZWN     ZWO     ZWP     ZWQ     ZWR     ZWS     ZWT     ZWU     ZWV     ZWW     ZWX     ZWY     ZWZ     ZXA     ZXB     ZXC     ZXD     ZXE     ZXF
    ZXG     ZXH     ZXI     ZXJ     ZXK     ZXL     ZXM     ZXN     ZXO     ZXP     ZXQ     ZXR     ZXS     ZXT     ZXU     ZXV     ZXW     ZXX     ZXY     ZXZ     ZYA     ZYB     ZYC     ZYD
    ZYE     ZYF     ZYG     ZYH     ZYI     ZYJ     ZYK     ZYL     ZYM     ZYN     ZYO     ZYP     ZYQ     ZYR     ZYS     ZYT     ZYU     ZYV     ZYW     ZYX     ZYY     ZYZ     ZZA     ZZB
    ZZC     ZZD     ZZE     ZZF     ZZG     ZZH     ZZI     ZZJ     ZZK     ZZL     ZZM     ZZN     ZZO     ZZP     ZZQ     ZZR     ZZS     ZZT     ZZU     ZZV     ZZW     ZZX     ZZY     ZZZ
    My suggestion will be create a custom table and keep all possible combination numbers in it and use this table

  • How to store serval char variables into a string variable?

    I have serval char variables, but i don't know how to put them together (without using arrays). I am thinking to store these char variables into a string variable but i don't know how to do it. For example,
    char letter1 = 'a', letter2 = 'b', letter3 = 'c';
    String letters;
    then how can i do to make letters = "abc" from using letter1,2,3?
    I am just a beginner of Java, if anyone can help me, i will appreciate that very much!!!

    String letters=""+leter1+letter2+letter3;is fine and dandy. What it actually compiles to is
    String letters = new StringBuffer().append(letter1).append(letter2).append(letter3).toString();Which ofcourse is much more code to write, but still good to know.
    So do see the API for java.lang.StringBuffer.
    Heikki

  • How to get a "char variable" with presentation variable???

    I want to pass a char variable with presentation variable, I don't have problems if I pass "int".
    For example in answers page I add a column that contains years of my dimension. 2000 until 2012 and prompted my presentation variable "year" (from my dashboard prompt) and when I go to dashboard if I choose in my prompt 2006 in my report appear 2006...any problem and easy. But my problem is if I would pass a char variable, in my prompt also I have months but not numbers else names: January, February, March...and a presentation variable that name is "month". If I do the same report but change column year to month (name) I don't have any results and I have an error.
    How can I solucionate this???
    Thank you!!

    Alex,
    Do you have separate columns for Year and Month Name. If Yes, Then why it is so confusing?
    1. create a dashboard prompt with month name column
    2. Assign it to monthname variable
    3. In your report use above variable any where.., but what ever you are doing should be logical and valid to get some data.
    In general above approach will work.
    You said, "No! I don't want to do a filter with month! I would like to pass this variable, in this example don't make sense but I need to pass a char variable with presentation variable to do another things..."
    what does that mean, what you are trying to do with the variable in your report. If you give a example that would be better.
    - Madan

  • How to convert DATE variable to CHAR variable

    dear all,
    How to convert DATE variable to CHAR variable
    thanq

    Depending on your final goal here are 2 options.
    DATA: datein        TYPE d.
    DATA: dateout(10)   TYPE c.
    DATA: dateout2(8)   TYPE c.
    datein = sy-datum.
    WRITE datein TO dateout MM/DD/YYYY.
    dateout2 = datein.
    WRITE:/ datein, dateout, dateout2.
    and the output
    05022008 05/02/2008 20080502    

  • Storing numbers in char variables.

    Hi All
    I need to store a number in a character variable
    Num =  686  (integer type)
    here c1 is the char variable of length 4.
    If I give C1 =  Num
    the value is not stored.
    How to store a number in a character variable.
    Regards
    Renuka.

    Works fine. run the code below.
    REPORT  ztest.
    DATA: n TYPE i VALUE '6666',
          c TYPE char4.
    c = n.
    BREAK-POINT.
    write: c , n.

  • Incrementing an array variable!!!

    Hello,
    I wanna know if we can increment an array variable by more than 1.
    When I use for(i=0;i<10;i+4) it is giving me an error.Just wanted to know if we can increment an array variable by any value other than 1.
    Thanks

    Your are right, I see that thank you
    Ok sorry guys for pasting the assignment. I have done some thing but me not sure weather I am doing right way or not. here is my code. And by the way how to return the integer to the main function "public static void main(String args[]){" from static integer function "static int isCentered(int[] a){"
    Code for Q. 1)
    Out put:
    {1,2,3,4,5} => 0(the middle element 3 is not strictly less than all other elements)
    {3,2,1,4,5} => 1(the middle element 1 is strictly less than all other elements)=>
    {3,2,1,4,1} => 0(the middle element 1 is strictly less than all other elements)
    {3,2,1,14,6} => 0(no middle element since array has even number of elements)
    {} => 0(no middle element)
    {1} => 1(satisfies the condition vacuously)
    import java.io.*;
    public class isCenteredArray{
    public static void main(String args[]){
    isCentered(new int[]{1, 2, 3, 4, 5});
    isCentered(new int[]{3, 2, 1, 4, 5});
    isCentered(new int[]{3, 2, 1, 4, 1});
    isCentered(new int[]{3, 2, 1, 1, 4, 6});
    isCentered(new int[]{});
    isCentered(new int[]{1});
    static int isCentered(int[] a){
    int ar=0;
    if(a.length%2 ==0){
      return ar;     
    int j=1;     
    for (int i=0; i<a.length; i++){
    if(j != a.length/2){
    if(a[i] > a[a.length/2]){
    ar = 1;
    }else{
    ar = 0;
    return ar;     
    j=j+1;     }     
    return ar;           
    Code for Q. 2)
    Out put:
    {1,2,3,0} => 1(because 1+2 = =3+0= =3)
    {1,2,2,1,3,0} => 1(because 1+2 = =2+1= =3+0= =3)
    {1,1,2,2} => 0(because 1+1 = =2 != 2+2)
    {1,2,1} => 0(because array does not have any even number of elements)
    {} => 1
    import java.io.*;
    public class isDualArray{
    public static void main(String args[]){
    isDual(new int[]{1, 2, 3, 0});
    isDual(new int[]{1, 2, 2, 1, 3, 0});
    isDual(new int[]{1, 1, 2, 2});
    isDual(new int[]{1, 2, 1});
    isDual(new int[]{});
    static int isDual(int[] a){
    int ar=0;
    for(int i=0; i<=a.length; i++){
    if(i%2 !=0){
    if((a[i-1] + a) == a[i+1]){
    ar = 1;     
    }else{
    ar = 0;     
    return ar;
    return ar;     
    Code for Q. 3)
    Out put:
    {1} => 1(true vacuously)
    {2} => 0(contains no odd elements)
    {1,1,1,1,1,1} => 1
    {2,4,6,8,11} => 1
    {-2,-4,-6,-8,-11} => 0
    import java.io.*;
    public class idOddHeavyArray{
    public static void main(String args[]){
    isOddHeavy(new int[]{1});
    isOddHeavy(new int[]{2});
    isOddHeavy(new int[]{1, 1, 1, 1, 1, 1});
    isOddHeavy(new int[]{2, 4, 6, 8, 11});
    isOddHeavy(new int[]{-2, -4, -6, -8, -11});
    static int isOddHeavy(int[] a){
    int ar=0;
    int oddheavynumber=0;
    for (int i=0; i<a.length; i++){
    if(a>oddheavynumber){
    oddheavynumber = a[i];     
         }else{
    oddheavynumber=oddheavynumber;          
    if(oddheavynumber%2==0){
    ar=0;     
         }else{
    ar=1;          
    System.out.println(ar);
    return ar;          
    Please check the way out how I did and let me know if I am going the wrong way...
    Thanks,
    Indoman

  • How to increment a character variable?

    Hi,
    I need to increment v_chgno by 1. But the following code gives me runtime error. Please can anyone guide me where i am going wrong.
    Data:  v_chgno TYPE char12 value 'CR0000000000',
              v_newchgno TYPE char12.
    v_newchgno = v_chgno + 1.
    Thanks in advance.
    Sunanda.

    Hi,
    It is not possible to increment the value when charecters are included in it, else if the variable is numeric even though declared as charecters will support arithemetic operations.
    Kindly refer the below code, it should work.
    Sample Code
    DATA: v_chgno TYPE char12 VALUE 'CR0000000000',
          v_chars TYPE char2,
          v_numeric_val TYPE char10,
          v_newchgno TYPE char12.
    v_chars = v_chgno+0(2).
    v_numeric_val = v_chgno+2(10).
    v_numeric_val = v_numeric_val + 1.
    SHIFT v_numeric_val RIGHT DELETING TRAILING space.
    OVERLAY v_numeric_val WITH '0000000000'.
    CONCATENATE v_chars v_numeric_val INTO v_newchgno.
    WRITE / v_newchgno.
    Pls do reward if useful.
    Regards,
    Farheen.

  • Cannot resolve symbol on char variable

    my compiler stops at this line
    char variablename = keyboardInputChar();
    i am trying to input a character and declare a variable at the same time.
    what am i doing wrong?
    any help appreciated.

    my compiler stops at this line
    char variablename = keyboardInputChar();Well, variable 'variablename' can definitely be resolved, because your defining it there; I think your compiler can't find method 'keyboardInputChar()' anywhere. Have you defined that method in the same class?
    kind regards

  • SAP Delivered Content Variable (Help Docs) on Time Chars Variables

    Hi,
    Is there any Helps docs available any where abt the functionality of Content Variables delvered by SAP (using SMOD)
    I am looking for a variable which selects  Based on Fiscal Period/Year...that selects Last 12 Closed Period.
    Lets assume current period is 03.2009 ,Then i need a user exit/sap exit that dynamically populates
    As current period is still open
    03.2008  -   02.2009
    Please update is there any Content variable for this purpose or what is the logic i should use for User exit
    Thanks

    just give in precise search in google and you will find lot of links like following to help you on this matter
    http://help.sap.com/saphelp_nw04/helpdata/EN/f1/0a5702e09411d2acb90000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/EN/eb/6ff4382f23f671e10000000a11405a/content.htm

  • Comparing to char variables

    I want to see if:
    char theSquare==("g");
    is this possible?
    I'm getting errors so that my program won't compile.
    I read in a char and store it in theSquare and I want to see what letter it is. It won't let me use .compareTo() or .equals() either for some reason. Please Help.

    char c = 'g';
    if (c == 'g') {
    do statements
    else { do statements }

  • Parsing char-variables to String

    Hello,
    I 've got a little problem: I got three characters like 'a','b','c' and want to parse these characters in a String like str = "abc". How can I do so , or isn't this possible in general ?
    Regards
    Findus

    or even more simple, even though this is not the
    proper programming theory you should use... let's
    pretend the chars are in an array called chars..It's not really any more simple than using a StringBuffer. Using StringBuffer and appending each characters is a lot more efficient than creating a new String object for each iteration. This is a lazy shortcut I used to use too, but it's not worth it :P

  • Concatenating char variables and integer (sy-index)

    Hi.
    I am trying to add a running number to the end of a character field, but encountered an error. The code is as follow:
      DO 10 TIMES.
         TXT_FILE = 'TXT_FILE' & SY-INDEX.
      ENDDO.
    Any help would be appreciated. Thanks.

    hi,
    do like this
    Do 10 Times.
      concatenate 'TXT_FILE' SY-INDEX into TXT_FILE.
    Enddo.
    <b>Reward for helpful answers</b>
    Satish

  • Evaluating a char variable which contains a Expression

    Hi,
    I am creating a function ,which has got three parametrers and it should return a numeric value.
    I will write down the function
    create function fun1(expr varchar,res1 number,res2 number)return number
    begin
    if expr then
    return res1;
    else
    return res2;
    end if;
    end;
    This is my logic, expr parameter can have any expressions,eg: CTC+basic+hra>5000
    my function should evaluate this and return the respective values.
    Anybody please help me out for this issue.If you have some other logic to implement the same please do replay.
    Regards
    Rupesh

    Here's a function (It can cause too many hard parses, I don't know any other solution for 9i)
    declare
      function fun1(
        expr  varchar2,
        res1  number,
        res2  number)
        return number
      is
        res  number;
      begin
        execute immediate 'select :res1 from dual where ' || expr ||
                          ' union select :res2 from dual where not ' || expr
                     into res
                    using res1, res2;
        return res;
      end;
    begin
      DBMS_OUTPUT.put_line(fun1('1+1&gt;1', 1, 2));
    end;

  • Incrementing and decrementing variable

    Hi guys
    I´m new in Labview Programming and I´m working with the  NXT module in Labview 2010, and I have some problems, because I´m used to the C programming
    and LabView is kind of diferent than C
    The thing is wath I wanna make a speed regulator using the NXT brick
    Using the left arrow button the speed will increase and using the right arrow button the speed will decrease
    I´m usin the servomotor connected to the PORT A of the NXT brick, 
    Thanks
    Diego 
    Solved!
    Go to Solution.

    I get this code working properly but I don´t know why sometimes when I press the Left Arrow Button of the NXT Brick, The screen shows "Speed of Motor : -1" and everything just Stop and don´t work again, I have to reset the NXT brick to get it working again.
    What are the NXT terminal of each one of the NXT VI of Labview? I see each one of the Lego VI have a NXT input and a NXT output and How do I have to connect this NXT Terminals for my code?
    Thank you for answer
    Diego
    Attachments:
    Medir luz.vi ‏15 KB

Maybe you are looking for

  • Help computer will not boot up!

    Hi, I followed the guide on PBfixit.com to replace my hard drive. After doing so, putting it back together, the computer will not start up, no chime. When plugged it it has the green light on, showing power. Help! Any suggestions would be thankful..

  • Lenovo 11e Chromebook not connecting to Meraki access point.

    I have a Meraki mr18 for an access point.  The 11e Chromebook will connect, but will not connect to the internet.  If I jump into the shell and ping an ip address, it will connect for about 10 times then I get the error:  "ping: sendmsg: No buffer sp

  • [Solved] Hanging while startx

    Hello, I'm new to archlinux and I tried to follow the instructions for installation. Now I am hanging at testing x. I typed "startx" It will load and hang at: "Initializing built-in extension DRI2" Not sure what I did wrong, With no key combination I

  • Starting the new multiple point Warp stabilizer

    I do aerial photography with a large rc helicopter. Camera movement is hard to get rid of. I am looking forward to the upgraded Warp stabilizer "VFX" to help with that. I have been using the Warp in AE and motion tracking. I just don't know how to la

  • Why I can't execute Plan Settlement after changing CO document in KANK?

    I changed assignment of Plan Settlement Business Transaction from Planning Transaction Group Number ranges to Settlement Group Number Ranges in KANK. I did it for having the document number ranges consistency : all settlement (Actual and Plan) within