Docstoc

18EAI_DataMappingWithScripts

Document Sample
18EAI_DataMappingWithScripts Powered By Docstoc
					  Section Four: Siebel Scripting




Module 18: Data Mapping with Scripts
                                Module Objectives

     After completing this module you will be able to:
        Describe the types of integration situations that require data
         transformation by scripts rather than by the declarative DTE
        Create a business service containing a custom script to transform
         data between a Siebel application and an external application
        Write code to access input and create output integration object
         and XML Hierarchy instances
        Create EAI Value Maps and use them with the EAIGetValueMap
         and Translate methods
        Use exception handling functions in data mapping scripts


     Why you need to know
        You may need to write custom scripts for data transformation
         between a Siebel application and an external application


Module 18: Data Mapping with Scripts                                2 of 26
                When to Use Scripts for Data Mapping

   There are no integration objects to represent external metadata
   To aggregate or index multiply-occurring components

              Address     Source                Address      Target
                 Street: 123 Roe St.                Street: 123 Roe St., Apt. 4G

                 Street2: Apt. 4G
                 City: Pacifica                     City: Pacifica


   To map two or more source components, with non-trivial
    relationships, to the same target component
   To exercise programmatic control
        Example: Using if/then or case statement logic

                  Otherwise, use Siebel Data Mapper instead of scripts
             to create maps that are easy to define, maintain, and upgrade

Module 18: Data Mapping with Scripts                                               3 of 26
                         Data Transformation Tasks

  In Siebel Tools:
   Create integration objects
        Siebel integration objects to represent Siebel data
        External integration objects to represent external data
   Create a business service to hold the data transformation code
   Write the data transformation eScript code
        Use Siebel data transformation functions to build maps that:
             Transform incoming external data into the Siebel structure
             Transform outgoing Siebel data into the external system's structure




Module 18: Data Mapping with Scripts                                       4 of 26
                              Create Integration Objects

      Create a Siebel integration object based on a business object
         Use the Integration Object Builder with the EAI Siebel Wizard
      Create an external integration object based on a document
       type definition (DTD) from the external application
         Use the Integration Object Builder with an EAI wizard
                    For XML: EAI DTD Wizard – requires DTD of external XML

      EAI Siebel Wizard                                                    EAI DTD Wizard



       Business                  Siebel (Internal)         External
        Object                  Integration Object    Integration Object          DTD of
                                                                                 XML from
            BC                           IC                  IC
                                                                                  External
      SVF        SVF                                                             Application
                                   ICF        ICF      ICF   ICF ICF




Module 18: Data Mapping with Scripts                                                5 of 26
                          Create a Business Service

  In Siebel Tools:
                                                              Hard-coded into
  1. Create a new business service                             the specified
                                                                 C++ class
          Set the Project property
          Set the Class property to CSSEAIDTEScriptService
  2. Add a method to the Execute business service
  3. Add the following arguments to the Execute method




Module 18: Data Mapping with Scripts                                 6 of 26
                     Create a Business Service Continued

  4. Choose the Business Services Method
      object, select the new business service,
      right-click to display the pop-up menu,
      and select Edit Server Scripts



  5. Choose the (declarations) procedure of
      the (general) object, and add the line

              #include "eaisiebel.js"

                                              Include the eaisiebel.js
                                            library of helper functions




Module 18: Data Mapping with Scripts                                      7 of 26
                     Create a Business Service Continued

  6. Change the Service_PreInvokeMethod                 Execute method
                                                     (provided by workflow)
      function to be:
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
return EAIExecuteMap (MethodName, Inputs, Outputs);
}

             Passed to the myMapFn function                     Transformed
                        (next slide)                             data return
                                                                  argument




Module 18: Data Mapping with Scripts                               8 of 26
                  Write the Data Transformation Code

     The EAIExecuteMap function passes its arguments to the
      function specified in the input arguments
                  function myMapFn (objectIn, objectOut)

Transformation function name;           Input Object; object type       Output Object; object type
 passed as MapName business               set by the Input Type           set by the Output Type
       service argument                business service argument        business service argument

      Business Service
                              Function Argument Object
         Argument                                                          Description
  Input Type   Output Type    Input Object    Output Object
    Siebel       Siebel       CSSEAIInt        CSSEAIInt      Maps to and from an integration
   Message      Message        MsgIn            MsgOut         object format (such as XML)
    Siebel        XML         CSSEAIInt           XML                 Maps to external XML
   Message      Hierarchy      MsgIn            Hierarchy           (no XML integration object)
    XML          Siebel          XML           CSSEAIInt             Maps from external XML
  Hierarchy     Message        Hierarchy        MsgOut              (no XML integration object)

Module 18: Data Mapping with Scripts                                                     9 of 26
                   Data Transformation Script Actions

   Accessing an Input Integration Object instance
   Creating an Output Integration Object instance
   Accessing an Input XML Hierarchy instance
   Creating an Output XML Hierarchy instance




Module 18: Data Mapping with Scripts                    10 of 26
        Accessing an Input Integration Object: Sequence

                             CSSEAIIntMsgIn             GetArgument()      Business
                            (Passed Input Object)                           Service
                                                                          Arguments
                                        GetIntObj()

Exists()
                              CSSEAIIntObjIn
FirstInstance()         (Integration Object Instance)
NextInstance()
                                        GetPrimaryIntComp()

Exists()               CSSEAIPrimaryIntCompIn           GetFieldValue()   Integration
FirstRecord()                (Primary Integration                         Component
NextRecord()                Component Instance)                              Fields

                                             GetIntComp()
Exists()                                                                  Integration
FirstRecord()               CSSEAIIntCompIn             GetFieldValue()
                                                                          Component
NextRecord()               (Integration Component                            Fields
                                   Instance)


Module 18: Data Mapping with Scripts                                          11 of 26
           Accessing an Input Integration Object: Code

  function myMapFn (ObjectIn, ObjectOut) {
       inIntObj = ObjectIn.GetIntObj(); //Get integration object
       //Iterate over all integration object instances
       While (inIntObj.NextInstance()) {
           //Get the primary component which is called "Quote"
           primaryIntComp = inIntObj.GetPrimaryIntComp("Quote");
           //Iterate over all instances of the primary component
           while (primaryIntComp.NextRecord()) {
              Quote Id = primaryIntComp.GetFieldValue ("Id");
              //Get component Quote Item which is child of Quote
              comp = primaryIntComp.GetIntComp ("Quote Item");
              //Process component similar to primary component
              while (comp.NextRecord()) {
                      Quote Item Id = comp.GetFieldValue ("Id");

Module 18: Data Mapping with Scripts                               12 of 26
        Creating an Output Integration Object: Sequence

                             CSSEAIIntMsgOut             SetArgument()      Business
                            (Passed Output Object)                           Service
                                                                           Arguments
                                        CreateIntObj()
NewInstance()
                              CSSEAIIntObjOut
                         (Integration Object Instance)

                                        CreatePrimaryIntComp()

NewRecord()
                       CSSEAIPrimaryIntCompOut           SetFieldValue()   Integration
                              (Primary Integration                         Component
                             Component Instance)                              Fields

                                              CreateIntComp()
NewRecord()                                              SetFieldValue()   Integration
                            CSSEAIIntCompOut                               Component
                           (Integration Component                             Fields
                                   Instance)


Module 18: Data Mapping with Scripts                                          13 of 26
            Creating an Output Integration Object: Code

  function myMapFn (ObjectIn, ObjectOut) {
       outIntObj = ObjectOut.CreateIntObj("Sample Quote");
       while (need new integration object instance) {
            outIntObj.NewInstance();
            //Create primary integration component called "Quote"
            primaryIntComp = inIntObj.CreatePrimaryIntComp("Quote");
            while (need new primary integration component instance) {
              primaryIntComp.NewRecord();
              primaryIntComp.SetFieldValue ("Id", Quote Id);
              //Create component Quote Item, a child of Quote
              comp = primaryIntComp.CreateIntComp ("Quote Item");
              //Process component similar to primary component
              while (need new integration component instance) {
                      comp.NewRecord();
                      comp.SetFieldValue ("Id", Quote Item Id);

Module 18: Data Mapping with Scripts                                14 of 26
          Accessing an Input XML Hierarchy: Sequence

              XML Hierarchy
               (Input Passed)

                         XPSGetRootElement()        XPSGetTagName()
                                                                        Tag Name
                                                    XPSGetTextValue()
           XML Root Element                                              Value
                                                    XPSGetAttribute()
                                                                        Attribute
                               XPSFindChild()
                               XPSGetChild()
                               XPSGetChildCount()
                                                    XPSGetTagName()
                                                                        Tag Name

               XML Element                          XPSGetTextValue()
                                                                         Value
                                                    XPSGetAttribute()
                                                                        Attribute


Module 18: Data Mapping with Scripts                                        15 of 26
              Accessing an Input XML Hierarchy: Code

  //XML: <message><Quote Id="id">Quote Val…
  function myMapFn (ObjectIn, ObjectOut) {
       root = XPSGetRootElement(ObjectIn);
       //Find the first child of root called quote
       Quote = XPSFindChild(root, "Quote");
       //Instead of finding first, iterate over all children called
          Quote
       numberChildren = XPSGetChildCount(root);
       while (iterator < numberChildren) {
           Quote = XPSGetChild (root, iterator);
           //Skip children of root that are not Quote
           if (XPSGetTagName(Quote) != "Quote") continue;
           Quote Val = XPSGetTextValue(Quote);
           Id = XPSGetAttribute(Quote, "Id");


Module 18: Data Mapping with Scripts                            16 of 26
           Creating an Output XML Hierarchy: Sequence

              XML Hierarchy
               (Input Passed)

                         XPSCreateRootElement()   XPSSetTagName()
                                                                      Tag Name
                                                  XPSSetTextValue()
           XML Root Element                                            Value
                                                  XPSSetAttribute()
                                                                      Attribute


                               XPSAddChild()

                                                  XPSSetTagName()
                                                                      Tag Name

               XML Element                        XPSSetTextValue()
                                                                       Value
                                                  XPSSetAttribute()
                                                                      Attribute


Module 18: Data Mapping with Scripts                                      17 of 26
              Creating an Output XML Hierarchy: Code

  //XML: <message><Quote Id="id">Quote Val…
  function myMapFn (ObjectIn, ObjectOut) {
       root = XPSCreateRootElement(ObjectOut, "message");
       while (need new Quote element) {
           Quote = XPSAddChild (root, "Quote");
           XPSSetTextValue(Quote, Quote Val);
           XPSSetAttribute(Quote, "Id", id);




Module 18: Data Mapping with Scripts                        18 of 26
                 Data Transformation Script Example

     Integration object to integration object map: Maps the Siebel
      Account object to its corresponding SAP/R3 object
  Input integration object components:        Output integration object components:
  • Order Object                              • BAPI Import
    (Order - Get SAP Order Status (Siebel))     (Order - Get SAP Order Status (BAPI Input))
  • Order                                     • Import Parameters

  function GetSAPOrderStatus_SiebelToBAPI (inputMsg, outputMsg)
  {
      var iOrderObj; // Siebel Order instance                           Set up EAI Input
                                                                        Message objects
      var iOrderComp; // Order
      var oGSObj; // BAPI instance                                     Set up EAI Output
      var oGSImportComp; // Import Parameters                          Message objects
      iOrderObj = inputMsg.GetIntObj ("Order - Get SAP Order Status
       (Siebel)");                             Read an input integration object instance
      oGSObj = outputMsg.CreateIntObj ("Order - Get SAP Order Status
       (BAPI Input)");                         Write an output integration object instance

Module 18: Data Mapping with Scripts                                                 19 of 26
               Data Transformation Script Example Continued

                                                           Read integration object instances
                                                               from the EAI message
    while (iOrderObj.NextInstance ())
                                                                 Get the primary integration
    {                                  Create the object         component, “Order”, from
                                         "Get Status"
        oGSObj.NewInstance ();                                     this integration object
        iOrderComp = iOrderObj.GetPrimaryIntComp ("Order");
        oGSImportComp = oGSObj.CreatePrimaryIntComp ("Import Parameters");
        if (iOrderComp.NextRecord ())
        {                                                   Write the "Import Parameters"
                                                                      component
            oGSImportComp.NewRecord ();
            oGSImportComp.SetCopySource (iOrderComp);
            oGSImportComp.CopyFieldValue ("SALESDOC","Integration Id");
        }
    }
}


Module 18: Data Mapping with Scripts                                                 20 of 26
      Data Transformation Business Services at Run Time

     Outbound:
        Reads a Siebel integration object instance (property set)
        Writes the data into an
         external integration object         Siebel (internal)                     External
         instance (property set)            Integration Object                Integration Object
                                                     IC                               IC

     Inbound:                                  IC        IC                   IC     IC      IC
        Reads an external integration
         object instance (property set)                        Business Service
        Writes the data into a Siebel
         integration object instance
         (property set)                                        Business Service


                                              Property Set                        Property Set
                                                                   map and         Customer
                                                Contact
                                                                  transform
                                             Chris        Li                   Dr. Chris      Li


Module 18: Data Mapping with Scripts                                                       21 of 26
                                   EAI Value Maps

   Are lookup tables that relate Siebel values to corresponding
    external system values
   Direction can be:
        Siebel Inbound (lookup key is the External System Value), or
        Siebel Outbound (lookup key is the Siebel Value)




Module 18: Data Mapping with Scripts                               22 of 26
                                Using EAI Value Maps

     To return a value map, use this statement in the eScript code

         EAIGetValueMap (type, direction, unmappedKeyHandler)


              String from the          "Siebel Inbound" or         (Optional) Literal value
                 Type field             "Siebel Outbound"          or function to return if a
                                                                    key has no mapping

        Returns a CSSEAIValueMap interface object

     To find specific keys in the Type-Direction map and retrieve the
      translated values, use the interface object’s Translate method
        Example: Translate an inbound SAP Country value
  var LangMap = EAIGetValueMap ("SAP Country", "Siebel Inbound", "");
  LangMap.Translate ("TR")                   Returns "Turkey"
                                           (see previous screen)

Module 18: Data Mapping with Scripts                                                     23 of 26
                               Exception Handling

     Types of errors
        Siebel errors: fatal
               Examples: Run-time eScript errors, business service invocation
                errors, BusComp errors, errors in data transformation functions
        User errors: fatal
               Raised by calls to the EAIRaiseErrorCode function in custom maps
        Map status flags
               Custom status information placed in the output property set using the
                SetArgument method
     Exception handling functions
        EAIRaiseError (message, formatParameters)
        EAIRaiseErrorCode (errorSymbol, message)
        EAIFormatMessage (message, formatParameters)



Module 18: Data Mapping with Scripts                                          24 of 26
                                       Summary

     This module showed you how to:
        Describe the types of integration situations that require data
         transformation by scripts rather than by the declarative DTE
        Create a business service containing a custom script to transform
         data between a Siebel application and an external application
        Write code to access input and create output integration object
         and XML Hierarchy instances
        Create EAI Value Maps and use them with the EAIGetValueMap
         and Translate methods
        Use exception handling functions in data mapping scripts




Module 18: Data Mapping with Scripts                                25 of 26
                                       Lab

     In the lab you will:
        Examine and run a data mapping eScript, then review the output




Module 18: Data Mapping with Scripts                              26 of 26

				
DOCUMENT INFO
Shared By:
Stats:
views:1112
posted:2/19/2010
language:English
pages:26
Description: Siebel Enterprise Application Intergration , EAI