How do i do a Advance replace string logic?

Hi all,
I have an issue on writing a logic to replace a string in a sentence
Suppose i fill in 3 input
1st input - *"The Name contains 'Test1' and 'Test2' and this is it"*
2nd input - *"The Name contains \"{mercName1}\" and \"{mercName2}\" and this is it"*
3rd input - *"(\"{mercName1}\")) and (\"{mercName2}\"))"*
The logic will compare 1st input and 2nd input, then replace mercName1/mercName2, and the output should be like this
output - *("'Test1'")) and ("'Test2'"))*
Currently i have make it works and here's the logic
public class ReplaceString {
     private String getRuleMap(String strRuleC_DRL, String strRuleM_Desc, String strRuleM_Map) {
          String[] strRuleC_DRL_split = strRuleC_DRL.split(" ");
          String[] strRuleM_Desc_split = strRuleM_Desc.split(" ");
          Map compareMap = new HashMap();
          if(strRuleC_DRL_split.length == strRuleM_Desc_split.length) {
               for(int x=0; x<strRuleC_DRL_split.length; x++) {
                    int compare = strRuleC_DRL_split[x].compareTo(strRuleM_Desc_split[x]);
                    if(compare != 0) {
                         compareMap.put(strRuleM_Desc_split[x].replaceAll("\"", ""), strRuleC_DRL_split[x].replaceAll("\"", ""));
          if(!compareMap.isEmpty()) {
               Iterator keyIter = compareMap.keySet().iterator();
               while(keyIter.hasNext()) {
                    String theKey = keyIter.next().toString();
                    String theValue = compareMap.get(theKey).toString();
                    if(strRuleM_Map.indexOf(theKey) > 0) {
                         strRuleM_Map = this.replace(strRuleM_Map, theKey, theValue);
          return strRuleM_Map;
     private String replace(String source, String pattern, String replace) {
          if (source!=null) {
               final int len = pattern.length();
               StringBuffer sb = new StringBuffer();
               int found = -1;
               int start = 0;
               while( (found = source.indexOf(pattern, start) ) != -1) {
                    sb.append(source.substring(start, found));
                    sb.append(replace);
                    start = found + len;
               sb.append(source.substring(start));
               return sb.toString();
          else return "";
      * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          ReplaceString rs = new ReplaceString();
          System.out.println(rs.getRuleMap("The Name contains 'Test1' and 'Test2' and this is it", "The Name contains \"{mercName1}\" and \"{mercName2}\" and this is it", "(\"{mercName1}\")) and (\"{mercName2}\"))"));
}Now, here's the problem, when i key in
input - *"The Name contains 'Test1 and Test2' and 'Test3 and Test 4' and this is it"*
i expect the output should be
output - *("'Test1 and Test2'")) and ("'Test3 and Test4'"))*
but i hit problem cause the string compare is only 1 to 1
Is there any advice? Thanks

You could try to use regular expressions?

Similar Messages

  • How can I get Advance Replacement Service added to our current contract?

    We have a contract with description "SBS 8x5xNBD 3yr Small Business Support Svc(SBS)" which still has two years due.  How can I tell if it already includes Advance Replacement for our country (Mexico) ?  If not, is it possible to add this service?

    I'm not sure but if you give the Small Business Support Center a call with your contract number or product serial number handy, they will be able to answer you.
    Per their contact page, their telephone number for their customers in Mexico is 001-866-915-4503.

  • Flash Charts - How to manipulate the #data# replacement string in XML

    I have a problem with the XML file for a flash chart. I am trying to display a 2dColumn chart of an SQL query with the general form:
    select null link, x as name, sum(y) as value from z group by (x);
    this generates multiple rows, which are displayed as a bar in the chart. So far so good. The problem is, that each row is defined as a block in the chart, but only one name entry is created "value", which is displayed in the legend of the chart.
    I can display the block names on the x-axis of the chart, however, I can't rotate them, so that they don't overlap in the display, which I would be able to do with names. I assume, that the blocks are defined in the #data# replacement string of the XML file. I would like to change the generated XML replacement string from the SQL to make each row selected a different name, and only have one block ("value").
    What would be the easiest way to achieve this?

    user587996,
    There's no way to manipulate the #data# replacement directly, but you could generate your own XML (see Re: Apex changing nulls to zeroes when creating Flash Charts for one way to do it).
    When you say "I can't rotate them, so that they don't overlap in the display" -- have you tried the Labels Rotation chart attribute, or is that not working?
    - Marco

  • Sync Outlook: Advanced: Replace information on this iPhone (how to set as default)

    Every time I sync Outlook with iTunes (iPhone 4s) I have to select -> Advanced -> Replace information on this iPhone, and then check Contacts and Calendar. I want this to be the DEFAULT action when I connect my iPhone. As it stands I have to turn on the "Prevent iPods, iPhones, and iPads from syncing automatically" in Preferences so that I have a chance to turn on the Replace option in Info -> Advanced.

    Hi there Greg,
    Welcome to Apple Support Communities.
    It sounds like you want to always replace content on your iPhone 5S with content from Outlook on your PC, to do this you’ll just have to Reset the Sync History in iTunes as shown below.
    Troubleshooting Sync Services on Windows with Microsoft Outlook 2003, Outlook 2007, or Outlook 2010 - Apple Support
    To reset sync history:
    Open iTunes.
    From the Edit menu, choose Preferences.
    Click the Devices tab.
    Click the Reset Sync History button.
    If the issue continues and you know all of the data is on the computer:
    Reset the Sync History again using the steps above.
    Select the device in iTunes and click the Info tab.
    Scroll down to the Advanced section, and under "Replace information on this iPhone/iPad/iPod touch" select Contacts or Calendars.
    Click Apply.
    Cheers,
    -Jason

  • Help with REGEXP_REPLACE upper replacement string

    Hi All,
    I am attempting to uppercase the replacement string from my reg expression without success:
    SELECT regexp_replace('src=/i/uie_v2/js','(/uie_v2/)',upper('\1')) from dual
    returns 'src=/i/uie_v2/js'
    I understand that upper cannot be used .. just showing as an example. Any ideas on how to achieve this ?
    Thanks in advance :)
    Greg

    >
    I need a way of using a search pattern that goes from the first double quote to the last slashThis can be achieved as below
    SQL> select str,regexp_substr(str,'"/([^"]*?/){1,}',1) res
      2  from testdata;
    STR                                                     RES
    <link rel="stylesheet" type="text/css" href="/i/uie_V2/ "/i/uie_V2/ext-3.0.0/resources/css/
    ext-3.0.0/resources/css/ext-all-uie.css">
    <script src="/i/uiE_v2/js/bob/bobsFile.js"></script>
    <script src="/i/UIE_v2/js/fred/fredsFile.js"></script>
    <script src="/i/uiE_v2/js/john/johnsFile.js"></script>
    <link rel="stylesheet" type="text/css" href="/i/uie_V2/ "/i/uie_V2/ext-3.0.0/resources/css/
    ext-3.0.0/resources/css/ext-all-uie.css">
    <script src="/i/uiE_v2/js/bob/bobsFile.js"></script>
    <script src="/i/UIE_v2/js/fred/fredsFile.js"></script>
    <script src="/i/uiE_v2/js/john/johnsFile.js"></script>For achieving yor replace, can we use PL/SQL as below?
    I think the same thing can be achieved using CONNECT BY..SYS_CONNECT_BY_PATH or Recursion. But PL/SQL seems to be better.
    And we can wait for a MODEL solution..
    SQL> create or replace function f1(p_str varchar2) return varchar2 is
      2    lc_str varchar2(4000) := p_str;
      3    ln_count number := 1;
      4  begin
      5    while regexp_substr(lc_str,'"/([^"]*?/){1,}',ln_count) is not null loop
      6      lc_str := regexp_replace(lc_str,'"/([^"]*?/){1,}',
      7          lower(regexp_substr(lc_str,'"/([^"]*?/){1,}',1,ln_count)),1,ln_count);
      8      ln_count := ln_count + 1;
      9    end loop;
    10    return lc_str;
    11  end f1;
    12  /
    Function created.
    SQL> select str,f1(str) res
      2  from testdata;
    STR                                                     RES
    <link rel="stylesheet" type="text/css" href="/i/uie_V2/ <link rel="stylesheet" type="text/css" href="/i/uie_v2/
    ext-3.0.0/resources/css/ext-all-uie.css">               ext-3.0.0/resources/css/ext-all-uie.css">
    <script src="/i/uiE_v2/js/bob/bobsFile.js"></script>    <script src="/i/uie_v2/js/bob/bobsFile.js"></script>
    <script src="/i/UIE_v2/js/fred/fredsFile.js"></script>  <script src="/i/uie_v2/js/fred/fredsFile.js"></script>
    <script src="/i/uiE_v2/js/john/johnsFile.js"></script>  <script src="/i/uie_v2/js/john/johnsFile.js"></script>
    <link rel="stylesheet" type="text/css" href="/i/uie_V2/ <link rel="stylesheet" type="text/css" href="/i/uie_v2/
    ext-3.0.0/resources/css/ext-all-uie.css">               ext-3.0.0/resources/css/ext-all-uie.css">
    <script src="/i/uiE_v2/js/bob/bobsFile.js"></script>    <script src="/i/uie_v2/js/bob/bobsFile.js"></script>
    <script src="/i/UIE_v2/js/fred/fredsFile.js"></script>  <script src="/i/uie_v2/js/fred/fredsFile.js"></script>
    <script src="/i/uiE_v2/js/john/johnsFile.js"></script>  <script src="/i/uie_v2/js/john/johnsFile.js"></script>Edited by: jeneesh on Oct 5, 2012 9:37 AM
    Not rigorously tested

  • Search and replace strings in a file while ignoring substrings

    Hi:
    I have a java program that searches and replaces strings in a file. It makes a new copy of the file, searches for a string in the copy, replaces the string and renames the new copy to the original file, thereafter deleting the copy.
    Now searching for "abcd", for eg works fine, but searching for "Topabcd" and replacing it doesnot work because there is a match for "abcd" in a different search scenario. How can I modify the code such that if "abcd" is already searched and replaced then it should not be searched for again or rather search for "abcd" as entire string and not if its a substring of another string.
    In the below code output, all instances of "abcd" and the ones of "Topabcd" are replaced by ABCDEFG and TopABCDEF respectively, whereas according to the desired output, "abcd" should be replaced by ABCDEFG and "Topabcd" should be replaced by REPLACEMEFIRST.
    try
              String find_productstring = "abcd";
              String replacement_productstring = "ABCDEFG";
              compsXml = new FileReader(compsLoc);
              compsConfigFile = new BufferedReader(compsXml);
              File compsFile =new File("file.xml");
              File compsNewFile =new File("file1.xml");
              BufferedWriter out =new BufferedWriter(new FileWriter("file1.xml"));
              while ((compsLine = compsConfigFile.readLine()) != null)
                    new_compsLine =compsLine.replaceFirst(find_productstring, replacement_productstring);
                    out.write(new_compsLine);
                    out.write("\n");
                out.close();
                compsConfigFile.close();
                compsFile.delete();
                compsNewFile.renameTo(compsFile);
            catch (IOException e)
            //since "Topabcd" contains "abcd", which is the search above and hence the string "Topabcd" is not replaced correctly
             try
                   String find_producttopstring = "Topabcd";
                   String replacement_producttopstring = "REPLACEMEFIRST";
                   compsXml = new FileReader(compsLoc);
                   compsConfigFile = new BufferedReader(compsXml);
                   File compsFile =new File("file.xml");
                   File compsNewFile =new File("file1.xml");
                   BufferedWriter out =new BufferedWriter(new FileWriter("file1.xml"));
                   while ((compsLine = compsConfigFile.readLine()) != null)
                         new_compsLine =compsLine.replaceFirst(find_producttopstring, replacement_producttopstring);
                         out.write(new_compsLine);
                         out.write("\n");
                     out.close();
                     compsConfigFile.close();
                     compsFile.delete();
                     compsNewFile.renameTo(compsFile);
                 catch (IOException e)
            }Thanks a lot!

    Hi:
    I have a java program that searches and replaces
    strings in a file. It makes a new copy of the file,
    searches for a string in the copy, replaces the
    string and renames the new copy to the original file,
    thereafter deleting the copy.
    Now searching for "abcd", for eg works fine, but
    searching for "Topabcd" and replacing it doesnot work
    because there is a match for "abcd" in a different
    search scenario. How can I modify the code such that
    if "abcd" is already searched and replaced then it
    should not be searched for again or rather search for
    "abcd" as entire string and not if its a substring of
    another string.
    In the below code output, all instances of "abcd" and
    the ones of "Topabcd" are replaced by ABCDEFG and
    TopABCDEF respectively, whereas according to the
    desired output, "abcd" should be replaced by ABCDEFG
    and "Topabcd" should be replaced by REPLACEMEFIRST.
    try
    String find_productstring = "abcd";
    String replacement_productstring = "ABCDEFG";
    compsXml = new FileReader(compsLoc);
    compsConfigFile = new
    BufferedReader(compsXml);
    File compsFile =new File("file.xml");
    File compsNewFile =new File("file1.xml");
    BufferedWriter out =new BufferedWriter(new
    FileWriter("file1.xml"));
    while ((compsLine =
    compsConfigFile.readLine()) != null)
    new_compsLine
    =compsLine.replaceFirst(find_productstring,
    replacement_productstring);
    out.write(new_compsLine);
    out.write("\n");
    out.close();
    compsConfigFile.close();
    compsFile.delete();
    compsNewFile.renameTo(compsFile);
    catch (IOException e)
    //since "Topabcd" contains "abcd", which is
    the search above and hence the string "Topabcd" is
    not replaced correctly
    try
                   String find_producttopstring = "Topabcd";
    String replacement_producttopstring =
    topstring = "REPLACEMEFIRST";
                   compsXml = new FileReader(compsLoc);
    compsConfigFile = new
    gFile = new BufferedReader(compsXml);
                   File compsFile =new File("file.xml");
                   File compsNewFile =new File("file1.xml");
    BufferedWriter out =new BufferedWriter(new
    dWriter(new FileWriter("file1.xml"));
    while ((compsLine =
    compsLine = compsConfigFile.readLine()) != null)
    new_compsLine
    new_compsLine
    =compsLine.replaceFirst(find_producttopstring,
    replacement_producttopstring);
    out.write(new_compsLine);
    out.write("\n");
    out.close();
    compsConfigFile.close();
    compsFile.delete();
    compsNewFile.renameTo(compsFile);
                 catch (IOException e)
    Thanks a lot!I tried the matches(...) method but it doesnt seem to work.
    while ((compsLine = compsConfigFile.readLine()) != null)
    if(compsLine.matches(find_productstring))
         System.out.println("Exact match is found for abcd");
         new_compsLine =compsLine.replaceFirst(find_productstring, replacement_productstring);
    out.write(new_compsLine);
    out.write("\n");
         else
         System.out.println("Exact match is not found for abcd");
         out.write(compsLine);
         out.write("\n");

  • Search and replace string function

    Hello, I am using the "search and replace string" function and it does nt seem to work consistently for me.   I am using it in a situation where I am taking an array of strings, converting this into a spreadsheet string then deleting all of the commas.  Has anyone experienced the same behavior? I have searched through other posts and found other simular faults but none of the fixes worked for this. I can post the code it needed.
    Thanks,
    Andrew

    I agree that commas are often not desirable, especially if your software should also work in countries where comma is used as a decimal seperator.
    Where are the commas coming from? Does (1) each element of the original array have one (or more), do you (2) use comma as seperator if you convert it to a spreadhseet string?
    For (1), you might just strip out the comma for each element right in the loop. For case (2) you would simply use a different separator to begin with, of course.
    Btw: you are abusing a WHILE loop as a FOR loop, because you have a fixed number of iterations. Please replace it with a FOR loop. If you use a FOR loop, LabVIEW can manage memory much more efficiently, because it can allocate the entire output array before the loop starts. For While loops, the total number of iterations is not known to the compiler. (Of course a real program would also stop the loop if an error occurs. In this case you would need to stay woth the WHILE loop. )
    Do you have a simple example how the raw array elements look like. How many commas are there?
    LabVIEW Champion . Do more with less code and in less time .

  • How much does Apple charge to replace a hard drive?

    I have a Macbook I bought in the Summer of 2008 (not sure the model, etc.) I know it was the smallest memory (a.k.a. cheapest model) if that helps at all.  I got a screen with a flashing folder/question mark this morning and everything I've read points to a hard drive failure.  I did all the troubleshooting that Apple has on the website and nothing worked.  I'm going to take it to the Apple store within the next week, but I was wondering how much Apple would charge to replace the drive.  For the record... I'm NOT tech savvy at all, and I am not going to replace it myself... I know it's cheaper, etc. but it's not worth it to me.
    Thanks in advance for any help you can give me!

    The brand of hard drive isn't that important to me. They're pretty much all the same. As to size, whatever you think you might need. Look at the ones at Newegg.com. A large hard drive doesn't cost that much more than a small one.
    Since your old hard drive died you'll need to start fresh after you've installed the new drive.
    Drive Preparation
    1.  Start up from the installer disk (hold down the C key or hold down the Option key after you hear the chime) When you get to the Install screen select Disk Utility under Utilities on the top menu.
    2. After Disk Utility loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list.Click on the Erase tab and set the format type to Mac OS Extended (Journaled.) and click Erase
    3. After it has erased click on the Partition tab in the Disk Utility main window.
    4. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID then click on the OK button. Click on the Partition button and wait until the process has completed.
    5. Quit Disk Utility and install the Mac OS

  • How to put jsp content in to string butter?

    Hello Friends,
    I'm new to J2EE. please tell me how can I put jsp content into string buffer. following is a part of code I wrote. I'm also reading data from database on some part of code.
    <html>
         <head>
              <title>JSP for AdminForm form</title>
         </head>
         <body style="font-family:verdana;font-size:10pt;"><=<br>
         <%@ include file="header.html" %>
              <html:form action="/admin">
                   <table border="1" width="700" height="500">
                   <tr>
                   <td border="1" width="100" height="5"> Check <br></td>
                   <td border="1" width="100" height="5"> SNo. <br></td>
    </tr>
    <tr>
                   <td border="1" width="150" height="5"> userId <br></td>
                   <td border="1" width="150" height="5"> Role <br></td>
                   <td border="1" width="150" height="5"> Dept. <br></td>
                   <td border="1" width="150" height="5"> Edit <br></td>
                   </tr>
    </table>
    </body>
    </html>
    please help me out.
    Thanks.

    You have to generate a replacement for the default ServletOuputStream so that every time the data is sent to the browser (via the output stream) it is also sent to a tool that can generate a String or StringBuffer (a StringWriter does this nicely). One way to do this is to generate a ServletOutputStream implementation that wraps a ServletOutputStream and StringWriter. You would implement each method in ServletOutputStream and pass the parameters to both wrapped streams, i.e.:
    public class ServletOutputStreamAndStringWriter extends ServletOutputStream {
      private ServletOutputStream sos;
      private StringWriter sw;
      pubic ServletOutputStreamAndStringWriter (ServletOutputStream sos, StringWriter sw) {
        this.sos = sos;
        this.sw = sw;
      public void print(String s) {
        sos.print(s);
        sw.write(s);
      public void println(String s) {
        sos.println(s);
        sw.swrite(s+System.getProperty("line.separator"));
      //etc... for all methods including flushes and closes...
    }Next you have to insert the ServletOutputStream implementation above into the application in a manner that doesn't require a re-write of the rest of your code. The best way to do this is to generate a ServletResponseWrapper implementation that returns your new implementation of the ServletOutputStream in the getOutputStream() method:
    public class SplitOutputServletResponse extends ServletResponseWrapper {
      private ServletOutputStreamAndStringWriter sosasw;
      public SplitOutputServletResponse(ServletResponse sr, ServletOutputStreamAndStringWriter sosasw) {
        super(sr);
        this.sosasw = sosasw;
      public ServletOutputStream getOutputStream() { return sosasw; }
    }Now all you have to do is replace the response you use in your application with this wrapper. The best way to do it is through a Filter:
    public class SplitOutputFilter implements javax.servlet.Filter {
      private FilterConfig fc;
      public void init(FilterConfig fc) { this.fc = fc; }
      public void destroy() { }
      /* This is where the filtering work gets done.  You get a request and a response, you pass the request,
          replace the response, and let the rest of the filter chain do its work (the JSP page gets generated and the
          response to the client is generated).  Then after the rest of the filter chain you get the text out of the
          StringWriter you generated for the ServletOutputStream
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
        // After the JSP does its work, the StringBuffer will be generated from this StringWriter
        StringWriter stringBufferFromHere = new StringWriter();
        // This is the tool used to deliver the JSP output to the above StringWriter
        ServletOutputStreamAndStringWriter output = new ServletOutputStreamAndStringWriter (response.getOutputStream(), stringBufferFromHere);
        // And this is the tool used to deliver the above output stream to the JSP pages
        SplitOutputServletResponse sosr = new SplitOutputServletResponse(response, output);
        // Now we replace the incoming ServletResponse with the wrapper generate above for the rest of the FilterChain
        // which includes the actual execution of the JSP
        chain.doFilter(request, sosr);
        // By the time we get to this point, the JSP has already generated the page.  We need to extract the text as
        // a StringBuffer, which we should have access to via the StringWriter
        StringBuffer jspOutput = stringBufferFromHere.getBuffer();
        // Then do whatever you need to do with the buffer...  Note that the FilterContext provides a reference to the
        // ServletContext which could help you store the buffer, put it in DB, or whatever you wanted to do with it...
    }Filters start at the beginning of a request cycle, can be mapped to particular URLs or groups of URLs. To see how to use them see: http://java.sun.com/products/servlet/Filters.html which also has some similar examples.

  • Accessing a JSTL variable in a JSP Scriptlet (need to replace string )

    I have
    <c:set var="myVar" value="..." />
    I need to replace single quotes and double quotes to be escaped because I pass them into javascript functions and set them as ID for div sections
    ... onclick ="func('${myVar}')" ..
    <div id="${myVar}">
    but if the string contains ' single quotes it messes up the javascript or double quotes messes up the ID portion of the HTML tag
    I know there is the JSTL function fn but I can't figure out how to do it properly in JSTL
    <c:set var="myVar"
    value="${fn:replace(myVar, "'", "\"")"/>
    But that gets tricky since the value portion is enclosed in quotes
    So I was thinking of using a Scriptlet part instead.

A: Accessing a JSTL variable in a JSP Scriptlet (need to replace string )

escaping quotes within quotes within quotes.... ARGH!
Recipe for a headache if ever there was one.
However you must be strong and resist the temptations of the dark side (Scriptlet code)
My suggestion for cleaning this up - write your own static function for escaping javascript strings.
public static String escapeJavascriptString(String s){
  return .......
}Then define the function in a tld:
<function>
    <description>
      Escapes a string for javascript purposes
    </description>
    <name>escapeJavascript</name>
    <function-class>com.mypackage.ELFunctions</function-class>
    <function-signature>java.lang.String escapeJavascript(java.lang.String)</function-signature>
    <example>
      <c:out value="${myfunc:escapeJavascript(name)}">
    </example>
  </function>Cheers,
evnafets

escaping quotes within quotes within quotes.... ARGH!
Recipe for a headache if ever there was one.
However you must be strong and resist the temptations of the dark side (Scriptlet code)
My suggestion for cleaning this up - write your own static function for escaping javascript strings.
public static String escapeJavascriptString(String s){
  return .......
}Then define the function in a tld:
<function>
    <description>
      Escapes a string for javascript purposes
    </description>
    <name>escapeJavascript</name>
    <function-class>com.mypackage.ELFunctions</function-class>
    <function-signature>java.lang.String escapeJavascript(java.lang.String)</function-signature>
    <example>
      <c:out value="${myfunc:escapeJavascript(name)}">
    </example>
  </function>Cheers,
evnafets

  • How are *Credit Card*--Cash Advances handled?

    How are *Credit Card*--Cash Advances handled? Can employees add that to their Expense report?
    Example: If the employee takes a $100 cash advance and reconciles the transaction in SAP Expense, we are expected to pay
    Credit Card Provider $100.
    However, how does the employee account for underutilizing that $100 (e.g. $20 remaining in their pocket).
    Does the individual create and link the $80 of expenses to that $100 cash advance and receive a $20 debit to their employee vendor?
    Also, we know that currently there is no MCC Code Mapping in the system for Cash Advance.
    Is there a work around this.

    Hi Rahul,
    I had a customer which had this situation. We solved this issue with a BAdI implementation in ERP.
    The traveler adds this withdrawal as a normal expense item which is assigned to special account alias code. The BAdI implementation recongnizes this alias code and removes the expenses and charges this costs to the employee.
    Example:
    Withdrawal        100 USD
    Taxi                     80 USD
    Bus                        5 USD
    Unused                15 USD
    Standard posting to FI:
    Taxi Costs                           80,00
    Bus Costs                            5,00
    Withdrawal                          100,00
    Employee Vendor                                85,00
    Credit Card Account                          100,00
    The correct  posting would be:
    Taxi Costs                           80,00
    Bus Costs                           5,00
    Employee                           15,00
    Credit Card Account                         100,00
    To achieve this posting it is required to
    map the withdrawal expense type to a special account alias code (in the coding
    example below: ADV)  and  to implement the following coding in BAdI
    BADI_DCFL_FIN_IDOC_DATA_TV:
      DATA: lr_item               TYPE REF TO dcfls_preproc_it.
      DATA: lr_vendor_item         TYPE REF TO dcfls_preproc_it.
    FIELD-SYMBOLS: <tv_item_adv>  TYPE dcfls_runtime_tv_item.
    FIELD-SYMBOLS: <tv_item_emp>  TYPE dcfls_runtime_tv_item.
    FIELD-SYMBOLS: <tv_header>    TYPE dcfls_runtime_tv_root.
      DATA: lt_string              TYPE TABLE OF string.
      DATA: ls_string              TYPE string.
      LOOP AT cs_preproc-item REFERENCE INTO lr_item.
        ASSIGN lr_item->bo_specific_item->* TO <tv_item_adv>.
        IF  <tv_item_adv>-tv_category = '03'  "Expense Item
        AND lr_item->ksymb = 'ADV'.
          CLEAR lr_vendor_item.
          LOOP AT cs_preproc-item REFERENCE INTO lr_vendor_item WHERE rtkey_it <> lr_item->rtkey_it.
            ASSIGN lr_vendor_item->bo_specific_item->* TO <tv_item_emp>.
            IF  <tv_item_emp>-tv_category = '01'  "Due Item
            AND <tv_item_emp>-pernr_d IS NOT INITIAL.
              EXIT.
            ELSE.
              UNASSIGN <tv_item_emp>.
            ENDIF.
          ENDLOOP.
          IF <tv_item_emp> IS ASSIGNED.
            <tv_item_emp>-wrbtr = <tv_item_emp>-wrbtr - <tv_item_adv>-wrbtr.
            DELETE cs_preproc-item WHERE rtkey_it = lr_item->rtkey_it.
          ELSE.
            "Create Vendor Item with negative amount
            <tv_item_adv>-tv_category = '01'.
            ASSIGN cs_preproc-bo_specific_root->* TO <tv_header>.
            SPLIT <tv_header>-note AT '/' INTO TABLE lt_string.
            READ TABLE lt_string INTO ls_string INDEX 4.
            IF sy-subrc = 0.
              <tv_item_adv>-pernr_d = ls_string.
            ENDIF.
            CLEAR: lr_item->ksymb,
                   <tv_item_adv>-note,
                   <tv_item_adv>-zuonr.
            <tv_item_adv>-wrbtr = <tv_item_adv>-wrbtr * -1.
          ENDIF.
        ENDIF.
      ENDLOOP.
      IF  <tv_item_emp> IS ASSIGNED
      and <tv_item_emp>-wrbtr IS INITIAL.
        DELETE cs_preproc-item WHERE rtkey_it = lr_vendor_item->rtkey_it.
      ENDIF.

  • Replace String

    how can we replace a char of subsrting with in a string
    e.g we have " Today is [Date] ......."
    i want to replace [Date] with todays date

    Here is a method to do it. Using indexOf and substring is actually faster than going through each character using startsWith as seen in some other implementations.
          * Replace occurances of a String with another.
          * This will replace all instances of 'Old' in 'S' with 'New'. The source
          * String is not modified.
          @param S Source String
          @param Old String to replace
          @param New String to put in the place of 'Old'
          @return String with replacements made.
         public static String replace(String S, String Old, String New)
              if( (S == null) || (Old == null) )
                   return S;
              StringBuffer B = new StringBuffer();
              int i = 0;
              int length = S.length();
              int size = Old.length();
              if(size == 0)
                   return S;
              while(i < length)
                   int q = S.indexOf(Old,i);
                   if( q < 0 ) //- There are no more occurences of the substring
                        B.append(S.substring(i));
                        i = length;
                   else //- q is the next occurence of Old
                        B.append(S.substring(i,q)); //- the part before Old
                        B.append(New);
                        i = q + size;
              return B.toString();
         }

  • Replacing Strings (again)

    Hallo,
    I have a string with lots of numbers in scientific notation, e.g. 1,23456E+10 (German OS). I want to save it to a spreadsheat file, but before that I want to replace all "," with "." and all "E" with "e". (Otherwise GNUplot cannot read them).
    With my idea and the ideas of the LabVIEW-Forum, only the first ones were replaced.
    Example: 1,0E-6 1,0E-6 becomes 1.0e-6 1,0E-6 and NOT 1.0e-6 1.0e-6
    How can I manage that? The common "Search and Replace String" works but stops after the first match.
    Arno
    PS: Please send VI's that can be loaded with LabVIEW 6.1^.
    Arno
    Please help me, thank you !!
    Arno
    PS: I am using LabVIEW 6.1."

    The E-->e is easy, just use "to lower case". :-)
    To replace all using search and replace, just wire a TRUE to the "replace all?" terminal.
    The attached example in LV6.1 shows both methods.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Format4GNUPlot.vi ‏21 KB

  • IPhone 4 advance Replacement service help

    I have set up an advance replacement service for my iPhone 4, my question is how am I supposed to return my original iPhone 4?
    Will the courier give me the new phone and take the old one or will the courier deliver my iPhone 4 And I'll have to post the original one back

    is there anyone in the uk who can help me, coz i remember the advisor saying that the courier would pick it up, but im not sure, so can anyone confirm this for me. i dont want the courier man taking my iphone 4 you see.
    and can someone tell me what courier apple uses

  • How much would it be to replace an iPhone 5s home button?

    My phone received some water damage and it looks like the home button needs to be replaced. Anybody know how much it would cost to replace?

    If your iPod Touch, iPhone, or iPad is Broken
    Apple does not fix iDevices. Instead, they exchange yours for a refurbished or new replacement depending upon the age of your device and refurbished inventories. On rare occasions when there are no longer refurbished units for your older model, they may replace it with the next newer model.
    ATTN: Beginning July 2013 Apple Stores are now equipped to do screen repairs/replacements in-house on iPhone 5s. In some cases while you wait. According to Apple this is the beginning of equipping Apple Stores with the resources needed to do most repairs for iPhones, iPads, and iPod Touches that would not require major replacements. Later in the year the services may be extended as Apple Stores become equipped and staffed with the proper repair expertise. So, if you need a screen repaired or a broken screen replaced or have your stuck Home button fixed, call your local Apple Store to see if they are now doing these in-house.
    You may take your device to an Apple retailer for help or you may call Customer Service and arrange to send your device to Apple:
    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support: Contacting Apple for support and service - this includes international calling numbers.
    You will find respective repair costs in the appropriate link:
    iPod Service Support and Costs
    iPhone Service Support and Costs
    iPad Service Support and Costs
    There are third-party firms that do repairs on iDevices, and there are places where you can order parts to DIY if you feel up to the task:
    1. iResq or Google for others.
    2. Buy and replace screen yourself: iFixit

  • Maybe you are looking for