Kyle Mathers > Siebel-Integration-Com-0.02 > Siebel::Integration::Com::BusComp

Download:
Siebel-Integration-Com-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Siebel::Integration::Com::BusComp - Abstraction of Siebel Business Component

SYNOPSIS ^

        use Siebel::Integration::Com;
        
        my $sa = Siebel::Integration::Com->new(
                        ConnectionType=>'Thick', 
                        UserName=>$inputs{user}, 
                        PassWord=>$inputs{pass}, 
                        CFG=>$inputs{cfg}, 
                        DataSource=>$inputs{DataSource}
                );

        #Query for and print employee's with logins containing ADMIN
        my @Fields = ('First Name','Last Name','Login Name'); #fields to activate and print
        my $BO = $sa->GetBusObject('Employee');
        my $BC = $BO->GetBusComp('Employee');
        $BC->ClearToQuery();
        $BC->SetSearchExpr('[Login Name] LIKE "*ADMIN*"');#logins containing ADMIN
        $BC->SetViewMode('AllView');#all view mode constants can be used as strings or you can use the int value
        $BC->ActivateFields(@Fields);
        $BC->ExecuteQuery('ForwardOnly');
        if($BC->FirstRecord()){
                print "Record(s) Found\n";
                do{
                        print "Id: " . $BC->GetFieldValue('Id') . "\t";
                        foreach my $field (@Fields){
                                print "$field: " . ($BC->GetFieldValue($field) // '') . "\t";
                        }
                        print "\n";
                }while($BC->NextRecord());
                print "Record Limit Reached\n";
        }else{
                print "No Records Found\n";
        }
        
        #Create a sys preference, then delete it
        my $BOPrefs = $sa->GetBusObject('System Preferences');
        my $BCPrefs = $BOPrefs->GetBusComp('System Preferences');
        if(!$BCPrefs->NewRecord('NewBefore')){
                die print "New record failed: " . $BCPrefs->Error();
        }
        $BCPrefs->SetFieldValue('Name','Test Pref');
        $BCPrefs->SetFieldValue('Value','Test Pref Value');
        $BCPrefs->WriteRecord();
        my $PrefId = $BCPrefs->GetFieldValue('Id');
        #Delete the sys preference, could just call delete since the record is still focused, but will query for the example.
        $BCPrefs->ClearToQuery();
        $BCPrefs->SetSearchSpec('Id', $PrefId);
        $BCPrefs->ExecuteQuery('ForwardOnly');
        if($BCPrefs->FirstRecord()){
                if($BCPrefs->DeleteRecord()){
                        print "New Preference Record Deleted\n";
                }else{
                        print "Delete failed: " . $BCPrefs->Error() . "\n";
                }
        }else{
                print "Can not find record to delete!\n";
        }
        
        #Query for current user. Update the users title and associate a new position. If the position is already associated disassociate it
        my $BOEmp = $sa->GetBusObject('Employee');
        my $BCEmp = $BOEmp->GetBusComp('Employee');
        $BCEmp->ClearToQuery();
        $BCEmp->SetViewMode('AllView');
        $BCEmp->ActivateFields('Personal Title', 'First Name');
        $BCEmp->SetSearchSpec('Login Name', $sa->LoginName());#query for current user
        $BCEmp->ExecuteQuery('ForwardOnly');
        if($BCEmp->FirstRecord()){
                my ($NewTitle);
                if($BCEmp->GetFieldValue('Personal Title') =~ /Mr/){#toggle users title between Mr, and Miss
                        $NewTitle = 'Miss';
                }else{
                        $NewTitle = 'Mr';
                }
                print "Setting " . $BCEmp->GetFieldValue('First Name') . "'s title to $NewTitle\n";
                
                my $PickTitleBC = $BCEmp->GetPicklistBusComp('Personal Title');
                $PickTitleBC->ClearToQuery();
                $PickTitleBC->SetSearchSpec('Value', $NewTitle);
                $PickTitleBC->SetViewMode('AllView');
                $PickTitleBC->ExecuteQuery('ForwardOnly');
                if($PickTitleBC->FirstRecord()){
                        if(!$PickTitleBC->Pick()){
                                print "Picking title failed: " . $PickTitleBC->Error();
                        }else{
                                $BCEmp->WriteRecord();
                        }
                }else{
                        print "Can not find title " . $NewTitle . " in the picklist BC\n";
                }
                #associate proxy employee position, if already assosiated then remove.
                my $MVGBC = $BCEmp->GetMVGBusComp('Position Id');
                #find out if Proxy position already associated, if found disassociate, if not found associate
                $MVGBC->ClearToQuery();
                $MVGBC->SetSearchSpec('Id', '0-57T1J');#proxy employee
                $MVGBC->ExecuteQuery('ForwardOnly');
                if($MVGBC->FirstRecord()){
                        $MVGBC->DeleteRecord();
                        print "Removed Proxy Employee\n";
                }else{
                        my $AssocMVG = $MVGBC->GetAssocBusComp();
                        $AssocMVG->ClearToQuery();
                        $AssocMVG->SetSearchSpec('Id', '0-57T1J');#proxy employee
                        $AssocMVG->ExecuteQuery('ForwardOnly');
                        if($AssocMVG->FirstRecord()){
                                if($AssocMVG->Associate('NewBefore')){
                                        print "Associated Proxy position\n";
                                }else{
                                        print "failed to associate Proxy position\n";
                                }
                        }else{
                                print "Can not find proxy employee record!\n";
                        }
                }
                $BCEmp->WriteRecord();
        }else{
                print "Can not find employee record something is wrong!\n";
        }

DESCRIPTION ^

The Siebel::Integration::Com modules are designed to remove the different method calls and error checking between the COM Data Control and COM Data Server interfaces. Changing between the two interfaces only requires a change in the parameters to Siebel::Integration::Com->new() rather than a rewrite of all calls. Beyond just replicating the base functions of the interfaces it is hoped that additional methods will be added to these modules to extend the functionality provided by the Siebel COM framework.

All methods that have been exposed keep the same names so there is no additional learning curve, you can program in Perl using the same method names as eScript

Base Methods

BC->Error()
        Returns the error text for the last operation, returns '' if no error.
BC->ClearToQuery()
        The ClearToQuery method clears the current query
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->SetViewMode(VisibilityType)
        The SetViewMode method sets the visibility type
        This will accept the numbers as per Siebel or you can use a string version of the type
        
        SalesRepView                            => 0
        ManagerView                             => 1
        PersonalView                            => 2
        AllView                                 => 3
        OrganizationView                        => 4
        GroupView                               => 5
        CatalogView                             => 6
        SubOrganizationView                     => 7

        Example: $bc->SetViewMode('AllView') is the same as $bc->SetViewMode(3), readability would be better served by AllView
        
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->ActivateField(FieldName)
        Activates a field so that the next query on the BC will return the fields value
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->ActivateFields(FieldName, FieldName, FieldName, ....)
        Activates an array of fields so that the next query on the BC will return the fields values
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->SetSearchSpec(FieldName, FieldValue)
        Sets the search specification for the BC you can call this multiple times to setup your query
        
        Examples: 
        BC->SetSearchSpec('Id', '0-1')
        BC->SetSearchSpec('Status', " <> 'New'")
        BC->SetSearchSpec('Status', "IS NULL")

        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->SetSearchExpr(Expr)
        Sets the search expression for the BC
        
        Example: BC->SetSearchExpr('[Name] = "Bob"')
        
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->ExecuteQuery(CursorMode)
        Queries the BC based on your SearchSpec, SearchExpr and any other settings
        This will accept the numbers as per Siebel or you can use a string version of the type
        
        ForwardBackward                 => 0
        ForwardOnly                     => 1

        Example: $bc->ExecuteQuery('ForwardOnly') is the same as $bc->ExecuteQuery(1), readability would be better served by ForwardOnly
        
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->FirstRecord()
        Returns 1 if there is a record to focus or 0 if there is no record to focus on
BC->NextRecord()
        Returns 1 if there is a record to focus or 0 if there is no record to focus on
BC->GetFieldValue(FieldName)
        Returns the field value.
        Returns undef for failure. A failure will set BC->Error
BC->SetFieldValue(FieldName, Value)
        Sets the field value
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->GetMVGBusComp(FieldName)
        Returns the MVG business component releated to the input field
BC->SetSortSpec(SortSpec)
        Sets the sort spec for the BC, See BUGS/LIMITATIONS this does not seem to work
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->DeactivateFields()
        Deactivates all fields not explicity needed to form the SQL or set as force active in the BC
BC->ExecuteQuery2(CursorMode, ignoreMaxCursorSize)
        Queries the BC based on your SearchSpec, SearchExpr and any other settings
        This will accept the numbers as per Siebel or you can use a string version of the type
        
        ForwardBackward                 => 0
        ForwardOnly                     => 1

        Example: $bc->ExecuteQuery2('ForwardOnly', 1) is the same as $bc->ExecuteQuery2(1, 1), readability would be better served by ForwardOnly
        
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error

        The Thin and Thick clients expect different values for ignoreMaxCursorSize. 
        The cover method will automaticly select the appropriate inputs to the underlying ExecuteQuery2 method possible inputs are 0, 1, true, false.
BC->GetFormattedFieldValue(FieldName)
        Returns a string that contains a field value that is in the same format that the Siebel client uses or undef if there was an error. 
        A failure will set BC->Error
BC->GetNamedSearch(SearchName)
        Rerurns the search related to the input name
        Returns undef for failure. A failure will set BC->Error
BC->SetNamedSearch(searchName, searchSpec)
        Sets a named search on the BC, this can not be overriden except using scripting
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->GetSearchExpr()
        Returns the full search expression for the BC
        Returns undef for failure. A failure will set BC->Error
BC->GetSearchSpec(FieldName)
        Returns the search expression for the specified field only
        Returns undef for failure. A failure will set BC->Error
BC->GetSortSpec()
        Returns the Sort Specification for the BC. See BUGS/LIMITATIONS this does not work for thin client connections
        Returns undef for failure. A failure will set BC->Error
BC->GetViewMode()
        Rerurns the view mode of the BC, this will be an integer number
        
        SalesRepView                            => 0
        ManagerView                             => 1
        PersonalView                            => 2
        AllView                                 => 3
        OrganizationView                        => 4
        GroupView                               => 5
        CatalogView                             => 6
        SubOrganizationView                     => 7
        
        Returns undef for failure. A failure will set BC->Error
BC->LastRecord()
        Returns 1 if there is a record to focus or 0 if there is no record to focus on
BC->PreviousRecord()
        Returns 1 if there is a record to focus or 0 if there is no record to focus on
BC->RefineQuery()
        Allows you to start refining the query, use after ExecuteQuery when you do not wish to clear the existing Query information
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->ParentBusComp()
        Returns a new Siebel::Integration::Com::BusComp Object
BC->Name()
        Reruns the BC name most useful with Pick, MVG and Assoc BC's where the name is not known at creation.
BC->GetUserProperty(PropertyName)
        Returns the value of the user property. Do not confuse it with User Properties as defined in Siebel tools
        Returns undef for failure. A failure will set BC->Error
BC->SetUserProperty(PropertyName, Value)
        Sets a user property to the BC, this is effectivly a global variable. Do not confuse it with User Properties as defined in Siebel tools
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->InvokeMethod(MethodName, MethodArg1, MethodArg2, ..., MethodArgN)
        Invokes a method on the business component object
        Returns the result of the Method call if there is an error it sets BC->Error
BC->GetPicklistBusComp(FieldName)
        Returns a new Siebel::Integration::Com::BusComp object based on the input fields picklist Business Component
BC->Pick()
        Used on a picklist Business Component returned from GetPicklistBusComp to pick the selected record in to the parent Business Component
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->SetFormattedFieldValue(FieldName, FieldValue)
        Sets the field value using the local format
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->WriteRecord()
        Write changes to the database
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->DeleteRecord()
        Delete the selected record and focus on the next record
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->GetAssocBusComp()

Returns a Siebel::Integration::Com::BusComp object. Called on a MVG Business Component to get the Associate Business Component. Query the Business Component returned from this call for the record you wish to associate to the base Business Component and then call the Associate method.

BC->Associate(NewBefore/NewAfter)
        Called on an Associate Business Component as returned from GetAssocBusComp to associate the selected record to the base record
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->UndoRecord()
        Undo changes made to the Business Component
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
BC->NewRecord(NewBefore/NewAfter/etc)
        Insert a new record
        Returns 1 for success
        Returns undef for failure. A failure will set BC->Error
New(ConnectionType=>'Thin/Thick', _BO=>Siebel::Integration::Com::BusObj, SApp=>Siebel::Integration::Com)
        Only called internally from Siebel::Integration::Com::BusObj->GetBusComp()
        Returns a Siebel::Integration::Com::BusComp object
        Sets BC->Error if an error occurs

REQUIREMENTS ^

See Siebel::Integration::Com

TESTING ^

See Siebel::Integration::Com

BUGS/LIMITATIONS ^

        SetSortSpec, does not apear to work, need to prove this is the DLL. Maybe specific to Siebel version.
        GetSortSpec does not work on thin client, seems the DLL does not support it.

SEE ALSO ^

The documentation for Siebel::Integration::Com contains additional information

REFERENCES

Oracle Help Business Component Methods

AUTHOR ^

Kyle Mathers, <kyle.perl at mathersit.com>

COPYRIGHT ^

The same as Siebel::Integration::Com

VERSION ^

Version 0.02 March 2013

syntax highlighting: