Replace Command
Friends
My requirement is to "Replace all occurrences of a particular word in a string with an other word".
Is there no "Replace all Occurrences" command in ABAP ?
I checked in the help and could not find it.
Is there any direct way of doing it ?
I can split the string into an internal table and use the replace. However, I am just curious to know if there is any other short cut ?
Here is my sample program I tested.
data: lf_str type string.
lf_str = 'This is a This test This is a This'.
write: / lf_str.
*Replace All Occurrences Of 'This' in lf_str with 'That'.
Replace 'This' with 'That' into lf_str.
write: / lf_str.
Thanks
Yes it is available.
following are options available with <i><b>replace</b></i>
REPLACE [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF]
[SUBSTRING] sub_string
IN [ section_of] dobj WITH new
[IN {BYTE|CHARACTER} MODE]
[{RESPECTING|IGNORING} CASE]
[REPLACEMENT COUNT rcnt]
[REPLACEMENT OFFSET roff]
[REPLACEMENT LENGTH rlen].
Sample code taken from ABAP key word documentation.
DATA: text1 TYPE string,
text2(18) TYPE c,
cnt TYPE i,
off TYPE i,
len TYPE i.
text1 = text2 = 'I know you know'.
REPLACE ALL OCCURRENCES OF 'know' IN:
text1 WITH 'should know that'
REPLACEMENT COUNT cnt
REPLACEMENT OFFSET off
REPLACEMENT LENGTH len,
text2 WITH 'should know that'
REPLACEMENT COUNT cnt
REPLACEMENT OFFSET off
REPLACEMENT LENGTH len.
Regards
Raja
Similar Messages
-
REPLACE command using passed variable values does not work
Hi SDN Community
Are you aware of the replace command not working when passing strings as opposed to a variable containing the string.
For example:
This works:
replace '>JUL 2008</a>' with I_TEXT_VALUE into
I_TEXT_VALUE_REPLACE.
This dosen't work:
replace I_TEXT_VALUE_MATCH with I_TEXT_VALUE into
I_TEXT_VALUE_REPLACE.
where I_TEXT_VALUE_MATCH = '>JUL 2008</a>'
where I_TEXT_VALUE = '>JUL 2008<BR>Actual</a>'
Thank you.
SimonHi SDN Community,
The following method was used to derive the same outcome required as per the REPLACE command.
LEN_REPLACE = STRLEN( C_CELL_CONTENT ) - 12.
I_TEXT_VALUE_REPLACE = C_CELL_CONTENT.
replace I_TEXT_VALUE_MATCH with I_TEXT_VALUE into
I_TEXT_VALUE_REPLACE.
I_TEXT_VALUE_REPLACE = I_TEXT_VALUE_REPLACE+0(LEN_REPLACE).
CONCATENATE I_TEXT_VALUE_REPLACE I_TEXT_VALUE INTO
I_TEXT_VALUE_REPLACE.
C_CELL_CONTENT = I_TEXT_VALUE_REPLACE.
Thank you.
Simon -
Accidentally dropped data using datapump's replace command
All,
I exported 2 partitions of a table using the following data pump command:
expdp user1/password1 directory=DPUMP_DIR tables=tab1:P27,tab1:P28 logfile=tab1.log dumpfile=tab1_27_28.dmp
I moved the dump file to staging and tried importing using the following command:
impdp user1/password1 directory=DPUMP_DIR tables=tab1:P27,tab1:P28 logfile=tab1.log dumpfile=tab1_27_28.dmp table_exists_action=APPEND
when I ran the command above, I got the following error:
ORA-31696: unable to export/import TABLE_DATA:"VOP"."R_REQUEST":"P28"."P28_RN" using client specified AUT
I checked this on Oracle Support website and got the following advie:
=====================================================
+*<Moderator edit - deleted MOS Doc content - please do not post contents of MOS Docs - this is a violation of your Support agreement>*+
=================================================================================
I then proceeded to use table_exists_action=replace (thinking it was only going to replace the 2 partions specified).
Using table_exists_action=replace deleted rows from all other partions and loaded the 2 partitions which I exported.
I have tried retrieving lodt data using command below but it didn't work:
SQL> flashback table user1.tab1 to timestamp (systimestamp - interval '120' minute);
I've enable row movement and we've always had flashback enabled:
db_flashback_retention_target integer 1440
Does anyone know how else I could retrieved lost data without having to export and import the entire table (which is almost 1 Terabyte)If your database in archivelog mode? If yes you can try doing PITR
-
Replace command by CTL dynamically or load custom bitmap in command
I am searching for customizing my booleans during VI execution.
Is there a way to:
- replace a command by an existing CTL (like right-click on my boolean > replace > select a command) during VI execution ?
or
- load dynamically some PNG or JPEG into a command (like right-click on my boolean > advanced > copy/paste image in the 4 states of the boolean) during VI execution ?
Hope you will understand what I mean...
Thanks,
Aurelien
ARDPI
Certified LabVIEW Developper
Attachments:
forum1.jpg 107 KB
forum2.jpg 66 KB
forum3.jpg 52 KBHi Synopsis,
I'm not sure I really understand what you mean, but changing appearence of a command button during execution is not possible simply using the right click of the mouse.
BUT, there is something which will interests you, maybe you'll be able to do things close to what you want to do by using Xcontrols.
Take a look at this tuto :
http://zone.ni.com/devzone/cda/tut/p/id/3198
And don't hesitate to feedback your opinion and give more details of what you want to do.
Regards,
Mathieu_T
Application Engineer
NI France
Mathieu_T
Certified LabVIEW Developer
Certified TestStand Developer
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
LabVIEW Tour
Journées Techniques dans 10 villes en France, du 4 au 20 novembre 2014 -
Replace command is not working
Hi,
I am using below code, but it is not replacing correctly.
data DWORK_VAL(510) type C.
DWORK_VAL = 'DWORK_VAL ~~~efghijklmnopqrstuvxyz~~~'.
loop at text_content assigning <fs>.
search <fs> for DWORK_VAL.
if sy-subrc = 0.
replace DWORK_VAL in <fs> with 'ABCDE...ashdalkjhsd----
888*****'.
modify text_content from <fs> index sy-tabix.
endif.
Thanks,example:-
Data : var1(6) type c.
Data : var2(6) type c.
Data : var3(15) type c.
Data : len type i.
var1 = 'GO'.
var2 = 'GONE'.
var3 = 'ABCDGOEFGH'.
len = strlen( var1 ).
REPLACE var1 LENGTH len WITH var2 INTO var3.
condense var3 no-gaps.
write:var3.
no need modify -
Recently i got to work in 4.6C and came across an issue with the statement
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB IN WA2 WITH SPACE. . I came to know that the class CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB does not exist.
So how can i remove these tabs ?Hi,
Please check the following:
In SAP 4.6C, REPLACE ALL OCCURENCES OF...
As per my knowledge there is no statement called REPLACE ALL OCCURENCES OF in SAP 4.6C.
Only REPLACE statement is available.
Best Regards,
Suresh -
Trim title off of string using the replace command
Below is a simple task to read in data from a text file to use in account creation.
Get-Content employee.txt |
ForEach{
$ID = ($_ -split ';')[0]
$fname = ($_ -split ';')[1]
$lname = ($_ -split ';')[2]
A problem that has came up which I did not anticipate was titles. Titles such as MBA etc. throw off the creation of the account. I have a title like this myself an understand why someone is proud to append it to the last of their name because
they worked very hard to get it. In this case I need to trim it off to create the account. Below is an example of a data file
1234;test;user, MBA;
4567;test;user2 MBA;
8901;test;user3;
Thought this would be an easy fix and here is how I attempted to correct it below
$lname = $string
$string -replace ",*" -replace " "
$string
My thought was a comma or a space could be used to divide the last name the same as I divided the individual fields in the text file with a semicolon. Is there an easy method to do this? The replace seems easy enough but the problem is I'm not familiar with
the syntax in powershell.RegEx is an excellent tool but itt tkes a programmers mind to understand its subtleties. It is a good excercize in declaritive thinking and in recursive parsing systems. Once understood the lesson is transferrrable.
I do not recomment it to new scripters. After you gains some mastery of a scripting system then RegEx becomes nmuch easier to understand. I am not a RegEx wizard although I have used it since before it had a name. It was part of all editors
before we had PCs. VI and HPs EDIT, MsEDIT and others. EDLIN uses a primitive form of RegEx from the minicomputer era. Of course EDLIN is no more.
¯\_(ツ)_/¯
I wouldn't necessarily call myself a new scripter, been doing it a few months now and whilst there is definitely a lot more i could learn, i find that when i need to accomplish something i figure it out eventually, it's how i learn best! It does leave me short
of tips and tricks you'd find in the early chapters of a book though! -
Request to let me know replacement command for the Translate command.
Hi,
Code Inspector show that Translate command is obsolete. please let me know the alternate command to be used for the Translate.
Thanks & Regards,
Madhuri.Hi,
no alternative command for translate , use set language before using the translate command .
Regards
Appana
Check this :
TRANSLATE c TO UPPER/LOWER CASE: Additional Information
Variants:
TRANSLATE c TO UPPER CASE.
TRANSLATE c TO LOWER CASE.
The way in which the TRANSLATE statement works depends on the R/3 logon language. In general, users log on to the R/3 System in the same language as that in which the data they want to edit was created. Logging on in the wrong language causes loss of data, unless a conversion has been defined to deal with a different language environment.
For example, if German umlauts are processed in a Russian environment, the TRANSLATE statement returns a '|' for an 'ö' and a '¶' for a 'Ö'. Such discrepancies occur in particular:
If the wrong language environment has been set inSET LOCALE LANGUAGE
If the user edits data that was not written in the logon language (without using SET LOCALE LANGUAGE)
If, for example, the data to be converted is stored in a structure struwith the language key languand the text field text, then you can work round the problem in one of two ways:
Example
DATA: BEGIN OF stru,
langu TYPE sy-langu,
text TYPE sy-xcode,
END OF stru.
SET LOCALE LANGUAGE stru-langu.
TRANSLATE stru-text TO UPPER CASE.
SET LOCALE LANGUAGE SPACE.
This solution ensures that every conversion is made in the appropriate language. If struis an internal table, it should be sorted beforehand, to reduce the number of times the system switches between languages. Depending on the table's range, this can substantially reduce processing time, since SET LOCALE LANGUAGE has a long processing time. The runtime is similar to the runtime for SQL statements.
Example
IF stru-langu = sy-langu.
TRANSLATE stru-text TO UPPER CASE.
ELSE.
ENDIF.
The above solution ensures that only texts created in the logon language are edited. If you want, you can bundle all other text lines in another internal table using COLLECT and then convert them using the first solution above.
Note
It is important to reset the language explicitly using SPACE, since SET LOCALE LANGUAGE also changes the system field sy-langu. Note also that a language key may not be meaningful, or a language may not be installed correctly, or you may not be able to edit data from a specific application server. In these special circumstances, the following function modules can be used:
SCP_MIXED_LANGUAGES_1_INIT
SCP_MIXED_LANGUAGES_1_SWITCH
SCP_MIXED_LANGUAGES_1_NORMAL
SCP_MIXED_LANGUAGES_1_FINISH -
Given that the COPY command is now deprecated (and clearly documented in 10gR2 - sqlplus user's guide that it will be obsoleted in future releases of SQL*Plus, will there be any replacement command in sqlplus?
We were planning to use it to implement for our simulation model - but given it is deprecated and does not support new data types, we are forced to look for alternatives. What are the alternatives for a local area network or copying data between two oracle accounts using different tablespaces on the same db server?
Pro*C/Direct Path Load,
expdp/impdp,
copy over dblink and then recreate the constraints and indexes,
which one will be faster, should be used based on the following?
What we want to do is to checkpoint (save) historical game data, and if required/necessary, be able to bring back the data from a saved game checkpoint X, where X can be any number (checkpoint 4 or 20, etc). We also want to hold onto the saved game checkpoint files so that we can take it to another place for after action review purposes.
Any input is appreciated.
regards.copying data between two oracle accounts using different tablespaces on the same db server?For this I would grant SELECT on the table to be copied to the target Oracle account and use CREATE TABLE ... AS SELECT ... and recreate constraints and indexes.
-
Hello,
I am trying to replace some text through replace command but indesign gets crashed. here is the exact scenario:
I have created a text frame then copied some text of around 400 chracters from notepad, then i tried to replace that copied text through replace command, the command seems to be working fine as it returns no error but as soon as I try to update the iterator it gets crashed. here is the code I have written in my plugin:
TextIterator begin(textModel, startIndex);
TextIterator end(textModel, endIndex);
for (TextIterator iter = begin; iter < end; iter++)
K2::shared_ptr<WideString> pWSText(new WideString("SampleText"));
InterfacePtr<ITextModelCmds> pITextModelCmds(textModel, UseDefaultIID());
if (!pITextModelCmds()
ASSERT_FAIL("Could not get ITextModelCmds");
break ;
InterfacePtr<ICommand> replaceCmd(pITextModelCmds(->ReplaceCmd(0, textModel->GetPrimaryStoryThreadSpan(), pWSText));
if (!replaceCmd)
break;
ErrorCode errResult = CmdUtils::ProcessCommand(replaceCmd);
// here the command executed without any error but when the control goes back to update the iterator it gets crashed.
call stack is telling this location from where the crash originated
Public.dll!CCopyOneStyleCmd::CreateName() + 0x520aae bytes
Any suggestion will be greatly appreciated!
Regards,
MS ChoudryHi MS Choudry,
if you want to replace the whole text you should use textModel->GetTotalLength() instead of textModel->GetPrimaryStoryThreadSpan() in the ReplaceCmd function. And you are not allowed to replace the last character which marks the end of the text. So use textModel->GetTotalLength()-1.
Markus -
How to undo the "replace with after effects composition" command?
Hi,
I don't know if there is a better way, but i make my color corection in after effects with Color Finesse and i use this command: right click on clip and "replace with after effects composition" - that a good way but, the problem is when i wanna to undo this and to bring back my old clip from an AE Composition.
this is how my clip looks beforee
and after
it works fi i use "undo" command, but after i save the project, and restart premiere, that command is gone.
my question: what can I do to bring back my old video?
thanks.You can try to go to one of the autosave versions and see if you can bring it back that way (if the history is cleared)...
Seems a little extreme
If you still have the original source audio in your sequence, as your example shows, park the CTI at the beginning of clip instance and target just the audio track (i.e. deselect the video track). Hit the M key to match frame the original master clip, hit I to mark an in point, and then hold down the Alt key and drag the Video Only button from the Source Monitor to the AE comp item. The AE comp will be replaced with the original video and linked to the audio.
The upshot of all this is that, unless you make a duplicate before using the "Replace" command or undo immediately after doing so, there is no direct way to get back to the original footage. -
dear all,
i am a student of abaper plz solve the below problem.
accept a string like 'emax technologies ,change all the occurenses of e to g?
As a student, you should be doing lots of searching and lots of reading documentation. Not until that should you post a question here. Please read the Rules of this forum to avoid trouble.
Edited by: kishan P on Aug 30, 2010 2:27 PMHi Sandeep,
Use REPLACE command to achieve this.
Do a F1 on REPLACE command.
And Please do search on SCN before posting such basic questions.
Regards
Abhii -
Dumb Q: problem with Find And Replace window in Flash 8
Dear Flash Group,
apologies if this is trivial, it's my first day using Flash.
I downloaded a Flash project from
http://www.flashorb.com/articles/benchmark_files/flash-benchmark.zip.
This
flash calls into a web service at localhost:8080. I used the
'Find and
Replace' window within Flash Professional 8 to locate the
string
'localhost:8080' and replaced it with plain 'localhost'.
However, when I 'Debug the Movie' (Ctrl-Shift-Enter), it
still tries to
access port 8080! Obsiously, my replace command did not do
what I thought it
would do. I opened the FLA file in a binary editor, and saw 4
more
references to 8080, One if them in 'Properties' of a
WebServicesConnector,
but I cannot figure out how to find the other occurences.
Checking on google, I see lots of people having similar
problems, but no
solutions
Any ideas?
Regards, /george
PS. What do you guys do for code completion - is there a tool
that would
bring Flash on par with an professional IDE?george,
> when I 'Debug the Movie' (Ctrl-Shift-Enter), it still
> tries to access port 8080! Obsiously, my replace
> command did not do what I thought it would do.
Agreed.
> I opened the FLA file in a binary editor, and saw 4
> more references to 8080, One if them in 'Properties'
> of a WebServicesConnector, but I cannot figure out
> how to find the other occurences.
Might they be the result of that WebServicesConnector
reference?
> Checking on google, I see lots of people having
> similar problems, but no solutions
That's really odd, actually. I'm on these boards every day,
and I've
never heard of this issue. I don't *think* the Find/Replace
dialog visits
panel contents, such as the Component Inspector panel, but I
wouldn't swear
to that.
> What do you guys do for code completion - is there
> a tool that would bring Flash on par with an
professional IDE?
Well, Flash is a professional IDE, of course. By definition,
if you pay
for something, you have acquired a professional product or
service. I know
what you mean, though. Flash itself rocks, but the Actions
panel can be
glaringly weak. Personally, I use SE|PY to edit ActionScript.
http://www.sephiroth.it/python/sepy.php
Sorry I can't speak to your other issue. :-/
David
stiller (at) quip (dot) net
Dev essays:
http://www.quip.net/blog/
"Luck is the residue of good design." -
Find & Replace text in html files
This is my first real attempt at using Automator, and it has become increasingly frustrating for me. I love the idea of Automator, nice interface, and it appears to be so easy to use. But, I can't get it to actually DO anything and I don't understand why.
Here is my goal:
to batch process multiple html files to remove certain characters and words (or replace them with empty space).
I currently open these files in Pages and do 6 separate Find & Replace commands for each file before I continue with my other processing tasks. This is very tedious and I believe the computer should be able to find & replace multiple items at one time. (I have used other utilities to do batch renaming and trimming file names before.)
All I want to do is select a group of files (usually 25 at a time) and have Automator get rid of all the unwanted words and characters before I open each file for final processing in Pages. I found a set of Automator actions for TextEdit which includes a Find & Replace action, but I've wasted over an hour so far trying to get it to work.
When I run the workflow, it acts like it's doing something, but the files remain unchanged. I have tried using actions such as Read Text File, Get Contents of TextEdit Document, Set Contents of TextEdit Document, along with 6 instances of Find & Replace, but I cannot get it to work.
I'm at a point today where I cannot afford to mess around with this anymore. I have to do it the long way in Pages or else I'll never get it done, but I want to get these Automator workflows to work before I have to repeat this task. (I do this at least once a week right now.)
Any ideas or suggestions? I've tried reading in the help menus and support pages, but perhaps I'm just not understanding something here.Any ideas or suggestions?
You might be interested in using TextWrangler. It can perform batch find-and-replace changes across multiple selected files.
Good luck!
Andrew99 -
ABAP command IMPORT/EXPORT
Hi!
I would like to know whats the replacement for the IMPORT and export commands used in 4.7c in ECC6. Can anyone tell me whats the replacement commands for import and export command that is used in abap/4 4.7c for ECC6.
ThanksHi Aarav,
there is nothing like replacement for import/export.there is another statements to transferdata which are Set/Get.
when you are working with sap you have sessions.so in between session if you want to transfer data then you will use set/get parameters.import/export are used within the session.means you opened se38 and written a program and then go back to se38 initial screen and entered another program name and in that program you want the data which is in the previous program you have written in the se38 in same session.
reward points if helpful.
Maybe you are looking for
-
How do I get my Safari browser to display on a tv screen?
I purchased a VGA converter cable earlier today, and now have it hooked up to the TV. It is showing my desktop background, but will not show any of my icons or the video I would like to watch on the TV. Also, the audio is coming out incredibly quiet
-
Issue with dynamically setting where clause in OAF
Hi All, I have a View object having the query below: SELECT rownum LINENUM, B.line_id LINE_ID, B.INVENTORY_ITEM_ID INVITMID , B.QUANTITY_DELIVERED PICKQTY from MTL_TXN_REQUEST_HEADERS A, MTL_TXN_REQUEST_LIN
-
Using Interactive forms in Webdynpro Abap
Hi all, I need to learn using Interactive forms in Webdynpro Abap. Can any please tell me from where to start with and what are the things that needs to be installed extra in the client system. Also please tell me where i can get the tutorials on it.
-
Solid State Drive (SSD) Questions for G4 "Sawtooth".
Below are some questions concerning using a Solid State Drive (SSD) in a G4 "Sawtooth". Would a controller card need to be installed for an SSD to work in this machine? Would the G4 be able to operate in Classic mode with the SSD? Would the G4 be abl
-
Hi all, I have a Main chain which has may local chains in it. I have marked all local chains as "start using metachain or API". When I schedule the main chain very often I get a message saying you following variant is not schedule and RSPROCESS event