0% found this document useful (0 votes)
51 views

Warehousing/bw/blog?start 15: String Functions in SAP BW

This document discusses string functions in SAP BW that can be used when extracting data from ECC/third party tools to avoid special character errors. It describes six string functions: shift, replace, translate, concatenate, condense, and split. Shift moves characters within a string. Replace substitutes one set of characters for another. Translate changes case. Concatenate combines strings. Condense removes leading spaces. Split divides a string into multiple strings using a delimiter. Examples are provided to demonstrate the usage of each function.

Uploaded by

Gautam Malhotra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Warehousing/bw/blog?start 15: String Functions in SAP BW

This document discusses string functions in SAP BW that can be used when extracting data from ECC/third party tools to avoid special character errors. It describes six string functions: shift, replace, translate, concatenate, condense, and split. Shift moves characters within a string. Replace substitutes one set of characters for another. Translate changes case. Concatenate combines strings. Condense removes leading spaces. Split divides a string into multiple strings using a delimiter. Examples are provided to demonstrate the usage of each function.

Uploaded by

Gautam Malhotra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

http://scn.sap.

com/community/data-
warehousing/bw/blog?start=15
String Functions in SAP BW
Posted by Phani KV Feb 1, 2015

String Functions in SAP BW

while we are extracting data form ECC/Third party tolls to BW we got the some time special
char errors . if we use the sting functions we aviod the special char issue errors.

1.Shift

2.Replace
3.Transalate

4.Concatenate

5.Condense

6.Split.

1 SHIFT – shift will move the char string by default left by 1 position.

Ex-

DATA : V1 TYPE STRING,


V2 TYPE STRING,
V3 TYPE STRING.
V1 = 'ABAP'.
V2 = 'OBJECTS'.
V3 = 'HARD WORK'.
SHIFT V1 BY 2 PLACES.
SHIFT V2 RIGHT BY 2 PLACES.
SHIFT V3 CIRCULAR BY 4 PLACES.

WRITE:/ V1,V2,V3.

Program output

2. REPLACE - Replace will replace the set of chars with another set of chars in a char string.
Ex-

data : text1 type string,


text2 type string,
text3(16) type c.
text1 = 'ABCDEFGHABCDEFGH'.
text3 = 'ABCDEFGHABCDEFGH'.
text2 = 'ABCDEFGHABCDEFGHABCDEFGH'.

WRITE /: TEXT1, TEXT3.


REPLACE 'D' IN TEXT1 WITH 'XYZ' .
REPLACE 'D' IN TEXT3 WITH 'XYZ' .
WRITE:/ TEXT1, TEXT3.
SKIP.
WRITE :/ 'BEFORE:', TEXT2.
REPLACE ALL OCCURRENCES OF 'DE' IN TEXT2 WITH 'XY'
WRITE :/ ' AFTER :', TEXT2.
SKIP.

Program output

Note -

Write statement – print the record.

SKIP – it will skip the one line.

3. TRANSLATE – translate to upper case to lowercase and lower case to upper case.

DATA : TEXT4 TYPE STRING,


TEXT5 TYPE STRING,
TEXT6 TYPE STRING.
TEXT4 = 'abcdefgh'.
text5 = 'ABCDEFGH'.
TEXT6 = 'AbcDEfGh'.

WRITE:/ 'BEFORE:', TEXT4.


TRANSLATE TEXT4 TO UPPER CASE.
WRITE:/ 'AFTER:', TEXT4.
SKIP.
WRITE:/ 'BEFORE:', TEXT5.
TRANSLATE TEXT5 TO LOWER CASE.
WRITE:/ 'AFTER:', TEXT5.
SKIP.
WRITE:/ 'BEFORE:', TEXT6.
TRANSLATE TEXT6 TO UPPER CASE.
WRITE:/ 'AFTER:', TEXT6.

Program output

4. CONCATENATE – it will merge more than char string into one char string.

DATA : CTEXT1 TYPE STRING,


CTEXT2 TYPE STRING,
CTEXT3 TYPE STRING.

CTEXT1 = 'RAMA'.
CTEXT2 = 'KRISHNA'.

CONCATENATE CTEXT1 CTEXT2 INTO CTEXT3.


WRITE:/ CTEXT3.
Program output

5. CONDENSE – it will remove the leading spaces.

DATA : CTEXT8 TYPE STRING,


CTEXT9 TYPE STRING.
CTEXT8 = ' ABAP OBJECTS'.
CTEXT9 = ' ABAP OBJECTS'.
SKIP.
WRITE:/ CTEXT8.
CONDENSE CTEXT8.
WRITE:/ CTEXT8.
SKIP.
WRITE:/ CTEXT9.
CONDENSE CTEXT9 NO-GAPS.
WRITE:/ CTEXT9.
Program output

6. SPLIT – it will split one char string to many char string but should be the separated by unique
special char.DATA : LV_TEXT6 TYPE STRING,
LV_PROF TYPE STRING,
LV_CAREA TYPE STRING,
LV_CCENTER TYPE STRING.
LV_TEXT6 = 'ABCD&VA00&XYZZ'.
SPLIT LV_TEXT6 AT '&' INTO LV_PROF LV_CAREA LV_CCENTER.
WRITE:/ LV_TEXT6,
LV_PROF,
LV_CAREA,
LV_CCENTER.
Program output

Note -

Write statement – print the record.

SKIP – it will skip the one line.

Hope it wil help.

You might also like