ABAP code help to replace one field with another

Hi All,
I have one DSO which is holding data for fields WBS(Old) and Company Code(Old).
and I have one table which holds the information for Ols WBS and Ols Comp Code along with their New WBS and New Comp code.
for eg:
In DSO :
Old WBS , Old Comp.Code
abc        ,  001
xyz        , 002
In Table:
Old WBS , Old Comp.Code , New WBS , New Comp.Code
abc,           001,                    ABC,            001-04
xyz,           002,                    XYZ,            002-04
Now my requirement is ,
search record by record from DSO and look into the table .
If abc record in DSO matches with abc record in table, then in DSO it should replace with new WBS and Com.Codes.
after the code, data in DSO shuld be lik this.
WBS , Comp.Code
ABC ,  001-04
XYZ,   002-04.
Thanks in advance,
Sai Chand.S

Hi
If these fields are key fields dont think its possible to overwrite. Else plz write the following Code in End Routine it will overwrite the existing values in DSO.
Select * from DSO into it_dso_temp. "U can even select only key fields WBS and CC fields.
If sy_subrc=0.
Sort it_dso_temp by WBS CC.
endif.
Select old WBS
           old CC
           new WBS
           new CC
from Table
into it_table
for all entries in it_dso_temp
where old WBS = WBS and old CC = CC.
if sy_subrc=0.
sort it_table by old WBS, old CC.
endif.
Loop at it_dso_temp assigning result_fields.
Read it_table into wa_table with key old WBS = fs_dso_temp-WBS
                                                           old CC = fs_dso_temp-CC Binary SEarch.
If sy_subrc = 0.
result_fields-WBS = wa_table-new WBS.
result_fields-CC = wa_table-new CC.
endif.
Endloop.
Refresh result_package.
result_package[] = it_dso_temp[].
Also if incoming data has only old values u can loop at result package instead of it_dso_temp. let me know in case of issues.
hope this helps !
Reg
Aparna

Similar Messages

  • How to replace one variable with another in large number of queries

    Hello guys!
    I have this situation: our company needs to use one variable instead of another for certain amount of queries.
    Is there some way to automatically replace one variable with another for a certain characteristic in big number of queries ( like 150 - 200 ) ? Doing this manually would take lots of time)
    Apreciate your help!

    you could try (at your own risk) the following:
    1. search the technical id (ELTUID) of your variable in table RSZELTDIR
    2. see where this variable is used in table RSZELTXREF (by filling RSZELTDIR-ELTUIID in RSZELTXREF-TELTUID)
    3. add similar entries for your new variable
    4. delete the entries for the old variable (they're part of the key, so you can't simply "change" them)

  • Stepping through a query result set, replacing one string with another.

    I want to write a function that replaces the occurance of a string with another different string.  I need it to be a CF fuction that is callable from another CF function.  I want to "hand" this function an SQL statement (a string) like this:   (Please note, don't bother commenting that "there are eaiser ways to write this SQL..., I've made this simple example to get to the point where I need help.  I have to use a "sub_optimal" SQL syntax just to demonstrate the situation)
    Here is the string I want to pass to the function:
    SELECT
      [VERYLONGTABLENAME].FIRST_NAME,
      [VERYLONGTABLENAME].LAST_NAME,
      [VERYLONGTABLENAME].ADDRESSS
    FROM
      LONGTABLENAME [VERYLONGTABLENAME]
    Here is the contents of the ABRV table:
    TBL_NM,  ABRV    <!--- Header row--->
    VERYLONGTABLENAME, VLTN
    SOMEWHATLONGTALBENAME, SLTN
    MYTABLENAME, MTN
    ATABLENAME, ATN
    The function will return the original string, but with the abreviations in place of the long table names, example:
    SELECT
      VLTN.FIRST_NAME,
      VLTN.LAST_NAME,
      VLTN.ADDRESSS
    FROM
      LONGTABLENAME VLTN
    Notice that only the table names surrounded by brackets and that match a value in the ABRV table have been replaced.  The LONGTABLENAME immediately following the FROM is left as is.
    Now, here is my dum amatuer attempt at writing said function:  Please look at the comment lines for where I need help.
          <cffunction name="AbrvTblNms" output="false" access="remote" returntype="string" >
            <cfargument name="txt" type="string" required="true" />
            <cfset var qAbrvs="">  <!--- variable to hold the query results --->
            <cfset var output_str="#txt#">  <!--- I'm creating a local variable so I can manipulate the data handed in by the TXT parameter.  Is this necessary or can I just use the txt parameter? --->
            <cfquery name="qAbrvs" datasource="cfBAA_odbc" result="rsltAbrvs">
                SELECT TBL_NM, ABRV FROM BAA_TBL_ABRV ORDER BY 1
            </cfquery>
         <!--- I'm assuming that at this point the query has run and there are records in the result set --->
        <cfloop index="idx_str" list="#qAbrvs#">      <!--- Is this correct?  I think not. --->
        <cfset output_str = Replace(output_str, "#idx_str#", )  <!--- Is this correct?  I think not. --->
        </cfloop>               <!--- What am I looping on?  What is the index? How do I do the string replacement? --->
            <!--- The chunck below is a parital listing from my Delphi Object Pascal function that does the same thing
                   I need to know how to write this part in CF9
          while not Eof do
            begin
              s := StringReplace(s, '[' +FieldByName('TBL_NM').AsString + ']', FieldByName('ABRV').AsString, [rfReplaceAll]);
              Next;
            end;
            --->
        <cfreturn output_txt>
        </cffunction>
    I'm mainly struggling with syntax here.  I know what I want to happen, I know how to make it happen in another programming language, just not CF9.  Thanks for any help you can provide.

    RedOctober57 wrote:...
    Thanks for any help you can provide.
    One:
    <cfset var output_str="#txt#">  <!--- I'm creating a local
    variable so I can manipulate the data handed in by the TXT parameter.
    Is this necessary or can I just use the txt parameter? --->
    No you do not need to create a local variable that is a copy of the arguments variable as the arguments scope is already local to the function, but you do not properly reference the arguments scope, so you leave yourself open to using a 'txt' variable in another scope.  Thus the better practice would be to reference "arguments.txt" where you need to.
    Two:
    I know what I want to happen, I know how to make it happen in another programming language, just not CF9.
    Then a better start would be to descirbe what you want to happen and give a simple example in the other programming language.  Most of us are muti-lingual and can parse out clear and clean code in just about any syntax.
    Three:
    <cfloop index="idx_str" list="#qAbrvs#">      <!--- Is this correct?  I think not. --->
    I think you want to be looping over your "qAbrvs" record set returned by your earlier query, maybe.
    <cfloop query="qAbrvs">
    Four:
    <cfset output_str = Replace(output_str, "#idx_str#", )  <!--- Is this correct?  I think not. --->
    Continuing on that assumption I would guess you want to replace each instance of the long string with the short string form that record set.
    <cfset output_str = Replace(output_str,qAbrs.TBLNM,qAbrs.ABRV,"ALL")>
    Five:
    </cfloop>               <!--- What am I looping on?  What is the index? How do I do the string replacement? --->
    If this is true, then you are looping over the record set of tablenames and abreviations that you want to replace in the string.

  • Universally replace one character with another and then change font

    Hello,
    I have a geologic map file where there are hundreds of labels like Cc, Cz, Cwu, etc... all in the Arial font. I need to change all of the capital C's with a character from the StratagemAge font. That is to say, I need to find all instances of one character in my file and then replace them with another character and then change the font of that selected character.
    I've been trying to figure out how to write an action to do this, but I was wondering if there is a way to do this easily already.
    Any suggestions?
    Jeremy

    > how do you turn off the dialog for the Find/Replace in action palette?
    At the left of each Action step is a square field. Mouse over it and the tooltip will read "Toggle Dialog On/Off".
    > I got an action that I wrote to work, but it takes a button click for each instance in my file that I want to change. Would yours have that same drawback as that?
    Yes, you would have to click each time to run the Action (or, you could assign a function key), but there would be no dialog to dismiss.
    But you can pile several iterations of the same steps in the Action; so that one execution of the Action does ten replacements with one click, for example.
    This would not be a particularly difficult thing to Javascript, but you are correct that scripting has a learning curve. This task is not something I would think often needed. Doing a few hundred replacements in a file, using an Action would not seem overly burdensome to me. But if it is a recurring need for you, it might be worth writing a script.
    JET

  • Replace one view with another with animation

    Hello:
    I'm clearly not following some basic principle here so I'd appreciate some guidance.
    My intentions is to create a (quiz type) app with several screens (I'm assuming each of them will be a view that I will create in the Interface builder). The goal is to let user advance from screen 1 to screen 2 then to screen 3, etc. by answering multiple choice questions (presented as buttons). So when one button is clicked the current screen would slide to the left and the next screen would slide in. This animation is very much similar to the default Navigation-type app behavior, but in my case I do not need the navigation bar on top (since user should not be able to go back). By studying the latter example, I was able to find the following code that slides view controlers one over another:
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    SecondPage *secondViewController = [[SecondPage alloc] initWithNibName:@"SecondPage" bundle:nil];
    [self.navigationController pushViewController:secondViewController animated:YES];
    [secondViewController release];
    but in my project, that doesn't seem to work, as, I'm assuming, I do not have the navigationController member.
    What am I doing wrong here?

    Hi Den -
    Den B. wrote:
    The issue I have now is how to change the initial UITableView to my own view (that I can design in the interface builder)?
    Looks like you've made a lot of progress since your original question, so I'll skip the response I might have written earlier, unless you think it would be helpful to go back there. To your current question, I guess I should first ask "What initial UITableView?". My best guess is that you've found the Navigation-based Xcode template, which includes an instance of UITableViewController as the root view controller. Based on that guess, I take it you now want to replace the table view controller with a vanilla UIViewController so the root view needn't be a table view. Are these assumptions correct?
    If so, here's how to make the replacement:
    1) In RootViewController.h, change the super class from UITableViewController to UIViewController;
    2) In RootViewController.m, remove all the lines from (and including) "#pragma mark Table view methods" upto -(void)dealloc;
    3) Open RootViewController.xib, and select Window->Document from the top menu to make sure the "RootViewController.xib" window is open. This is the window that displays icons, not the editor window which displays the view. Delete the Table View icon (select it, then Edit->Delete). Then drag a UIView object into that window from the Library, then Ctrl-drag from File's Owner to the View icon to connect the 'view' outlet of File's Owner to the View object;
    4) Double-click on the newly added View icon to open the IB editor window and populate that window with the subviews you want, returning to RootViewController.h and .m to add IBOutlet properties and IBAction methods as needed. Once RootViewController.h is saved you can make the required connections to File's Owner in IB.
    Here's an example of how to hide the nav bar and transition to the next view from an action method:
    // RootViewController.m
    #import "RootViewController.h"
    #import "SecondViewController.h"
    @implementation RootViewController
    - (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = YES;
    - (IBAction)nextView {
    SecondViewController *vc2 = [[SecondViewController alloc]
    initWithNibName:@"SecondViewController" bundle:nil];
    [self.navigationController pushViewController:vc2 animated:YES];
    [vc2 release];
    PS. It "suks" to go from being a pro on one platform to a complete noob on another
    Many of us at this forum jumped from platforms such as Windows to iOS without any prior Cocoa experience, so you're among friends who understand the transition. In my case, after the first few weeks, I never wanted to see another dev environment again. So hang in there! It will be fun soon.
    - Ray

  • Formula to filtering one field with another

    Post Author: MWinn
    CA Forum: Formula
    I need to pull information from fields based on the contents of another field. For example, I want to use the SBCODE.SCDDS2 field in one location in the report, but it will only return the correct information if SBCODE.SCDTYP field = "PR". In another location on the report I want to use the SBCODE.SCDTNM field, but it will only return the correct information if the SBCODE.SCDTYP field = "TE". Is there a formula I can use to accomplish this?
    Thanks,
    Michael D. Winn

    Post Author: MWinn
    CA Forum: Formula
    Thank You for your input, I just returned from vacation and saw your solution, unfortunately I had already tried that formula and although it does return the correct Problem Codes it also returnes 'WD" (work done) codes with the same numbers. So I end up with a report that has 2 or 3 of the same ticket numbers but different Problem Descriptions (because the formula returns WD codes as well). For some reason this formula does not limit itself to just the "PR" code.

  • How do you replace one image with another

    I have a page that displays the results of a search for information about a club. One of the items is the club's logo. It is displayed using the following code
    <img src="<?php echo $row_clubedit['club_logo_url']; ?>" alt="The Club's Logo"  class="logo" title="The Club's Logo">
    This works fine, except when no club has been selected, in which case it shows the default question mark in a blue box.
    It would be nice if I could display the Federation Logo, to which all the clubs belong, until a club is picked.
    Is there a simple way to set a default image that would be replaced from a data set.
    $row_clubedit['club_logo_url'] holds the url to the log in the format http://www.club.org/clublogo.png
    <img src="<?php echo ( 'federation_logo_url'); ?>" alt="The Club's Logo"  class="logo" title="The Club'c Logo">
    The logic I suppose would be
    if club_logo_url does not exist,
              then print the  federation logo,
         else print the club logo.
    How do you code that in php?
    I'm only a beginner at PHP.

    <img src="<?php echo $row_clubedit['club_logo_url'] == "" ? "http://www.club.org/clublogo.png" : $row_clubedit['club_logo_url']; ?>" alt="The Club's Logo"  class="logo" title="The Club's Logo">
    should do it

  • How to replace one symbol with another?

    I have a symbol with some very basic animations. I would like to set conditions upon which one symbol is swapped out for a symbol in a library. Each symbol is the same size, but so far I can't seem to get this right. I've attempted createChildSymbol but nothing really works.  I've got it set up as:
    My Stage:
    container0container (rectangle)
    container1container (rectangle)
    container2container (rectangle)
    button1
    button2
    My library symbols:
    Symbol_1
    Symbol_2
    Symbol_3
    Symbol_4
    Symbol_5
    I want to be able to click button 1, and replace the container1>container with container1>Symbol2 and then play the animation associated with container1
    Can anyone advise me on this?

    Not sure if it is what you want but try this:
    sym.$('down_btn').click(function(){
    var firstS = sym.createChildSymbol("Symbol_1", "container1");
    sym.play('down1');
    sym.$('up_btn').click(function(){
    var firstS = sym.createChildSymbol("Symbol_2", "container1");
    sym.play('up1');

  • How do I replace one table with another

    In my swing application I go out over the network and retrieve information, and then present that info in a table. Problem is this button can be pressed more than once, so in this case the old table needs to be replaced. Looking through the API their does not seem ot be a remove to compliment add. Right now when I hit the button multiple times another table just gets added to the right of the previous table.
    So how do I get rid of the first table?
    m

    Im not that advanced yet -- although I have looked over the literature and understand what you mean. Seems to me tables are more complicated than other swing elements. In any case, the container class DOES have a remove method, which is being used succesfully. Thanx for replying.
    m

  • Replacing one namespace with another using XML Anonymizer Module

    I've following XML message
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Result xmlns:ns0="urn:source_namespace">
       <ns0:Function/>
       <ns0:r/>
    </ns0:Result>
    but I need to have a little bit different namespace (which do not exist in above message)
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Result xmlns:ns0="urn:target_namespace">
       <ns0:Function/>
       <ns0:r/>
    </ns0:Result>
    Any idea how to archieve this using  XML Anonymizer Module?

    Hi,
    You don't need a UDF to do this. Follow this...
    1. Edit the Message Type Result XML Namespace as urn:target_namespace from urn:source_namespace.
    2. Save this and activate it.
    3. In the Message Mapping go to edit and reload this new Message Type, save the changes and activate it.
    This blog How to remove namespaces in Mapping - XI By Sameer Shadab shows you hove to remove the namespace in you case you use the same to change the namespace
    Thanks
    SaNv...

  • Putting 7 table fields into one field with line breakes included!

    Hi People
    I Need to assamble 7 fields from a view, into one field with some line brakes in Reports, how do I do that???
    E.g :
    Field names : Name, Collection1, StreetName, StreetNo, ExtraCity, ZipCode, City
    Should be put into one field called address and be displayed like this
    Name
    Collection1
    StreetName StreetNo
    ExtraCity
    ZipCode City
    I hope someone can help me *S
    /Stig :-)

    The following should give you some idea. It might depend if you run your report on Windows or Unix.
    select
    Name        || decode(Name, null, null, chr(13)||chr(10))||
    Collection1 || decode(Collection1, null, null, chr(13)||chr(10))||
    StreetName  || decode(StreetName, null, null, ' '||StreetNo||chr(13)||chr(10))||
    ExtraCity   || decode(ExtraCity, null, null, chr(13)||chr(10))||
    ZipCode     || decode(ZipCode, null, null, ' '||City )
    from MyView

  • How to replace one char with two chars in email address policy?

    I very much like to replace the 'ß' char in the surname with 'sz'. However, applying filter '%rßsz%[email protected]' on 'Preußig' leaves me with '[email protected]'.
    So, how do I replace one char with two chars in email address policy?

    As far as I know, your only solution is to manually create such addresses instead of using e-mail address policy.
    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."

  • Qosmio X500-10W - Can I replace the HDD with another one?

    Hello
    I have a Qosmio X500-10W with two HDD Toshiba MK5055GSX 500GB 5400RPM 8MB ??SATA II but is one of hs so I wonder if I can be replaced by a more powerful style HDD 750GB 7200tr / min 16MB Toshiba course?
    merci

    Hey,
    Your question is a little bit hard to understand but I think you want to replace the HDD with another (faster) model, right?
    Well, thats no problem. HDDs with 7200rpm will work, they are a little bit louder but they are faster so if you need more performance no problem.
    Also 750GB or more is no problem because SATA interface is not capacity limited. Theoretically 1TB or more should also work.
    Anyway, you can buy the 750GB you mentioned it will work. :)

  • Replacement Path Variable with Another Variable

    Hi,
    I am currently trying to create a report that would need me to have the same values for different characteristics (e.g. clearing date, posting date, net due date). I have seen that there is a way in the replacement path variable that would replace its value with another variable that is ready for input. I also looked into SAP help but I can't seem to figure out on how to do it specifically. Does anyone know a step-by-step process on how to do this? How does this work?
    Thank you in advance!

    take an e.g.
    u have characteristic say ch1
    u want to restrict it with replacement path variable
    first of all create a variable var1
    click what it is based upon for e.g. 0calday, 0material etc.
    make it user entry variable
    select single or multiple entry
    make it mandatory
    save it and hit okey
    click on ch1
    right click and say restrict
    in new window create a new variable
    give its name and technical name
    processing path is replacement path
    go to next tab of replacement path
    select several ooptions
    replace variable with another variable
    select a variable called var1
    change the offset length and offset start with different parameters.
    hit okey
    this way u have restricted ch1 with replacement path variable var1
    now when u run report u have to enter value of var1
    which will then further feeded to ch1
    this way u can create replacement path variables at lots of instances and then u can always feed the value from var1 at different time
    make sure as this ur requirement is date
    try to use 0calday as reference infoobject all the times....

  • Since i got the new Iphone 4s it constantly drops calls. Apple have replaced the phone with another new iphone 4s but i am still having the same problem. I have checked with vodapohe that there is no issue from there end, given a new sim, still drops out

    Since i got the new Iphone 4s it constantly drops calls. Apple have replaced the phone with another new iphone 4s but i am still having the same problem. I have checked with vodapohe that there is no issue from there end, given a new sim, still drops out

    Have a look at this it might help
    http://support.apple.com/kb/TS4148

Maybe you are looking for

  • How to active a PDF Based Form in ERP System

    Hi , One of user facing problem "When I try to active a PDF Based Form in ERD, I got the following error: u201CINVALID http CONNECTION : ADSu201D Please can anyone help me in this ,what should i do and how to proceed it slove this issue. Thanks and R

  • Publishing cancels with "access denied" error when publishing updates to desktop layout

    Hello, all, Wondering if anyone else has run into this issue: we update and republish our help projects frequently. We're currently using a layout based on the desktop layout (colors, fonts, and some other screen elements have changed). The project g

  • Keeping track of apps

    Is there an easy way to find all apps on iPad , Seems like they are not all listed in general set up ? Also not all listed when search using keyword apps? Don't wamt to have to uise Mac lalptop.

  • Add release strategy in the PO document type

    Dear all, I create one PO Return but there is no release strategy in ME28, what should I do to add the release strategy for that PO doc type. Thanks Pauline

  • [Request] Anjal

    Anjal is an email client designed for netbooks, although it looks like it could be nice even if you don't use a netbook. It's the only email client I have seen that implements gmail-style (conversation) threading, which is slightly different than the