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

Similar Messages

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

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

  • Key figure Date in Decimal format

    Hi all,
       I have a key figure 0CPR_ACFR_K  (Date) which is in Decimal format.
       Data in PSA for the particular field was like this '07102008'
       but after that it is changing to 7327.98  that is in decimal format.
       But i dont want this to happen ie. it should not get converted to Decimal or
       i want to convert the decimal value again to the equivalent date.
       pls help in this.

    Hi  jean liker,
    It will get converted due to its properties. If you want to use this particular object as keyfigure, you can create a variable with processing type replacement path and use. Its better to maintain as char.
    [Replacement Path: Replacement with a Characteristic Value|http://help.sap.com/saphelp_nw04/helpdata/en/03/6ba03cc24efd1de10000000a114084/frameset.htm]
    Hope it Helps
    Srini

  • Loading the data from a packed decimal format file using a sql*loader.

    Hi ,
    In one of the project i'm working here i have to load the data into oracle table from a file using a Sql*loader but the problem is the data file is in the packed decimal format so please let me know if there is any way to do this....I search a lot regarding this ..If anybody faced such type of problem ,then let me the steps to solve this.
    Thanks in advance ,
    Narasingarao.

    declare
    f utl_file.file_type;
    s1 varchar2(200);
    s2 varchar2(200);
    s3 varchar2(200);
    c number := 0;
    begin
    f := utl_file.fopen('TRY','sample1.txt','R');
    utl_file.get_line(f,s1);
    utl_file.get_line(f,s2);
    utl_file.get_line(f,s3);
    insert into sampletable (a,b,c) values (s1,s2,s3);
    c := c + 1;
    utl_file.fclose(f);
    exception
    when NO_DATA_FOUND then
    if utl_file.is_open(f) then utl_file.fclose(f); ens if;
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;SY.

  • DBMS_XMLSave.insertXML Fails on decimal format

    DBMS_XMLSave.insertXML Fails on decimal format
    The following example fails when using collections of complex elements. The error is:
    java.lang.NumberFormatException: 1.0'
    Example is:
    create table test_parent(p_id NUMBER(18),
    test_col number(10))
    alter table test_parent add constraint pk1 primary key(p_id)
    create table test_child(t_id NUMBER(18),
    test_col number(10),
    p_id NUMBER(18))
    alter table test_child add constraint pk2 primary key(t_id)
    alter table test_child add constraint fk1 foreign key (p_id) references test_parent(p_id)
    insert into test_parent values(1,1)
    insert into test_child values(1,1,1)
    insert into test_child values(2,2,1)
    insert into test_child values(3,3,1)
    create type test_c AS OBJECT (t_id NUMBER(18),test_col NUMBER(10));
    CREATE OR REPLACE TYPE test_cs AS TABLE OF test_c
    CREATE OR REPLACE VIEW test_view(parent_id,parent_num,child)
    AS SELECT p.P_id,
    p.test_col,
    CAST(MULTISET(SELECT c.t_id,
    c.test_col
    FROM test_child c
    WHERE p.p_id = c.p_id) AS test_cs) AS child
    FROM test_parent P
    CREATE OR REPLACE TRIGGER test_trig INSTEAD OF INSERT ON test_view
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Trigger proccessing');
    END;
    SHOW ERRORS
    DECLARE
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    xmlDoc CLOB := '<ROWSET>
    <ROW>
    <PARENT_ID>2.0</PARENT_ID>
    <PARENT_NUM>2.0</PARENT_NUM>
    <CHILD>
    <T_ID>1.0</T_ID>
    <TEST_COL>1.0</TEST_COL>
    </CHILD>
    </ROW>
    </ROWSET>';
    BEGIN
    insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    END;
    DECLARE
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    xmlDoc CLOB := '<?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <PARENT_ID>1</PARENT_ID>
    <PARENT_NUM>1</PARENT_NUM>
    <CHILD>
    <TEST_C>
    <T_ID>1.0</T_ID>
    <TEST_COL>1</TEST_COL>
    </TEST_C>
    <TEST_C>
    <T_ID>2</T_ID>
    <TEST_COL>2</TEST_COL>
    </TEST_C>
    <TEST_C>
    <T_ID>3</T_ID>
    <TEST_COL>3</TEST_COL>
    </TEST_C>
    </CHILD>
    </ROW>
    </ROWSET>';
    BEGIN
    insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    END;

    If you have access to ON, check out document 119140.1.
    Apparently it's a bug in the jdbc driver in pre-Oracle 8.1.7 databases...the workaround looks messy though.

  • 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

  • Presentation variable(Date) in German Format

    Hi,
    I like to know whether it is possible to use date(prompt) in German format.
    e.g., We need to filter out the date(06.01.2009) which is given in Dashboard prompt as a Presentation variable.
    The date which we have given in prompt should be accessed by reports to perform some calculations and return back the calculation values.
    As we have tried the presentation variable(date) in US Format,it is working fine.
    Regards,
    Sakthi

    Hi kishore,
    I am not clear with the above mentioned forum link.
    We are using presentation variable for dynamic calculations inside the report.
    Suppose if we are giving date for dynamic calculation,as far as we are using this format (01.Jan.09) and convert the above format in required as used for calculations.
    The problem comes when german date format(01.Dez.2008) is given in prompt,it will throw an error.
    Because both German and US will have January & Januar Jan(First 3 letters as same) but when it comes for some months like December(Dezember(German)),we cannot convert into required format.
    Is there any solution for the above issue.

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

  • Property to set hex/binary/decimal format at run time?

    Hi, I'd like to allow my user to choose between hex/binary/decimal formats in his number input. I'm happy to do the radio button stuff and the code to "hear" what he wants, but I can't find a property of my variable which selects the format at run-time - there is of course the "Format & Precision..." which I can get at by right mouse click BEFORE running, so I know it's likely to be available at run-time. Any suggestions welcome. Thanks, Richard.

    It's not necessary to use property node because you can use the builtin
    property of the indicator.
    Click the rigth mouse button over the indicator and select show radix.
    On the left side of the indicator appear radix that you can push to choose
    between hex, binary, octal and decimal.
    Bye
    Golzio
    "R" ha scritto nel messaggio
    news:[email protected]..
    > Hi, I'd like to allow my user to choose between hex/binary/decimal
    > formats in his number input. I'm happy to do the radio button stuff
    > and the code to "hear" what he wants, but I can't find a property of
    > my variable which selects the format at run-time - there is of course
    > the "Format & Precision..." which I can get at by right mouse click
    > BEFORE run
    ning, so I know it's likely to be available at run-time. Any
    > suggestions welcome. Thanks, Richard.

  • 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

  • Convert decimal to User Decimal format

    Hi All,
    I have number in this format 10.000,52.I want to change this format to my User decimal format whcih  is entred in SU01.
    Can anybody please help me out.
    Thanks,
    Swapna.

    Hi Swapna,
    Please go to SU01 --> Enter user id --> display --> Anc click on default tab and check the decimal notation.
    Declare one field to currency type and then try
    Use FM BKK_AMOUNT_CONV_TO_INTERN_MAIN.
    you can check by changing the values in su01.but remember your change reflect only when you logoff SAP and again login.so once logoff is needed.
    regards,
    Ranveer.

  • Convert a String to Decimal Format in European format

    Hi Experts,
    I am having a string as a context type for a input field, where the user can enter the Price, I need to convert the same into European format "###.###,00", I am using this below code to convert the string to decimal format
    User will enter the input as 10 as it needs to be converted into 10,00. Also, 1000 which has to be converted as 1.000,00
    String Str1 = wdContext.currentvn_temptable.getVa_TempUnitPrice();
    Locale mylocale  = Locale.GERMAN;
    String pattern="###.###,00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(Str1);
    wdComponentAPI.getMessageManager().reportSuccess("Unit Price" + " " + pattern + " " + output);
    When I execute the above code, i am getting an error called "Malformed Pattern ###.###,00"
    Please let me know, how to convert a String to Quantity in European format
    Thanks & Regards,
    Palani

    Hello!
    Try to change your pattern to this one 
    Locale mylocale  = Locale.GERMAN;
    String pattern = "#,#00.00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(1111111.222);
    Pattern has an influence on number of digits between separators, but you have to use ',' for grouping and '.' for decimal. Character values for separators correspond to your Locale object.
    Thanks, Mikhail

  • Decimal format time value to convert into time (hr:min:sec)value in a graph

    I need to develop a graph in WAD, in BW7. In the graph the value must be showed as HR:MIN:SEC, which I cannot get it right.
    The keyfigure value  carries the duration(hr:min:sec) in decimal format.  In the query, I use this keyfigure for calculation. To get the time broadcasted for a week range. I get the total duration (say 507835.000). Now I need to convert this value back to hr:min:sec. I use the below formulas to get the hr, min, sec.
    D = 507835
    Val1 = D/3600
    Val2 = Frac(val1)
    Val3 = Val2 * 60
    Val4 = frac(Val3) * 60
    Hr = Val1 – Val2
    Min =  Val3 – frac(Val3)
    Sec =  Val4
    In another formula in the query I add Hr + Min/100 + Sec/10000 to get hr.minsec format.
    When I do an average on count of weeks,  this doesn’t round off correctly.
    I tried to also use the Data function TIME() which when the time is > 24 hrs changes the value.
    Lets say if it is 39:00:00, it shows value as 15:00:00 instead of keeping the value 39:00:00.
    When I used this value in the graph it did not show the HR:MIN:SEC values in the value axis instead  it showed 0.0, 0.1,….1.0. Bcoz of this the graph is blank.
    Can anybody help me to resolve this problem.
    Thanks alot
    Anima

    I checked SU01 and didn't see anything there to customize...
    In my workstation, control panel / regional and languages settings / tab regional Options / customize; my time format is HH:mm:ss; the HH has to be in capital letter to display the time in 24 hour...
    but this is strange anyway... are you reporting with web frontend or excel?

Maybe you are looking for