Process a formula that is in an string

Hi,
does anybody know how to process a formula that comes in an string?
Por ejemplo:
a = 1.
b = 2.
c = 3.
string = '( a + b ) * c'.
string = '( 1 + 2 ) * 3'.
how can I get the result of that formula.
Thanks in advance.

You can try to generate a Dynamic Subroutine-pool and call it from the your program.
Check this sample code:
DATA: l_string TYPE string,
      a TYPE i,
      b TYPE i,
      c TYPE i,
      res TYPE i.
DATA: l_source TYPE STANDARD TABLE OF char72 WITH HEADER LINE.
a = 1.
b = 2.
c = 3.
FIELD-SYMBOLS: <fs> TYPE ANY.
l_string = '( A + B ) * C'.
l_source = 'PROGRAM ZTEST_TMP_123.'.
APPEND l_source.
l_source = 'form test using a b c changing res.'.
APPEND l_source.
l_source = 'RES = '.
APPEND l_source.
l_source = l_string.
APPEND l_source.
l_source = '.'.
APPEND l_source.
l_source = 'endform.'.
APPEND l_source.
DATA: prog TYPE string,
      tab  TYPE STANDARD TABLE OF string,
      mess TYPE string,
      sid  TYPE string.
GENERATE SUBROUTINE POOL l_source NAME prog
         MESSAGE mess
         SHORTDUMP-ID sid.
IF sy-subrc = 0.
  PERFORM ('TEST') IN PROGRAM (prog) IF FOUND
  USING a b c CHANGING res .
ELSEIF sy-subrc = 4.
  MESSAGE mess TYPE 'I'.
ELSEIF sy-subrc = 8.
  MESSAGE sid TYPE 'I'.
ENDIF.
WRITE: l_string, '=', res.
Regards,
Naimesh Patel

Similar Messages

  • Doing mathematical formulas with numbers stored as strings

    Hi Everybody.
    I know I must be doing something stupid here, but I just can't see it.
    I'm just trying to do a simple maths formula of one number divide by another. However, one of the numbers is stored as a string.
    I have tried  'X' / Ccur ({'String'}) and even done a seperate formula that succesfully converts the string to a number and  then try 'X' /  ({'conversion formula'}) and still no luck.
    What am I missing and can anybody help please?
    Thanks
    Graham

    Thanks both.
    Works perfectly. Didn't see the ToNumber conversion in the choices available and have not used it before.
    I'll also provide better descriptions as well in the future.
    Regards
    Graham
    Points awarded accordingley  :O)

  • Using a formula that works in Excel

    Is there a way to create this type of formula that works in Excel but not in Numbers 09
    =SUMPRODUCT(--(Utilization!A10:A190="Jan"),--(Utilization!C10:C190="Personal"),- -(Utilization!D10:D190))
    This is referring to second page "Utilization" but doesn't have to in new numbers spreadsheet.
    Have 3 columns. 1st with month, 2nd describing type of work, 3rd with hours.
    New cell will have product of 1st two items.
    Can pm example if this sounds confusing. Thanks.

    You're right, it sounds confusing. It sounds like you want to create products of Months X Description of work X Hours and then sum them up.
    It's as amazing to me that it would work in Excel as that you think it would work in Pages or Numbers.
    Jerry

  • Formula that creates additional rows

    Greetings everyone. I am fairly new to Apple numbers. I have a spreadsheet that calculates an investment return for clients year by year based on their age. I need the spreadsheet to go out to the clients age 100. There is an input page that I put in the clients age as well as additional information that it uses to calculate the investment return. It then takes the clients age and starts off the first column (client age) with that value. Each row has about 5 columns with different information being displayed. I am looking for a way for numbers to take the clients age column and automatically continue to create additional rows until it gets to the clients age 100. I would want each additional row to have the same formatting, formulas, and color scheme as the row before it. Is their a formula that would do this or do I need to create some sort of script?
    Thank you,
    Matt S.

    You can put the last row (the totals) in a footer and it will always be there or it can be a regular row that is TRUE so it is not hidden.
    If you make the table 125 years in length and automatically hide the unnecessary rows as I have outlined, you won't have to add rows, subtract rows, or tailor it in any other way for each client. It will tailor itself to the correct length based on the age you specify on the client's input page. And next year, when they are a year older, you can change their age in the client input page and the table will change accordingly.
    Depending on how you handle the formulas within the spreadsheet, you can sum things up the normal way with the SUM function or you can sum them up with SUMIF where the "if" is "if the row is TRUE". In other words, if every row that is FALSE has zeros, you can use SUM; if the rows that are FALSE have nonsensical numbers, you could use SUMIF. Formulas for things like rate of return might take some finessing but they too can be done. Any charts you might have can be made to not show hidden data (it's a checkbox), so they too are not a problem.
    I guess I'm from the school of "if it can be done within Numbers, then do it within Numbers" versus throwing scripts into the mix. It will be more versatile and portable if it does not require a script because a script is a separate entity, not part of the spreadsheet. Also, if you make changes to the spreadsheet, you may have to make corresponding changes to the script. That's just my opinion. It's your call. I'm sure Yvan can set you up with a terrific script.

  • Date issue in processing billing documents that shipped in a prior period

    Date issue in processing billing documents that shipped in a prior period that is now closed:
    SAP values those deliveries with the current document date in A/R when it should be the original delivery date.  Baseline date needs to stay the delivery date, but is getting copied from the billing date in the new period.  A user exit exists (& needs to be applied) to manipulate the baseline date when the accounting document is being created.
    Any input is appreciated.

    Hi
    Try with Invoice Correction Request concept
    Sale document Type: RK
    Reference Document Type : Billing Number
    for Understanding the Invoice Correction request check below link
    [Creating Invoice Correction Requests|http://help.sap.com/saphelp_46c/helpdata/en/dd/55feeb545a11d1a7020000e829fd11/content.htm]
    Regards,
    Prasanna

  • Is it possible to create a formula that converts a resource hours into full time units in project server 2010

    Hi
    Is it possible to create a formula that converts a resource available hours into full time equivalent units in project server 2010? Say a resource has 160 available hours for any given month this will translate into 1 FTE for this month. If it is 80 hours
    for that month then it will be 0.5 FTE and so on and so forth.
    Thanks,
    -Maurizio

    Maurizio,
    It's a bit late, but there are two OLAP cubes that can provide you with this information in a pivot table in Project Server 2010.
    "MSP_Portfolio_Analyzer" and "Resource Timephased" contains capacity measures that be used to provide calculated measures when the cube database is generated. You change OLAP cube configuration in "Server Settings -> Database Administration -> OLAP
    Database Management". In either of the aforementioned cubes, use "Calculated Measures" to create two measures:
    Member Name
    MDX Expression
    Available (FTE)
    ([capacity]-[work])/[capacity]
    Work (FTE)
    [Work]/[Capacity]
    These two fields will appear in the pivot table field list as "Values", and when combined with a "Time" column, can give you a picture of FTE usage and availability.
    I prefer the portfolio version since it contains project/assignment data and resource data, letting you see just  how resources are being utilized.
    One thing I have not been able to get around is getting ""Maximum Units" for a resource factored into the measure. A common practice is to allocate more that "100%" to generic resources to represent teams for planning purposes. The OLAP measures will show
    only 0.0 to 1.0 FTE for any resource, even if a resource represents more than one body.
    If you have an SSRS query you could share, I would appreciated it!
    Hope this helps!
    JTC
    JAckson T. Cole, PMP, MCITP

  • Process Task Adapter that looksup value

    Hi,
    Any help on creation of a process task adapter that will lookup a value in OIM.
    I wanted to make this as a generic adapter, by passing the lookup name and a codekey value which should fetch the decoded value in that lookup table.
    By doing so, I wanted to set few attributes so that when a attribute value got changed in USR form, it should search the mapped lookup and the codekey value (using a process task definition) and then set the decoded value in the targetted attribute.
    Thanks in advance.
    Regards.

    Here is the thread which might help you. Solution is there.
    Adapter for querying lookup table
    Sunny

  • HT1657 hi ! just rented a movie through an apple tv and it stopped, i cant get it back and when go to check rentals its like in process and nothing is hapening still in process, why is that? can u fix it?

    hi ! just rented a movie through an apple tv and it stopped, i cant get it back and when go to check rentals its like in process and nothing is hapening still in process, why is that? can u fix it?

    Mr. Churchill - First, to answer your last questions:
    Yes, the movie is fully downloaded, all 3.69 GBs.
    No the Apple TV has 127.5 GBs of its 144.63 GBs free.
    Second, I tried turning the Time Capsule WiFi rounter and Apple TV off (for at least two or three minutes, not the usual 10 seconds recommended) and I still could not move the movie.
    Third, I severed the link and set it up again re-synced all 5,103 items back and still when I move the movies to the Apple TV box and Apply it, after 35 seconds it stops the sync and moves it back the the Rented Movies box.
    Though I have set my Apple TV to sync with my MacBook Pro I cannot find a way to connect it to other than shared library, but not the "not shared library" (Is this what the Rented Movies are?). Is what Fletch is talking about int the "Rental Movies not showing up on Apple TV" discussion my problem and a solution?
    Fletsch
    Re: Rental Movies not showing up on Apple TV 
    Mar 4, 2008 1:58 PM (in response to Mark_Mac)
    there are three possibilities: you have not upgraded to version 2.0 or in Summary on the ATV device in iTunes, you should look whether you have it set up to only sync or otherwise disables movie syncing, or you have not paired your Mac to the ATV (on your tv, settings/computers/connect to itunes library - not shared library) 
    MacMini core duo, Mac OS X (10.4.8)
    Or is it something else?

  • Working day formula that excludes weekends and holidays in WEBI

    Hi Guys,
    Can we calculate a working day formula that excludes weekends and holidays in WEBI OR in Universe?
    The universe I am working on is using stored procedures, so there are no joins or modelling done. Although there is a workday stored proc  that I can bring in the universe.
    I am just thinking if there is no modelling or joins done in the universe how will this help me in webi?
    Your suggestions will be very helpful.
    Thanks,
    Jitan

    One more suggestion I need from you  -
    I have a Work_Calendar_VW that has the following columns -
    Calendar_Date - 5/1/2014
    Calendar_Year - 2014
    Calendar_Month - 5
    Calendar_Day - 1
    Work_Day - 1
    Day_Type - WD (Work Day)  For Weekends this will be displayed as WE
    The columns have all dates for current year in SQL Server.
    I am going to pull this into the universe and create 2 derived tables to calculate MTD Day counts.
    Derived Table 1  - Calculate Yest Work Day... this will remove all the weekends and holidays and give me the last working day. This includes couple of case statments to check each day if it's a working day or weekend.
    For Work Day the above code will be 1 and for weekend 0
    Derived Table 2  - This will give me the count of working days in current month using the above view and Derived table 1 Below is the code  -
    SELECT COUNT(*)
    FROM Work_Calendar_VW
    WHERE [Work_Day] = 1 AND
       (Calendar_Date BETWEEN CAST(CONVERT(VARCHAR(25),MONTH(LastWoringkday()),101) + '/01/'
       + CONVERT(VARCHAR(25),YEAR(LastWoringkday()),101) AS DATE)
      AND LastWoringkday()).
    I cannot do joins because this universe has been built using stored proc and would like to implement this in BO universe.
    let me know if this is the right approach.
    Thanks,
    Jitan

  • After I import the photos into light room from a folder, the deveop module cannot be accessed? What can I do to process those photos that are on my hard driive?

    After I import the photos into light room from a folder, the deveop module cannot be accessed? What can I do to process those photos that are on my hard driive?

    If you are using a standalone version of Lightroom, you may have updated with the CC-licensed update. That will not work. If this is your situation then it will be necessary for you to uninstall Lightroom and then install an update from a different website. Assuming that you are using Lightroom 5, this is where you need to download from:
    Product updates
    After you make the change you will be able to continue from where you left off. The switchover does not affect your images or your catalog.

  • How can I create a custom formula that checks if a PC file exists? (CR10)

    Post Author: lgayosso
    CA Forum: Formula
    Hello,
    I need to create a formula that validates whether a PC file exists or not to display a message ('File Found' or 'File not found'). I created a custom formula that displays the appropriate message based on a report field composed of the FilePath + FileNameWithExtension that works correctly if the field includes a value or not (Basic Syntax below):
    If {ctDocumentImages.ImgPath} <> ""  Then    Formula = "File Found"Else    Formula = "File not found"End If
    Now I want to validate that the {ctDocumentImages.ImgPath} value corresponds to an existing file; that is, I need to check that the file specified at {ctDocumentImages.ImgPath} location truly exists to determine that the file is actually 'found'. How can I accomplish this?
    Any help is greatly appreciated,
    Lucio

    Post Author: lgayosso
    CA Forum: Formula
    [email protected]:
    ( my file connection name was CrystalReports_Reports.File Name)  I have generated a report, that shows all my rpt file names, size, last updated.... etc )
    Go to database expert, create new connection, select file system data, your starting directory will be
    genplex\E\JEMS51_Server\Imaging\Int\2007\.....  you can then report on the file names found in that directory / subdirectory, etc...  When creating the link you can select all files, or just *.rpt  for example
    Ok, so you define more than one connection on your report to be able to access the File System Object, right? The problem is that my reports are generic and meant for distribution for customers where no generic base folder will exist. The value of the starting directoy is then unknown, FilePath+Name then can be any value.
    Lucio

  • Structure XPTO contains formulas that use cells as part of the formula

    Hi,
    I'm having the following error in query designer.
    "Structure XPTO contains formulas that use cells as part of the formula".
    In the query i'm working I don't use cells.
    Do you know what this error means.
    Best regards,
    João Arvanas

    Hi João, Is there a possibility any of your formulas in the structure may be referencing some other query / CKFs? Is it possbile your structure was created in another query & reused in your new one? If so, you may unlock all links using the option 'Remove Reference' which can be accessed by right clicking on your structure.

  • N8: How to see services/processes (not Apps) that ...

    How to see services/processes (not Apps) that are currently running?
    For those unfamiliar with the terminology, a service is the same as an application,
    only it doesn't have a user interface. Process, the same.
    Even when you kill all your applications, many processes are necessarily kept
    running, such as those for the phone UI or telephony. I want to see which.
    For example, I am suspecting that Battery Monitor application installs a service
    to log usage data and that this service runs constantly.
    I'd like to see some advanced task manager or something similar, that would
    allow me to see all running processes.
    I had such apps on Android. Are they available fro Symbian?
    N8 / RM-596

    This is the first fully compatible one that springs to my mind:
    http://www.smartphoneware.com/taskman-for-symbian3-product.php
    Y tasks may also work:
    http://www.drjukka.com/YTasks.html

  • I need help creating a formula that looksup cell data and give a value.

    I want to have the table "At a glance"  show the total days a driver has worked, there total in sales and there total in milage. The table shown is a example of what I want to have happen. I want to input any name into cell B2,C2,D2,ect. that is found in the row C2:C17 of Checkpoint (Truck 1) and Checkpoint (Truck 2) and return the total amount of day the driver has driven both trucks, The total in sales the driver has collected (Truck 1 and 2) and How many miles the driver has driven (Truck 1 and 2). I realize that these tables are not labeled correct. If I enter a name into B2 and the driver associated with that name hasnt driven then I want "N/A' to show in cell B2 and so one. I assume that the formula that is created for cell B2 will be copied and pasted into cell C2, D2, ect..
    If someone could help me with this problem I'd really appreciate it.
    Thanks.

    Hi br,
    To show the number of days worked by a driver, you need to COUNT the number of times that driver's name appears in row 2 of both tables.
    To calculate his total sales and total mileage, you need to SUM the amounts he brought in each day and the distances he drove each day.
    Your functions for this are COUNTIF and SUMIF.
    Formulas in At a Glance:
    B2: =COUNTIF(Truck 1 :: $3:$3,B$1)+COUNTIF(Truck 2 :: 3:3,B$1)
    B3: =SUMIF(Truck 1 :: $3:$3,B$1,Truck 1 :: $5:$5)+SUMIF(Truck 2 :: $3:$3,B$1,Truck 2 :: $5:$5)
    B4: =SUMIF(Truck 1 :: $3:$3,B$1,Truck 1 :: $12:$12)+SUMIF(Truck 2 :: $3:$3,B$1,Truck 2 :: $12:$12)
    Fill all three formulas right to the last column of At a Glance.
    To put N/A in place of the 0 in Roger's column and the empty columns, wrap each of the formulas in an IF statement:
    Bn: =IF(AND(ISERROR(MATCH(B$1,Truck 1 :: $3:$3,0)),ISERROR(MATCH(B$1,Truck 2 :: $3:$3,0))),"N/A",formula)
    Where formula is the formula used in column B above.
    Regards,
    Barry

  • I am trying to produce a formula that would allow an IF / THEN condition.

    I am trying to produce a formula that would allow an IF / THEN condition.
    I would like to be able to say that the selected cell would equal a specific cell if another cell had specific text entered in it..... i.e.
    In a sheet that contains cell from A1 to A3....
    That in cell A1 a dollar amount is entered, say $10.00
    That in A2 the text HELP is entered
    I would like to be able to have
    A3=A1 IF A2 contains HELP
    and it would be even better, if it contained anything else a $0.00 would be entered in the A3 cell
    Thanks in advance, Darrell

    Hi Darrell,
    Welcome to apple Discussions and the numbers '09 forum.
    A good place to start would be to download and read the first chapter of the Numbers '09 User Guide, which would give you a general overview of using a spreadsheet.
    For your particular question, a look at the IF function (page 150 of the iWork Functions and Formulas User Guide) seems in order.
    Both guides can be downloaded using the appropriate item in the Help menu in Numbers.
    The syntax of IF is this:
    =IF(if-expression,if-true,if-false)
    In a sheet that contains cell from A1 to A3....
    In Numbers, Sheets contain tables, charts, text boxes and other objects. Cells are contained in Tables.
    That in cell A1 a dollar amount is entered, say $10.00
    The entry would be 10, 10.0 or 10.00. The cell would be formatted for Currency.
    That in A2 the text HELP is entered
    I would like to be able to have
    A3=A1 IF A2 contains HELP
    and it would be even better, if it contained anything else a $0.00 would be entered in the A3 cell
    You want the formula to determine the value in cell A3, so the formula goes in that cell.
    Your condition (expression) is that A2 contains the text "HELP". As an expression, that's A2="HELP"
    If the expression is TRUE, you want the value returned to A3 to be the value in A1: A1
    If the expression is FALSE, you want the value returned to A3 to be 0 (with the cell formatted to show the value as currency).
    Substituting those into the template for the IF function, you get:
    =IF(if-expression,if-true,if-false)
    =IF(A2="HELP",A1,0)
    Regards,
    Barry

Maybe you are looking for