Char to INT2 conversion

Hi all,
i have a character type variable of length 250 and it is assigned to a structure containing 15 fields and one of the field is of type INT2.
Now a character value of '77' is transformed to '14135' for that INT2 field when i assign the string to the structure.
Can any one tell me the reason behind this and is there any FM that would mimic the same conversion.
For INT2 data type the number of characters are 5 and the internal format is ABAP type as 's' and length = 2.
Amogh

HI Amogh,
   can you show your coding? I get 77 in int2 type variable also.
Regards,
ravi

Similar Messages

  • Char to Date conversion problem - again!

    Hi,
    in order to make date selection 'more attractive' for end users I have been tasked with presenting a text field with 'January 2010', 'February 2010' etc to the end users for their prompts.
    So far so easy...
    However, I then need to use the values to derive either dates, or years, or date numbers.
    This all works fine during development when I am testing using a default parameter thus; -
    '@{MYMONTHYEAR}{September 2010}' - which is fed into various very complex functions.
    BUT - when I try to use the report in conjunction with the parameter I get; -
    'The evaluation of the index 6 expression on row count -1 failed. [nQSError: 46046] Datetime value 2010/09/01 does not match the specifiied format'
    However, cast('2010/09/01' as date) works fine... and convoluted as the logic of my functions is, the fundamental char to date conversion is exactly in this format.
    Anyone shed any light on this, give me a guaranteed way to handle char to date conversion?
    thanks,
    Robert.

    Hi,
    I tried your workaround case when 1=2... but I still get the same error....
    Not when I have the format from my default value, but when I get the value from a dashboard prompt in a page.
    The full error is; -
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 46046] Datetime value 2012/09/01 does not match the specified format. (HY000)
    SQL Issued: SELECT s_0, s_1, s_2, s_3, s_4, s_5, s_6, s_7, s_8, s_9, s_10, s_11, s_12, s_13, s_14, s_15, s_16, s_17, s_18, s_19, s_20, s_21, s_22, s_23, s_24, s_25, s_26, s_27, s_28, s_29, s_30, s_31, s_32, s_33, s_34, s_35, s_36, s_37, s_38, s_39, s_40, s_41, s_42, s_43, s_44, s_45, s_46, s_47, s_48, s_49, s_50, s_51, s_52, s_53, s_54, s_55, s_56, s_57 FROM ( SELECT 0 s_0, "Vivaldi Detail"."Product Global Hierarchy"."Tobacco Category Groups" s_1, "Vivaldi Detail"."Product Global Hierarchy"."Tobacco Category" s_2, "Vivaldi Detail"."Product Global Hierarchy"."Total Tobacco Products" s_3, FILTER("Vivaldi Detail"."Fact Sales Detail"."SOM %" USING ("Vivaldi Detail"."Time"."Year" =cast((cast(right('September 2012',4) as integer)-1) as char(4)))) s_4, FILTER("Vivaldi Detail"."Fact Sales Detail"."SOM %" USING ("Vivaldi Detail"."Time"."Year" =cast((cast(right('September 2012',4) as integer)-2) as char(4)))) s_5, FILTER("Vivaldi Detail"."Fact Sales Detail"."SOM %" USING ("Vivaldi Detail"."Time"."Year" =cast((cast(right('September 2012',4) as integer)-3) as char(4)))) s_6, FILTER(FILTER("Vivaldi Detail"."Fact Sales Detail"."SOM %" USING ("Vivaldi Detail"."Time"."Year" =cast((cast(right('September 2012',4) as integer)-1) as char))) USING "Vivaldi Detail"."Time"."Month Number" <=month(CASE WHEN 1=2 THEN CURRENT_DATE ELSE cast(right('September 2012',4)||'/'||CASE left('September 2012',LOCATE(' ','September 2012')-1) WHEN 'January' THEN '01/01' WHEN 'February' then '02/01' when 'March' then '03/01' when 'April' then '04/01' when 'May' then '05/01' when 'June' then '06/01' when 'July' then '07/01' when 'August' then '08/01' when 'September' then '09/01' when 'October' then '10/01' when 'November' then '11/01' ELSE '12/01' END as date)END)) s_7, FILTER(FILTER("Vivaldi Detail"."Fact Sales Detail"."SOM %" USING ("Vivaldi Detail"."Time"."Year" =right('September 2012',4))) USING "Vivaldi Detail"."Time"."Month Number" <=month(CASE WHEN 1=2 THEN CURRENT_DATE ELSE cast(right('September 2012',4)||'/'||CASE left('September 2012',LOCATE(' ','September 2012')-1) WHEN 'January' THEN '01/01' WHEN 'February' then '02/01' when A brief sample of a typical formula which causes this is; -
    FILTER(FILTER(FILTER("Fact Sales Detail"."SOM %" USING ("Time"."Year" =   right('@{MYEAR}{September 2010}',4))) USING ("Time"."Month Number" = 2)) USING "Time"."Month Number" <= month(CASE WHEN 1=2 THEN CURRENT_DATE ELSE cast(right('@{MYEAR}{September 2010}',4)||'/'||CASE left('@{MYEAR}{September 2010}',  LOCATE(' ','@{MYEAR}{September 2010}') -1) WHEN 'January' THEN '01/01'  WHEN 'February' then '02/01' when 'March' then '03/01' when 'April' then '04/01' when 'May' then '05/01' when 'June' then '06/01' when 'July' then '07/01' when 'August' then '08/01' when 'September' then '09/01' when 'October' then '10/01' when 'November' then '11/01' ELSE '12/01' END as date)  END    ))The September 2010 default being EXACTLY what is selected from the dashboard prompt when testing. It does not error, but returns no data in isolation, but when when from the prompt it errors...
    And the date format, if fed into a cast ('2012/09/01' as date) does not error.
    Anyone help - this is really driving me mad, syntax is good - it should work!!!
    thanks,
    Robert.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Char to float conversion

    Hi,
    I am holding float value in a variable which i want to convert it into float again.
    Help Will be rewarded

    hi,
    u can take a float variable and move char into it directly.
    float1 = char1.

  • Reg : CHAR to FLTP conversion

    Hi All,
    I want to convert char value '55.5'  to floating point value.
    I tried using the below function modules. These two function modules does not accept the decimals .
    CHAR_FLTP_CONVERSION
    CHAR_FLTP_CONVERSION_TO_SI
    can any one suggest how can i convert the decimal char values ('55.55') to floating point values.
    thanks
    Vijay

    hi
    data:pack type p deimals 2.
    first pass char value to pack and then from pack pass it to floting point variable.
    Regards
    Neha

  • Abt char to numeric conversion

    There is a field named bcode in data base that is of char length 3 , i want 1 to 10 insert in dat field, is it possible , i know yes , so tell me dat field is behaving like character when i m selecting values from selection screen , what i want when i m entering 1 to 7 it should show only then as a numeric field do , how we can do dat? tell me in details?

    Then follow Sandipan Ghosh's suggestion above.  Read the database table into an internal table, convert the character numeric data to integer.  Change your select option to be integer.
    Or create a table, e.g. z_numtab, with two fields - CH3 type CHAR 3, and INT type INT1.  Populate it with all the numbers 0-999.  Then use it to convert the select option to a series of equalities.
    DATA: num TYPE c LENGTH 3,
          int TYPE i.
    DATA: lt_numtab TYPE STANDARD TABLE OF z_numtab.
    SELECT-OPTIONS: s_num FOR num.
    RANGES: r_num FOR i.
    FIELD-SYMBOLS: <ls_numtab> TYPE z_numtab.
    AT SELECTION-SCREEN..
      LOOP AT s_num.
        IF s_num-low CN ' 0123456789' OR s_num-high CN ' 0123456789'.
          MESSAGE e000(s1) WITH 'Numerics only'.
        ENDIF.
      ENDLOOP.
    START-OF-SELECTION.
      LOOP AT s_num.
        r_num-option = s_num-option.
        r_num-sign   = s_num-sign.
        r_num-low    = s_num-low.
        r_num-high   = s_num-high.
        APPEND r_num.
      ENDLOOP.
      SELECT * FROM z_numtab INTO TABLE lt_numtab WHERE int IN r_num.
      REFRESH s_num.
      s_num-sign = 'I'.
      s_num-option = 'EQ'.
      LOOP AT lt_numtab ASSIGNING <ls_numtab>.
        s_num-low = <ls_numtab>-ch3.
      ENDLOOP.
      SELECT * FROM dbtab INTO TABLE lt_dbtab WHERE bcode IN s_num.
    matt

  • Char to date conversion

    How to convert a date into char????
    When i'm using TO_CHAR('26-JAN-01','DD/MM/YY') it is showing error?
    Can anybody suggest me where i was wrong?
    Thanks in advance.

    Hi,
    Welcome to the forum!
    1002903 wrote:
    How to convert a date into char????
    When i'm using TO_CHAR('26-JAN-01','DD/MM/YY') it is showing error?
    Can anybody suggest me where i was wrong?'26-JAN-01' is a VARCHAR2, not a DATE. The first argument to TO_CHAR is supposed to be a DATE. If you use a VARCHAR2 in a place where a DATE is required, Oracle does not raise an error immediately. Oracle will try to convert the VARCHAR2 to a DATE, but that's likely t result in an error, anyway. Always call functions with the right types of arguments, not the wrong types.
    If you have a string that represents a DATE, you can convert it into a DATE using the TO_DATE function. You can then call TO_CHAR on the results, to get a string in whatever format you want:
    TO_CHAR ( TO_DATE ( '26-JAN-01'   -- or any string expression (a literal like this works, but it's silly)
                      , 'DD-MON-YY'
            , 'DD/MM/YY'
            )

  • Char to netprice conversion

    experts
    i am getting data from the flat file.
    i am getting amount which is 10 chars and i am storing it as in char
    data : price(10) type c.
    now i want to move it to sap netprice which is like this
    data :netpr type vbap-netpr.
    now i am trying to move the data like this.
    move price to netpr." here it is giving error as both are diffent types
    even i tried like this also
    write price to netpr" here also giving error.
    i cannot change the price  data type , so please tell me how to convert price which is char type to netpr.

    hi
    when the price is coming in your char field , just you need to take care to remove  comma ','. means in char field if 1,234.34 then you should use  string operations  REPLACE ,CONDENSE  etc  to make it  1234.34. if 1,234.00 to  1234.00
    you may hav to write logic as the user may hav different  decimal format , you can use FM SUSR_GET_USER_DEFAULTS to get the  user decimal format , and write code accordinly , ,,  Just remember delete commas , but  dot . should be in proper place to represent decimal..
    then just use "move char_field  to  netprice_field"  now it will not give any error.
    thanks
    Kakoli

  • Char to numeric conversion

    Hello,
             I am calling a subrouting from SAP SCRIPT.
             But in the subroutine I am not able to change the currecy value to integer.
            FORM cal_Tot tables ntwr structure itcsy
                                            tot structure itcsy.
           DATA value type vbap-netwr.
           value = ntwr-value.
            ENDFORM.
    If the value of ntwr-value is 300.0 its working but
    if the value of ntwr-value is 1,345.0 this is giving runtime error.
    How can store 1,345 into variable value

    Hi ,
    Chk this one
    report zcurr.
    data: input type  bapicurr-bapicurr .
    data: c(20) type c.
    data: output(15) type p decimals 2.
    c = '12,345.78'.
    clear sy-subrc.
    while sy-subrc = 0.
      replace ',' with space into c.
    endwhile.
    condense c no-gaps.
    input = c.
    call function 'BAPI_CURRENCY_CONV_TO_INTERNAL'
      exporting
        currency                   = 'INR'
        amount_external            = input
        max_number_of_digits       = 25
    importing
        amount_internal            = output
      RETURN                     =

  • Need help in Report.... Conversion of data elements

    Hi All,
    Iam doing a report. Chk the code below
    SELECT roleid
        FROM SRRELROLES
        INTO gs_roleid
        WHERE objkey = gs_guid
        AND objtype = ‘BUS2010020’.
    When i activate this it is throwin an error sayin dat <b>" GS_GUID and OBJKEY is not mutually convertible in a unicode program.... "</b>
    <b>Here objkey is RAW 16  and gs_guid is char(70)..</b>
    Can anybody help me out in this... and is there any conversion routines for doing this.
    Thanks,
    Shiva shekar k

    declare a gs_guid variable as raw data type .. and then convert it to char
    and for conversion refer
    convert raw type to char
    Convert RAW 1022 TO CHAR 255
    Convert RAW 1022 to CHAR 255

  • Performance question when compare date with date or char with char

    Hello from Germany (Frankfurt) !
    I am working on Oracle 9.2.0.8.0
    and have to solve following problem:
    Comparison of a date and char fields.
    Now two ways to do it.
    Either I compare char with char and convert date to char,
    or I compare date with date and convert char to date.
    Now the performace question. Which operation takes more effort for the database?
    So why not to try and to see the results?
    First create table:
    CREATE TABLE TEST (
    char_date VARCHAR2(8),
    real_date DATE
    NOLOGGING;
    Then insert 1.000.000 rows
    BEGIN
    for x in 1..1000000
    loop
    insert into test (char_date, real_date) VALUES('19990101', TO_DATE('2006.01.01', 'YYYY.MM.DD'));
    end loop;
    COMMIT;
    END;
    Collect statistics
    EXEC dbms_stats.gather_table_stats('TESTER', 'TEST');
    Now run some selects for date to char conversion:
    Elapsed: 00:00:00.00
    SQL> select * from test t where TO_DATE(char_date, 'YYYYMMDD') > real_date;
    no rows selected
    Elapsed: 00:00:03.02
    SQL> select * from test t where TO_DATE(char_date, 'YYYYMMDD') > real_date;
    no rows selected
    And some selects for char to date conversion:
    Elapsed: 00:00:03.02
    SQL> select * from test t where char_date > TO_CHAR(real_date, 'YYYYMMDD');
    no rows selected
    Elapsed: 00:00:02.05
    SQL> select * from test t where char_date > TO_CHAR(real_date, 'YYYYMMDD');
    no rows selected
    Elapsed: 00:00:02.05
    SQL>
    As you see when I compare char with char and convert date to char it seems to be faster (almost 1 second)
    Is the test correct?
    I still not sure, what gets better performance...
    Any idea?
    Thanks!

    Depends on whether you want the right results or not.
    Why don't you run the following two queries and see if the difference in results tells you anything?:
    with t as (select to_date('01/02/2007', 'dd/mm/yyyy') date_col from dual
               union all
               select to_date('02/02/2007', 'dd/mm/yyyy') from dual
               union all
               select to_date('03/02/2007', 'dd/mm/yyyy') from dual
               union all
               select to_date('03/03/2006', 'dd/mm/yyyy') from dual)
    select *
    from   t
    where  date_col < to_date('04/03/2006', 'dd/mm/yyyy');
    with t as (select to_date('01/02/2007', 'dd/mm/yyyy') date_col from dual
               union all
               select to_date('02/02/2007', 'dd/mm/yyyy') from dual
               union all
               select to_date('03/02/2007', 'dd/mm/yyyy') from dual
               union all
               select to_date('03/03/2006', 'dd/mm/yyyy') from dual)
    select *
    from   t
    where  to_char(date_col) < '04/03/2006';

  • Do and don't in ABAP

    hiii
    i would like yo know according to u're own experience what are the things to do when doing ABAP
    1. like never for select statement inside a loop
    2. don't select unnecessary things
    3. refresh internal table before using , clear after append etc..
    4. when doing open dataset ".txt or .xls"  store field in char and do conversion for curency value , date and qty.
    share the problems that you have encounter so as to prevent us programmer not to do same error.
    i am also searching for an edditor application (with abap syntax such as textpad) where i can store my program  code .  It is easier to read and work with when SAP application is not available etc...?

    In addition to the links that jackandjay listed, check out this .pdf by Marilyn Pratt. It helped me learn a lot as well.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5ac31178-0701-0010-469a-b4d7fa2721ca

  • Simple doubt in select statement

    hi all,
    Although this is a very simple ques.
    Can u pl tell me why i m not getting the value into v_adrnr ?
    Chk the following code.
    V_VBELN  = '0080000001'.
      SELECT SINGLE ADRNR
             FROM VBPA
             INTO V_ADRNR
             WHERE VBELN = V_VBELN
             AND   PARVW = 'BP'.
    i have cheked the table vbpa for the above mentioned conditions.I can see the
    value for adrnr in database as 0000022741.
    But while i run the above code i cant see value on v_adrnr.
    Pl help.

    First PARVW has a domain with a conversion routine based on table TPAUM so "BP" is internal code "RE"
    Use CONVERSION_EXIT_PARVW_INPUT
    CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
      EXPORTING
        input = V_PARVW
      IMPORTING
        output = V_PARVW.
    Second
    Have you defined V_VBELN with reference to the element VBELN, char 10 with conversion Alpha
    Then it should work
    Regards

  • Can anyone explain this? ORA-01722

    Hi all,
    Can anyone understand this?
    I have 3 database servers both running on windows 2000 advanced server, they're used by the development team. Also we have our production database.
    The 3 databases are cloned from the production, so database configuration parameters are all equal. Today I've received a query from the development team to run on the production, the query is just simple like this:
    SELECT *
    FROM x
    WHERE x.field_v = 177762522
    I get this error
    ORA-01722: invalid number
    this is a hudge table, and the fiedl_v is a varchar2(9) type.
    The worst thing is that on the others 3 databases this query returns results, except on the production.
    So, can anyone explain me why does the implicit (char to number) conversion occours on the development databases , and fails on the production? What are the main reasons that can influence datatype conversion like this one?
    Both databases have the 9.0.6 patch.
    The 3 development BD's are totally cloned from the production.
    Thanks.

    William:
    There is no guarantee on the order of evaluation of the predicates. Even with your isnum function, the invalid number could arise. The only safe way is to compare strings to strings as in your first example.
    To make the isnum "safe", you would need something more like:
    SELECT *
    FROM (SELECT *
          FROM x
          WHERE isnum(x.field_v) = 'Y' and
                ROWNUM > 0)
    WHERE x.field_v = 177762522;The ROWNUM > 0 predicate in the in-line view will prevent predicate pushing and guarantee that the isnum condition is evaluated first.
    John

  • How to get the day as numeric value without formatting the date?

    Hello,
    to reduce the costs of a sql-statement I need to get the day of a date-value as number (to compare it to a numeric value) without any formatting. Every formatting results in a full table scan of the table with the date field. Is there any function to solve this problem?
    Oracle version is 11g.
    Thanks Carsten

    CarstenDD wrote:
    select T1.SYSID from T2,T1
    where T2.SysT1 = T1.SYSID
    and T2.Date1 < '01.03.2011' --German date format
    and to_number(to_char(T2.Date2,'DD')) = 1
    and T2.Inactive = 0
    The explain plan shows a full table scan on T2. With EXTRACT(DAY FROM T2.Date2) there is no difference.It probably would and should in any case.
    Look at your predicates, which of them would reduce the resultset to a fair size compared to the total number of records in the table?.
    - You may have a huge number of records when you say date less than
    - Of these perhaps one seventh have day = 1
    - My guess is that most have Inactive = 0
    Besides, you should not rely on implictit char to date conversion, always use TO_DATE
    How many records are in the table? - How many will that query return?
    Regards
    Peter

  • Converting a hex String to its corresponding hex value...?

    Yeah, I'm having quite a bit of fun guessing this one... :p
    I have a string of n characters and have used Integer.toHexString( ( int )str.charAt( i ) ) to convert each character to a string representing its hex value. Now I need to USE that value for bit-wise operations, like, say, applying the AND, OR, etc. operators...
    Example:
    hexvalue &= 0xC000FFFF; //the second value is the one extracted from the string;
    How can achieve this...? Any help is greatly appreciated... :}

    Since a Java char is numerically a Java short, you can apply bitwise operators to chars directly - the conversion to hex simply changes the way that the char is viewed; the result can also be viewed as a number in other bases.
    For instance, the char 'A' can be also be represented as any of the following values:
    binary - 1000001
    octal - 101
    decimal - 65
    hex - 41
    Likewise, 'Z' can also be viewed as
    binary - 1011010
    octal - 132
    decimal - 90
    hex - 5A
    "Anding" the letter 'A' with 'Z' ('A' & 'Z') or doing the same using any of the other representations will result in (binary 1000000, octal 100, decimal 64, or hex 40) - the bit pattern is the same, only the representation of the result varies.

Maybe you are looking for