Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sander_vanwilligen
Active Contributor


As you might know SAP BW does not allow every possible character in character strings. An upload or activation can terminate in such cases. It occurs frequently with character strings where users (or interfaces) can freely enter text.

SAP delivered various Function Modules for validation of character strings. Unfortunately cleansing of character strings is not provided by SAP. It would be very helpful to have a comprehensive ABAP Add-on for cleansing of character strings.

In blog Introducing an Add-on for Cleansing Character Strings I introduced such an Add-on which I developed. In this document I will provide you with detailed implementation instructions for creating the Character String Cleansing Add-on and using it in Transformation Rules.

Please have a look here to download the attachments.

Create Class


SAP Menu: Tools > ABAP Workbench > Development > Class Builder

T/code: SE24

 

Create Class ZCL_CLEANSE_CHARSTRING as shown in the following screenshot.

 



Figure 1: Class

 

Refer to one of the attached files depending on your SAP BW release:

  • File ZCL_CLEANSE_CHARSTRING_v1.txt contains the coding for release 7.31 and below;

  • File ZCL_CLEANSE_CHARSTRING_v2.txt contains the coding for release 7.40 and higher.


 

From here you can quite easily build up the class using copy & paste:

  • Source code can be found in Part 1 of the attached file;

  • Description of Title, Attributes, Methods and Parameters can be found in Part 2 of the attached file.


 

For the copy & paste action of the source code you should switch to the Source Code-based Class Builder using the corresponding push button. This is the easiest way to copy and paste all coding. The class will now contain all methods, parameters and attributes. Only the texts of the various metadata elements are missing. This will be a manual copy & paste action for every respective metadata element.

Using the Cleansing Add-on


The Cleansing Add-on is intended to be used in a Transformation Rule and can be considered as a recurring activity. Go to the respective Transformation Rule (e.g. Characteristic 0REF_DOC_NO).

 



Figure 2: Transformation rule

 

Choose Rule Type “Routine”, specify the source field and write coding in the Routine.

 

The easiest way is to remove all “default” coding, use the Pattern function, choose for ABAP Objects Pattern and specify Class ZCL_CLEANSE_CHARSTRING and Method EXECUTE. Then proceed as follows:

 

  • Fill importing parameter I_CHAVL_INPUT with the respective source field;

  • Fill importing parameter I_ALLOW_LOWERCASE (optional), ‘X’ means lowercase allowed;

  • Fill importing parameter I_REPLACE_CHAR with the replacement character (optional) , default is the SPACE symbol *);

  • Fill exporting parameter E_CHAVL_OUTPUT with the result field.


 

*) The replacement character may contain one of the following characters: _?#* or the SPACE symbol. Any other character will be replaced by the default SPACE symbol.

 

The coding of your routine should look similar as in the next screenshot.

 



Figure 3: Coding example

12 Comments
Labels in this area