Can we declare variable dynamic

Hi ,
Can we declare variables dynamically.
[ java uses this feature in Garbage Collection.]
Thanks ,
Adi

but jvm uses this dynamic decalration in Garbage
Collection.
then can't we use the same.I'm not sure I understand what you mean? Do you mean that objects are dynamically created at runtime? Yes they are but the variables in the class definitions were all declared at compile time.

Similar Messages

  • Can I declare variables in Reports from SQL Query

    Hi
    I have a Report from SQL Query published as a portlet on a page among other reports. In the query report I am using the fuction WWCTX_API.GET_USER at quite a few places to filter the data returned to the user. Can I assingn the user id to a variable at some level & replace the fuction WWCTX_API.GET_USER with the variable in all the places.
    For eg:
    usr varchar2(25);
    usr:= PORTAL30.WWCTX_API.GET_USER;
    select USER_ID, USER_LVL, BUSINESS_ID, BRANCH_ID from crs_user where user_id=usr;
    can i declare variable and assign the value like the above at any level(Report or Page Level) to the acces the variale in queries.
    Thanks in advance

    I have found that you can't use a * in a dynamic page.
    Try this:
    <ORACLE>
    DECLARE
    usr varchar2(25):=PORTAL30.WWCTX_API.GET_USER;
    BEGIN
    for c in
    (SELECT <column_name> <alias> FROM PORTALWORK.CRS_USER WHERE USER_ID=usr)
    Loop
    htp.p(c.<alias>);
    END;
    </ORACLE>
    You can also add table tags for column formating:
    <table>
    <tr><td>column 1</td></tr><tr><td nowrap>
    <ORACLE>
    DECLARE
    usr varchar2(25):=PORTAL30.WWCTX_API.GET_USER;
    BEGIN
    for c in
    (SELECT <column_name> <alias> FROM PORTALWORK.CRS_USER WHERE USER_ID=usr)
    Loop
    htp.p(c.<alias>);
    END;
    </ORACLE>
    </td></tr></table>
    Martin

  • Declaring variable dynamic of decimal format

    Hi SDN Community,
    Can you possibly provide a sample of how to declare a variable to be dynamic.
    the situation is that using the TABLE CLASS INTERFACE,
    the numbers from I_VALUE come in as long decimal places. eg. 20.58498497
    i wish to have a declaration to then use this further in the code.
    for example
    DATA: ROUNDEDNUMBER type i DECIMALS 2.
    but i want instead of 2, to have this dynamic,
    the dynamic value is populated by I_NUMERIC_PRECISION which is derived from the settings of the Bex query.
    hence my anticipated result is 20.6 (which has been rounded as well)
    I have seen Field symbols achieve this?
    Thank you.
    Simon

    Hi all,
    I had the same issue und solved it in this way:
    DATA: lv_decim TYPE numc1 VALUE 0.
    DATA: lr_packed TYPE REF TO data.
    FIELD-SYMBOLS: <fs_packed> TYPE ANY.
    CREATE DATA lr_packed TYPE p DECIMALS lv_decim.
    ASSIGN lr_packed->* TO <fs_packed>.

  • How to declare variable in the scipt

    data is coming from standard program .
    rf140-stida key entry date.
    bsik-bldat posting date
    i want to display difference between  rf140-stida and bsik-bldat in scipt form it will give number of days.
    how can i declare variables for this.
    how to write code in my form.

    Hi
    U need to create a routine to calculate the difference:
    /: DEFINE &DELTA& = SPACE
    /: PERFORM <FORM NAME> IN PROGRAM <PROGRAN NAME>
    /: USING &RF140-STIDA&
    /: USING &BSIK-BLDAT&
    /: CHANGING &DELTA&
    &DELTA&
    The routine has to be defined in your Z-PROGRAM and to have these interface:
    FORM <FORM NAME>  TABLES IN_TAB_EM     STRUCTURE ITCSY
                                                       OUT_TAB_EM STRUCTURE ITCSY.
      DATA: DELTA TYPE I.
      DATA: DATE1 LIKE SY-DATUM,
                 DATE2 LIKE SY-DATUM.
    * ---> Rembember the date has the ouput format, so it has to be converted in the
    * input format
      READ TABLE  IN_TAB_EM WITH KEY NAME = 'RF140-STIDA'.
      IF SY-SUBRC = 0.
         DATE1(4)     = IN_TAB_EM-VALUE+6(4).
         DATE1+4(2) = IN_TAB_EM-VALUE+3(2).
         DATE1+6(2) = IN_TAB_EM-VALUE(2). 
      ENDIF.
      READ TABLE  IN_TAB_EM WITH KEY NAME = 'BSIK-BLDAT'.
      IF SY-SUBRC = 0.
         DATE2(4)     = IN_TAB_EM-VALUE+6(4).
         DATE2+4(2) = IN_TAB_EM-VALUE+3(2).
         DATE2+6(2) = IN_TAB_EM-VALUE(2). 
      ENDIF.
      DELTA = DATE1 - DATE2.
      READ TABLE  OUT_TAB_EM WITH KEY NAME = 'DELTA'.
      IF SY-SUBRC = 0.
         WRITE DELTA TO OUT_TAB_EM-VALUE.
         MODIFY OUT_TAB_EM INDEX SY-TABIX.
      ENDIF.
    ENDFORM.
    Max

  • What happens to dynamically declared variables when I'm not using them?

    Hello, I'm making a game using Flash Pro cc. But I wonder what happens to aTile, which is dynamically declared MovieClip variable through a loop. And each aTile gets the 2 EventListener's.
    for(var i:Number=0; i<pVector.length;i++){
        var aTile:ATile=new ATile();
        aTile.x=pVector[i].x;
        aTile.y=pVector[i].y;
        aTile.gotoAndStop(Math.ceil(Math.random()*Color));
        nVector.push(aTile);
        Spr.addChild(aTile);
        aTile.addEventListener(MouseEvent.CLICK,Clicked,false,0,true);
        aTile.addEventListener(Event.COMPLETE, stop,false,0,true);
         // the current function ends here. what happens to aTile now ?? Is it going to be garbage collected? By the way, this piece of code runs whenever a player starts a new level of my game. And I don't make use of the aTile variable in other functions. I use only the nVector variable. And does declaring a dynamic variable in a loop mean a multiple of them are created? For example, if I loop the piece of code above 5 times, does it mean 5 aTile variables are created? Or each time you declare
    var aTile:ATile=new ATile(); again, does it replace the 'old' aTile with the 'new' aTile and therefore only 1 aTile exists after the loop????

    I feel there is a gap in understanding of using variables by reference vs. by value. You should look it up.
    1. new instructs Flash to create a distinct instance that per se has absolutely nothing to do with aTile variable.
    2. REFERENCE to this new instance is assigned to variable aTile. aTile var is a temporary pointer to instance.
    3. It does not replace old tile - it replaces reference.
    4. If reference to the instance is not stored elsewhere - upon exiting of function this instance will be gced.
    5. By creating another reference to the instance you prevent it from GC. One of the ways you preserve instance is by adding it to display list when using addChild.
    You can look at this this way (it is a lame example but still it illustrates parts of the concept)
    Say you have
    1. basket;
    2. basket is small and can hold only one apple;
    3. table;
    4. an apple;
    5. apple can be placed into the basket or table;
    6. dog who love apples.
    7. Dog is trained not to take apples from baskets but table but is free to eat apples that are on the ground.
    So, once apple is in the basket or on the table - it is safe.
    If you move these entities into the realm of AS3, basket and table become declared variables, apple an instance and dog garbage collector.
    What this example demonstrates is that apple exists independently of basket or table. You can put apple to the basket OR on the table OR you can put apple into basket and place basket onto the table.
    1. Find apple instance (if you know whether apple is in the basket, on the table or in the basket on the table)
    2. Prevent dog from eating apple.
    3. Allow dog to eat it (destroy it when garbage collector kicks in) by assuring that apple is in neither basket or on the table.

  • Can we declare arrayList as variable ??

    Hi,
    Can we declare arrayList as variable ???
    Help me regarding this....
    Thanks in advance

    Plz can u show me with example....ArrayList al = new ArrayList().
    http://www.google.co.in/search?hl=en&safe=off&q=ArrayList+Java&btnG=Search&meta=

  • Declare variables with no definite number.

    Hi all,
    I need to declare field symbols and references depending upon the number of fields in a table. Suppose, I use a method to get the number of fields of a table at runtime which have no definite number. How can i declare field symbols or references or for that matter say any other variable dynamically.
    Example:
    At run time .. for fields
    itab-one----
    <fs_one>
    itab-two----
    <fs_two>
    itab-three----
    <fs_three>
    itab-n----
    <fs_n>
    How can I do that? A sample code will be helpful
    Thanks
    Ali

    FIELD-SYMBOLS: <DYN_TABLE> TYPE TABLE , <WA> ,  <LS_LINE>.
    DATA :  FS_SUM_GL LIKE LINE OF IT_YMM_ST.
    FORM MOVE_TO_DYNAMIC_TAB .
      DATA  : FIELD(10)   ,
               INDX1(3) .
      DATA: WA_DREF TYPE REF TO DATA.
      DATA :  FS_SUM_GL LIKE LINE OF IT_YMM_ST_TNUOT_MLY.
      CREATE DATA LP_DATA LIKE LINE OF <DYN_TABLE>.
      ASSIGN LP_DATA->* TO <LS_LINE>.
      LOOP AT IT_YMM_ST.
        MOVE-CORRESPONDING IT_YMM_ST TO <LS_LINE>.
        INSERT <LS_LINE> INTO TABLE <DYN_TABLE>.
      ENDLOOP  .
      DATA L_COUNTER_ROLL TYPE I .
      LOOP AT <DYN_TABLE> INTO <LS_LINE> .
        MOVE-CORRESPONDING <LS_LINE> TO FS_SUM_GL.
        CLEAR : FIELD , INDX1 , L_COUNTER_ROLL .
        L_COUNTER_ROLL = 1 .
        LOOP AT IT_EKKN  WHERE EBELN = FS_SUM_GL-EBELN.
                        AND   EBELP = FS_SUM_GL-EBELP.
         IF SY-SUBRC  = 0  .
          INDX1 = L_COUNTER_ROLL.
          SHIFT INDX1 LEFT DELETING LEADING SPACE.
          CONCATENATE 'KOSTL'  INDX1 INTO FIELD .
          ASSIGN COMPONENT FIELD  OF STRUCTURE <LS_LINE> TO <FS1>.
          <FS1> = IT_EKKN-KOSTL .
          MODIFY <DYN_TABLE> INDEX SY-TABIX FROM  <LS_LINE> .
          L_COUNTER_ROLL = L_COUNTER_ROLL + 1 .
         ENDIF.
        ENDLOOP .
      ENDLOOP .

  • Can a session variable be an array?

    I have a dynamic list which may have multiple values
    selected. I can capture the resulting array in a $_POST variable.
    Using the Insert Record behavior, I cannot cause the $_POST
    variables to be sent to the redirect page unless I use session
    variables. Can a session variable be defined as an array? If so,
    how do I declare it as an array and how do I move the form variable
    array to a session variable array? If it can't be an array, how do
    I define the target variables for 0 to x items from a form variable
    array?

    I can't answer specifically for PHP but in the other
    languages as session
    variable is basically a holding place for a value. As a comma
    is a valid
    character then if you have a comma delimited list (which is
    what a form give
    you if multiple items are selected) then you simple assign it
    to the session
    variable and it will be stored as such.
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "Rankin" <[email protected]> wrote in
    message
    news:ef9suk$iqe$[email protected]..
    >I have a dynamic list which may have multiple values
    selected. I can
    >capture
    > the resulting array in a $_POST variable. Using the
    Insert Record
    > behavior, I
    > cannot cause the $_POST variables to be sent to the
    redirect page unless I
    > use
    > session variables. Can a session variable be defined as
    an array? If so,
    > how
    > do I declare it as an array and how do I move the form
    variable array to a
    > session variable array? If it can't be an array, how do
    I define the
    > target
    > variables for 0 to x items from a form variable array?
    >

  • Get type of variable dynamically

    Hi,
    i want to get the type of a variable. For example, the following code :
    data: my_var type zmystruct.
    In ABAP, i want to get type 'zmystruct' and after to create dynamically a new variable of this type.
    Thanks for help.

    HI,
    You use the following syntax to define reference types:
    <b>TYPES dtype {TYPE REF TO type}|{LIKE REF TO dobj}.</b>
    The syntax for a direct declaration of a reference variable is as follows:
    <b>
    DATA ref {TYPE REF TO type}|{LIKE REF TO dobj}.</b>
    The addition REF TO defines a data type dtype for a reference variable and declares the reference variable ref. The specification after REF TO specifies the static type of the reference variable. The static type constricts the object set to which a reference variable can point. The dynamic type of a reference variable is the data type and the class of the object respectively, to which it currently points. The static type is always more universal or equal to the dynamic type
    You can use the TYPE addition to define data types for data and object reference variables. The LIKE addition exclusively defines data types for data reference variables.
    The syntax and meaning of the additions TYPE and LIKE are completely equal for both statements with the exception that TYPES creates an independent reference type, whereas DATA creates a bound reference type.
    Regards
    Sudheer

  • How can i use month dynamically in the report?

    Hi Xperts,
    i have requirment that i need to display the data on the report output only for one month.
    and it will dynamically change in every month with out using any selections in the selection screen.
    i found that i have to use customer exits for it.
    can any one please tell me where and what is to be written in that code?(as i don't have any ABAP knowledge).
    Regards,
    sat
    Edited by: SAP534 on Dec 30, 2010 8:07 AM

    There are SAP Standard Variable Exits that will pick the current month based on the report execution date.
    You just have to activate them from standard content and use those variables in your query. You dont have to write any code to use this.
    you can even use variable offsets to pick prior month or next month or even a range of last 12 months etc.
    0CMONTH is a SAP Standard Variable that needs to be activated from standard content and used in the query. There are some other SAP Standard variables such as 0LMONTH for last calendar month 0CMQUAR for current quarter etc that may also come in handy for reporting.
    Similar variables are also available for 0FISCPER infoobject if your fiscal year is different than the calendar year.
    Good luck.
    MP.

  • Can I create a dynamic number of inputs during runtime?

    Can I create a dynamic number of inputs during runtime?
    Oracle 11g
    Application Express 4.0.2.00.06
    Here is my problem:
    We have a table that holds metadata about files (hardcopy or softcopy files).
    We expect we may need more columns in the table at some point and don't want to modify the table or the application.
    So in order to do this I would like to create:
    A table called TBL_FILE with the columns:
    TBL_FILE_ID               NUMBER                (This will be the primary key)
    TBL_FILE_NAME          VARCHAR2(1000) (This will be the name of the file)
    A second table will be called TBL_FILE_META with the columns:
    TBL_META_ID               NUMBER               (This will be the primary key)
    TBL_FILE_ID               NUMBER                (This will be the forign key to the file table)
    TBL_META_COLUMN     VARCHAR2(30)     (This is what the column name would be if it existed in TBL_FILE)
    TBL_META_VALUE          VARCHAR2(1000) (This is the value that record and the 'would be' column)
    So a person can have as much meta data on the file with out having to add columns to the table.
    The problem is how can I allow users to add as much data as they like with out having to re develop the page.
    Other things to note is that we would like this to be on a single page.
    I know how to add we can create multi-row inserts by using a SQL Query (updateable report),
    however the TBL_META_VALUE column in the TBL_FILE_META will sometimes be a select list and other times a text box or number field.
    So I don't see now a SQL Query (updateable report) would work for this and I can't create an array of page items at run time can I?
    Any idea's how I could accomplish this? Is there a better way of doing this?
    Also is there a term or a name for what I am doing by creating these 'virtual' columns in another table?
    I found this method when looking at Oracles Workflow tables.

    Welcome to the Oracle Forums !
    >
    Can I create a dynamic number of inputs during runtime?
    Oracle 11g
    Application Express 4.0.2.00.06
    Here is my problem:
    We have a table that holds metadata about files (hardcopy or softcopy files).
    We expect we may need more columns in the table at some point and don't want to modify the table or the application.
    So in order to do this I would like to create:
    A table called TBL_FILE with the columns:
    TBL_FILE_ID NUMBER (This will be the primary key)
    TBL_FILE_NAME VARCHAR2(1000) (This will be the name of the file)
    A second table will be called TBL_FILE_META with the columns:
    TBL_META_ID NUMBER (This will be the primary key)
    TBL_FILE_ID NUMBER (This will be the forign key to the file table)
    TBL_META_COLUMN VARCHAR2(30) (This is what the column name would be if it existed in TBL_FILE)
    TBL_META_VALUE VARCHAR2(1000) (This is the value that record and the 'would be' column)
    So a person can have as much meta data on the file with out having to add columns to the table.
    The problem is how can I allow users to add as much data as they like with out having to re develop the page.
    >
    Creating Page Items dynamically is not available. You will have to create excess items and hide/show , etc. But you cannot change the Item Type. All in all, too many limitations in this approach.
    >
    Other things to note is that we would like this to be on a single page.
    >
    The 100 item limit will hit you if you go with extra item on page. With Tabular Form that should not be a limitation, unless you are exceeding the 50 item limit of APEX_APPLICATION.G_Fnn items, and the 60 column limitation of Report region with "Use Generic Column Names (parse query at runtime only)" of Dynamic region.
    >
    I know how to add we can create multi-row inserts by using a SQL Query (updateable report),
    however the TBL_META_VALUE column in the TBL_FILE_META will sometimes be a select list and other times a text box or number field.
    >
    If the type if item is variable it only means you need a way to store the item type. Meta Data of the Meta Data.
    >
    So I don't see now a SQL Query (updateable report) would work for this and I can't create an array of page items at run time can I?
    >
    Yes, you can do it. Updatable report/ Tabular Form query can be constructed from the Meta Data using PL/SQL Function Returning SQL Query . It will be a bit of coding in PL/SQL where you use the Meta Data and the Meta Data of the Meta Data to piece together your SELECT with the right APEX_ITEMs. It might have a performance penalty associated with it, but will not be a serious degradation.
    >
    Any idea's how I could accomplish this? Is there a better way of doing this?
    Also is there a term or a name for what I am doing by creating these 'virtual' columns in another table?
    I found this method when looking at Oracles Workflow tables.
    >
    I guess that is just a good TNF. It is the Master-Detail Design Pattern, that sound more modern ? ;)
    Regards,

  • Declare variables in an MDX query

    Is it possible to declare variables in an MDX query like transact sql? something like this:
    DECLARE @date1 date
    DECLARE @month1 int
    set @date1 = '12-12-2012'
    set @month1=DATEPART(m, @date1)-1
    select @date1 as dt1, @mesreferencia as mt1

    Hi ,
      In MDX , you will not be able to put variables in MDX. But Query scoped calculated measures can be used for such cases. The equivalent MDX for the above is
    WITH MEMBER [MEASURES].Dt
    As
    CDATE('12-12-2012')
    MEMBER MEASURES.DTPart
    As
    DATEPART("M", MEASURES.Dt)-1
    SELECT {MEASURES.Dt,MEASURES.DTPart} ON 0
    FROM [Adventure Works]
    Best Regards Sorna

  • Declare variables in function module

    hi gurus,
    i am making a function module in which i need to make some performs so as to do code reusability. but for that i need to declare variable globally. As i am working wth function modules for the fisrt time. can anyone please help me with that. i dnt want these variables in improt or export parameters.
    regards
    vibhor

    hi vibhor,
    there is a tab "display object list" on the top of the sap screen when u r in dat function module. press that.
    on the left side of ur screen there will complete lists of object used in fm. in includes there will a top include, declare all the variables u need globally in that top include. u can also create more includes for different performs if u want for modularizing ur program..
    regards
    palak

  • Issue while Passing Values to Variable Dynamically in ODI

    Hi All,
    We are trying to pass values to ODI variable dynamically. The value passed is File path. We are successfully able to achieve this when we are passing the relative path i.e. ‘..\demo\xml’ but while we are trying to pass the absolute path i.e. ‘D:\ODI\oracledi\demo\xml\’ we are getting the below given error in the Load step of the interface..
    com.sunopsis.sql.SnpsMissingParametersException: Missing parameter
    at com.sunopsis.sql.SnpsQuery.completeHostVariable(SnpsQuery.java)
    at com.sunopsis.sql.SnpsQuery.updateExecStatement(SnpsQuery.java)
    at com.sunopsis.sql.SnpsQuery.executeQuery(SnpsQuery.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandScenario.treatCommand(DwgCommandScenario.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.i(e.java)
    at com.sunopsis.dwg.cmd.g.y(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)
    Googling for the same has yielded the following results :-
    •     if the file name has : in it then ODI will consider it as a binding variable rather path. .. So try relative path. – Relative Path is working but we need to achieve this by giving absolute path.
    •     make sure you are using LKM File to SQL rather SQL to SQL. – We have tried by 3 different LKMS—File to SQL, SQL to SQL and SQL to Oracle but the error is same in all.
    Any pointers regarding the same will be very helpful.
    Thanks In Advance.
    Regards,
    Abhishek Sharma

    Hi Cezar,
    Thanks for the response. The issue here is we are picking this path from a table. We have FILE_PATH column in one database table and in ODI variable we have given SQL query as 'Select FILE_PATH from tablename'. Then we are taking the refresh value of this variable and passing it on to our interface.
    If the Path in table is given as relative path it works , else for absolute path it doesnt work. How can we achieve the solution recommended by you in this case. The FILE_PATH value in table may change, so we need to pick the file from whatever path it fetches from the select statement. Hence we cannot hard code it here.
    Please suggest.
    Thanks Again.
    Regards,
    Abhishek Sharma

  • Declaring variable

    private var _history:Vector.<BitmapData>;
    can any1 plz explain me this format of declaring variable specially ".<BitmapData>" part....
    Thanx..

    A Vector is a special kind of array than can only hold one 'type' of data. So in your example, the array _history will only hold BitmapData objects. This makes the access of the array much faster. Contrast this with _myArray:Array that might contain a mixture of object types as in:
    _myBitmap:Bitmap
    _myMovieClip:MovieClip
    _myArray = new Array();
    _myArray.push(_myBitmap);
    _myArray.push(_myMovieClip;
    If you pushed _myMovieClip into your _history Vevctor, you would get an error at run time since _myMovieClip is not a BitmapData object.
    You can see more here:  http://help.adobe.com/en_US/AS3LCR/Flash_10.0/Vector.html

Maybe you are looking for