cancel
Showing results for 
Search instead for 
Did you mean: 

Technical exception from CO using simple API

Former Member
0 Kudos
50

I tried to use background execution callable object to dynamically modify GP due date, and I got the following exception when calling notifManager.updateNotification()

Error#1#/System/Server#Plain###

Technical exception from CO using simple API

#

Here are my code:


            // Instantiate the runtime and notification managers
            IGPRuntimeManager rtManager = GPProcessFactory.getRuntimeManager();
            logger.errorT("rtManager=" + rtManager);

            // instantiate notification manager
            IGPNotificationManager notifManager =
                GPProcessFactory.getNotificationManager();
            logger.errorT("notifManager=" + notifManager);

            // get process instance information
            IGPProcessInstance process =
                rtManager.getProcessInstance(
                    executionContext.getProcessId(),
                    executionContext.getInitiator());
            logger.errorT("process=" + process);

            // retrieve a single notification instance
            Enumeration notifications = process.getNotificationInstances();
            IGPNotificationInstance notification = null;
            logger.errorT("notification(s)=" + notifications);
            while (notifications.hasMoreElements()) {
                notification =
                    (IGPNotificationInstance) notifications.nextElement();
                logger.errorT("notification=" + notification);
            }

            String notifID = notification.getNotificationID();
            String activityID = notification.getActivityInstanceID();
            boolean dueDate = notification.isDueDateNotification();
            long createDate = notification.getCreationDate();
            IGPDeadline oldDeadline = notification.getDeadline();

            logger.errorT("notifID=" + notifID);
            logger.errorT("activityID=" + activityID);
            logger.errorT("dueDate=" + dueDate);
            logger.errorT("createDate=" + createDate);
            logger.errorT("oldDeadline=" + oldDeadline.toString());

            // create a duration of one hour
            IGPDuration duration =
                GPNotificationFactory.createDuration(
                    1,
                    IGPDuration.DURATION_HOUR);

            // create a deadline with duration one hour (start date is current system time)
            IGPDeadline newDeadline =
                GPNotificationFactory.createDeadline(
                    IGPDeadline.DEADLINE_FROM_PROCESS_START,
                    duration,
                    System.currentTimeMillis(),
                    0);
            logger.errorT("newDeadline=" + oldDeadline.toString());

            // update the status – cancel the notification
            notifManager.updateNotificationStatus(
                executionContext.getProcessId(),
                activityID,
                notifID,
                IGPNotificationInstance.NOTIFICATION_STATUS_CANCELLED);
            logger.errorT("updateNotificationStatus OK");

            notifManager.updateNotification(
                executionContext.getProcessId(),
                activityID,
                notifID,
                newDeadline);
            logger.errorT("updateNotification OK");

            executionContext.processingComplete();

In addition to that, is it possible to dynamically modify due dates set in action level? I've set due date on both process and action levels, but it seems the notification manager only retrieves notification instances in process level.

Thanks in advance!

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

All.

Is it possible to retrieve the notification associated with the action, when the background CO is called? So far I've could only retrieve the actions info with the code found in:

http://help.sap.com/saphelp_nw04s/helpdata/en/44/9b8724b05a74a2e10000000a11466f/frameset.htm

Even though this manual says that you can access the notifications from the process AND the activities and blocks that have them, when I get the notification instances from the process (process.getNotificationInstances();) this only gets the notification at a process level. I need to get the notification associated with the current action, so I can update the action's deadline and other data.

Has any one done this before or could you point me in the right direction

Former Member
0 Kudos

Hi Anish,

I probably didn't state my problem clearly.

What I wanted to do was to dynamically modify the "Due Date" information of an Action in GP. In GP design time, it's the tab where one can specify due dates (up to 3 times) and associate notification callable objects when deadline reached.

I've looked into the APIs for both Action and Activity; they seem to be able to access everything associated with actions in runtime, but no notification nor due dates....

Regards,

Jimmy

Former Member
0 Kudos

Jimmy

I'm trying to accomplish the same task you are, but with similar results. I used the logT method on the logger, instead of errorT and got a GPInvocationException a message regarding a conflict with the notification version. What I did for your code to work was to remove line that modifies the status

notifManager.updateNotificationStatus(...

because this was causing the version change. Once this line was removed, the process' notification was updated and executed after an hour. Our problem still remains, because we both want to update the calling Action (or another).

I will try to access the Action through the process' component tree, just to obtain the activity ID and use the updateNotification method.

Former Member
0 Kudos

Hi, Anish

Thanks for your hint.

I looked up the GP's API, but still couldn't find method to access to an action's due date information. Is there any?

Former Member
0 Kudos

Hi Jimmy,

If you checked the code snippet in my first reply, that is the code you got to use with some tweaking.

IGPActivity is implemented by IGPAction which provides you methods like getOutputParameters(), getInputParameters(), setOutputParameters(), setInputParameters(), to modify input output parameters related to an action.

Try the methods mentioned in the IGPActivity for more information. I think this should resolve your issue.

Regards,

Anish

Former Member
0 Kudos

Hi Jimmy,

Retrieving Information about Action’s Parameters, Result States, or Process Exceptions

IGPActionInstance instance =

rtManager.getActionInstance(processID, actionID, loggedUser);

if (instance.getTemplate().isAction()){

//the action template

IGPAction action = (IGPAction) instance.getTemplate();

//a collection of IGPAttributeInfo objects

Collection output = action.getOutputParameters().getAttributes();

Iterator itr = output.iterator();

while(itr.hasNext()){

IGPAttributeInfo attr = (IGPAttributeInfo)itr.next();

String name = attr.getTechName();

int type = attr.getType();

}

http://help.sap.com/saphelp_nw2004s/helpdata/en/fb/5e6f4169e25858e10000000a1550b0/frameset.htm

//an array of IGPResultStateInfo objects

IGPResultStateInfo[] states = action.getResultStates();

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

String resultState = states<i>.getName();

...

IGPAttribute and Attribute Info will allow you to get information of Action parameters and set and get their values.

Regards,

Anish