2 Replies Latest reply: Feb 25, 2013 8:34 AM by gimbal2 RSS

    Need help to change some code

    993097
      Hi Experts,

      I am new to Java and i struck up in some java code. could some one modify the code according to my requirement please..

      we hava a booking form contains the details like Destination ware house no, load number,PO number, line number.... When the supplier submit the form,Here we should reject the booking form .

      The booking form should reject in some cases where i have mentioned below. accordingly could some one modify the java code please..



      We have to reject such a booking form through the logic


      If Destination Warehouse = Different AND Load number = Common then


      “Reject the booking form”


      Else if


      Destination Warehouse = Different AND Load number = Different then



      "Pass the Booking form"


      Else If


      If Destination Warehouse = Common AND (Load number = Common OR Load number = Different)


      “Pass the booking form”



      Else


      it should Reject the form for different site on same load.



      The java code has been written like this. could someone modify it according to my requirement as i am new to Beginner to Java

      String[] vendor = new String[status.length];
      String[] load = new String[status.length]; //array of load numbers
      String[] site = new String[status.length]; // array of site (dest wh) numbers
      String[] temp = new String[20];
      String[] lstatus = status;
      String[] fail_loads = new String[status.length];
      String[] fail_sites = new String[status.length];

      MappingTrace trace = container.getTrace();
      trace.addInfo("No. of records: " + status.length);
      /*
      for(int i=0;i<status.length;i++){
      result.addValue(status);
      }
      */
      try{
      if (status.length != 1) {

      //Split input into Load Number and Vendor Number
      for (int i = 0; i < status.length; i++) {

      temp = status[i].split(":");
      load[i] = temp[1];
      site[i] = temp[5];
      if (temp[2].equals("9999999999")) vendor[i] = null;
      else vendor[i] = temp[2];
      temp = null;
      }

      //Get Loads with two or more vendors
      String p_vendor = vendor[0];
      String p_load = load[0];
      String p_site = site[0];
      int idx = 0;
      int idxs = 0;

      trace.addInfo("Load Length: " + load.length);
      for (int i = 1; i < load.length; i++) {
      if (vendor[i] != null) {
      if (p_vendor != null && load[i].equals(p_load) && !load[i].equals("00")) { //same load as previous
      if (!vendor[i].equals(p_vendor)) { //second vendor in same load
      fail_loads[idx] = load[i];
      idx = idx + 1;
      }
      if (!site[i].equals(p_site)) { //second site in same load
      fail_sites[idxs] = load[i];
      idxs = idxs + 1;
      }
      }
      p_load = load[i];
      p_vendor = vendor[i];
      p_site = site[i];
      }
      trace.addInfo("For Loop 2: Index: " + i);
      }

      trace.addInfo("fail Loads length: " + fail_loads.length);
      trace.addInfo("fail Sites length: " + fail_sites.length);
      //Set values in array Status[]

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

      for (int j = 0; j < fail_loads.length; j++)
      if (load[i].equals(fail_loads[j])) {
      //set status[i] to fail
      trace.addInfo("status[" + i + "] = " + status[i]);
      String msg = "fail" + status[i].substring(4);
      if (msg.length() <= 30)
      msg += ":999";
      status[i] = msg;
      trace.addInfo("status[" + i + "] = " + status[i]);
      break;
      }

      for (int j = 0; j < fail_sites.length; j++)
      if (load[i].equals(fail_sites[j])) {
      //set status[i] to fail
      trace.addInfo("status[" + i + "] = " + status[i]);
      String msg = "fail" + status[i].substring(4);
      if (msg.length() <= 30)
      msg += ":998";
      status[i] = msg;
      trace.addInfo("status[" + i + "] = " + status[i]);
      break;
      }


      result.addValue(status[i]);

      }// end for i

      }//endif

      else

      result.addValue(status[0]);

      }//end try
      catch (Exception e)
      {
      StringWriter stringWritter = new StringWriter();
      PrintWriter printWritter = new PrintWriter(stringWritter, true);
      e.printStackTrace(printWritter);
      String error = "Exception: "
      + stringWritter.toString();
      trace.addInfo("This is exception: " + e.getStackTrace());


      }

      Thanks,
      Suesh
        • 1. Re: Need help to change some code
          mycoffee
          I guess not a lot of people having free time to do your homeworks
          • 2. Re: Need help to change some code
            gimbal2
            990094 wrote:
            I am new to Java and i struck up in some java code. could some one modify the code according to my requirement please..
            No. Ask for help so YOU can change it and learn from it, don't flat out ask other people to do it for you. People will just assume you'll be the one flipping their burgers in the future if you do that.
            new to Java
            There is a forum that has this exact name, I suggest you take your further questions (not requests to outsource work) there.