Parsing Boolean Formula

Hey guys, i'm having some trouble with a program i've been working on. Im a bit of a newbie so do forgive me if I seem as though i'm being a bit thick. I'm trying to split a boolean formula into it's sub formulas and parse the results into an array. For example, with the formula a&(a&b) i would have 'a' and 'a&b' store in the array and with the formula a&(a&b)&(b&c) I would have 'a', 'a&b' and 'b&c' I've been trying at it for a while now but don't seem to be getting anywhere. Code I have so far is:
import java.io.*;
public class ReadString
     public static void main (String[] args)
          String[][] myArray = new String[40][4];
          System.out.print("Please enter a formula: ");
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          String inputtedFormula = null;
          try
               inputtedFormula = br.readLine();
          catch (IOException ioe)
               System.out.println("IO error trying to read your formula!");
               System.exit(1);
          myArray[0][0] = inputtedFormula;
          Loopy(myArray);
     public static void Loopy (String myArray[][])
          int countStart = 0;
          int countEnd = 0;
          String formula = myArray[0][0];
          int stringLength = formula.length();
          int stringPosition = stringLength;
          for(;stringPosition>=0;stringPosition--)
I know I need to run through the formula and keep track of open and closed brackets and also keep track of start and end positions of these brackets so the code knows which sections to parse separately but I just can't figure it out and pretty much feel like i've hit a brick wall. Any help will be much appreciated.

How very helpful, thanks for that. I have been researching but so far everything i've found is either too rigid or not complex enough. I've tried using stringTokenizer and streamTokenizer but couldn't get the results i needed. All i could do was remove the brackets and take what's between but i need the program to recognise the operators and i don't really know how to do this

Similar Messages

  • Using a boolean formula in condition

    Hi All,
    In my report I've two prices, legal price and audit price.
    Legal price is a Nav. att. in cube it is an attribute of material.
    My requirement is to show only those records where audit price < legal price.
          First, I tried to achieve this by putting audit price in condition and creating a varriable for legal price, but it didn't do anything that condition shows all the records.
    Then I've created a boolean formula called flag and put this condition in it. It shows me 0 and 1 correctly. But, when I create any condition based on this flag saying flag > 0 or flag = 1, or flag = 0; I got no record.
    Can anyone pls. explain what I'm doing wrong or Bex. treat boolean formulas differently in conditions.
    Regards
    Tarun

    Tarun,
       Try this.
       Create a calculated key figure = audit price - legal price.
    Now create a condition on this new key figure like if value < 0 to display.
    You can hide this field.
    Hope it Helps
    Srini

  • CF9 Service not starting - error parsing boolean property notifyclientonalert

    Hi, I clean installed CF9 (after uninstalling CF8) on win2003 32bit and all was workign fine, however after a server restart the CF9 Application service refuses to start automatically or manually. I am getting an error in windows event logs saying see Coldfsuion logs, but there is nothing in these logs, not very helppful!  any ideas apart from a reinstall?
    After reinstalling I get the same problme, but this tuime in coldfusion server log I get the following error message
    "Error","jrpp-2","11/17/11","16:21:59",,"Monitor service: Error parsing boolean property notifyclientonalert, using default false"
    thanks
    Oli

    Hi Oli,
    Suggest try start CF from CMD prompt. Run cmd as an admin, CD ColdFusion9\bin\ , type CFSTART press enter. Some detail of what happens?
    HTH, Carl.

  • Another Boolean formula in BW 3.5

    Hello,
    Again I'm sorry for asking questions about formula, but I'm having real problems with this
    =IF((-A-B)>0,IF(((-A-B-C-D)/(-A-B))<30%,(-A-B-C-D)/(-A-B),""),"") and getting it into boolean logic. I've tried breaking the two IF calculations and creating two formula and then a third that combines the two and I'm getting figures, but not what I would expect.
    I also want my result as a percentage and can't get this to work at all.
    Any help would be really really appreciated.
    Thanks,
    Sam

    Hi Sam,
    if I understand correctly your formula, maybe you can try to insert the next one:
    ( (-A-B) > 0 ) * ( (-A-B-C-D) / (A-B) < 0,3) ) ) * (-A-B-C-D) / (A-B)
    For percentage, you can use the fx mentioned above.
    Hope it helps.
    Best regards.
    Simone.

  • Can BEX boolean formula give text value?

    The logic is:
    If quantity > 4, then "Successful", otherwise "failed".
    In BEX formula boolean:
    (quantity > 4) * "Successful" + (quantity < 4) * "failed".
    But somehow we can't find a way of adding the text wording "Successful" or "failed" into the BEX formula window.  Any workaround?
    Thanks and we will give you reward points!

    Hi Kevin,
    Instead of displaying text in the report column you can populate 1 or 0 using a formula or formula variable. Again if you are displaying the report on web you can use the concept of table interface which can replace 1 or 0 with the required text (n BW3.5).
    http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm

  • Parsing Boolean Array in FPGA

    Hi All,
    Although I have programmed in LabVIEW many times, I am quite a novice when it comes to programming on an FPGA, and I have been learning as I go (which up to this point has worked with little issue).  However, I have been unable to resolve my latest issue, and the more I read about the FPGA, the less certain I am that what I am trying to do in even possible.
    The task at hand involves reading in a set number of bits from the digital input/output lines of the FPGA and parsing these bits into specific words/"bytes."  For the purposes of the VI that I have attached, I have faked reading in a set number of bits by supplying three 26-bit words (78 bits total) that have been been defined on the front panel.  After supplying the specified bits, I am trying to parse the bit array into specific words that are given by the following logic:
    1.  Search for a start bit of 0 (false bit).
    2.  Once the start bit of 0 (false bit) is found the word that is trying to be parsed is the next 10 bits.
    3.  After the start bit and ten data bits is a stop bit of 1 (true bit).
    4.  Repeat steps 1-3, five additional times.
    From the above logic, there should be six parsed words in total for the supplied VI.  Unfortunately, I cannot simply take 12 bits (1 start bit, 10 data bits, and 1 stop bit) at a time, as the number of filler bits in between successive words is variable.  The VI that I have supplied is one version of how I have proposed to accomplish the aforementioned logic, but I cannot compile the VI/project, as I continually receive errors that "Arrays must be fixed in size."  To my knowledge, all the arrays in the VI have been preallocated and the logic seems deterministic.
    If anyone has any suggestion as to why this VI is not compiling, I would be greatly appreciative.  Thank you in advance for taking the time to look at this, and I look forward to resolving this issue.
    With gratitude,
    Gregory
    Solved!
    Go to Solution.
    Attachments:
    Example_Bit_Parser.vi ‏9 KB

    Unfortunately, you're going to have to rework this VI to make it run on an FPGA.  You can't relocate arrays in memory in an FPGA the way you can on a PC.  You have a variable-sized array as the output of delete from array, because the length input isn't fixed at compile time.  Also, two dimensional arrays aren't allowed.  Remember that when you code for an FPGA you're actually writing the hardware - each value in an array is essentially a circuit (this is my overly-simplified understanding).  The compiler can't allocate the right number of wires to carry an array if it can't determine the array size.  The array isn't in memory so there's no way to rearrange it at run-time.
    There are a couple of ways you could work around this, all of which will require iterating through every element in the input array.  You could use an FPGA FIFO, and only put the values into the FIFO that are data (ie, loop until you hit a start bit, put the next 10 values into the FIFO).  Then on the other side of the FIFO, possibly in a separate loop, read 10 bits at a time to get your data words.  Another approach is to rearrange the array as you go.  Keep track of the current location in the input array.  Whenever you hit a start bit, move the next 10 bits (you may have to do this one at a time) to the current location in the input array, incrementing the current location each time.  When you've finished all the input, all the data words will be at the beginning of the array in 10-bit units, which you can then split out as needed.

  • Parse formula

    Hi, all:
    I am developing a salary system by using J2EE. As we know, the salary and allowance systems of various company have great differently. So I create a table to store formula. Also, I also create a salary item table to maintain salary items. When I calculate salary, I need to parse salary formula. Who has algorithms? I want a algorithm which can parse +, - *, /, ().
    For example: one of salary items is:
    f9 = (f10-2000)*0.8;
    f1 = f2 + f3 - f4;
    f1, f2, f3, ...., f9, f10 represent salary and allowance items.
    Any help would be useful.
    Thanks!

    Here is the code, there are other classes refered to in this one, but you should be able to figure out what they are based on the name. If you have any questions let me know
    import java.util.StringTokenizer;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
      *@author Steven Bell
      *@version 1.0 3/5/03
      *the ExpressionTree class is used to evaluate and hold a mathmatical expression
    public class ExpressionTree{
         SimpleStack numberstack, opstack, cellrefs;
         String originalexpression;
         Token root;
         Graph graph;
           *creates an Expression tree
           *@param expression the expression to be evaluated
           *@param graph a reference to the Graph where cells are stored
           *@throws MalformedCellException thrown if the expression is invalid
         ExpressionTree(String expression, Graph graph)throws MalformedCellException{
              originalexpression      = expression;
              this.graph              = graph;
              StringTokenizer extoken = new StringTokenizer(expression, OperatorToken.OPERATORS, true);
              String[] tokens         = new String[extoken.countTokens()];
              for(int i=0;i<tokens.length;i++){
                   tokens=extoken.nextToken();
              buildTree(tokens);
         //creates the tree from the array of tokens each token is a portion of the expression
         private void buildTree(String[] tokens)throws MalformedCellException{
              boolean checkunaryminus = true;
              boolean unaryminus = false;
              numberstack = new SimpleStack(13);
              opstack = new SimpleStack(13);
              cellrefs = new SimpleStack(13);
              for(int i=0;i<tokens.length;i++){
                   if(LiteralToken.isLiteral(tokens[i])){
                        if(unaryminus){
                             numberstack.push(new LiteralToken(-1*Double.parseDouble(tokens[i])));
                             opstack.pop();
                             unaryminus = false;
                        }else{
                             numberstack.push(new LiteralToken(Double.parseDouble(tokens[i])));
                        checkunaryminus = false;
                   }else if(CellToken.isCell(tokens[i])){
                        Cell tempcell = getCell(tokens[i]);
                        cellrefs.push(tempcell);
                        Token temp = new CellToken(tempcell);
                        if(unaryminus){
                             temp = buildSubTree(new LiteralToken(0), (OperatorToken)opstack.pop(), temp);
                             unaryminus = false;
                        numberstack.push(temp);
                        checkunaryminus = false;
                   }else if(OperatorToken.isOperator(tokens[i])){
                        if(unaryminus) throw new MalformedCellException("illegal expression operator after minus");
                        char op = tokens[i].charAt(0);
                        if(checkunaryminus){
                             if(op=='-'){
                                  opstack.push(new OperatorToken(op));
                                  checkunaryminus = false;
                                  unaryminus = true;
                             }else{
                                  opstack.push(new OperatorToken(op));
                        }else{
                             if(op=='('){
                                  opstack.push(new OperatorToken(op));
                             }else if(op==')'){
                                  OperatorToken temp = (OperatorToken)opstack.pop();
                                  while(temp.instancePriority() != OperatorToken.getPriority('(')){
                                       if(numberstack.numObjects()<2){
                                            throw new MalformedCellException("Incefficient Numbers");
                                       Token r = (Token)numberstack.pop();
                                       Token l = (Token)numberstack.pop();
                                       numberstack.push(buildSubTree(l, temp, r));
                                       temp = (OperatorToken)opstack.pop();
                             }else{
                                  if(!opstack.isEmpty()){
                                       OperatorToken ot = (OperatorToken)opstack.peek();
                                       if(OperatorToken.getPriority(op)<ot.instancePriority()){
                                            if(numberstack.numObjects()<2){
                                                 throw new MalformedCellException("Incefficient Numbers");
                                            Token r = (Token)numberstack.pop();
                                            Token l = (Token)numberstack.pop();
                                            numberstack.push(buildSubTree(l, (OperatorToken)opstack.pop(), r));
                                  opstack.push(new OperatorToken(op));
                             checkunaryminus = true;
                   }else{
                        throw new MalformedCellException("illegal expression Failed all tests");
              while(!opstack.isEmpty()){
                   if(numberstack.numObjects()<2){
                        throw new MalformedCellException("Incefficient Numbers");
                   Token r = (Token)numberstack.pop();
                   Token l = (Token)numberstack.pop();
                   numberstack.push(buildSubTree(l, (OperatorToken)opstack.pop(), r));
              root = (Token)numberstack.peek();
         *gets the value of this expression
         *@return String returns the value of this expression in a String
         public String getValue(){
              double temp = root.getValue();
              return String.valueOf(temp);
         *gets the original expression that was parsed
         *@return String the original expression
         public String getEquation(){
              return originalexpression;
         *get the cells that are reference in this expression
         *@return Cell[] array of cells this expression holds
         public Cell[] getReferences(){
              Cell[] returncells = new Cell[cellrefs.numObjects()];
              int index = 0;
              while(!cellrefs.isEmpty()){
                   returncells[index++]=(Cell)cellrefs.pop();
              return returncells;
         //builds one three node subtree
         private Token buildSubTree(Token l, OperatorToken ot, Token r){
              ot.setLeftChild(l);
              ot.setRightChild(r);
              return ot;
         //uses buildSubTree to create a tree until more of the expression needs to be parsed
         private Token buildSubTrees(char op)throws MalformedCellException{
              if(op==')'){
                   OperatorToken ot = (OperatorToken)opstack.peek();
                   while(ot.instancePriority()!=0){
                        if(numberstack.numObjects()<2){
                             throw new MalformedCellException("Incefficient Numbers");
                        Token r = (Token)numberstack.pop();
                        Token l = (Token)numberstack.pop();
                        numberstack.push(buildSubTree(l, (OperatorToken)opstack.pop(), r));
              }else{
                   OperatorToken ot = (OperatorToken)opstack.peek();
                   while(OperatorToken.getPriority(op)<ot.instancePriority()){
                        if(numberstack.numObjects()<2){
                             throw new MalformedCellException("Incefficient Numbers");
                        Token r = (Token)numberstack.pop();
                        Token l = (Token)numberstack.pop();
                        numberstack.push(buildSubTree(l, (OperatorToken)opstack.pop(), r));
              return (Token)numberstack.peek();
         //gets or creates cell that is referenced in expression
         private Cell getCell(String cellname)throws MalformedCellException{
              int row = 0;
              int col = 0;
              Pattern colpatt = Pattern.compile("[a-zA-Z]+");
              Pattern rowpatt = Pattern.compile("\\d+");
              Matcher m = colpatt.matcher(cellname);
              m.find();
              String columnstring = m.group().toUpperCase();
              m = rowpatt.matcher(cellname);
              m.find();
              String rowstring = m.group();
              row = Integer.parseInt(rowstring);
              row--;
              char[] colchar = columnstring.toCharArray();
              for(int j=colchar.length-1;j>=0;j--){
                   col+=colchar[j]-'A'*Math.pow(26, j);
              if(row<0||col<0){
                   throw new MalformedCellException("illegal expression");
              Vertex v = graph.doesCellExist(col, row);
              if(v!=null){
                   return v.getCell();
              return new Cell(col, row, "0", graph);

  • Formula at run time

    Hi everyone
    I need to create a piece of code that takes a number of channels and creates
    a new channel making use of a formula, this is no problem if you want to
    hard code the formula, but it seems almost impossible if you want to change
    the formula at run time.
    Any suggestions?
    Thanks
    Jannie

    There are VIs that come with LabVIEW (probably full / pro only) that let you do this, provided I understand what you're asking.
    I suggest searching the palettes for "Eval Formula String.vi".  This is the "easy" way to do it, but it will parse your formula string every time it is called.  This parsing can be rather time consuming.  If you want to do the parsing first, and then run the calculation multiple times, you can split up the parsing and evaluation by using "Parse Formula String.vi" first, then use the outputs from it to a call to "Eval Parsed Formula String.vi" inside a loop.

  • Record Selection Formula and Parameters

    We've currently upgraded from Crystal Reports 9 to Crystal Reports 2008 (SP3).  In our legacy reports, we use the "record selection formula editor" to filter the results of our report.  This is an example of one of our formulas:
    {DOVREP_TIME_AND_EXPENSE.ITEM_DATE} >= {?FROMDATE} and {DOVREP_TIME_AND_EXPENSE.ITEM_DATE} <= {?TODATE}
    In this formula, we pass in the FROMDATE and TODATE from our .NET applicaiton to filter on dates.  After upgrading to Crystal Reports 2008 (SP3) this no longer works.  I get an error "Error in formula Record_Selection".  It looks as if it was having issues parsing the formula.  If I replace my parameters (?FROMDATE/?TODATE) with hard coded dates it works fine (It also worked fine in Crystal Reports 9) so from what I can tell adding the parameters causes parsing errors. Also in the error it shows the formula and it's defintily messed up:
    ((( NOT {DOVREP_TIME_AND_EXPENSE.ITEM_DATE} >= {?FROMDATE}) AND ( NOT {DOVREP_TIME_AND_EXPENSE.ITEM_DATE} <= {?TODATE})))
    I'm not sure why it is adding the NOT to the formula or the extra brackets...
    Any suggestions?
    Regards,
    Mike

    David,
    First off, the way I determined it was the beta dlls was that I installed CR 2008 SP3 runtimes fresh and ran my report.  I didn't experience any issues.  I then took the beta dlls and replaced the originals, rebooted and ran my report again.  The report failed to execute as I described above.  I then took my backup of the SP3 dlls and replaced the beta dlls, rebooted and tested again.  I worked fine with the original dlls. 
    The formula that I was passing into that report was a bit more complex than I first described.  I had a few other conditions in the formula that checked for a project ID.  I tested it with just the dates and there wasn't any issues (as in your example), as soon as I added additional parameters that's when the "NOT"'s were included.  Could you try your test again with a few additional parameters?  Here is an example of what I was passing into the report:
    ((({DOVREP_TIME_AND_EXPENSE.ITEM_DATE} >= {?FROMDATE}  )   AND   ( {DOVREP_TIME_AND_EXPENSE.ITEM_DATE} <= {?TODATE})))  AND (({%PROJECT_ID}=99 OR {%PROJECT_ID}=113 OR {%PROJECT_ID}=112 OR {%PROJECT_ID}=103 OR {%PROJECT_ID}=107 OR {%PROJECT_ID}=111)))
    Mike

  • If..then formula requiring numeric values

    Post Author: scd07
    CA Forum: Formula
    I have the need to create a formula that will analyze one field in order to determine the value of another field.  Below is a formula that follows the correct logic, but as it is a Boolean formula, it returns a  True/False answer, instead of the correct (numeric) data.  I do not know how to rephrase the formula that will return the numeric value.
    if {TLORDER.BILL_NUMBER} = previous ({TLORDER.BILL_NUMBER}) then {TLORDER.TOTAL_CHARGES} = 0 else {TLORDER.TOTAL_CHARGES} = {TLORDER.TOTAL_CHARGES}
    I appreciate any help!  Thank you!

    Post Author: scd07
    CA Forum: Formula
    Ok, this formula also works well, and I can now go in and create a Running total.  But again, I barely know what I am doing!  Here is what I put in the formula:
    Whileprintingrecords;Currencyvar Amount;
    if {LEGSUM.LS_TRIP_NUMBER}={LEGSUM.LS_TRIP_NUMBER} then Amount := Amount + {@Total Charges}
    This is providing a running total of the Last entry for each group.  It is not totaling All the records within the group.  I certainly appreciate your help with this.  I am actually a network person being impressed into reporting duty, and I am definitely experiencing "Trial by fire".  Thanks!
    Sara

  • Formula String

    Dear Friends,
    I have a table Earnings_Type with following structure;
    Earning_Name          Basis          Amount/Formula
    aaa               % On Basic Pay 20
    bbb               Flat Amount     1500
    ccc               Formula          (aaa+bbb)*30/100
    ddd               Formula          ccc*20/100
    The basic pay is a reserved word and takes its value from employee table. The basis is a poplist with the options % On Basic Pay/Flat Amount/Formula. The amount is a field to hold a number type data. In case the option being Formula the amount field is replaced by a field to take user entered formula in varchar2 type data.
    I request someone to advise me how to handle the formula entered by user to convert in to the value?
    Thanks

    It looks to me as though it's slightly more complex than that - it looks as though they want the formulae lines to pick up the values for aaa and bbb i.e. 20 and 1500. I don't think this can be done through a simple poplist.
    There needs to be a look-up table somewhere to store the values. The validation tigger needs to read this table to recover all the necessary values. I think to make this truly dynamic will require parsing the formula (because until we do that we don't know how many variables are in the formula). Of course this is a recursive piece of code, as formula ddd requires the execution of formula ccc.
    This will be easier in 10g, as the need MODEL clause allows us to do spreadsheet type execution in SQL. Until then, we're looking at something rather messy in Forms.
    I think this might be better implement as a set of checkbox and radio group items:
    AAA: y/n
    BBB: y/n
    Multiplier: none CCC DDD
    Yes it requires hard-coding, but it will be a lot simpler to implement. Providing the framework doesn't change very often the hardcoding isn't much of an issue (indeed, it can be made fairly dynamic with the various SET_ITEM built-ins). The actual values for the choices can still be dynamic, by keeping them in a database table.
    Cheers, APC

  • Formulas in sql

    I have a table in sql that needs to hold specific formulas. For example 2% + .15 and I will need to use this column to figure out prices. How would I be able to do that, and what datatype does it have to be?
    Debra has a question

    I need to be able to store in sql any form of formula in a column called discount later on I will do the cost * whatever the discount is.
    And as I said, you should really try to avoid it. It can be horrendeously complicated. Instead, identify the possible components in your formulas and make these column in a table or something like that. Then use a static expression from these columns.
    If you really need to do formulas, T-SQL is completely the wrong venue. You need to be able to parse the formulas and have a language defined for them. So it will have to be .NET - which you can do inside SQL Server if needed. But as I said, try to avoid
    it - it could take many hours to implement a solution.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Formula Builder

    hai
    what is formula builder and formula collusion wt is the difference between them
    plz give me the answer......
    with regards...
    Raghavendra

    Hi,
    Use
    You can use the Formula Builder to implement methods for Business Add-Ins without writing a single line of ABAP code. The methods are implemented by means of socalled formulas.
    This type of implementation does not require you to have programming knowledge. However, the functions it offers are more restricted than if you implement a method by writing ABAP code. If the range of functions provided by the Formula Builder is not sufficient, you can change the implementation type of the method at any time.
    Features
    A formula can consist of the following steps:
    Condition
    You define a Boolean formula expression whose result can be true or false. This formula expression is a logical condition based on the importing and changing parameters of the method. Depending on whether the condition is true or false, the system triggers different steps. If you do not specify a dependent step for one of these two possibilities, the system continues with the next superior step.
    Substitution
    The system replaces the value of a specific parameter with another value which you define as a constant value or by means of a mathematic formula. Substitution is only possible if the method contains changing, exporting or returning parameters.
    Message
    The system issues a message. All messages issued are collected in a log table. You define the message variables as constant values or by means of mathematic formulas. The system can only issue a message if you created a log table during method definition.
    Exception
    The system exits the method. No further steps are executed, and the application program continues in accordance with the exception defined. You can additionally display a message whose variables you define as constant values or by means of mathematic formulas. An exception can only be triggered if the method contains exceptions.
    A formula editor is available which you can use to enter formula expressions. After starting the formula editor, you can display information on how to use it by choosing the pushbutton next to the status display (traffic light).
    Activities
    You implement the method using the BAdI Builder. For information on this topic, see Implementing Business Add-Ins. To implement a method as a formula, choose the Formula implementation type on the Interface tab. Double-clicking the method name takes to to the Formula Builder: BadI Implementation screen.
    You can change the implementation type of the method on the Interface tab. You can implement a method both using a formula and using ABAP code. At the runtime of the application program, the system executes the implementation type currently chosen.
    You create the necessary steps in the left section of the screen. To do this, choose and then select the appropriate step type from the dropdown list. Using the other icons available or the context menu (which you can call by clicking the right mouse button), you then determine the arrangement and the descriptions of the steps. You can also copy steps to use them as templates for other steps, or you can delete individual steps.
    To specify the parameters for the individual steps, double-click the corresponding entry in the left section of the screen. You then enter the data required in the right section of the screen.
    The formula builder has two modes: Standard and expert mode. In the standard mode, you can only enter the formulas using the pushbuttons and by double clicking on functions and fields. In the expert mode, however, you can enter formulas directly. You can also toggle between the tow modes when entering a formula.
    The company code field (0COMP_CODE) is not included in your data target or InfoSource. However you can determine the company code from the first four character spaces of the cost center (0COSTCENTER).
    You create the following formula for this purpose:
    SUBSTRING( cost center, '0' , '4')
    Syntax:
    SUBSTRING( String, Offset , Länge )
    Step-by-Step Procedure in Standard mode:
    In the transformation library, on the right hand side under Show Me, choose the category Strings. From the list, select the Substring function by double-clicking on it. The syntax of the formula is displayed in the formula window: SUBSTRING( , , )
    The cursor automatically appears over the first parameter that needs to be specified.
    From the list on the left-hand side of the screen, choose the Cost Center field by double-clicking on it.
    Place the cursor where you want to enter the next parameter.
    Enter the number 0 using the Constant button (for the Offset parameter). The commas are added automatically.
    Place the cursor where you want to enter the next parameter.
    Enter the number 4 using the Constant button (for the Length parameter).
    Choose Back. The formula is now checked and saved if it is correct. You receive a message if errors occurred during the check, and the system highlights the erroneous element in color.
    ____For Formula Collision see this link
    http://help.sap.com/saphelp_bw32/helpdata/en/d2/02223c5f00612be10000000a11402f/frameset.htm
    *********Asgin points if usefull*********
    Cheers
    Satya

  • Create xml file with values from context

    Hi experts!
    I am trying to implement a WD application that will have some input fields, the value of those input fields will be used to create an xml file with a certain format and then sent to a certain application.
    Apart from this i want to read an xml file back from the application and then fill some other context nodes with values from the xml file.
    Is there any standard used code to do this??
    If not how can i do this???
    Thanx in advance!!!
    P.S. Points will be rewarded to all usefull answers.
    Edited by: Armin Reichert on Jun 30, 2008 6:12 PM
    Please stop this P.S. nonsense!

    Hi,
    you need to create three util class for that:-
    XMLHandler
    XMLParser
    XMLBuilder
    for example in my XML two tag item will be there e.g. Title and Organizer,and from ur WebDynpro view you need to pass value for the XML tag.
    And u need to call buildXML()function of builder class to generate XML, in that i have passed bean object to get the values of tags. you need to set the value in bean from the view ui context.
    Code for XMLBuilder:-
    Created on Apr 4, 2006
    Author-Anish
    This class is to created for having function for to build XML
    and to get EncodedXML
      and to get formated date
    package com.idb.events.util;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import com.idb.events.Event;
    public class XMLBuilder {
    This attribute represents the XML version
         private static final double VERSION_NUMBER = 1.0;
    This attribute represents the encoding
         private static final String ENCODING_TYPE = "UTF-16";
         /*Begin of Function to buildXML
    return: String
    input: Event
         public String buildXML(Event event) {
              StringBuffer xmlBuilder = new StringBuffer("<?xml version=\"");
              xmlBuilder.append(VERSION_NUMBER);
              xmlBuilder.append("\" encoding=\"");
              xmlBuilder.append(ENCODING_TYPE);
              xmlBuilder.append("\" ?>");
              xmlBuilder.append("<event>");
              xmlBuilder.append(getEncodedXML(event.getTitle(), "title"));
              xmlBuilder.append(getEncodedXML(event.getOrganizer(), "organizer"));
              xmlBuilder.append("</event>");
              return xmlBuilder.toString();
         /End of Function to buildXML/
         /*Begin of Function to get EncodedXML
    return: String
    input: String,String
         public String getEncodedXML(String xmlString, String tag) {
              StringBuffer begin = new StringBuffer("");
              if ((tag != null) || (!tag.equalsIgnoreCase("null"))) {
                   begin.append("<").append(tag).append(">");
                   begin.append("<![CDATA[");
                   begin.append(xmlString).append("]]>").append("</").append(
                        tag).append(
                        ">");
              return begin.toString();
         /End of Function to get EncodedXML/
         /*Begin of Function to get formated date
    return: String
    input: Date
         private final String formatDate(Date inputDateStr) {
              String date;
              try {
                   SimpleDateFormat simpleDateFormat =
                        new SimpleDateFormat("yyyy-MM-dd");
                   date = simpleDateFormat.format(inputDateStr);
              } catch (Exception e) {
                   return "";
              return date;
         /End of Function to get formated date/
    Code for XMLParser:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLParser {
    Enables namespace functionality in parser
         private final boolean isNameSpaceAware = true;
    Enables validation in parser
         private final boolean isValidating = true;
    The SAX parser used to parse the xml
         private SAXParser parser;
    The XML reader used by the SAX parser
         private XMLReader reader;
    This method creates the parser to parse the user details xml.
         private void createParser()
              throws SAXException, ParserConfigurationException {
              // Create a JAXP SAXParserFactory and configure it
              SAXParserFactory saxFactory = SAXParserFactory.newInstance();
              saxFactory.setNamespaceAware(isNameSpaceAware);
              saxFactory.setValidating(isValidating);
              // Create a JAXP SAXParser
              parser = saxFactory.newSAXParser();
              // Get the encapsulated SAX XMLReader
              reader = parser.getXMLReader();
              // Set the ErrorHandler
    This method is used to collect the user details.
         public Event getEvent(
              String newsXML,
              XMLHandler xmlHandler,
              IWDMessageManager mgr)
              throws SAXException, ParserConfigurationException, IOException {
              //create the parser, if not already done
              if (parser == null) {
                   this.createParser();
              //set the parser handler to extract the
              reader.setErrorHandler(xmlHandler);
              reader.setContentHandler(xmlHandler);
              InputSource source =
                   new InputSource(new ByteArrayInputStream(newsXML.getBytes()));
              reader.parse(source);
              //return the results of the parse           
              return xmlHandler.getEvent(mgr);
    Code for XMLHandler:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    Created on Apr 12, 2006
    Author-Anish
    *This handler class is created to have constant value for variables and function for get events,
        character values for bean variable,
        parsing thr date ......etc
    package com.idb.events.util;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Locale;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.helpers.DefaultHandler;
    import java.util.*;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLHandler extends DefaultHandler {
         private static final String TITLE = "title";
         private static final String ORGANIZER = "organizer";
         IWDMessageManager manager;
         private Event events;
         private String tagName;
         public void setManager(IWDMessageManager mgr) {
              manager = mgr;
    This function is created to get events
         public Event getEvent(IWDMessageManager mgr) {
              manager = mgr;
              return this.events;
    This function is created to get character for setting values through event's bean setter method
         public void characters(char[] charArray, int startVal, int length)
              throws SAXException {
              String tagValue = new String(charArray, startVal, length);
              if (TITLE.equals(this.tagName)) {
                   this.events.setTitle(tagValue);
              if (ORGANIZER.equals(this.tagName)) {
                   String orgName = tagValue;
                   try {
                        orgName = getOrgName(orgName);
                   } catch (Exception ex) {
                   this.events.setOrganizer(orgName);
    This function is created to parse boolean.
         private final boolean parseBoolean(String inputBooleanStr) {
              boolean b;
              if (inputBooleanStr.equals("true")) {
                   b = true;
              } else {
                   b = false;
              return b;
    This function is used to call the super constructor.
         public void endElement(String uri, String localName, String qName)
              throws SAXException {
              super.endElement(uri, localName, qName);
         /* (non-Javadoc)
    @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
    This function is used to call the super constructor.
         public void fatalError(SAXParseException e) throws SAXException {
              super.fatalError(e);
    This function is created to set the elements base on the tag name.
         public void startElement(
              String uri,
              String localName,
              String qName,
              Attributes attributes)
              throws SAXException {
              this.tagName = localName;
              if (ROOT.equals(tagName)) {
                   this.events = new Event();
         public static void main(String a[]) {
              String cntry = "Nigeria";
              XMLHandler xml = new XMLHandler();
              ArrayList engList = new ArrayList();
              engList = xml.getCountries();
              ArrayList arList = xml.getArabicCountries();
              int engIndex = engList.indexOf(cntry);
              System.out.println("engIndex  :: " + engIndex);
              String arCntryName = (String) arList.get(engIndex);
              System.out.println(
                   ">>>>>>>>>>>>>>>>>>>>" + xml.getArabicCountryName(cntry));
    Hope that may help you.
    If need any help , you are most welcome.
    Regards,
    Deepak

  • The document does not have a valid format.

    I created a special format document when I had Pages '08. I needed the proportions of the document to match the special paper on which the document would be printed so I created a special size for my document rather than 8 1/2 x 11. If I remember right it was closer to 8 1/2 x 13 or so. Anyway, I have now upgraded to Pages '09 and can no longer open any of these special format documents. I have versions of a couple of the documents that were created in Pages '08 without the special proportional size page and they open without issue. However the special size documents all get "The document does not have a valid format" and will not open. I really NEED these documents. I have seen some posts about renaming to a .zip and then something about an index file but I don't understand where this index file might be and what good it will do to open it. Also I know the files exist because they are still showing their original file sizes (not 0 MB). Any assistance would be appreciated.

    Don't continue to search fruhulda.
    I never saw such files.
    The only things which I may recognize are :
    the strings :
    mluc
    (10) nbNO --> Norvegian
    (16) svSE --> Sveridge
    (4) fiFI --> Finnish
    (1) daDK --> Danish
    (17) zhCN --> Chineese(1)
    (5) frFR --> French
    (8) jaJP --> Japanese
    (3) enUS --> English (US)
    (12) ptBR --> Portuguese (Brasil)
    (15) esES --> Spanish
    (18) zhTW --> Chineese(2)
    (14) ruRU --> Russian
    (9) koKR --> Korean
    (6) deDE --> Deutch (Germany)
    (2) nlNL --> Dutch (Nederland)
    (7) itIT --> Italian
    They are the symbols used to identify the languages used for 16 versions
    Two others are missing:
    (11) Polish (Polska) missing
    (13) Portuguese (Portugal) missing
    I found also
    iMac in plain ASCII and .i.M.A.C (dots are in fact NIL characters) which is the Utf 16 representation of iMac.
    During a few seconds I thought that it was a piece of System Files but the page thumbnail must be available somewhere so that the Finder is able to display it.
    I will send these genetically modified documents to Apple Bugs Hunters.
    Yvan KOENIG (VALLAURIS, France) lundi 31 janvier 2011 17:46:39
    At the very end there is also the trailing string which fool the message parser:
    the formula : *_Copyright Apple, Inc., 2010

Maybe you are looking for

  • Error when creating new oc4j-instance

    1. when i create a new oc4j-instance via EMWeb i get the following: The operation failed.. Instance: iasdb.test.xxx.ch Message: Keine Meldung für diese Exception definiert. Base Exception: java.lang.NoClassDefFoundError:nullKeine Meldung für diese Ex

  • Macbook Pro 17"  2.66(Early 2009 model) 8gb ram upgrade

    Hi, I want to upgrade my early 2009 unibody macbook peo 17" 2.66 to 8gb ram.The problem is in my country they sell hi-level and team brands (2x4gb).The specs of this brands are almost same with apple compatible rams except pin number.I searched on th

  • Normalized Message

    Why a new Normalized Message in JBI ? Why cannot SOAP be used ? what i can see is Normalized Message has is the payload message, metadata and attachments.All these three can be addressed by SOAP.(Message Body, header and attachment ) Regards, Siddhar

  • Processing OrdImage data into a BLOB column

    Hi, I am importing 30Mb Tiff images into an ordsys.ordimage column within an image table. All is fine with the import part. I now want to populate a blob column in the same table with a jpeg generated from the tiff. I have tried many variations of th

  • Essbase Application Access Rights

    Hi, I have a essbase application without planning, and try yo give read rights to a user via Shared Service , but without giving essbase admin rights, user can't see application, i give to user read on application and server access on essbase, unfort