Skip to Content
avatar image
Former Member

Mapping issue

Hi Folks,

I am working File to Proxy..where pi picks file with records and process to sap.

IS00~TP~~08152012~DM435~CNY~User~1.0~50~9523.17~9523.17~~IS0126~303011000~0~0~CN002~0~0~0~~

IS00~TP~~08152012~DM435~CNY~User~1.0~40~9523.17~9523.17~~IS0126~984000000~0~V~CN002~0~0~0~~

IS00~TP~~08152012~DM435~CNY~User~1.0~50~32758.67~32758.67~~IS0126~303011000~0~0~CN001~0~0~0~~

IS00~TP~~15082012~DM435~CNY~User~1.0~40~32758.67~32758.67~~IS0126~984000000~0~V~CN001~0~0~0~~

In above file the date format should be MMDDYYYY,if i pass the date format like in 4th record it should through error.

But i have done 1:1 map as of now..it is picking files successfully,but my req is if i send wrong date format then it should through error in PI itself..

Can anyone suggest me what to do in this case..

Thanks

Kalyan

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Sep 25, 2012 at 03:47 PM

    write a user defined fucntion in mapping level to validate the date format , if format is wrong then throw manual exception (mapping failure) with some custome message.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Kalyan,

      Here it is once again

      public void chkdate(String[] strDate,String[] reqDateFormat,ResultList result,Container container){

      MappingTrace importanttrace;

      importanttrace = container.getTrace();

      java.util.Date tempDate = null;

      java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(reqDateFormat);

      sdf.setLenient(false);

      try

      {

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

      {

      try

      {

      tempDate = sdf.parse(strDate[i]);

      result.addValue(strDate[i]);

      }

      catch(Exception e)

      {

      //result.addValue(e.getMessage()+ " : Error: The given date format is wrong, Required date format is: " + reqDateFormat) ;

      importanttrace.addInfo(e.getMessage());

      }

      }

      }

      catch (Exception e)

      {

      e.printStackTrace();

      }

      }

      Regards

      Anupam