on 07-02-2008 8:20 AM
Hi friends,
I have a mapping requirement as folows.
Source field : KRATE
Target field : Rate
Mapping requirement is as follows
if source is 15; you need to map it to 000000000001500 ( in other words 11spaces (or zeros ), 15 ( the value ) and then two zeros. )
Can someone tell me how do i do that?
Hi Sameer,
Can you please tell me the values you have used for the 2 constants and the number of zeros you have used for the 2 formatnumbers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Try this :
Make UDF with 2 inputs a & b (of type value)
Source -
\
-
\UDF----> Target
Source--
/
Constant[.]-/indexOf2--
/
UDF:
int cnt = Integer.parseInt(b);
if(a.length()<15)
{
String str = "";
for(int i=0 ; i<(15-a.length()) ; i++)
str=str+'0';
// String val = a.substring((a.length()-3) , a.length());
if( cnt >= 0 )
return( str + a.substring(0,cnt) + a.substring(cnt+1,a.length()) );
else
return(stra"00");
}
else
return(a);
Thanks,
mahi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi patrick,
I am not sure whether input has 2 digits after decimal or 3 digits after decimal.I want the mapping to take care whatever may be the input may be.Thats why i was asking for the requirement as such.Anyway tomorrow i will confirm that with you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Manikandan
Try my solution as shown in the image.
https://weblogs.sdn.sap.com/weblogs/images/17804/solution.JPG
Replace Name with KRATE and Name1 with the output.
I think the picture is self-explanatory.
Sameer
Hi sameer,
if the source is 105.125 output should be
000000000105125.If we round it off it will become 126.I need not want rounding off.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi patrick and sameer,
If there are 3 digits after the decimal your concept will not work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
that's exactly why it's important to know how your requirements look like.
You only said:
>i.e if it is 1000,the target should be 000000000100000
>if the source is say 1000.50,the target should be
>000000000100050
How should we know that you can have a input like 1.234?
Anyway you could place a round-function between mul and formatNumber and then it shoul work.
Regards
Patrick
Edited by: Patrick Koehnen on Jul 3, 2008 12:17 PM
Hi Induja,
i.e if it is 1000,the target should be 000000000100000
if the source is say 1000.50,the target should be
000000000100050
Can you understand now?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you can do it like this:
standard function mul (multiply):
input1: sourceValue
input2: constant (100)
output goes into formatNumber (000000000000000)
This should work.
But like I mentioned above you have to be sure that your source value is numeric and is not empty. If you are not sure you have to check this first.
Regards
Patrick
Hello,
Try this :
**********************************************
if(a.length()<15)
{
String str = "";
for(int i=0 ; i<(15-a.length()) ; i++)
{
str=str+'0';
}
String val = a.substring((a.length()-3) , a.length());
if( val.substring(0,1).equals(".") )
return( str + a.substring(0,a.length()-3) + val.substring(1,3) );
else
return(stra"00");
}
else
return(a);
*********************************************
Just use this UDF
Source-----> UDF -
> target
Thanks,
Mahi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If your requirement is this
>> if source is 15; you need to map it to 000000000001500 ( in other words 11spaces (or zeros ), 15 ( the value ) and then two zeros. )
write an UDF something like this
String before = "00000000000";
String after = "00";
if (source.equals("15"))
{
source = before + source + after;
}
else
{
//your error message
}
return source;
Hope this will help you.
Regards
Aashish Sinha
PS : reward points if helpful
Edited by: Aashish Sinha on Jul 3, 2008 10:06 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That UDF is not working.output is same as the source without any zeros
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Could you tell me if I have understood it right,if the source KRATE is an integer,you want it to be concatenated with 2 zeroes in the end.If it has digits after the decimal point,you want the zeroes to be concatenated after the entire number excluding the decimal points.
i.e if it is 1000,the target should be 000000000100000
if the sorce is say 1000.50,you want the target to be 000000010005000.
Please could you tell me if this your requirement?
Thanks and Regards,
Induja
Hi MANIKANDAN subash chandran ,
write a UDF.
if(x.length()<15)
{
String str = "";
for(int i=0;15<(15-a.length());i++)
{
str=str+'0';
}
return(str+x);
}
else
{
return(x);
}
Regards,
Jayasimha Jangam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Induja,
Your method works fine for integers well.For eg if the input is 15 ouput is 000000000001500.If source is 1000 output is 000000000100000.But if the source is 1000.50 output is 000000000100000 which is not right.Last 2 digits should be 50.I am getting this error because we are concatenating 2 zeros as a constant.Is there any other method?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you have to make your requirements clear otherwise it is not so easy to help you
You said your output should have always a length of 15 and the last two digits are the decimals.
How exactly could your input look like?
could this be valid inputs:
123456789012345
12.8
0.22
and if yes what should be the output?
Regards
Patrick
Hi,
You can try this as well and check.Take your source field KRATE and map it to the FormatNumber arithmetic function and specify it as 13 zeroes,then use the concat function to concatenate this with two zeroes and finally map the result to your target field Rate.
Thanks and Regards,
Induja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys ,
What should be the procedure if its not a 2 digit number.It can be a number ranging from 1 git to 15 digits.
To Boopalan....
I think your procedure holds good if we dont know the number of digits.Am i right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys,
It will be a 2 digit value always at the source side.
We need to pad 11 zeroes and then the 2 digit number and then 2 zeroes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Manikandan,
Use the FormatNumfunction of the arithmetic functions. Have a look at the help doc to know more about it:
http://help.sap.com/saphelp_nw04/helpdata/en/ef/df564b6aa24fc9ab0d685460747de5/frameset.htm
Regards,
Sanjeev.
hi....
u can do it directly by standard function concate.
for concate function, take 1st argument as constant with 11 zeros, second argument ur source feild.
go for one more concate function take above result as 1st argument,second argument again constant with 2 zeros,and map it to target field.
Sreedhar Goud.
Hey,
Try for this way:
(Source) if exists (eg15) --> Constant (00) (eg1500) then --use this UDF (for filling the Zeros) ---Target
UDF:
if(a.length()<15)
{
String str = "";
for(int i=0;15<(15-a.length());i++)
{
str=str+'0';
}
return(str+a);
}
else
{
return(a);
}
Thanks,
Boopathi
Edited by: Boopathi Thangavel on Jul 2, 2008 10:38 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi.......
that means always u will get 2 digit number only at source side?
Sreedhar Goud
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
what can be other source values and what should happen then?
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.