BOB: Business Objects Board
Not endorsed by or affiliated with SAP

Register | Login 

Want to sponsor BOB? 
Want to sponsor BOB? (Opens a new window)  

General Notice: No events within the next 45 days.

Rescheduling the report using BO SDK jsp

Goto page 1, 2  Next
 
Search this topic... | Search SDK (VBA/ASP/JSP)... | Search Box
Register or Login to Post    Forum Index -> SDK (VBA/ASP/JSP)  Previous TopicPrint TopicNext Topic
Author Message
kpavan999
Forum Member
Forum Member



Joined: 26 Jan 2011

Posts: 10



PostPosted: Mon May 12, 2014 7:11 am 
Post subject: Rescheduling the report using BO SDK jsp

I have the pseudo code to reschedule the failed report through UI using jsp.I dont want to waste time again coding from the beginning if someone already has.
Can someone please help me with the code if have handy? I can customize as per my requirement.
Any help is much appreciated.

Below is the algorithm I have.
1) Retrieve the failed instances in an IInfoObjects collection
2) Loop through the collection and get the ISchedulingInfo class for each InfoObject
3) Call ISchedulingInfo.setType(CeScheduleType.ONCE) and ISchedulingInfo.setRightNow(true) on each failed instance. Do NOT save each object
4) Outside the loop, call IInfoStore.schedule(<InfoObjects collection from step1>)

You may want to remove events to ensure the job actually kicks off as soon as a slot is open on the system
Back to top
joepeters
Forum Fanatic
Forum Fanatic



Joined: 29 Aug 2002

Posts: 6622
Location: Connecticut, USA


flag
PostPosted: Mon May 12, 2014 9:35 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

This is part of the code that I use. It's a Java application, but could be easily converted to JSP.

Couple of important things to note -- by default, a rescheduled instance will assume the owner of the user doing the reschedule. My script sets it to the original owner. I also remove any Events that the instance is waiting for.

This is what it does:
  1. Ask user for timeframe to evaluate
  2. Get failed instances during the timeframe
  3. For each failed instance, check if there is a successful instance during the same time period; if found, take no action.
  4. Get a new IInfoObjects collection for the failed instance
  5. Get the original owner ID, and set the scheduled owner to match
  6. Set instance to run immediately
  7. Remove any Events associated with the instance
  8. Set the expiration date (one day in the future)
  9. Ask if instance should be rescheduled
  10. If yes, reschedule the instance and delete the failed instance


Code:
      Integer inStart = new Integer(getInput("Start hours ago","12"));
      Integer inEnd = new Integer(getInput("End hours ago (negative for future)","0"));
      
      Calendar calStart = Calendar.getInstance();
      calStart.add(Calendar.HOUR,-inStart); 
      Calendar calEnd = Calendar.getInstance();
      calEnd.add(Calendar.HOUR,-inEnd);
      
      SimpleDateFormat sdfGMT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      SimpleDateFormat sdfHere = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
      sdfGMT.setTimeZone(TimeZone.getTimeZone("GMT"));
      
      String strStart = sdfGMT.format(calStart.getTime());
      String strEnd = sdfGMT.format(calEnd.getTime());
      
      System.out.println("Looking for failed instances between " + sdfHere.format(calStart.getTime()) + " and " + sdfHere.format(calEnd.getTime()));
      
      String userInput="";

      String timeCondition = "'" + strStart + "' and '" + strEnd + "'";
      
      IInfoObjects oInfoObjects = oInfoStore.query("select top 100 * from ci_infoobjects where si_schedule_status = 3   and si_update_ts between  " + timeCondition);

        Date exDate;
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, 1);
        exDate = calendar.getTime();

       outfor:

       for(int x =0;x < oInfoObjects.size();x++)
       {
          IInfoObject oI = (IInfoObject)oInfoObjects.get(x);
          IInfoObjects oSuccess = (IInfoObjects) oInfoStore.query("select * from ci_infoobjects where si_parentid = " + oI.getParentID() + " and si_schedule_status in (1,9,0) and si_kind = '" + oI.getKind() + "' and si_update_ts  between " + timeCondition );
          if(oSuccess.size() > 0)
             continue outfor;
          
          IInfoObjects oScheds = oInfoStore.query("select * from ci_infoobjects,ci_appobjects where si_id = " + oI.getID());
          IInfoObject oSched = (IInfoObject) oScheds.get(0);

          Integer iOwner = (Integer) oI.properties().getProperty("SI_OWNERID").getValue();
         
           oSched.getSchedulingInfo().setScheduleOnBehalfOf(iOwner);
           oSched.getSchedulingInfo().setRightNow(true);
           oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);
          
           while(oSched.getSchedulingInfo().getDependencies().size() > 0)
              oSched.getSchedulingInfo().getDependencies().remove(0);
          
           oSched.getSchedulingInfo().setEndDate(exDate);
           System.out.print("   reschedule? ");
           userInput = scanner.nextLine();
          
           if(userInput.toUpperCase().equals("Y"))
           {
              oInfoStore.schedule(oScheds);
              oI.deleteNow();
           }
       }
   }
   
   String getInput(String prompt,String defaultValue)
   {
      System.out.println(prompt + " (" + defaultValue + "):");
      String result = scanner.nextLine();
      if(result.equals(""))
      {
         System.out.println(defaultValue);
         return defaultValue;
      }
      return result;
   }
Back to top
kpavan999
Forum Member
Forum Member



Joined: 26 Jan 2011

Posts: 10



PostPosted: Tue May 13, 2014 2:09 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

Hey Joepeters,

Thanks a lot. This is what exactly Im looking for.
With my limited knowledge I will try to convert into JSP.

Meantime just in case if you find the same code in JSP please do reply here, I think it will be helpful for many out here.

Thanks agiain for your prompt reply.
Back to top
kpavan999
Forum Member
Forum Member



Joined: 26 Jan 2011

Posts: 10



PostPosted: Wed May 14, 2014 5:41 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

Hi Joepeters,

I have somehoe managed to get the code in JSP using your logic, but unfortunately it is not working. If you dont mind, can you please see if you can find what is causing the issue?
Im neither getting the error nor able to reschedule the report.

Im completely sure about the code till try block.
Thanks a lot for your help.

Code:

<%@ page import = "com.crystaldecisions.sdk.occa.infostore.*" %> 
<%@ page import = "com.crystaldecisions.sdk.framework.CrystalEnterprise" %> 
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException" %> 
<%@ page import = "com.crystaldecisions.sdk.framework.IEnterpriseSession" %> 
<% 
    // logon information 
    String boCmsName  = "*******" ; 
    String boUsername = "********" ; 
    String boPassword = "*******" ; 
    String boAuthType = "secEnterprise" ; 
          // report 
    String reportName = "23A_Fails" ; 
          // logon 
    IEnterpriseSession ceSession = CrystalEnterprise.getSessionMgr().logon( boUsername, boPassword, boCmsName, boAuthType ) ; 
    IInfoStore         oInfoStore = (IInfoStore)ceSession.getService( "", "InfoStore" ) ; 
    // get the scheduled report 
   String cr_query = "Select Top 1 * " 
                      + "From CI_INFOOBJECTS " 
                      + "Where SI_NAME='" + reportName + "' "  ;
                      //+ "and SI_INSTANCE=1 and SI_RECURRING=1 " ; 
    IInfoObjects boInfoObjects = oInfoStore.query( cr_query ) ; 
    if ( boInfoObjects.size() == 0 ) { 
       out.println( "<b>Scheduled report not found: '" + reportName + "'</b><br />" ) ; 
       ceSession.logoff() ; 
       return ; 
    } 

    try { 

         IInfoObjects oInfoObjects = oInfoStore.query("select top 1 * from ci_infoobjects where SI_NAME='" + reportName + "' " );
             out.println("select top 1 * from ci_infoobjects where SI_NAME='" + reportName + "' ");
          IInfoObject oI = (IInfoObject)oInfoObjects.get( 0 );
          IInfoObjects oSuccess = (IInfoObjects) oInfoStore.query("select * from ci_infoobjects where si_parentid = " + oI.getParentID() + " and si_schedule_status in (1,9,0) and si_kind = '" + oI.getKind() + "'  "  );
//         if(oSuccess.size() > 0)
//            continue outfor;
          IInfoObjects oScheds = oInfoStore.query("select * from ci_infoobjects,ci_appobjects where si_id = " + oI.getID());
          IInfoObject oSched = (IInfoObject) oScheds.get(0);
          Integer iOwner = (Integer) oI.properties().getProperty("SI_OWNERID").getValue();
          oSched.getSchedulingInfo().setScheduleOnBehalfOf(iOwner);
           oSched.getSchedulingInfo().setRightNow(true);
           oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);

    } catch ( SDKException e ) { 
       out.println( "<font color=red><b>couldn't reschedule report</b></font><br />" ) ; 
       out.println( e.toString() ) ; 
    } 
    // logoff 
    ceSession.logoff() ; 
%> 
Back to top
joepeters
Forum Fanatic
Forum Fanatic



Joined: 29 Aug 2002

Posts: 6622
Location: Connecticut, USA


flag
PostPosted: Wed May 14, 2014 7:20 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

The first thing I see is that you're not looking for a failed instance; your query will pick up the base report, and not an instance.

The next thing I see is that you're not calling oInfoStore.schedule(oScheds), which is what actually creates the schedule instance.
Back to top
kpavan999
Forum Member
Forum Member



Joined: 26 Jan 2011

Posts: 10



PostPosted: Thu May 15, 2014 1:09 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

You are right,

1) I'm hardcoding for a single report just to see how it works.
2) I didn't use "oInfoStore.schedule(oScheds)" as it wasn't there in your code as well. But I have used in the new code below, still the report is not scheduled as per the old report scheduled instance..

What is happening here is, report is getting scheduled but it is not sending mail/attachment unlike the original schedule instance.
Below are the details of the rescheduled instance

Quote:

Title: SDK_TEST
Document Type: Web Intelligence Report
Status Success
Destination: Default
Owner: ****
Creation Time: 5/15/2014 1:53 AM
Start Time: 5/15/2014 1:53 AM
End Time: 5/15/2014 1:53 AM
Duration: 3 sec
Server Used: mdwnew.AdaptiveJobServer
PID: 27131966
Parent Object Path: **********
Remote Instance in Federated Cluster: No
Expiry: 5/15/2024 1:53 AM
Formats: Web Intelligence


Code:

<%@ page import = "com.crystaldecisions.sdk.occa.infostore.*" %> 
<%@ page import = "com.crystaldecisions.sdk.framework.CrystalEnterprise" %> 
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException" %> 
<%@ page import = "com.crystaldecisions.sdk.framework.IEnterpriseSession" %> 
<% 
    // logon information 
    String boCmsName  = "***" ; 
    String boUsername = "***" ; 
    String boPassword = "***" ; 
    String boAuthType = "secEnterprise" ; 
          // report 
    String reportName = "SDK_TEST" ; 
          // logon 
    IEnterpriseSession ceSession = CrystalEnterprise.getSessionMgr().logon( boUsername, boPassword, boCmsName, boAuthType ) ; 
    IInfoStore         oInfoStore = (IInfoStore)ceSession.getService( "", "InfoStore" ) ; 
    IInfoObjects oInfoObjects = oInfoStore.query("select top 1 * from ci_infoobjects where SI_NAME='" + reportName + "' " );
    IInfoObject oI = (IInfoObject) oInfoObjects.get(0);
          IInfoObject oSched = (IInfoObject) oInfoObjects.get(0);
           oSched.getSchedulingInfo().setRightNow(true);
           oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);
             oInfoStore.schedule(oInfoObjects);
             
%>




Now my doubt is can we reschedule the report directly or we need to get all the scheduling info like from/to/events etc and then apply them for the new schedule? I think it will be a tedious job as it could be SMTP or FTP or inbox or anything.
Back to top
kpavan999
Forum Member
Forum Member



Joined: 26 Jan 2011

Posts: 10



PostPosted: Tue Jun 03, 2014 5:39 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

Hi Joepeters,

just wanted to know if in case you got a chance to look into my issue.


Last edited by kpavan999 on Fri Jun 20, 2014 8:05 am, edited 1 time in total
Back to top
joepeters
Forum Fanatic
Forum Fanatic



Joined: 29 Aug 2002

Posts: 6622
Location: Connecticut, USA


flag
PostPosted: Wed Jun 04, 2014 10:48 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

I just got back from vacation.

kpavan999 wrote:
You are right,
1) I'm hardcoding for a single report just to see how it works.

Yes, but you are hardcoding for the base report, not the instance. So your code is creating a new schedule from the base; it is not rescheduling an existing instance.
kpavan999 wrote:
2) I didn't use "oInfoStore.schedule(oScheds)" as it wasn't there in your code as well.

Yes, it's there: oInfoStore.schedule(oScheds);

kpavan999 wrote:
What is happening here is, report is getting scheduled but it is not sending mail/attachment unlike the original schedule instance.

This is expected as you are scheduling the base report. Your initial CMS query needs to be more specific -- you are currently querying on si_name; you either need to use si_parentid instead or add si_recurring=1.

Joe
Back to top
kpavan999
Forum Member
Forum Member



Joined: 26 Jan 2011

Posts: 10



PostPosted: Thu Jun 05, 2014 4:09 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

Thanks a lot joepeters,
Now I got the confidence that this code will work.

It is now taking the properties like, report format/emailing info etc.
The only problem is -> it is going to pending status though we are setting it to runNow and the old recurring instance doesnt have any events to wait for or to trigger.

Code:

<%@ page import = "com.crystaldecisions.sdk.occa.infostore.*" %>
<%@ page import = "com.crystaldecisions.sdk.framework.CrystalEnterprise" %>
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException" %>
<%@ page import = "com.crystaldecisions.sdk.framework.IEnterpriseSession" %>
<%
    // logon information
    String boCmsName  = "***" ; 
    String boUsername = "***" ; 
    String boPassword = "***" ; 
    String boAuthType = "secEnterprise" ; 
    // report 
    String reportName = "SDK_TEST" ; 
          // logon
    IEnterpriseSession ceSession = CrystalEnterprise.getSessionMgr().logon( boUsername, boPassword, boCmsName, boAuthType ) ;
    IInfoStore         oInfoStore = (IInfoStore)ceSession.getService( "", "InfoStore" ) ;
   // IInfoObject oI = (IInfoObject) oScheds.get(0);
    IInfoObjects oScheds = oInfoStore.query("select top 1 * from ci_infoobjects where   si_recurring=1 and SI_NAME='"+reportName+"'" );
   
          IInfoObject oSched = (IInfoObject) oScheds.get(0);
           oSched.getSchedulingInfo().setRightNow(true);
           oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);
         
while(oSched.getSchedulingInfo().getDependencies().size() > 0)
               oSched.getSchedulingInfo().getDependencies().remove(0);
         
   oInfoStore.schedule(oScheds);
             
%>


Can you please tell me if there is still anything needed to make it run as expected.
Back to top
joepeters
Forum Fanatic
Forum Fanatic



Joined: 29 Aug 2002

Posts: 6622
Location: Connecticut, USA


flag
PostPosted: Thu Jun 05, 2014 7:08 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

The code looks ok. Is the report set to use a specific job server?

If you go into CMC, select the instance that's generated by this script, and reschedule it (still in CMC), does it work?
Back to top
kpavan999
Forum Member
Forum Member



Joined: 26 Jan 2011

Posts: 10



PostPosted: Thu Jun 05, 2014 7:13 am 
Post subject: Re: Rescheduling the report using BO SDK jsp

It is now resolved, posting the solution for the benefit of others....

I just changed the order of below 2 commands

Code:

           oSched.getSchedulingInfo().setRightNow(true);
           oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);


as

Code:

           oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);
           oSched.getSchedulingInfo().setRightNow(true);


Thank you Joepeters for your help so far.
Back to top
satheesh_rvs
Forum Member
Forum Member



Joined: 02 May 2019

Posts: 7



PostPosted: Thu May 02, 2019 1:17 pm 
Post subject: Re: Rescheduling the report using BO SDK jsp

Hello All,

i am using the above thread for developing a script to re-run a failed job in BOE BI . am creating a vb script . i got stuck with how to write the below JSp code to VBs . Please help with key words to achieve the below 3 steps in VBS.

IInfoObject oSched = (IInfoObject) oScheds.get(0);
oSched.getSchedulingInfo().setRightNow(true);
oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);
Back to top
joepeters
Forum Fanatic
Forum Fanatic



Joined: 29 Aug 2002

Posts: 6622
Location: Connecticut, USA


flag
PostPosted: Thu May 02, 2019 2:02 pm 
Post subject: Re: Rescheduling the report using BO SDK jsp

Code:
Dim oSched as IInfoObject
oSched = oScheds(1)
oSched.SchedulingInfo.RightNow = True
oSched.SchedulingInfo.Type = ceScheduleTypeOnce
Back to top
satheesh_rvs
Forum Member
Forum Member



Joined: 02 May 2019

Posts: 7



PostPosted: Thu May 02, 2019 4:01 pm 
Post subject: Re: Rescheduling the report using BO SDK jsp

Hello Joe,

Thank a lot for your timely help . Since am new to this topic , could you please validate the below VBS script which will help me to push it confidently in server . Also let me know whether SDK needed for running this VB script .
Code:


strComputerName = CreateObject("WScript.Network").ComputerName

On Error Resume Next

Set SessionManager = CreateObject("CrystalEnterprise.SessionMgr")
    Set esession = SessionManager.Logon("USERNAME", "PASSWORD", strComputerName, "secEnterprise")
    Set oInfoStore = esession.Service("", "InfoStore")
  set oScheds = oInfoStore.Query("select top 1 * from ci_infoobjects where   si_recurring=1 and SI_NAME='"TESTJOB"'"")

oSched = oScheds(1)
oSched.SchedulingInfo.RightNow = True
oSched.SchedulingInfo.Type = ceScheduleTypeOnce

while(oSched.SchedulingInfo.Dependencies.size > 0)
               oSched.SchedulingInfo.Dependencies.remove(0)
wend
         
   oInfoStore.schedule(oScheds)

SessionManager.logoff

WScript.Quit
Back to top
satheesh_rvs
Forum Member
Forum Member



Joined: 02 May 2019

Posts: 7



PostPosted: Fri May 03, 2019 2:15 pm 
Post subject: Re: Rescheduling the report using BO SDK jsp

@joepeters
Can some one please help me for completing this sscript .
Back to top
Display posts from previous:   
Register or Login to Post    Forum Index -> SDK (VBA/ASP/JSP)  Previous TopicPrint TopicNext Topic
Page 1 of 2 All times are GMT - 5 Hours
Goto page 1, 2  Next
 
Jump to:  

Index | About | FAQ | RAG | Privacy | Search |  Register |  Login 

Get community updates via Twitter:

Not endorsed by or affiliated with SAP
Powered by phpBB © phpBB Group
Generated in 0.0962 seconds using 17 queries. (SQL 0.0023 Parse 0.0633 Other 0.0306)
CCBot/2.0 (https://commoncrawl.org/faq/)
Hosted by ForumTopics.com | Terms of Service
phpBB Customizations by the phpBBDoctor.com
Shameless plug for MomentsOfLight.com Moments of Light Logo