on 11-08-2012 11:50 AM
Hi All,
Our requirement is proxy to file(fcc).
we have one amount field with fixed length 10 and sender side length 16(in proxy class).
our condition is if negative value comes we put negative sign at first position and we have to produce the value like "-000040000" or " -40000".
is it possible with graphical mapping?
if possible please provide me the mapping screen shot for that field.
its urgent.
Thankyou,
vishnu p.
Hi Grzegorz,
We have one value "-40000" from proxy.
now how to place "zeros" inbetween "-" and "40000" or how to place "spaces" before "-40000"?
if we dont know the length of the amount field which is coming from proxy how we handle that situation?
i mean how we place "zeros" or "spaces"?
Thankyou,
vishnu p.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Grzegorz,
These two are my conditions:
1) For participants that are not contributing to the plan but appear on the file please Zero Fill the amount field(s).
2)A negative sign in the amount fields can be added in the first space of the amount field, ie."-000012.34" or directly next to the contribution amount " -12.34"
Thankyou,
vishnu p.
Hi Vishnu,
Try this UDF
public String IncludeZero(String a,Container container){
try
{
int l=a.length();
int i,j;
String s="",t="";
j=10-l;
if(a.indexOf('-')>=0)
{
for(i=0;i<j;++i)
{
t=t+"0";
}
for(i=0;i<l;++i)
{
if(a.charAt(i)=='-')
{
s=s+"-"+t;
}
else if((a.charAt(i)>='0' && a.charAt(i)<='9') || a.charAt(i)=='.')
{
s=s+a.charAt(i);
}
}
a=s;
}
if(a==null || l==0)
{
a="0000000000";
}
}
catch(Exception e)
{
e.printStackTrace();
}
return a;
}
Map the field carrying the value in the way shown below
Here empid is the field carrying the numeric value. Positive values will pass as it is. If there is no value in the source then you will have 10 zeroes in output.
For negative values you will have output as expressed in your earlier post.
Regards
Anupam
Hi Anupam,
I follow your code but i got some errors like this:
Thankyou,
vishnup.
Hi Baskar,
After removing extra "}" i got this error.
Hi Vishnu,
From the screenshot the UDF looks fine. This should not cause any errors.
How did you do the message mapping? could you put here a screen shot? Did you save and activate the mapping? Finally if everything is ok then just replace the UDF with this new one
public string SDN(String a, Container container) throws StreamTransformationException
{
return a;
}
This is only to test if the error is for all UDF's or only for specific one.
If this test UDF does not give any error then please try replace the original UDF with following code
public string SDN(String a, Container container) throws StreamTransformationException
{
int l=a.length();
int i,j;
String s="",t="";
j=10-l;
if(a.indexOf('-')>=0)
{
for(i=0;i<j;++i)
{
t=t+"0";
}
for(i=0;i<l;++i)
{
if(a.charAt(i)=='-')
{
s=s+"-"+t;
}
else if((a.charAt(i)>='0' && a.charAt(i)<='9') || a.charAt(i)=='.')
{
s=s+a.charAt(i);
}
}
a=s;
}
return a;
}
This is a strange problem.
The UDF is running fine in my system.
Regards
Anupam
Hi Vishnu,
Apologies I forgot to add few lines(27-30) from my first code(which was giving errors) into my second code.
Could you please kindly add them in my final code (that is the code you marked as correct answer)?
I feel this is much better code than previous ones try this
public string SDN(String a, Container container) throws StreamTransformationException {
if(a==null || a.length()==0)
{
a="0000000000";
return a;
}
int l=a.length();
int i,j;
String s="",t="";
j=10-l;
if(a.indexOf('-')>=0)
{
for(i=0;i<j;++i)
{
t=t+"0";
}
for(i=0;i<l;++i)
{
if(a.charAt(i)=='-')
{
s=s+"-"+t;
}
else if((a.charAt(i)>='0' && a.charAt(i)<='9') || a.charAt(i)=='.')
{
s=s+a.charAt(i);
}
}
a=s;
}
return a;
}
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.