on 05-09-2007 5:13 PM
I know I have seen this before, but cannot find it when searching.
I need to do something similar to the Substring function, where I start from position 4, but the length behind this position is variable. Due to the IDOC it only passes the value...
I think I possibly saw a UDF for this somewhere - unless I can use some standard mapping!
It is probably very simple - but it is late in the day and my eyes are square! = )
<i> I need a drink......</i>
Can anyone help?
Message was edited by:
Barry Neaves
hi Barry,
if I get it right - in your messge mapping do this:
idoc value - length function -> second parameter to substring function
(and the first will be constant 4)
Regards,
michal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For substring function, you have 1 input and 2 parameters (you set the parameters by double-clicking the function box).
I also didn't understand how you can pass the output of length function two 2nd parameter of substring function (since it is a parameter and not an expected input).
You could always create a UDF...
...
public String UDSubstring(String a,String b,String c,Container container){
int d = Integer.parseInt(b);
int e = Integer.parseInt(c);
if ((e == 0) && (a.length() >= d)) {
return a.substring(d);
}
else if ((e > d) && (a.length() >= e)) {
return a.substring(d, e);
}
else return "";
}
...
They don't bite, you know...
Regards,
Henrique.
<b>Edit:</b> followed by Michal's correction...
I guess it is getting late and/or I am being stupid - Take your pick 😛
I am mapping field VARYF from HR Infotype.
VARYF > UDF > Format Number > Target Field
I am chopping the first four characters off of VARYF (unsuccesfully despite the excellent help I am receiving from Michal and Henrique - you will be rewarded!)
I am trying to use Michal's suggestion:
public String SubstringWithoutLength(String a,String b,Container container){
int i = Integer.parseInt(6);
String c = VARYF.substring(4,i);
But I guess I am doing something wrong!
What should String A (VARYF?) and String B (Length?) be?
I assume String C is the result?
I need to go home!!!
Thanks to Michal and Henrique for your help so far!
Barry,
Just do like this:
Create a SubstringWithoutLength <b>VALUE</b> UDF with input parameters as 'a' and 'b'. Then add this code:
You import java.*; in the UDF
int i = Integer.parseInt(a);
String c = b.substring(4,i);
return c;
Basically you are passing the lenght in the 'a' variable and the value in the 'b' variable. In mapping you map like this:
VARYF>Lengh(Standard Function)>
VARYF--> SubstringWithoutLength --> Result
You give this two as your input paramters to your funciton. Then it should work like a BOOM.
---Satish
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.