dynamically load cube with Groovy - ERROR: Unable to execute Groovy job

      dynamically load cube with Groovy - ERROR: Unable to execute Groovy job

      Hi there

      I hope someone can help me resolve the error highlighted below which was encountered with the following Groovy script. The objective of the script is to dynamically load the actuals for the current financial period to a cube, where the Financial Year extends from Apr to Mar.

      I would be most grateful for any assistance in this regard.

      thanks

      Roger


      Script
      import java.util.Calendar;

      import java.util.Locale;

      now = Calendar.getInstance();
      int y = now.get(Calendar.YEAR);
      int mo = now.get(Calendar.MONTH);


      if (mo < 4){
      mo = (mo + 9);
      } else {
      mo = (mo - 3);
      yr = (yr + 1);
      }


      String year = yr;
      String mon = mo;


      API.setProperty("Curr_Yr",year);
      API.setProperty("Curr_Mth",mon);
      state = API.executeLoad("Data_Load_CYAct_Oracle");



      LOG file
      2012-09-20 10:24:04,922 INFO : Starting execution of job Dynamic_CurrMth_Actual
      2012-09-20 10:24:04,922 INFO : Variables: Prior_Mth:1 ; Curr_Yr:2013 ; Curr_Mth:5 ; Bud_Yr:2013 ; Prior_Yr:2012
      2012-09-20 10:24:04,922 INFO : Execution parameters: #logLimit:100 ; #failOnError:true ; #syncMode:single
      2012-09-20 10:24:04,938 ERROR : Unable to execute groovy job: startup failed:
      Script3.groovy: 1: expecting EOF, found 'String' @ line 1, column 218.
      = (mo - 3); yr = (yr + 1); } String yea
      ^


      1 error

      2012-09-20 10:24:04,938 INFO : Finished execution of job Dynamic_CurrMth_Actual after 0.016s with status: Failed
      .
      Hello Roger,

      I think this is your problem:

      tech28 wrote:

      String year = yr;
      String mon = mo;


      You can not convert an Integer to a String. Try this:

      Source Code

      1. String year = ""+yr;
      2. String mon = ""+mo;


      Let me know if that helps you.

      Regards.
      Djordja Markovic

      Interessant things:
      Internal derby:
      jedox.com/community/palo-forum…ad&postID=14338#post14338
      Calculate your cube size:
      jedox.com/community/palo-forum…ad&postID=14406#post14406
      Hi Djorda

      Thanks for the response. I have just retested using your suggestion but the job still fails with the same error:

      2012-09-20 10:24:04,938 ERROR : Unable to execute groovy job: startup failed:
      Script3.groovy: 1: expecting EOF, found 'String' @ line 1, column 218.
      = (mo - 3); yr = (yr + 1); } String yea


      I have also checked the the 'String' assignment syntax using a standalone groovy console and it works with or without the ""+ so the error may lie else where.

      kind regards

      Roger
      Hi Robert

      I have tried that as well and it still hasn't worked. By a process of elimination I have worked out that the problem lies with the 'If { } and else { }' statement, but I still can't figure it out.

      See latest iteration:

      import java.util.Calendar;
      import java.util.Locale;

      now = Calendar.getInstance(); tested ok
      int yr = now.get(Calendar.YEAR); tested ok
      int mo = now.get(Calendar.MONTH); tested ok

      if (mo < 4) {
      mo+= 9;
      } else {
      mo-= 3;
      yr+= 1;
      }

      string year = yr.toString(); tested ok
      string mon = mo.toString(); tested ok

      API.setProperty("Curr_Yr",year); tested ok
      API.setProperty("Curr_Mth",mon); tested ok
      state = API.executeLoad("Data_Load_CYAct_Oracle"); tested ok

      Post was edited 1 time, last by “tech28” ().

      Hi

      ;) After reviewing the 'Loop with Groovy' post by Djordja, I finally stumbled upon the problem/ solution. It turns out that the 'if{ } else { }' statement wasn't properly ended with a semi-colon (as simple as that). For good measure, I also removed the 'String' type that preceded the variables 'year' and 'mon'. See the final solution below.

      import java.util.Calendar;
      import java.util.Locale;

      now = Calendar.getInstance();
      int yr = now.get(Calendar.YEAR);
      int mo = now.get(Calendar.MONTH);

      if (mo < 4) {
      mo=(mo+9);
      }else{
      mo=(mo-3);
      yr= (yr+1);
      };

      year = yr.toString();
      mon = mo.toString();

      API.setProperty("Curr_Yr",year);
      API.setProperty("Curr_Mth",mon);
      state = API.executeLoad("Data_Load_CYAct_Oracle");



      I can now load my cubes each month without lifting a finger. Thank you for your posts. Much appreciated