Replace in ABAP Strings - Position-based replacement
Details
- Details
- Category: ABAP
- Created on Tuesday, 29 January 2013 09:32
- Last Updated on Tuesday, 29 January 2013 10:26
- Published on Tuesday, 29 January 2013 09:32
- Written by Administrator
- Hits: 56390
REPLACE SECTION OF
Syntax
REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new
[IN {BYTE|CHARACTER} MODE].
Effect
When replacing position-based, the section in dobj is replaced starting at the offset specified in off for the length specified in <>ABlen with the content of data object new. For off and len, data objects of data type i are expected. You must specify at least one of the additions OFFSET or LENGTH. If you specify an offset but no length, the content of data object dobj is replaced starting at the offset off to the end. If you specify a length but no offset, the offest 0 is implicitly used. The values of off and len must be greater than or equal to 0 and the section specified by off and len must lie within the length of dobj.
Addition
... IN {BYTE|CHARACTER} MODE
Effect
The optional IN {BYTE|CHARACTER} MODE addition determines whether byte-type or character- type processing is carried out. If the addition is not specified, character string processing is carried out. Depending on the processing type, dobj and new have to be byte-type or character- type.
Example
Use the FIND statement to determine offset and length of the first word "know" in the data objects text1 and text2 and to replace this section position-based in text1 and text2 by "should know that". After the first REPLACE statement, text1 contains the complete content "I should know that you know" and sy-subrc contains 0. After the second REPLACE statement, text2 contains the truncated content "I should know that" and sy-subrc contains 2.
Article from : http://help.sap.com
- << Prev
- Next