Thursday 1 August 2013

Teamcenter Unified Architecture Workflow Action Handler Registration for the Task

Action Handler :
Action Handler is ITK program written to customize the task action.

Suppose we want to get some of the information from the particular task, when that task is executed in workflow in such case we register our Handler(ITK program) with the task in workflow designer. Handler will get called when task is executed. As a beginner it is difficult to write task handler , so I thought to present you with simple example of writing Action Handler. We will write Custom exit for the Handler program.

Description of Function is written as comment just above the functions .

//Call back function which is executed when library is loaded by teamcenter 
//In below function simple_custom_handlers  function is register to execute when
//library is loaded .
 extern DLLAPI int tata_register_callbacks()
{
     CUSTOM_register_exit("tata","USER_gs_shell_init_module",(CUSTOM_EXIT_ftn_t)simple_custom_handlers);
     printf("\nTata custom ets_Test_Workflow registering");
     JOURNAL_comment ("Tata custom ets_Test_Workflow registering");
         return ( ITK_ok );
}
//This function is executed from tata_register_callbacks() function above on library load
extern DLLAPI int simple_custom_handlers( int *decision , va_list args)
{
        int retcode = ITK_ok;
        retcode = ActionHandler_register_action_handlers();
        *decision  = ALL_CUSTOMIZATIONS;
        args = NULL;
        return retcode;
}
//This function is executed from simple_custom_handlers(int *decision , va_list args) function   
//above on library load in this function we have registed our Our Funciton or Handler //(ets_Test_Workflow) using EPM_register_action_handler .
int ActionHandler_register_action_handlers()
{
    int retcode = ITK_ok;
        if ( retcode == ITK_ok )
        {
                retcode = EPM_register_action_handler (
                                                        "ets_Test_Workflow",
                                                        "Description Assigned",
                                                        ets_Test_Workflow
                                                        );
printf("\nTata custom ets_Test_Workflow registering***************************");
        }
        return retcode;
}
//This function is executed at the task where you have registered it 
int ets_Test_Workflow(EPM_action_message_t msg)
{
          tag_t     *attachments      = NULLTAG;
          int n_items =0;   
          tag_t    *item_tags        = NULLTAG;
          int  noAttachment =0,t=0,R=0;
          tag_t    rootTask  = NULLTAG;
          char    *inTask    = NULL;
          int ifail =0;
          printf("\nets_Test_Workflow\n");
      /* ifail=(WSOM_find("eTS",&n_items,&item_tags));
          printf("\n  item %d \n",n_items);*/
          ifail=(EPM_ask_root_task(msg.task,&rootTask));      
          AOM_ask_value_string(msg.task,"object_name",&inTask) ;
          printf("\nInput Task Name:%s\n",inTask);fflush(stdout);
          ifail=(EPM_ask_attachments(rootTask,EPM_target_attachment,&noAttachment,&  attachments));     
     printf("Target Attachment:%d\n",noAttachment);
        return 0;
}

How to Compile :
Set MSDEV_HOME Variable if you have not done it before or set it as environment variable
1) Set MSDEV_HOME=c:\Program Files (x86)\Microsoft Visual Studio 8\VC
2) compile -DIPLIB=none eTs_Workflow.c
3) link_custom_exits tata

{Note: Parameter for link_custom_exits is library name/sitename}

Handler is written and library is generated ,to make it available in Handler pane for registration with task please refer my previous article of Teamcenter Unified Architecture Register Custom exit

WorkFlow Designer :
Now we will use workflow designer to attach Handler to Task. I am considering here that you have created a simple workflow using workflow designer .We will edit the workflow to attach our Action handler to task.

Select Process Template >> select edit mode as shown in snap below :





click ok and Part will get submitted to life cycle.

Action Handler get executed once task of workflow get executed.

Teamcenter Unified Architecture Register custom exit


Custom Exit :

Custom exit is used to write code which is basically server exit or user exit but written without affecting the other code. That means if we found something wrong is happening just because of our code we can remove immediately our code by simply removing preference from Front end TCUA Client without recompiling whole code .


Things to consider while registering custom exit :
(Here i have consider that you have successfully generated .dll custom library)
 
Add Preference : For custom exit there is need to add library using preference {Only Site Preference }
How to add : Go to Edit->option

Option window will looks like :



Please search for TC_customization_libraries in search option (highlighted above using red square box).
If no result found then click on index and then on new option which appears after we clicked on index.Refer below Snap

After selecting specified field in above snap we will get :
  

Launch teamcenter:
Statement written in sitename_register_callback funciton will appear in TAO window.  


 

Teamcenter Unified Architecture What is user exits Server exits Custom exits?



In simple terms Use exit is Already written function which we will modify as per requirement like we are changing logic of Part Revision i.e Default Part Revision is starts with “A”  we can 
 modify it to “NR”  that means  we are Modifying Already available function.

In simple terms Server exits is New function which we want to be executed on the server side when some event from Client (User Interface like Rich Client) happens.
 Eg: If we have provided Some Menu option in Rich Client to user and we want on Click event of it, some Functionality on the server side to be executed in that case we go for writing Server exit.



In simple terms Custom exits is Way to modify User Exit and Server exit to avoid unintentional changes in the code which affect the other functionality.