Dynamically change data type of a field

Hello,
I'm trying to dynamically create a SQL statement which will insert record sin to my SQL data base.
I dynamically bring field name sand values. then concatenate them in a string and then Execute the SQL string in a native SQL eXEC statement.
It all worked fine till I used signle quotes for all field values.
but now I wante dto insert a field of type "Money" is SQL which is nothing but AMount/currency in SAP.
Now If I remove this quotes it is working fine. but If I have a negative number the "-" sign comes in the end in my abap code and gives a short dump in insert statement.
now I wante dto make that variable dynamic in to currency rather than String.
Please let me know how Can I change it dynamically.
EG: w_field_value = 3000.25-  (value in SAP / w_field_value is of TYPE String)
Before I concatenate this , I wanted to change its type to AMOUNT ...
thanks.

Just Use the field Symbols.
Regards
Rusidar S

Similar Messages

  • Impact of changing data type of a field in Database table

    Hi All,
    I need to change the data type of a field(which is not a key field and it has no dependency with any other field) from NUMC to CHAR by maintaining the same length. Please let me know if there will be any impact in doing this. Hope the following things need to be taken care:
    - Take backup of entire data in the table before doing the change
    - After changing the data type, I need to set the option 'Save Data' and then 'Activate and Adjust Database' in 'Database Utility'.
    - Use 'Where Used List' to check the related objects.
    Please let me know if there is any impact or any thing else need to be taken care apart from the above things.
    Thanks in advance.
    Regards
    Vidhya.

    Hi,
    even if the length is same there would be no impact.
    just v need to adjust the database in the database utility.
    check the table maintenence generator also. if not reflected there u need to delete it and create it again.
    reward if useful,
    teja

  • How to change data type for a field?

    Hi Experts,
    I have one std screen having one field having numeric type. So it will accept only numeric value. Remember I am using standard transaction.
    Now my user wants to enter the special character like + or - in that field(having data type numeric).
    How i can change the data type for the particular field  so that it will also accept + or -?
    Plz reply me as earliest as possible.
    Thanks in advance.

    Hi salil ,
    u have to change / create Domain of  that Data Element.
    but u have to check the Implications. i have done the same thing , but that one is Customer defined one , i got nearly 20 short dumps while doing the TP.
    regards
    Prabhu

  • How to dynamically change data type

    Hi 
    Let say I have 1 byte in the folowwing hex format (1F )
    Then if I say convert it to 24 bit then the number should become 1F 00 00 and if I say convert it 32 bit the number should become 1F000000
    Could you please help me to implement this in LabVIEW ?
    Thanks

    Ah right, now I see why you mentioned dynamically changing the data type - LabVIEW is a strictly typed language which means you must end up with one of the numeric formats in LabVIEW (with 64-bits being the largest). If you're going to have more than 8 bytes, I'm not sure what the solution would be, if you're going to have 8 bytes or less then I would just assume the worst case and convert/fit the numbers into a U64.
    Here's an example:
    I am starting off with an empty U64, taking each input byte and shifting the U64 left by one byte and then adding the input byte.
    I guess that leads to my next question - what are you going to do with the numbers? Would having an array of U8's or converting the bytes to a character string not be better? If you have a string or array these can have a dynamic length so you can more easily manipulate the data (e.g. by performing string/array indexing functions).
    Certified LabVIEW Architect, Certified TestStand Developer
    NI Days (and A&DF): 2010, 2011, 2013, 2014
    NI Week: 2012, 2014
    Knowledgeable in all things Giant Tetris and WebSockets

  • Changing data type on a field with populated data

    Hi
    I have a table that has already been populated
    i wish to change the data type of one of the fields from number to varchar2
    this field has the same value you in it throughout
    value = 2005 and i wish to change it to 2005/06
    What is the best way to do this ?
    thanks

    As stated in the user guide, you can change the datatype of a column only when the value of this column is NULL in all existing rows. One workaround (in 10g) would be to add another column, update the new column, drop the old column and rename the new column to the old column's name. Here's an example:
    CREATE TABLE test (col1 NUMBER(8));
    INSERT INTO test VALUES (2005);
    COMMIT;
    ALTER TABLE test add (col2 VARCHAR2(8));
    UPDATE test
       SET col2 = TO_CHAR(col1) || '/06';
    COMMIT;
    ALTER TABLE test DROP (col1);
    ALTER TABLE test RENAME COLUMN col2 TO col1;C.

  • Dynamically change the type of a field

    Hello,
    After finishing reading the adobe documentation and looking at almost all the samples in the Adobe website, i still have no clues how to do the dynamic type changing in the E-Forms.
    Do you think it's possible to change dynamically the type of a field at runtime or during the generation of the pdf?
    Example:
    i send a table to the PDF with the following information:
    Table X line 1 column1 --> textfield type
    Table X line 2 column1 --> Numeric field type
    The result must be the generation of the table X with at the first line a text field and at the second line a Numeric. Of course those field will be editable.
    Possible ?? or not?
    Thx for your help,
    Pelaez Lopez Philippe

    Let me guess, you would like to work with Adobe as you would work with WD. You cannot generate forms from scratch. And that is equal to create a single field, than dynamically duplicate it, distribute it all around the paper and change the types to the right ones. This is not possible. You can only create a superbig form and use hiding.
    If you would like to see a super-big-crazy example, check form MEDRUCK delivered by SAP. This form is superbig, but your output can contain only few fields according to the print type you need.
    If you form is that complicated you cannot build it this way, then the requirement is probably not structured and goes against the meain stream (which needs the structure:))
    Otto

  • Can we change the data type of a field based on the value of the field

    HI Gurus,
    My Requirement is as below -- Could you please guide me
    in the Printable Adobe form -- for ex - as usual for dates fields in the Object Pallette the object type is a date/time field  and for quantity/currency fields corresponding fields are taken
    now in case the either the date, quantity or currency is initial in place of displaying 0.00 or empty date we need to display N/A (Not Applicable)
    for this I would like to change the data type of the field
    to put it simply --
    we need to change the data type of date field from DATE&TIME to Char type to hold N/A or  Quantity field to Char field to hold N/A
    how can we realize this in SAP adobe forms
    Thanks in Advace
    Ramchander Rao.K

    Hello Ramchander,
         You cannot change the data type of the field at run time in Adobe forms because the type of field you choose at the time of design level is associated with the data type itself.
    If you want to achieve your requirement, then your main idea should be to set the data type as CHARACTER itself while designing the field in the adobe form itself. CHAR field will comfortably hold the value of Calculation/amount field, Currency field, Amount, Date, Time HHMMSS, Unit Accuracy, Currency key, Floating point number, Numeric text, Client, Language and many other data types.
    After designing the field as TEXT field in Adobe form you have two options.
    Option 1:
    Select the Date field initially as type TEXT field or CHAR field in Adobe forms.
    Suppose the name of the field is TEXTFIELD1, then write the Javascript code on this field in Initialize event as below.
    if ( this.rawvalue == null )
         this.rawvalue = "N/A";
    If the field is not blank, then it will show the date. Else it will show "N/A".
    Option 2:
    Select the Date field initially as type TEXT field or CHAR field in Adobe forms. Do the formatting part in ABAP itself. It will increase the performance. Avoid Javascript as much as possible.
    Suppose you have a DATE variable l_dats of type DATS. Then take another variable l_date of type CHAR. Then write the below ABAP code.
    MOVE l_dats TO l_date.
    IF l_date IS INITIAL.
         l_date = 'N/A'.
    ENDIF.
    Bind the l_date to the TEXT field in the form.
    Even in this case, if the field is not blank, then it will show the date. Else it will show "N/A".
    But I will suggest you to use Option 2 of keeping the AMOUNT, QUANTITY, DATE, TIME fields etc as CHAR or TEXT fields in Adobe form and do the required formatting in ABAP itself.

  • Activation error while changing the data type of a field of a table

    hi friends,
    i am facing one problem while changing a data type of a field of a table.
    i just created one table(Yqm32) .i have assigned charcter data type to one field(ztotal_count) .now i want to change this charcter data type to numeric data type.
      while changing to NUMC data type activation error is comming as below.
    Table is not yet classified                           
    Field ZTOTAL_COUNT: Type change                       
      ALTER TABLE is not possible                         
    Structure change at field level (convert table YQM32) 
    Check on table YQM32 resulted in errors   
    Table YQM32 could not be activated                       
    (E- Structure change at field level (convert table YQM32)
    plz suggest.i need to change the data type from char to numc.
    Thanks & Regards

    Hi Pabitra......
    From the SE11 change the table as u wanted and then from menubar select
    UTILITIES--> DATABASE UTILITY
    It will open database utility
    there u select the Activate and adjust database button.
    then the database table will get adjusted.
    just try it once.........
    Suresh......

  • Changing data types of  fields in structures

    Hello,
       Currently we are working for upgrade to ECC 6.0 .
       In some transactions we are using BAPI_MATERIAL_SAVEDATA to create material.
      We have some additional fields in MARA and MARC table , which we fill using BAPI_TE_MARA and BAPI_TE_MARC structures.
        In these structures we have different data types for fields earlier in 4.6C
    Now this function module is only working if we change  data types of  fields in these structures only to char type. It is going for dump , if we maintain any other data type.
      Could any body tell me why should we change for char data type ?
    Regards,
      SATYA

    Hi,
    Check enhancement category (Extras --> Enhancement Category) for structures before enhancement. For example, for BAPI_TE_MARA structure, enhancement category is given as character type or numeric type. That means you can add the fields of data type only C and N. No other data types are allowed. If you select as not classified then you can add any data type. This option plays important role while enhancement.
    Regards,
    Prasanth

  • How can I read the data type of a field in an MS Access database

    I need to be able to determine if a field in an Access database is of a certain data type, and if it isn't, to change it to what it should be.
    I can't seem to find any way of reading the data type of any field in any table - can anyone give me a metod of getting this info?
    Thanks
    ..Bob

    Does <cfdbinfo> work for Access DBs?
    You might be better off asking this on a MS Access forum.  It's more of an Access issue than a CF one.
    Adam

  • How to change data type of attribute in caf

    hi.
    this is my problem.
    i been added a attribute in an entity service called emloyee. named "Birthday", use the data type "com.sap.caf.core.date".
    when i tried modify the entity service, i hit exception about "DST Daylight Saving Time".
    because of DST, the date will add an hour such like "1957/04/01 00:00:00.0" to "1957/04/01 01:00:00.0", and com.sap.caf.core.date will throw an exception.
    is anyone had same problem like me?
    how to fixed it(if passable)?
    and, how to change data type?
    thanks.

    Hi Sruthi,
    all you need to do on this is open the report go to the parameters, select the parameter that you wish to change and click "Edit". This will allow you to change thefield to a date rather than a date time.
    Regards,
    Noel

  • Change data type from number(11,6) to number (11,8)

    I have a table, which has a million records...I have to change data type of some of the columns from number (11,6) to number (11,8).
    I thought of taking the backup of the table , truncating the original table, change the data type and then insert data back.
    Is it a safe option considering so many records ?

    the first number is precision and the second is scale:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14196/schema002.htm#sthref472
    so yes, 11,6 can hold larger numbers than 11,8
    create table foobar (two number(5,2),
                         three number(5,3))
    insert into foobar values (123.45,12.345); 
    --works fine
    insert into foobar values (123.45,123.45);
    --gives error ORA-01438: value larger than specified precision allowed for this column

  • How to check data type of the field symbol at run time

    Hi,
    My code is as following:
          LOOP AT <fs> ASSIGNING <wa_covp_ext>.
            ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
            IF sy-subrc = 0.
              ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
              IF sy-subrc = 0.
                  SELECT SINGLE sname INTO <f_zzname> FROM pa0001
                                WHERE pernr = <f_pernr>
                                AND endda GE sy-datum
                                AND begda LE sy-datum.
             ENDIF.
          ENDIF.
        ENDLOOP.
    This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.
    How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.

    check this ...
    write describe statement  ...
    field-symbols : <f_zzname> .
    data : sname like pa0001-sname,
           typ(10).
    assign sname to  <f_zzname>.
    describe  field <f_zzname> type typ.
    write : typ. <-- typ contains character type in this case ..
    U can check if typ is of character(C) if so .. write the select statement ...

  • Change data type "dynamical​ly"

    Hello,
    I will try to explain my question, please tell me if it's not enough clear.
    I read a text file wich describe me how to read datas in a product (their size, name, adress, type ...).
    There is a lot of type (U8, U16, U32, STRING, DATE, I8, DBL ...).
    The problem is I can't have an output in my VI for each type.
    My goal is to make a VI with an output that adapt itself to the data type and I don't know how.
    Maybe if it's possible to change the output declared dynamically depending on the type ... ?
    An other idea is to create a cluster with all the data and just write in the good box with a condition structure but it's not the goal here.
    Thank you in advance !!

    From your question (reading data from a text file), I'm assuming that (a) you can tell when one "piece of data ends and another begins" (for example, it might be a CSV file, with commas separating the fields, or there might be tabs or spaces between entries, or they might be all fixed width, e.g. 8 characters), and (b) you might know "in advance" the type of each piece of data.
    If Assumption (a) is not true, then you may have real difficulties, so I'll assume it's true.  If Assumption (b) is also true, then you need a bunch of sub-VIs, "Read Integer", "Read Float", "Read String", maybe "Read Boolean".  Note that, depending on what you want to do with the data, you might not need a separate "Read I32", "Read I8", "Read U8" routine, as you could read everything as I32 and "coerce" it to the correct type when you go to use it.  Similarly, read all Floats as "Dbl".  I'm assuming that you "know" the appropriate "use" for each variable, such as "The Fifth Variable is the first name of the Account Holder", so you'd want to use "Read String" and output a String when processing the fifth "chunk of data" from the file.
    If Assumption (b) is not true, you can still (sometimes) do a pretty good job reading/parsing the data.  I've done this for data I've read from an Excel Workbook.  What you do is apply some "rules", and hope that the data conforms to the rules.  Here's an algorithm to illustrate what I mean.
    Read in the data (as a string).
    Does it "conform to an integer number" (i.e. consist of possibly a leading + or - followed by only digits)?  Then it is an integer.
    Does it "conform to a float" by also having a single period?  Then it is a float.
    Otherwise it is a String.
    Note you could ask about being "True" or "False" if you need to process Booleans.
    BS

  • How to Find the Data Type of the Field In a Database Table

    Hi Experts,
    I'm currently working on a program which needs to find out the data type of the given field in a database table. In addition to accessing DD03L directly, is there any other workaround such as function module to help me achieve this? It would be helpful if a demo example could be provided.
    Thanks a lot.

    Hi,
    Use this..
    DESCRIBE FIELD dobj  TYPE typ.
    write typ.
    type will contain the data type of the object.
    and check this thread also....
    Re: How to get datatype of fields in dynamic structures
    Cheers,
    Simha.
    Reward all the helpful answers..

Maybe you are looking for