cancel
Showing results for 
Search instead for 
Did you mean: 

how to remove leading 'S' in target field

Former Member
0 Kudos

hi

i have to remove the leading 'S' in the target field, can some on help me with this reqmnt.

regards

manoj

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Why not use UDF to remove the leading S:

String input = 'SSSSSSSSSS test';

String result = input;

int len = input.length();

for (int i=0; i<len; i++)

if (input.charAt(i) == 'S')

result = input.substring(i+1);

else break;

Former Member
0 Kudos

can u just guide me how to put the java code in the udf and use in the message mapping?

regards

mano

Former Member
0 Kudos

Hi Manoj,

Check out : http://help.sap.com/saphelp_nw04/helpdata/en/d9/3033f96c79674f90e3ab8d101a595b/frameset.htm

Activities

       1.      To create a new user-defined function, choose Create New Function (This graphic is explained in the accompanying text) in the data-flow editor at the bottom of the screen, on the left-hand side.

       2.      Specify the attributes of the new function in the subsequent window:

Name:
Technical name of the function. The name is displayed in the function chooser and on the data-flow object.

Description:
Description of how the function is used.

Cache:
Function type (see above).

Arguments:
In this table, you specify the number of input values the function can process, and name them. All functions are of type String.

       3.      In the subsequent window, you can create Java source code:

                            a.      You can import Java packages to your methods from the Imports input field, by specifying them separated by a comma or semi-colon:

You do not need to import the packages java.lang.*, java.util.*, java.io.*, and java.lang.reflect.* since all message mappings require these packages and therefore import them. You should be able to access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the package under Import. In other words, you do not have to import it as an archive into the Integration Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the SAP Logging Service (see also: Runtime Environment (Java-Mappings)).

In addition to the standard packages, you can also specify Java packages that you have imported as archives and that are located in the same, or in an underlying software component version as the message mapping.

                            b.      Create your Java source text in the editor window or copy source text from another editor.

       4.      Confirm with Save and Close.

       5.      User-defined functions are limited to the message mapping in which you created the function. To save the new function, save the message mapping.

       6.      To test the function, use the test environment.

The new function is now visible in the User-Defined function category. When you select this category, a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the function to the data-flow editor, choose the arrow next to the button and select from the list box displayed.

Thanks,

Pooja

Former Member
0 Kudos

Hi Manoj,

  • On the bottom leftside corner of MM, you will find a button for "Create New Function"

  • Click on that , which will pop-up a new screen.

  • In the new screen , provide the function name

  • IN you case, keep the cache as : "Value" only ( default one)

  • Change the default argument "a" to "input".* Click on "Create Function"

  • Copy and paste the code given by Jayson in here. ( remove top one line and add a line for the function return )

String result = input;
int len = input.length();
for (int i=0; i<len; i++)
if (input.charAt(i) == 'S')
result = input.substring(i+1);
else break;
return result;

*_Save and close_ your function screen

===============================

Your UDF is ready.

Use it as :

Input field -> UDF--> target field

Thanks,

Pooja Pandey

Former Member
0 Kudos

Pooja's instruction is very detailed. just follow it and it will be working as expected.

Former Member
0 Kudos

thank u pooja

u have made me understand have UDF works.

can u help me with, how to remove leading 'S' and leading zeros in target field. it should remove both leading 'S' and leading zeros.

regards

mano

Former Member
0 Kudos

Change the condition in Jayson's code from

if (input.charAt(i) == 'S' )

to

if (input.charAt(i) == 'S' || input.charAt(i) == '0')

Former Member
0 Kudos

THANK U pooja

the code worked fine.

Answers (0)