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.

Similar Messages

  • How to increment a character

    for eg/- i want to generate a,b,c,d,e,f...
    in C i can add 1 to ascii value, but in java '+ ' will cause concat. Point to some API if there is

    Usually I just create literal of the characters I want to run over, and then use charAt(i++) to get the next one.
    e.g.
    "abcefghijk".charAt(index);You can use casts though - cast character to int and back again as in:
    ch = (char)((int)ch + 1);

  • 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>

  • How do I get "CO" variable 01 to 67 in character format?

    Post Author: Dennis Hernan
    CA Forum: Data Connectivity and SQL
    I have 2 databases. "DBA"."RMS_A0_SEGMENT" & "DBA"."RMS_G0_SEGMENT". The A0 segment has a CNTY variable. We create table B from A only to create SELYEAR & CO. SELYEAR is numeric because it is "2007 as". CO is numeric because it is "CNTY as". The values in CNTY are 1 to 67 numeric. How do I get "CO" variable 01 to 67 in character format?
    Is this standard SQL or would you call it Crysal SQL format? Select "B"."CNTY", "B"."SR", "B"."SEG", "B"."FED_AID",         "B"."TBK_CODE", "B"."PAVE_CYC", "B"."SURFACE",  "B"."LENGTH",         "B".SELYEAR, "C"."KEY_YEAR", "C"."SEG", "C"."SR", "C"."CNTY", "C"."SLDSTATU", "B"."CO" FROM (SELECT "A"."CNTY", "A"."SR", "A"."SEG", "A"."FED_AID",         "A"."TBK_CODE", "A"."PAVE_CYC", "A"."SURFACE",  "A"."LENGTH",         2007 as SELYEAR, CNTY as CO             FROM   "DBA"."RMS_A0_SEGMENT" "A") "B" LEFT JOIN "DBA"."RMS_G0_SEGMENT"  "C"  ON ("B"."SEG" = "C"."SEG") AND ("B"."SR" = "C"."SR") AND ("B"."CNTY" = "C"."CNTY") AND         ("B".SELYEAR = "C"."KEY_YEAR")

    Post Author: Dennis Hernan
    CA Forum: Data Connectivity and SQL
    Here's a simple example: SELECT "A"."A01_CTY_CDE", "A"."DIST_CODE","A"."CTY_NAME", A01_CTY_CDE AS CO NUMERIC(2) FROM SYSADM.CNTY_DIST_XREF "A" I'm trying to create the CO variable numeric(2) from the A01_CTY_CDE which is character(2). The values in A01_CTY_CDE are 1 to 67 character, I need CO to be numeric to merge with another linked table. "I am using the Add Command In Database Expert". I need 4 variables when this is done in the Command Database, A01_CTY_CDE, DIST_CODE,CTY_NAME all charater from the original database "SYSADM.CNTY_DIST_XREF". Also I'm trying & need your help, to create a variable CO with a numberic format, and the values equal to the A01_CTY_CDE variable. Call If you like, Dennis, 717.787.7293.

  • How to create a global variable in forms 6i

    How to create a global variable in forms 6i

    :GLOBAL.my_var := 15; Well, this statement is not correct! Global variables
    stores a character string of up to 255 characters in
    length. Thus, valid statement for Khurram example
    is:
    :GLOBAL.my_var := TO_CHAR(15);
    or
    :GLOBAL.my_var := '15';
    But numeric values are implicitly converted by oracle so there's nothing in fact wrong with the statement...
    :GLOBAL.my_var := 15;
    ;)

  • How to add a character before formula values in BEx.

    Hi Guys,
    Can anybody please let me know how to add a character before result of a formula.
    Ex. formula is 10/30*100
    I want to see in report 33.3 %
    thanks in advance
    peter b

    hi..
    You can use a formula variable with Customer Exit

  • How to use escape character in update statement.

    Hi All,
    I'm trying to update table using following sql update statement, but everytime it's asking me for the input due to the '&' value in below sql.
    UPDATE xyz_xyz
       SET NAME = 'ABC & PQR'
    WHERE ID = (SELECT ID
                   FROM abc_abc
                  WHERE NAME = 'C & PQR');Please let me know how to use escape character syntax or let me know if there is any alternative solution.
    Thanks,
    Vishwas

    Hi,
    By default, & marks a substitution variable name.
    If you're not using substitution variables in that statement (or, if this is in PL/SQL, in that entire package or procedure) then the easiest thing to do is just diable substitution variables; then & will be a normal character:
    SELECT  DEFINE  OFF
    UPDATE xyz_xyz
       SET NAME = 'ABC & PQR'
    WHERE ID = (SELECT ID
                   FROM abc_abc
                  WHERE NAME = 'C & PQR');
    SET  DEFINE  ONIf you can't do that, then & is always taken literally if it comes right before a single-quote, so you could say:
    UPDATE xyz_xyz
       SET NAME = 'ABC &' || ' PQR'
    WHERE ID = (SELECT ID
                   FROM abc_abc
                  WHERE NAME = 'C &' || ' PQR');There is a SQL*Plus "SET ESCAPE" command, too, but if you use it, you have to worry about whether the escape character is to be taken literally or not.
    SET   ESCAPE  \Yet another alternative is to make some other character, such as ~, mark the substitution variables:
    SET  DEFINE  ~Read all about them in the SQL*Plus manual.
    http://download.oracle.com/docs/cd/B28359_01/server.111/b31189/ch2.htm#sthref103

  • How to set NLS character set for report 9i servlet output?

    Hi,
    I am running a Reports 9i report. My problem is that the output HTML file is UTF8 encoded while ALL my 9iASR2 registry setting are set to EEISO8859P2. When I issued the http://&lt;host:port&gt;/reports/rwservlet/showenv?server=servername command it returned that the NLS setting is UTF8.
    Can somebody please help me, how to set this environment variable for the report servlet to EE..P1? Thank you in advance.
    Regards,
    Tamas Szecsy

    Dmitry,
    recently I got this from Oracle support. :-(. Currently when I set the Windows 2000 local and default local to Hungarian and the charset to EE..P2 then I get Central-European encoded charset. I think you will have to experience around to get correct result (if it is possible at all).
    +++++++++++++++++++++++++++++++++++++++++++++++++++++
    This is bug Number 2472932 NLS:RWSERVLET SETS INVALID CHARSET AT THE HTTP HEADER
    marked as fixed in 9.0.2.2 . unfortunately this bug is not published so I will not be able to sent you the bug as a whole but here is problem description in bug:
    iAS9.0.2.0.1 (Reports9.0.2.0.1) on Solaris2.8
    Running rdf with rwservlet sends the invalid charset at the http header.
    Say ias is up with LANG=C, http header for the rwservlet
    is always sent as "iso-8859-1" regardless of rwserver's NLS_CHARACTERSET.
    This is the TCP/IP packet for the GET /reports/rwservlet?report=xxx&....
    HTTP/1.1 200 OK Date: Sat, 20 Jul 2002 01:15:37 GMT Cache-Cont
    rol: private Content-Language: en Server: Oracle9iAS/9.0.2 Ora
    cle HTTP Server Oracle9iAS-Web-Cache/9.0.2.0.0 (N) Content-Leng
    th: 6908 Content-Type: text/html; charset=ISO-8859-1 Set-Cooki
    In this example, to produce a html with other charset than
    iso-8859-1,usually the outputted html has the charset information at
    meta tag by setting "Before Report Value" property in rdf.
    However charset in meta tag is less priority than http header, browser
    such as IE6 or Netscape7 firstly displays the page in iso-8859-1.
    Hence the characters other than iso8859p1 gets garbage.
    To workaround it with IE6/NS7, set proper encoding manually.
    ('View'-'Encoding' for IE 'View'-'Character coding' for NS7 )
    However, NS4.7 does not have workaround for it.
    Besides, starting opmn in LANG=ja, the rwservlet's http header becomes
    Shift_JIS!!. Thus rwserver seems to set the http header based on the
    LANG on Solaris.
    To fix these issues,
    - The http header for rwservlet shold be based on the nls_characterset
    for the rwserver.
    This is no problem for reprots jsp run.

  • How can i reuse same variables that i create using c:set var="index" /

    hi all,
    please some one helpme!!!!!!
    how can i reuse same variable that i create using
    <c:set var="index" value="${0}"/>
    cause later in the program i use index to do some condition and based on that i increment ...
    so for example if i say...
    <c:if test="${index==0}">
    <c:set var="index" value="${index+1}"/>
    </c:if>
    will it be like
    if(index==0)
    index++;
    can i do like i did be4. if not what do i need to do to reuse. cause i use the variable atleast 5 time and its keep changing on diff condition level.

    Have you tried it?
    It should work, provided you are on the same page.
    The c:set tag creates the variable in pageScope by default.
    If you forward to another JSP you need to set the scope to be "request" so that it is still available.

  • How to swap two string variables without using a 3rd variable?

    How to swap two string variables without using a 3rd variable?
    ex.
    A = "aa"
    B = "bb"
    Result required
    A = "bb"
    B = "aa"
    Thanks

    How to swap two string variables without using a 3rd
    variable?
    Something like this.
    Append A with B (so A equals "aabb")
    Set B equal to a substring of A starting with the first character and ending at A's length minus B's length. (So B equals "aa")
    Set A equal to a substring of A starting from B's length and ending at the end of A. (So A equals "bb")

  • How to find the value variable

    Hi, I am doing looping and dynamically creating the variable, after this, I will get the string that is the variable. In this stage how can I get the variable value.
    For Example, pls look into the follow proc
    CREATE OR REPLACE PROCEDURE VALUE_TEST AS
    MYSTRING1     VARCHAR2(100);
    MYSTRING2     VARCHAR2(100);
    A     VARCHAR2(100);
    B     VARCHAR2(100);
    BEGIN
         MYSTRING1     := 'FIRST VALUE';
         MYSTRING2     := 'SECOND VALUE';
         FOR I IN 1..5 LOOP
              A := 'MYSTRING' || I;
              B := 'MYSTRING' || I;
              DBMS_OUTPUT.PUT_LINE(A || ' ' ||B);
         END LOOP;     
    END;
    When I print the value of A, I should get the value of MYSTRING1, that is 'FIRST VALUE'.
    If anybody know, how to do that, pls let me know ASAP.
    Thanx a lot.
    Vijay.P

    Hi Vijaykumar...
    In A := 'MYSTRING' || I; you are NOT replacing your variable named 'A' with the variable named 'MYSTRING' concatenated to the value of the loop counter.
    You are replacing you variable named 'A' with a character string 'MYSTRING' concatenated to the value of the loop counter. The confusion may come from the fact that the name of the variable is a character string that is identical to the character string in your replacement statement.
    So you get...
    MYSTRING1 MYSTRING1
    MYSTRING2 MYSTRING2
    MYSTRING3 MYSTRING3
    &....The PL/SQL compiler intreprets the characters between the 's as a character string.
    To get...
    FIRST VALUE1 FIRST VALUE1
    FIRST VALUE2 FIRST VALUE2
    FIRST VALUE3 FIRST VALUE3
    &....remove the ' so the PL/SQL compiler will reconize it as a named variable.
    If you are trying to construct a variable name using concatenation, that cannot be done in PL/SQL without dynamic sql, a somewhat more complicated endeavor.
    Good luck. Hope this helps.

  • 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 do I use bin variable in package without asking a user?

    hi,
    I would like to write an SQL but I want to use bind variable in package as a static without asking user? Like below?
    I would like to ask you, below there is a emp_id variable? Is this BIND variable?
    DECLARE
    bonus NUMBER(8,2);
    emp_id NUMBER(6) := 100;
    BEGIN
    SELECT salary * 0.10 INTO bonus FROM employees
    WHERE employee_id = emp_id;
    END;
    If not, like this SQL how can define a BIND variable as static inside a code? not asking a user?
    db version. 9.2.0.8
    regards and thanks

    OracleADay wrote:
    I would like to ask you, below there is a emp_id variable? Is this BIND variable?
    DECLARE
    bonus NUMBER(8,2);
    emp_id NUMBER(6) := 100;
    BEGIN
    SELECT salary * 0.10 INTO bonus FROM employees
    WHERE employee_id = emp_id;
    END;
    /In the query "SELECT salary * 0.10 INTO bonus FROM employees WHERE employee_id = emp_id" emp_id is turned into a bind variable because
    if you are coding static SQL in PL/SQL then PL/SQL wil automatically use bind variables: please read http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/overview.htm#sthref145.
    This can also be proved with SQL trace. The following code:
    alter session set sql_trace=true;
    declare
    v number;
    c number;
    begin
    select count(*) into c
    from t
    where x=v;
    end;
    show errors
    alter session set sql_trace=false;generates following raw trace file section with 10G XE:
    =====================
    PARSING IN CURSOR #2 len=79 dep=0 uid=69 oct=47 lid=69 tim=33338762257 hv=2860574766 ad='3c10120c'
    declare
    v number;
    c number;
    begin
    select count(*) into c
    from t
    where x=v;
    end;
    END OF STMT
    PARSE #2:c=46800,e=329811,p=0,cr=9,cu=0,mis=1,r=0,dep=0,og=1,tim=33338762253
    =====================
    PARSING IN CURSOR #1 len=35 dep=1 uid=69 oct=3 lid=69 tim=33338788761 hv=3539261652 ad='3c10053c'
    SELECT COUNT(*) FROM T WHERE X=:B1
    END OF STMT
    PARSE #1:c=0,e=216,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=1,tim=33338788755
    =====================Edited by: P. Forstmann on 17 mai 2011 17:47
    Edited by: P. Forstmann on 17 mai 2011 17:55

  • How can I use environment variables in a controller?

    Hi all,
    How can I use environment variables in a controller?
    I want to pass a fully qualified directory and file name to FileInputStream and would like to do it by resolving an env variable, such as $APPLTMP.
    Is there a method somewhere that would resolve this??
    By the way,Did anyone used the class of "oracle.apps.fnd.cp.request.RemoteFile"?
    The following is the code.
    My EBS server is installed with 2 nodes(one for current,and other is for application and DB).I want to copy the current server's file to the application server's $APPLTMP directory. But the result of "mCtx.getEnvStore().getEnv("APPLTMP")" is current server's $APPLTMP directory.
    Can anyone help me on this?
    private String getURL()
    throws IOException
    File locC = null;
    File remC = new File(mPath);
    String lurl = null;
    CpUtil lUtil = new CpUtil();
    String exten;
    Connection lConn = mCtx.getJDBCConnection();
    ErrorStack lES = mCtx.getErrorStack();
    LogFile lLF = mCtx.getLogFile();
    String gwyuid = mCtx.getEnvStore().getEnv("GWYUID");
    String tmpDir = mCtx.getEnvStore().getEnv("APPLTMP");
    String twoTask = mCtx.getEnvStore().getEnv("TWO_TASK");
    // create temp file
    mLPath = lUtil.createTempFile("OF", exten, tmpDir);
    lUtil.logTempFile(mLPath, mLNode, mCtx);
    Thanks,
    binghao

    However within OAF on the application it doesn't.
    what doesnt work, do you get errors or nothing ?XX_TOP is defined in adovars.env only. Anywhere else this has to go?
    No, it is read from the adovars.env file only.Thanks
    Tapash

  • How to use one Bex Variable for two purposes in one query?

    Hi,
    I want to prompt for a UOM in a query. Then I want to use that one UOM variable to do 2 tasks in the query:
    1. Perform a UOM conversion on one restricted key figure (no filtering)
    2. Filter in a second restricted key figure (no conversion)
    How would I use a variable (or two?) to do this? I do not want to have 2 UOM prompts.
    Thanks!
    Gregg

    Oh, it all seems so easy now!  Hindsight 20-20...
    Solution was to create a new input ready variable for Unit.
    1. Restrict the key figures which need restricting using new variable
    2. For conversions, in BI backend us T-code RSUOM and create new conversion type associated with new variable. Then for each key figure needing conversion, set the conversion parameter to use the new conversion type.
    Between both 1 & 2 above, the same variable is used & thus prompted only once.
    Solution works perfectly.... as it should. Hope this helps someone else!

Maybe you are looking for