Mathematical functions - Frac, trunc, ceil

Hi,
I'm trying to use Mathematical functions like ceil, trunc... in a class method
but they don't work.
How can I solve the problem?
data: appo_dec type p decimals 2,
        wa_val  type p decimals 2 value '1.75'.
appo_dec = FRAC( wa_val ).
The variable appo_dec always is zero.
This code work in a report but not work in a class method.

Well, so your variable probably becomes empty somewhere before calling FRAC...
I gave it a try, got no issue at all...
*       CLASS lcl_test DEFINITION
CLASS lcl_test DEFINITION.
   PUBLIC SECTION.
     CLASS-METHODS: _frac.
ENDCLASS.                    "lcl_test DEFINITION
*       CLASS lcl_test IMPLEMENTATION
CLASS lcl_test IMPLEMENTATION.
   METHOD _frac.
     DATA: l_dec TYPE p DECIMALS 2,
           l_val TYPE p DECIMALS 2 VALUE '1.75'.
     l_dec = FRAC( l_val ).
     WRITE: l_dec.
   ENDMETHOD.                    "_frac
ENDCLASS.                    "lcl_test IMPLEMENTATION
START-OF-SELECTION.
   lcl_test=>_frac( ).
Kr,
Manu.

Similar Messages

  • Overloaded Functions : FRAC(), FLOOR(), CEIL() strange behavior...

    Hello,
    These ABAP commands have a different behavior in a report or in a user-exit.
    For instance :
    DATA: v_frac LIKE vbep-bmeng,
               v_floor LIKE vbep-bmeng,
    or (same results)
    DATA: v_frac type p decimals 3,
               v_floor type p decimals 3.
    The code in my report ( ztest ) is :
          vbep-bmeng =  1333 / 1000.
          v_frac = FRAC( vbep-bmeng ).
          v_floor = FLOOR( vbep-bmeng ).
    I see, in debug mode:
       v_frag set to 0.333 -> works fine
       v_floor set to 1.000 -> works fine
    Now in my User-exit (include MV45AFZZ), I put exactly the same code.
    I see, in debug mode,
       v_frag set to 0.000 -> ????
       v_floor set to 1.333 -> ???
    I don't understand why the results are different ?
    In the Exit, the types P or Quant seem to be considered as Integer...
    any idea ?
    ( R/3  ECC5, ABAP 6.40)
    Thank you
    Ramdane

    hi,
    MV45AFZZ is an include of main program SAPMV45A. Whatever reason but the fixed point arithmetic is not turned on in this main program (an OSS issue?), I guess that is the reason, that the calculation fails.
    hope this helps
    ec

  • Problem in mathematical Functions

    Hi All,
    I am using a mathmatical function FRAC but getting error
    Field "FRAC" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.
    getting this error for any of the functions like CEIL, FLOOR etc.
    My Statement is -
    lv_mmm = frac(lv_time).
    Do i need to include something to get it working?
    Thanks,
    Nilanjana
    Edited by: nilanjana sinha on Aug 25, 2010 12:30 PM

    Hello,
    try:
    lv_mmm = frac( lv_time ).
    You have to insert spaces before and after lv_time. This is valid for all functions.
    regards,
    Pedro

  • How to use mathematical functions in XSL mapping

    Hi,
    I am using Jdeveloper 10.1.3.3. I need to insert mathematical functions like "multiply,divide,power" etc in my mapping. But in the XSL i am getting all string functions and very few math functions for number.
    I am newbie in Jdev. Please if anyone can share how this can be done.
    Thanks

    Hi,
    The RfcAdapter trys to find a Sender Agreement for this RFC call but the lookup failes. The values used for this lookup are:
    Sender Party/Sender Service: The values from Party and Service belonging to the sender channel.
    Sender Interface: The name of the RFC function module.
    Sender Namespace: The fix RFC namespace urn:sap-com:document:sap:rfc:functions
    Receiver Party/Receiver Service: These fields are empty. This will match the wildcard
    Regards,
    Suryanarayana

  • How do mathematical functions in a table invoked in jsf page

    hi i need detail about how can i do mathematical functions for data in table in jsf page using adf bc. for example in my table(sales) i give product id,name,unit price, quantity then i want to calculate product of quantity and unit price in a table automatically and store in total amount column

    Hi,
    John suggestion would work. Another option is to define it in EL using #{row.quantity * row.unitPrice} as the outputText value. Then add a numberConverter to the outputText using type="currency". The best option, imho, is to define the totalAmount attribute on the VO and implement the product there. However, keep the converter on the inputText and don't use the display hints on the VO.
    Regards,
    ~ Simon

  • Create a mathematical function out of samples

    hello
    I'd like to know how can i create a mathematical function out of
    samples of a signal (sine wave for example ) .
    the samples (around 1000 samples) are known( taken from a text file),
    and also the time between every sample is known.
    thanks a lot
    Elad

    What you are probably looking for is fitting experimental data to a model function.
    LabVIEW has many fitting algorithms built-in and it depends on the desired function to decide what is best. You can fit to a line, polynomial, or exponential, etc., or you can use levenberg-marquardt for more complex models.
    If you want to fit to a single sine function, you could use "Extract single tone".
    Tell us a little more about your data.
    LabVIEW Champion . Do more with less code and in less time .

  • Programming mathematical function spaces in f#.....

    This is a very general question in order to perhaps get some redirection to the appropriate resources....II am interested in the idea of representing mathematical function spaces using f# to program the function relationships..... The idea s that in math...
    Function spaces use function instead of vectors in vector spaces... I would like to get an idea of how to implement function spaces in f#.....?????????.......
    Thank you........

    g2d.draw(polygon)

  • What is the mathematical function associated to linear, map ranges, polynomial, table scale?

    What is the mathematical function associated to linear, map ranges, polynomial, table scale? I'd like to use the scale of daqmx for use with other types of data.

    yes, refer to the help, but only found information on the first option "linear". what I intend to is to be able to climb a number, using one of the existing scales, but don't be that mathematical function is necessary to use.

  • Add a mathematical function in Query Designer ?

    Hi,
    Do you know if it is possible to add a function in the Query Designer on formula screen ? If yes ... how ?
    Thanks a lot,
    CG.

    You can use the CEIL and FLOOR Functions for this
    Suppose you have a Key Figure K.F . hide this key figure and create a new formula Key Figure and create a formula as shown below.
    ( FRAC ( 'K.F' ) >= 0.5 ) * CEIL ( 'K.F' ) + ( FRAC ( 'K.F' ) < 0.5 ) * FLOOR ('K.F' )
    CEIL, FLOOR and FRAC will be available under Mathematical Functions

  • Performance: Mathematical functions

    I'm a recent convert to Oracle and need some advice.
    Scenario:
    1. Our client has a web application written in Java that queries an Oracle database to extract a list of stores based on their location.
    2. The client approached us to rewrite the application in .Net, but the database remains Oracle10g
    3. In the existing Java application there were no stored procedures used so we created much of the logic, that used to be in Java, in stored procedures.
    Problem:
    When extracting a list of stores, 5 at the most, the performance is considerably slower than their existing application. One of the points mentioned is that Oracle isn't the best place to put code that relies on mathematical equations.
    Finer detail:
    Each store record in the database has a latitude and longitude value. The user searches by postal code and the application has to return the X closest stores to them.
    We have a function which accepts the lat and long values and calculates a distance based on math equations including the use of Sin, Atan, etc.
    So in the select query we would have something to the effect of:
    SELECT storeName, round(CalcDistance(parms),13) AS Distance FROM Stores WHERE .... ORDER BY Distance
    Should this kind of code be done rather in the business logic layer or are we missing something about Oracle?
    Regards,
    J.Hov

    user11303583 wrote:
    One of the points mentioned is that Oracle isn't the best place to put code that relies on mathematical equations. As a general statement that is completely false.
    Finer detail:
    Each store record in the database has a latitude and longitude value. The user searches by postal code and the application has to return the X closest stores to them.
    We have a function which accepts the lat and long values and calculates a distance based on math equations including the use of Sin, Atan, etc.
    So in the select query we would have something to the effect of:
    SELECT storeName, round(CalcDistance(parms),13) AS Distance FROM Stores WHERE .... ORDER BY DistanceOk, the problem you are experiencing is generally referred to as context switching. This happens when you call a PL/SQL function from within SQL and you're doing it many times e.g. a function call for each row. This is because for each row the function is called and the value is passed back, causing oracle to have to switch between the SQL 'engine' and the PL/SQL 'engine', passing all relevant information in the process.
    Likewise you can get a performance problem if you call SQL lots of times from within PL/SQL (rather than using single SQL's effecting many rows).. e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_sysdate DATE;
      3  begin
      4    v_sysdate := SYSDATE;
      5    INSERT INTO mytable SELECT rownum FROM DUAL CONNECT BY ROWNUM <= 1000000;
      6    DBMS_OUTPUT.PUT_LINE('Single Transaction: Time Taken: '||ROUND(((SYSDATE-v_sysdate)*(24*60*60)),0));
      7    EXECUTE IMMEDIATE 'TRUNCATE TABLE mytable';
      8    v_sysdate := SYSDATE;
      9    FOR i IN 1..1000000
    10    LOOP
    11      INSERT INTO mytable (x) VALUES (i);
    12    END LOOP;
    13    DBMS_OUTPUT.PUT_LINE('Multi Transaction: Time Taken: '||ROUND(((SYSDATE-v_sysdate)*(24*60*60)),0));
    14    EXECUTE IMMEDIATE 'TRUNCATE TABLE mytable';
    15* end;
    SQL> /
    Single Transaction: Time Taken: 1
    Multi Transaction: Time Taken: 37
    PL/SQL procedure successfully completed.
    SQL>As you can see the performance difference can be quite a good factor higher if there's a lot of context switching.
    The way to solve this is to either write your SQL statement within PL/SQL so that it processes many rows in one go, or for your particular issue, re-write your SQL statement to do the calculation as part of the SQL rather than calling user defined PL/SQL functions. You may find using Oracle's built in spatial packages useful as these are already compiled as low-level code and optimised for performance, but you may find, if the calculations can be done within the SQL itself it will be the quickest.

  • Mathematical Functions in Pages

    Hey Ya'll
    Just started a degree course in Civil Engineering. My whole school is working in Word ~ God can you believe it...!! Anyhow, just trying to work through pages to see if it will be compatible ( and in most cases it is as I can save all docs in Word). But what about complex mathematical equations & functions. In WORD you can create the most outrageous functions and equations but in pages you can only add, subtract and the other easy stuff. Is there a program out there that will allow me to keep working in pages but use the complex stuff as well or should I just throw in the towel and buy Office??
    Thanks in advance.
    RutterNFA

    The result is awful !
    But, if I understood well the OP's question, it was not about a formula editor but about the ability to create complex formulas in table's cells.
    But what about complex mathematical equations & functions. In WORD you can create the most outrageous functions and equations but in pages you can only _add, subtract and the other easy stuff_ .
    But maybe I am wrong.
    About Equations editor, look at:
    http://www.uoregon.edu/~noeckel/Keynote.html
    http://evolve.lse.ac.uk/software/EquationEditor/
    http://www.mathmagic.com/download/
    and even at the Equation editor embedded in openOffice.
    Yvan KOENIG (from FRANCE lundi 13 octobre 2008 14:00:57)

  • Oracle mathematical functions

    Hey guys,
    Not sure if this falls under the PL/SQL category or not, but in regards to Oracle's mathematical or numeric functions: i.e. SUM, MIN, MAX, COUNT, etc., does it also do division within a field? I.e. COUNT(*) of one field divided by COUNT(*) with a HAVING or WHERE attatched to it? (or vice versa rather)
    In other words, if I have 65 records, and it's maybe a yes-no field, and maybe 43 have the value "yes", for example, can it divide the count total of 43 by 65 to render a percentage value, or does that just need to be handled by whatever supplementary programming language (i.e. java, C++, Perl, etc.) by creating a double or int value and the like?
    Forgive me if this seems obvious, as I'm not totally versed in Oracle, but realize it has many capabilities.
    Thanks!

    Something like this ?
    TEST@db102 SQL> select a, b, a/b from
      2  (select count(*) a from emp where deptno=30),
      3* (select count(*) b from emp)
    TEST@db102 SQL> /
             A          B        A/B
             6         14 .428571429
    TEST@db102 SQL>                              
    [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Can text be displayed in a formula column using mathematical functions?

    I am working with Financial Reports version 11.1.1.3 and I'm trying to accomplish the following scenario:
    Column D is a data column
    Column E is a text column containing the value "TEXT"
    Column F is a formula column with the following formula: IfThen([D]=0,[E],[D])
    What I want to see happen is if the value in column D is 0 then I want the value "TEXT" to appear in column F, otherwise; I want to show the data value that is in column D. Is it possible to display text in a formula column and if so, what is the syntax for that? Or does anyone have another way to accomplish this? Any help would be appreciated.
    Thanks!

    Short answer: No.
    For your particular issue, I would suggest putting your TEXT value in the #zero and #missing overrides in Report Studio.
    In general, Hyeprion Reporting does not do any real text validations or functions like you could use in Excel.

  • First Mathematical Function

    I'm stumped. I am filtering a query and I need to be able to
    use a First function in ColdFusion, like in Access.
    This is what my query is in Access:
    SELECT First(query2.Latitude) AS Latitude,
    First(query2.Longitude) AS Longitude
    FROM query2
    This is what I need my query to be in ColdFusion:
    <cfquery name="getAVG" dbtype="query">
    SELECT min(passedzip.Latitude) AS latitude,
    MIN(passedzip.Longitude) AS longitude
    FROM passedzip
    </cfquery>
    Of course, ColdFusion doesn't support the First function and
    it's really screwing me up. Min doesn't work - I need First.
    Does anybody out there have a clue as to how to work around
    this? I am using a query of queries in my site to get the results I
    need.
    Thank you!

    How about just using #QueryName.ColumnName# outside of a
    <cfoutput
    query=""> or <cfloop query=""> loop. It will always
    return the first
    row in your query.
    Or more properly... #queryName.ColumnName[1]# which is what
    the above is
    a short cut to though this allows one to get the second row
    if they
    desire, ex. #queryName.ColumnName[2]#. And of course if you
    replace the
    integer in the row designation with a variable containing an
    integer,
    then all kinds of fun things can be done.

  • Mathematical functions in Diadem

    Can someone tell me how I simply add two channel properties together in Diadem VB script.
    Or if I can calculate a new value by adding a variable to a channel property.
    The output from the addition I would like to put back into a new Channel Property.
    This code does not seem to work.
    msgbox ChnPropValGet(1, "maximum") + ChnPropValGet(2, "maximum")
    Thanks

    You are correct - it looks like ChnPropValGet only shows up in DIAdem 10.1.  I use different versions of DIAdem, so often re-create the new functions that I enjoy and register them as a user command (using ScriptCmdAdd).  I think something like the function below should give you somewhat similar results.  And yes, you should be able to put this value into a channel property by using the ChnPropSet command, and perhaps the ChnPropCreate command, if you want to create a new property.  For example, the bit between the dashed lines saves the sum of the maximum values to the variable, "MaxSumVal" and then creates a property for channel #5 called "MaxSum" and sets this value to MaxSumVal.  But you could also put the value in an already-created property, but some excisting channel properties are read-only.  I hope this is not confusing!
    MaxSumVal = ChnPropValGet(4, "maximum") + ChnPropValGet(3, "maximum")
    Call ChnPropCreate(5, "MaxSum", DataTypeFloat64)
    Call ChnPropSet(5, "MaxSum", MaxSumVal)
    Call ChnPropSet(5, "Description", MaxSumVal)
    Public Function ChnPropValGet(ChnNum, ChnProperty)
      Dim ChanType
      ChanType = ChnPropGet(ChnNum, "displaytype")
      Select Case ChanType
        Case "Numeric"  ChnPropValGet = Val(ChnPropGet(ChnNum, ChnProperty))
        Case "Text"     ChnPropValGet = ChnPropGet(ChnNum, ChnProperty)
        Case "Time"     ChnPropValGet = ChnPropGet(ChnNum, ChnProperty)
        Case Else       ChnPropValGet = ""
      End Select
    End Function ' ChnPropValGet

Maybe you are looking for

  • Using a serial Wacom tablet on a Mac Pro

    I have a good Wacom tablet with serial port interface that I would like to connect to a Mac Pro. Is there some way to do this? Is there any sort of serial to usb adapter or would that not work with a Mac Pro? Thanks for any advice.

  • Change of Customer Payment Term

    Hi Gurus, We are planning to change the payment term of our customer accounts this October. For example: Customer A Payment term last September is payable in 20 days. October 10- payment term was changed to 10 days Kindly advise if the postings that

  • Fax and phone interference

    The fax test says "not using cord supplied with printer,"  but I am using that cord as directed.   Problem--incoming phone calls are triggering the fax signal, and we can't hear the voice when we pick up after two rings.   How to separate the voice c

  • Hardware requirement for Oracle WebTier

    Hi everyone. I'm planning for webcenter portal site and the first task is sizing for hardware server. I have some document on Oracle public site that describe some information for Middleware server. But with WebTier I got nothing. Searching internet

  • Converting PDF files

    A client of mine has a company logo in the form of a pdf document. We were just wondering if there was a way to convert the PDF to a jpg or png file format. Any help would be greatly appeciated for our video to music conversion site. [ link removed b