cancel
Showing results for 
Search instead for 
Did you mean: 

UDF-Mapping error

Former Member
0 Kudos

Dear Experts,

My scenario is File-Proxy,the requirement  is checking the Bank GL codes having range

from 14400000 to 14432000 and 22125000 to 221256000, with another variable called posting key.


if posting key=40,the last digit should replace with 1,

if posting key=50,the last digit should replace with 2,



if the GLs are out of this range then the GL should post  as such(input GL and output GL are same).



Below is the code snippet


public String calculate1(String var1, int var2, Container container) throws StreamTransformationException{


int temp;

temp=Integer.parseInt(var1);

if(temp>14400000&&temp<14432000)

{

if(var2=40)

  {

  temp=temp+1;

  }

else if(var2=50)

{

var1=var1+2;

}

  }

else if(temp>22125000&&temp<221256000)

{

if(var2=40)

{

temp=temp+1;

}

else if(var2=50)

{

var1=var1+2;

}

}

return var1;

Also attaching my screenshot of message mapping.

when executed the message mapping the following error is showed

Source text of object Message Mapping: GeneralLedgerDetailTrans2_ | http://lntinfra.com/pi/sapgl/tcsbancs has syntax errors:
  • Source code has syntax error:
    D:\usr\sap\PFD\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Map351ae450628711e5c665005056a70029\source\com\sap\xi\tf\_GeneralLedgerDetailTrans2.java:9: cannot find symbol
    symbol : class string
    location: package java.lang
    import java.lang.string;
    ^
    D:\usr\sap\PFD\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Map351ae450628711e5c665005056a70029\source\com\sap\xi\tf\_GeneralLedgerDetailTrans2_java:1321: incompatible types
    found : int
    required: boolean
    if(var2=40)
    ^
    D:\usr\sap\PFD\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Map351ae450628711e5c665005056a70029\source\com\sap\xi\tf\_GeneralLedgerDetailTrans2__.java:1325: incompatible types
    found : int
    required: boolean
    else if(var2=50)
    ^
    D:\usr\sap\PFD\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Map351ae450628711e5c665005056a70029\source\com\sap\xi\tf\_GeneralLedgerDetailTrans2__.java:1332: incompatible types
    found : int
    required: boolean
    if(var2=40)
    ^      



Please guide on how to resolve this error.


Thanks &Regards,

Kalpana


Accepted Solutions (1)

Accepted Solutions (1)

former_member186851
Active Contributor
0 Kudos

Hello Kalpana,

for IF and else if conditions ,change to

if(var2==40)

and on which line your getting that String error?

Answers (5)

Answers (5)

Former Member
0 Kudos

Hello All,

Thanks for your reply.The issue is resolved once I added (var2==50).

Regards,

Kalpana

RaghuVamseedhar
Active Contributor
0 Kudos

Kalpana,

Please try this.


public String udf_test(int GL, int key, Container container) throws StreamTransformationException {

    if ((GL >= 14400000 && GL <= 14432000) || (GL >= 22125000 && GL <= 221256000)) {

        if (key == 40) {

            GL = GL + 1;

        } else if (key == 50) {

            GL = GL + 2;

        }

    }

    return GL + "";

}

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Kalpana,

Pls try the below corrected udf and check the outcome.

Code snippet:

int temp;

temp=Integer.parseInt(var1);

if((temp>=14400000) && (temp<=14432000))

{

if(var2.equals("40"))

  {

     temp=temp+1;

  }

else if(var2.equals("50"))

{

  temp=temp+2;

}

  }

else if((temp>=22125000) && (temp<=221256000))

{

if(var2.equals("40"))

{

temp=temp+1;

}

else if(var2.equals("50"))

{

   temp=temp+2;

}

}

return String.valueOf(temp);

vinaymittal
Contributor
0 Kudos

import java.lang.string; DELETE THE IMPORT STATEMENT

USE THIS CORRECTED CODE

int temp;

temp=Integer.parseInt(var1);

if(temp>14400000&&temp<14432000)

{

     if(var2==40)

       {

            temp=temp+1;

       }

     else if(var2==50)

     {

          var1=var1+2;

     }

}

else if(temp>22125000&&temp<221256000)

{

if(var2==40)

{

temp=temp+1;

}

else if(var2==50)

{

var1=var1+2;

}

}

return var1;

Former Member
0 Kudos

Kalpana, please delete "import java.lang.string;" from the mapping, class String (capital S) is contained in java.lang package which is imported by default in any java class, no need to do that explicitly.