2 Replies Latest reply: Jan 29, 2014 4:37 AM by rukbat RSS

    check duplicate

    Tshifhiwa

      hi how can i check the reference that is not duplicate and date format is DDDCCYYnnnnnnn, CC must be 20 and YY must not be less than the current year, nnnnnnn is the sequetial number of the file and to complete the 7 numeric characters, zero's must be populated in front of the number.  DDD must be a valid reporting entity code. there must not be a duplicate

      code i try

      private boolean test-date()

          {

              String s_Ref = this.transactionFile.getsReference();

              boolean flag = true;

       

              if(!isValidPattern(s_Ref, "[0-9]{14}"))

              {

                  em.setS_errorMessage("Reference", 533,cc);

              }

       

              if(isBlank(s_Ref))

              {

                  em.setS_errorMessage("Reference", 102,cc);

              }

       

              s_Ref = s_Ref.trim();

              if(s_Ref.length() != 14)

              {

                  em.setS_errorMessage("Reference", 201,cc);

              

              }else

              {

                  //get the adcode and validate

                  this.s_adCode = s_Ref.substring(0,3);

                  transactionFile.setsAdCode(s_adCode);

                  transactionFile.sAdCode = s_adCode;

       

                  s_adCode = (Integer.parseInt(s_adCode))+"";

              

                  if(!isMemberOf(s_adCode, cc.al_codes))

                  {

                      em.setS_errorMessage("Reference", 202,cc);

                  }else

                  {

                      //get the year and validate

                      String s_year = s_Ref.substring(3,7);

       

                      Calendar cal = Calendar.getInstance();

                      String s_currYear = cal.get(Calendar.YEAR)+"";

                  

                      if(!isEqualTo(s_year.substring(0, 2), "20") ||  !isEqualTo(s_year.substring(2,4), s_currYear.substring(2, 4)))

                      {

                          em.setS_errorMessage("Reference", 201,cc);

                      }else

                      {

       

                      }

                  }

       

              }

       

              return flag;

          }

       

      the reference number is like 201401030234509

       

      if there is duplicate show error code 105