cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Problem

vishnu_pallamreddy
Contributor
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

vishnu_pallamreddy
Contributor
0 Kudos

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.

vishnu_pallamreddy
Contributor
0 Kudos

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.


anupam_ghosh2
Active Contributor
0 Kudos

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

vishnu_pallamreddy
Contributor
0 Kudos

Hi Anupam,

I follow your code but i got some errors like this:

Thankyou,

vishnup.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You might have one extra curly brace either { or } .  Please check your code. This can cause this error.

anupam_ghosh2
Active Contributor
0 Kudos

Hi Vishnu,

                 I have tested the code in PI 7.0 it works fine. Could you please show screen shot of how you are trying to create the UDF? Please choose the UDF of type "value" and paste the code I wrote. Please do not paste line number 1 and line number 38 in the UDF.

Regards

Anupam

vishnu_pallamreddy
Contributor
0 Kudos

Hi Baskar,

After removing extra "}" i got this error.

  •          com/sap/xi/tf/_MOAEligibleData_To_GreatWestEligibleData_MM_.java[748] package Muni.org_Fin_PosPayToKeyBank does not exist
    private Muni.org_Fin_PosPayToKeyBank.PaddingFunction PaddingFunction = new Muni.org_Fin_PosPayToKeyBank.PaddingFunction();
    ^
  • com/sap/xi/tf/_MOAEligibleData_To_GreatWestEligibleData_MM_.java[748] package Muni.org_Fin_PosPayToKeyBank does not exist
    private Muni.org_Fin_PosPayToKeyBank.PaddingFunction PaddingFunction = new Muni.org_Fin_PosPayToKeyBank.PaddingFunction();
    ^
    Note: F:\usr\sap\DI1\DVEBMGS06\j2ee\cluster\server0\.\temp\classpath_resolver\Map5c2390e029ce11e2a530000003dc6e16\source\com\sap\xi\tf\_MOAEligibleData_To_GreatWestEligibleData_MM_.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors      
vishnu_pallamreddy
Contributor
0 Kudos

Hi Anupam,

Please find my udf creation screen shots.

when i click the "test" tab in mapping i got following popup.

what is the problem?

Thankyou,

vishnup.

anupam_ghosh2
Active Contributor
0 Kudos

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

vishnu_pallamreddy
Contributor
0 Kudos

Hi Anupam,

Below screen shot represents my mapping and when i am going to save the mapping i got the popup below.

Thankyou

vishnu.

anupam_ghosh2
Active Contributor
0 Kudos

Hi Vishnu,

                   Did you try the test UDF code with just one line in it?

I think this problem is not due to UDF.

Regards

Anupam

Former Member
0 Kudos

Hi,

you need to create the local UDF via the Function Library ..

i.e Expand FL in your message where there will be an entry with LocalUserFunction and instanceName Local click on this and then add your UDF under Functions and java areas and save..

This should solve your issue..

HTH

Rajesh

vishnu_pallamreddy
Contributor
0 Kudos

Thank You Anupam,

we solve the issue based on your instructions.

we wrote another code based on your code.

thank you very much.

thankyou

vishnup.

vishnu_pallamreddy
Contributor
0 Kudos

Hi Anupam,

If no value comes from proxy to pi your code not working.

what is the problem?

what we can do for that situation?

if no value comes we pass 10 zeros to that field.

please give me fast reply.

Thankyou,

vishnup.

anupam_ghosh2
Active Contributor
0 Kudos

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

Answers (1)

Answers (1)

former_member184681
Active Contributor
0 Kudos

Hi Vishnu,

Please use search function before posting a new thread - similar requirement was discussed multiple times in SCN. See an example of an answered thread here:

Regards,

Greg