Findind Data type of a variable in Run Time

Hi Experts,
    I am trying to find the data type of variable in runtime with "DESCRIBE FIELD" statement.
    but it always shows data type C by default. i have written this code.....
    DATA: w_value TYPE d.
    DESCRIBE FIELD p_value TYPE w_value.
   My requirement is that if  i pass a variable of any type(like date, time , char, Integer , Decimal etc.) from selection screen i  will   give the correct data type of variable.
Please let me know how to acheive this problem.
Regards,
Shri

Hey Raj,
In this code it always ask a date type variable.
Still my problem i snot getting solve.
check the below one which might give u a fair idea
DATA: Desc_object         TYPE ref to cl_abap_typedescr.
Parameters:   p_char           TYPE char10 ,
              p_date           TYPE d,
              p_int            type i.
Field-symbols : <any_type> type any.
START-OF-SELECTION.
  If p_char is not initial.
     assign p_char to <any_type>.
  elseIf p_date is not initial.
     assign p_date to <any_type>.
  elseif p_int is not initial.
     assign p_int to <any_type>.
  endif.
IF <any_type>  is assigned.
  desc_object = cl_abap_typedescr=>describe_by_data( <any_type> ).
  WRITE: / desc_object->absolute_name.
  WRITE: / desc_object->type_kind.
ENDIF.
The Catch lies in assigning the variables to field symbol. I think you already have that part of code
Edited by: A J Raj on Dec 9, 2009 7:12 PM

Similar Messages

  • Setting data type of an object at run time

    This is something of an advanced problem, so I hope there's
    someone out there who can speak to this. I apologize for the length
    of the post, I'm just trying to be clear about a rather unclear
    conundrum. --
    We all use arrays to hold collections of things. As you know,
    an array is its self a type (Array) and so there is no way to
    declare, for instance, an array of MovieClips or an array of
    Strings. Heres what happens: lets pretend that we have 3 movie
    clips clip1_mc, clip2_mc, and clip3_mc, and an Array called
    anArray. so we can legally do this. anArray.push( clip1_mc );
    anArray.push( clip2_mc ); anArray.push( clip3_mc );. An array of
    size 3. Now the code: trace( typeof anArray[0] ); will output
    "object." This can be a problem. If you try this: var
    newClip:MovieClip = anArray[0]; you get a type mismatch from the
    compiler. "Found Object where MovieClip is required." It
    necessitates this: var newClip:MovieClip = MovieClip( anArray[0] );
    Bummer no?
    Ok. So fast forward. Lets assume a class List that uses an
    array to hold the items in the list. So the class uses the Array
    class in "composition." So you have methods like insert( ); and
    retrieve(). Retriece() returns an item from an index in the array.
    Because of the aforementioned problem, no matter what type the
    thing was going into the list it comes out with type Object because
    the retrieve function must return an item of some type, the only
    option is to declare the return type of the retrieve() function as
    Object. Lets say you know that this is a list of Strings. You could
    write the retrieve()'s code like: return String( returnItem ); And
    type the object "on the way out" .. but what if you want the list
    to work with any type object, you would have to have a variable to
    hold the desired type of objects in the list. And then as the
    objects are being returned, you'd cast them to the type stored in
    that variable. I guess that you'd pass the type to the constructor
    of the List: var aList:List = new List( "AddressCard" ); -- That
    should declare a List (Array) of AddressCards.
    Is there a way to do this? have the type specified in casting
    be dynamic?
    And the flip-side of that is detecting the name of the class
    of an object instance. The thing here would be to try to derive a
    String from the name of the constructor function. (which is always
    the class name) In actionscript 3 there is a service package--
    mx.util -- I think, that has a function to return the qualified
    class name of an object. But is there a jimmy rig for this in AS2?
    My actual project does not use an Array to implement List. (
    or Stack ) It uses a structure called a "linked list" - which is a
    whole other topic, but same problem as with Arrays is also present
    in the linked list versions and so requires the same solution. If
    one is willing to type things explicitly when assigning an item in
    the list to a variable of some type, this thing is quite excellent.
    But I don't like it. I have the package with docs, code, sample
    fla's, diagrams and everything that I would encourage people to
    download, look at, try and whatever and then come back here with
    any thoughts on it. There is a component with Flash professional
    that is a list like structure, but it's so general that it crosses
    the line into bloat. Ie: if you are using a list as a stack, you
    only need getTop() and pop() and push() not all the other (12 or
    so) methods in the class. Mine are patterned after structures from
    the C++ standard template library. And the code style is C++, but I
    think it's actually easier to read that way.
    the files:
    http://www.null.bz/ADL_Lib/ADT_Lib.zip
    Thanks in advance, for your efforts! I really appreciate all
    of it, helpful or not.

    First reactions:
    >>var newClip:MovieClip = MovieClip( anArray[0] );
    Even though you must use a cast to prevent the compile time
    error, you don't get an error on this line because the compiler
    skips typechecking for values accessed with the [] operator.
    >>Is there a way to do this? have the type specified in
    casting be dynamic?
    Nope. You must effectively type check all objects used
    through array elements yourself.
    Reading on...

  • Any idea what this errorr means? the data type of the reference does not match the data type of the variable

    I am using Veristand 2014, Scan Engine and EtherCat Custom Device.  I have not had this error before, but I was trying to deploy my System Definition File (run) to the Target (cRio 9024 with 6 modules) and it failed. It wouldn't even try to communicate with the target. I get the 'connection refused' error.  
    I created a new Veristand project
    I added the Scan Engine and EtherCat custom device.
    I changed the IP address and auto-detected my modules
    i noticed tat Veristand didn't find one of my modules that was there earlier. (this week)
     So, i went to NiMax to make sure software was installed and even reinstalled Scan Engine and Veristand just to make sure.
    Now, it finds the module, but when i go to deploy it getsto the last step of deploying the code to the target, and then it fails.
    Any thoughts?
    Start Date: 4/10/2015 11:48 AM
    • Loading System Definition file: C:\Users\Public\Documents\National Instruments\NI VeriStand 2014\Projects\testChassis\testChassis.nivssdf
    • Initializing TCP subsystem...
    • Starting TCP Loops...
    • Connection established with target Controller.
    • Preparing to synchronize with targets...
    • Querying the active System Definition file from the targets...
    • Stopping TCP loops.
    Waiting for TCP loops to shut down...
    • TCP loops shut down successfully.
    • Unloading System Definition file...
    • Connection with target Controller has been lost.
    • Start Date: 4/10/2015 11:48 AM
    • Loading System Definition file: C:\Users\Public\Documents\National Instruments\NI VeriStand 2014\Projects\testChassis\testChassis.nivssdf
    • Preparing to deploy the System Definition to the targets...
    • Compiling the System Definition file...
    • Initializing TCP subsystem...
    • Starting TCP Loops...
    • Connection established with target Controller.
    • Sending reset command to all targets...
    • Preparing to deploy files to the targets...
    • Starting download for target Controller...
    • Opening FTP session to IP 10.12.0.48...
    • Processing Action on Deploy VIs...
    • Setting target scan rate to 10000 (uSec)... Done.
    • Gathering target dependency files...
    • Downloading testChassis.nivssdf [92 kB] (file 1 of 4)
    • Downloading testChassis_Controller.nivsdat [204 kB] (file 2 of 4)
    • Downloading CalibrationData.nivscal [0 kB] (file 3 of 4)
    • Downloading testChassis_Controller.nivsparam [0 kB] (file 4 of 4)
    • Closing FTP session...
    • Files successfully deployed to the targets.
    • Starting deployment group 1...
    The VeriStand Gateway encountered an error while deploying the System Definition file.
    Details:
    Error -66212 occurred at Project Window.lvlibroject Window.vi >> Project Window.lvlib:Command Loop.vi >> NI_VS Workspace ExecutionAPI.lvlib:NI VeriStand - Connect to System.vi
    Possible reason(s):
    LabVIEW: The data type of the reference does not match the data type of the variable.
    =========================
    NI VeriStand: NI VeriStand Engine.lvlib:VeriStand Engine Wrapper (RT).vi >> NI VeriStand Engine.lvlib:VeriStand Engine.vi >> NI VeriStand Engine.lvlib:VeriStand Engine State Machine.vi >> NI VeriStand Engine.lvlib:Initialize Inline Custom Devices.vi >> Custom Devices Storage.lvlib:Initialize Device (HW Interface).vi
    • Sending reset command to all targets...
    • Stopping TCP loops.
    Waiting for TCP loops to shut down...
    • TCP loops shut down successfully.
    • Unloading System Definition file...
    • Connection with target Controller has been lost.

    Can you deploy if you only have the two 9401 modules in the chassis (no other modules) and in the sysdef?  I meant to ask if you could attach your system definition file to the forum post so we can see it as well (sorry for the confusion).  
    Are you using any of the specialty configurations for the 9401 modules? (ex: counter, PWM, quadrature, etc)
    You will probably want to post this on the support page for the Scan Engine/EtherCAT Custom Device: https://decibel.ni.com/content/thread/8671  
    Custom devices aren't officially supported by NI, so technical questions and issues are handled on the above page.
    Kevin W.
    Applications Engineer
    National Instruments

  • What is it about data types of local variables?

    Hey there!
    I'm trying hard to access the booleans, whose refnums got stored into an array. As the example show, everything's fine unless I start using local variables: I can access the data in the topmost FOR loop. As soon as variables come into play, it seems as if I have to explicitly typecast the data. Is it just me? There has to be a less complicated way... can anybody give me a hint?
    Kind regards,
    Severin
    Attachments:
    data types of local variables.jpg ‏96 KB
    data types of local variables_7.11.vi ‏39 KB

    Hi Severin,
    The output from that property node is of variant data type. You can convert it to boolean by using the Variant to Data VI. See attached example
    Sarah
    Applications Engineer | National Instruments | UK & Ireland
    Attachments:
    data types of local variables_7.11.vi ‏41 KB

  • Want to find the Data type of a variable at runtime ?

    Hi,
    I Want to find the Data type of a variable at runtime ?
    I think there is a function module... But i forgot ..... Can you please help me out.
    Points are rewarded immediately.

    hi,
    do this way
    REPORT ysantest LINE-SIZE 350.
    DATA : v_num TYPE n,
    v_type(2).
    DESCRIBE FIELD v_num TYPE v_type.
    WRITE : v_type.

  • How to know the data type of a variable?

    Hi,
       Can anyone tell me which function can return the name data type of a variable?
        Thanks!
    Message was edited by: Long Zheng

    Hi long,
    1. I don't know whether this will serve your purpose.
    2.
    REPORT abc.
    DATA : components     LIKE     rstrucinfo OCCURS 0 WITH HEADER LINE.
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    CALL FUNCTION 'GET_COMPONENT_LIST'
      EXPORTING
        program    = sy-repid
        fieldname  = 'T001'
      TABLES
        components = components.
    LOOP AT components.
      WRITE :/ components-compname , components-type.
    ENDLOOP.
    regards,
    amit m.

  • Load a variable at run time

    I have the following code to load in some images and
    display/move them:
    this.createClassObject(mx.controls.Loader, "myLoader", 1);
    this.createClassObject(mx.controls.Loader, "myLoader2", 2);
    this.createClassObject(mx.controls.Loader, "myLoader3", 3);
    this.createClassObject(mx.controls.Loader, "myLoader4", 4);
    this.createClassObject(mx.controls.Loader, "myLoader5", 5);
    myLoader.scaleContent = false;
    myLoader2.scaleContent = false;
    myLoader3.scaleContent = false;
    myLoader4.scaleContent = false;
    myLoader5.scaleContent = false;
    var images:Array = ["
    http://www.mysite.com/images/image_01.jpg",
    http://www.mysite.com/images/image_01.jpg",
    http://www.mysite.com/images/image_01.jpg",
    http://www.mysite.com/images/image_01.jpg",
    http://www.mysite.com/images/image_01.jpg"
    myLoader.contentPath = images[0];
    myLoader._x = 0;
    myLoader._y = 0;
    myLoader2.contentPath = images[1];
    myLoader2._x = 320;
    myLoader2._y = 0;
    myLoader3.contentPath = images[2];
    myLoader3._x = 640;
    myLoader3._y = 0;
    myLoader4.contentPath = images[3];
    myLoader4._x = 960;
    myLoader4._y = 0;
    myLoader5.contentPath = images[4];
    myLoader5._x = 1280;
    myLoader5._y = 0;
    This works great, but what I'm wondering is, can I load in
    the images array variable at run time from an external file so I
    could edit that file on the server in order to change images,
    without having to re-publish the flash file? Thanks for any help.
    Bob

    Adrian,
    Have a look at: http://www.oracle.com/technology/products/database/htmldb/howtos/howto_create_upload_spreadsheet_form.html
    It's not 100% what you're looking for (as it requires you to cut & paste from the spreadsheet), but it may do what you're after.
    Thanks,
    - Scott -

  • Exporting DI batch to BAT and set DI parameter/variable at run time

    Hi All,
    We are looking to call DI batch job externally and pass parameter/variable at run time.
    We tried exporting DI batch to a bat file and setting substitution parameters during export.
    In the exported .bat file, it references a .txt file which shows the name of the substitution paramemters but the value of the parameters are encrypted.
    Does anyone know how to pass parameter/variable to a DI batch job at run time externally?
    Thanks,
    Bobby

    I tried out this method and I have some additional issues.
    1. if we use the BOE scheduler the text parameter file is using a specific naming convention that is not clearly documented. it is like : -GV"$VAR=ENCRYPTEDVALUE;"... trying to modify it with a clear value like -GV"$VAR=MYVALUE;" was simply ignored by the scheduler... seems also that BOE did not sent any scheduling request to the DI Job Launcher...
    What is the proper convention please?
    2.Is there a better way to enter this parameter than editing the TXT file. Most of the BOE InfoView users are not allowed to modify or store documents.. This is not very convenient if they cannot enter simply the parameter values in a let say more confortable way...
    Thank you and cheers

  • Bind variables at run time

    We have a view object with LOV, this LOV has a bind variable. How can we set this bind variable at run time through this view object?

    Hi bara,
    1. Wat you ve to do is create a transient attribute in the child entity.
    2. Create an association between master and child.
    3. The value should be a groovy expression such that it refers the field in master table which needs to be passed to the LOV.
    4. Add the transient attribute in ViewObject also.
    4. Use ViewAccessors and map the transient attribute to the bind variable in the List View Object
    Regds,
    Srinidhi

  • How to get the data type of a variable

    Hi
    I'm new to java and I'd like to put some variables with different data type into the HashMap. But when I'm going to get the value
    of the variable I want to know its data type (int,String,long,float etc.) before I do some processing.
    here's my sample code:
    //start...
    Map m = new HashMap();
    String s1 = "String1";
    String s2 = "String2";
    int i1 = 5;
    int i2 = 10;
    m.put(1,s1);
    m.put(2,i1);
    m.put(3,12);
    m.put(4,s2);
    //end...
    when I'm going to retrieve the variable, I'd like to assign it to another variable with the same data type. but the problem is, before
    I assign it I must know its data type so that I could not have an error.
    thanks in advance

    I don't think you will be able to put primitives (ints, floats, etc) in, without wrapping 'em first (java.lang.Integer, java.lang.Float...).
    You can get the type with
    Object biggles;
    // Get biggles
    if( biggles instanceof String )
       System.out.println( "Biggles is a string, yeah biggles" );or with refection
    Class bigglesClass = biggles.getClass();
    System.out.println( "Biggles is of type: " + bigglesClass.getName() );

  • How to convert data type while using @variable function

    Hi Gurus,
    I have a query.
    i have created a Derived Table and the statement is given below.
    select 1 as SENSITIVITY_LEVEL,1 as SUBSENSITIVITY,@variable('US_T') as NITEMS, ...........
    here  in @variable('US_T') "US_T" is hard coded value. I want to change to data type of hard coded value as numeric or integer
    i am using sap BI 4.0 universe design tool.
    Thanks in Advance.
    Regards,
    Jeet

    Hi Jeet,
    Since it is text you can't convert into number.
    Can you please let mw know the exact requriement of yours?
    why you need this
    Thanks,
    Swapnil

  • Having trouble assigning the Data Type to Shared Variables

    I have some type definitions that I need to use as shared variables.  When making the shared variable, I create it and then name it.  I then select "From Custom Control..." in the Data Type field and select the applicable type definition.  The problem is that it displays some other type definition.  Am I doing something wrong?  I am using LV v.8.6. I don't recall having this problem with v.8.5.1.

    Hi Hunter,
    All the custom controls are set to Type Def.  Since sending my question, I noticed that the system uses the first similarly used custom control and it's name.  For example, I have several clusters that each have four numeric controls in them.  When creating a shared variable for each of the various clusters, it uses the first custom control that was set up as a shared variable.  I hope this makes sense to you.  I have not had a chance to see if the shared variables are working because I have other issues to deal with first. 
    What troubles me is that I don't recall seeing this with v.8.5.1.
    I suppose I could and perhaps should use a common type def for all similarly used shared variables.
    Dave

  • Loading the final static variables at run time.. Please help

    Hello, fellow developers & Gurus,
    Please help me figure out the best way to do this:
    I need to load all my constants at run time. These are the public static final instance variables. The variables values are in the DataBase. How do I go about loading them.

    Your original question was diffeent, but your further posts show what you really want to do:
    1) all constants in 1 class
    2) available readonly for other classes
    3) updatable during runtime by changing in the database
    Did I understand you right?
    Then smiths' approach solves point 2):
    Instead, make the variables available through a method
    call - that way you avoid the whole final variable
    versus read-only attributes problem.
    //GLOBAL VARIABLES EXPOSED AS PUBLIC PROPERTIES
    public final class GlobalProperties
    public static int getTableSize();
    public static int getRowSize();
    Each "constant" should be a private static variable, and these methods simply return their values.
    The variables are initialized in a static initializer by accessing the db. Ok.
    You habe a table with one row containing as columns all the constants.
    A method readConstants() does a "select constant1, constant2, ... from const_table" and sets all the variables.
    The static initializer calls this method.
    Right?
    Ok, then you simply call readConstants() everytime you want to synchronize with the actual content of const_table.
    Was it this?

  • How to change value of instance variable and local variable at run time?

    As we can change value at run time using debug mode of Eclipse. I want to do this by using a standalone prgram from where I can change the value of a variable at runtime.
    Suppose I have a class, say employee like -
    class employee {
    public String name;
    employee(String name){
    this.name = name;
    public int showSalary(){
    int salary = 10000;
    return salary;
    public String showName()
    return name;
    i want to change the value of instance variable "name" and local variable "salary" from a stand alone program?
    My standalone program will not use employee class; i mean not creating any instance or extending it. This is being used by any other calss in project.
    Can someone tell me how to change these value?
    Please help
    Regards,
    Sujeet Sharma

    This is the tutorial You should interest in. According to 'name' field of the class, it's value can be change with reflection. I'm not sure if local variable ('salary') can be changed - rather not.

  • Changing data in the table control during run time of transaction F-28

    Dear Experts,
    in transaction F-28 of second screen of second column (Field Name: Assignment) currently the data is getting from BSEG table and populating this column of table control, now I have a requirement that the data should be get from the other ZTABLE and populate this column during run time instead of the data from BSEG table, please let me know your suggestions, if you guys feel it will be done using User Exit then please let me know the suitable exit for this.
    Best Regards
    Venkat

    Hi Venkat,
    Use the appropriate sort key in the GL to fill up the assignment field automatically.
    U can create ur new sort key through OB16
    Regards,
    Kiran

Maybe you are looking for

  • How to map from XML(xsd) to Service

    Hi , when i try to map from generated Xml to Service input i am getting below error like Failed to load "" type.   Please verify the fully-qualified type name is valid.  Details: "".  The type must derive from System.Web.Services.Protocols.SoapHttpCl

  • How to use CompositeData for mbean operations

    Hi all, I am trying to register a mbean whose operations have a composite data type interface something like below, any ideas how to achieve this? /**MXBean**/ public interface someXXXXxxxMXBean {     public ReturnCompositeDataInterface doSomething(P

  • Why methods equals() and hashCode() is defined in Object Class?

    Why methods equals() and hashCode() is defined in Object Class?

  • How to handle same product with different part numbers and pricing in SAP.

    I am a new user and want to learn if the following scenario can be handled by SAP. Our business buys a product from a supplier which has 2 different part numbers and prices. It is the same product. One is the primary product whilst the other is avail

  • I cannot import files on to FCPX.

    I have tried everything, trashing preferences and reinstalling app, but nothing seems to work. I deleted movie files to make space on the hard drive, since then I cannot get fcpx to load any files and work properly. What am I doing wrong?