Skip to Content

Mapping Issue, remove a field from source payload

Hi Experts,

Currently in production we have an interface which is failing in mapping daily, because one field is coming as Alphanumeric and that field is used in subtraction/Addition functionality in many fields in the mapping.

Mapping is quite complex and the clients are not ready to make changes in the current mapping.

So, as a workaround we decided to add another mapping(Graphical/XSLT/Java) before our current mapping(in Operational Mapping).

Mapping needs to handle

** To check that field(LtNumber) if it is alphanumeric say(W708088), then we need to delete the LtNumber field from the source payload and pass the entire payload as it is to our second mapping(current mapping).

Please suggest how I can handle it in an appropriate way and performance is also not affected.

Thanks,

Nidhi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 06, 2016 at 05:02 PM

    Hi Nidhi

    Create a udf to check the alpha numeric value.

    LtNumber-->UDF-->target field.

    UDF Code:

    try{

    int i = Integer.parseInt(var1);

    }

    catch(NumberFormatException e){

    return "0";

    }

    return var1;

    Regards

    Osman Jabri

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Nidhi Srivastava

      Add "continue" statement in the code, that will solve the issue.

      for(int i=0;i<var1.length;i++){

      try{

      int temp = Integer.parseInt(var1[i]);

      }

      catch(NumberFormatException e){

      result.addValue("0");

      continue;

      }

      result.addValue(var1[i]);

      }

  • Jan 06, 2016 at 05:15 PM

    Hi Nidhi,

    Try this.

    Assumptions here - The target field is of occurrence 0..1

    Non-numeric field:

    Numeric field:

    UDF Code:

    if (input[0].matches("[0-9]+"))
      result.addValue(input[0]);
    else
      result.addSuppress();
    

    Hope it helps!

    Thanks!


    Capture.PNG (75.2 kB)
    Capture.PNG (15.3 kB)
    Capture.PNG (15.8 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • Jan 07, 2016 at 11:24 AM

    Hi Nidhi,

    Try this this will work for multiple context too.

    UDF : All values of context

    for(int i=0;i<var1.length;i++)

    {

    if (var1[i].matches("[0-9]+")) 

      result.addValue(var1[i]); 

    else 

      result.addSuppress(); 

    }

    Br,

    Manoj


    1.PNG (19.3 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • Jan 06, 2016 at 05:23 PM

    Hello Nidhi,

    In the first mapping for the LtNumber field use the below UDF and logic

    for (int i=0; i<input.length(); i++) {
            char c = input.charAt(i);
            if (c < 0x30 || (c >= 0x3a && c <= 0x40) || (c > 0x5a && c <= 0x60) || c > 0x7a)
                return false;
        }

        return true;
    }

    Input------->UDF----->CreateIF------>LTNumber.

    Let us know if you face any issues.

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Nidhi,

      Try the below piece of code

      public String createTargetCheck(String input, Container container) throws StreamTransformationException{

      int flag = 0;

      for(int i=0;i<input.length();i++)

      {

      char c = input.charAt(i);

      if (c < 0x30 || (c >= 0x3a && c <= 0x40) || (c > 0x5a && c <= 0x60) || c > 0x7a)

      flag=flag+1;

      }

      if(flag>0)

      {
        return "false";
      }

      else

      {

        return "true"
      }

      }

      Let me know if you face any issues.

  • Jan 06, 2016 at 07:25 PM

    Hi Nidhi,

                 Do you need to delete the entire field or only delete the value within tags?

    Regards

    Anupam

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 08, 2016 at 04:02 AM

    Hi All,

    Thanks for your response.

    Again a confusion is like -

    IF I am adding a map(1-1, just removing the field if it is alphanumeric) before the main map(currently existing), will it impact performance or delay the messages?

    Is it better to go for Graphical mapping or I can think for Java/XSLT from performance point of view?

    Please suggest.

    Thanks,

    Nidhi

    Add comment
    10|10000 characters needed characters exceeded