Table of Contents

Search

  1. Preface
  2. Working with Transformations
  3. Aggregator Transformation
  4. Custom Transformation
  5. Custom Transformation Functions
  6. Data Masking Transformation
  7. Data Masking Examples
  8. Expression Transformation
  9. External Procedure Transformation
  10. Filter Transformation
  11. HTTP Transformation
  12. Identity Resolution Transformation
  13. Java Transformation
  14. Java Transformation API Reference
  15. Java Expressions
  16. Java Transformation Example
  17. Joiner Transformation
  18. Lookup Transformation
  19. Lookup Caches
  20. Dynamic Lookup Cache
  21. Normalizer Transformation
  22. Rank Transformation
  23. Router Transformation
  24. Sequence Generator Transformation
  25. Sorter Transformation
  26. Source Qualifier Transformation
  27. SQL Transformation
  28. Using the SQL Transformation in a Mapping
  29. Stored Procedure Transformation
  30. Transaction Control Transformation
  31. Union Transformation
  32. Unstructured Data Transformation
  33. Update Strategy Transformation
  34. XML Transformations

Transformation Guide

Transformation Guide

Step 3. Fill Out the Method Stub with Implementation

Step 3. Fill Out the Method Stub with Implementation

The final step is coding the procedure.
  1. Open the
    <Procedure_Name>
    .cpp stub file generated for the procedure.
    In the BankSoft example, you open fv.cpp to code the TxINF_BankSoft::FV procedure.
  2. Enter the C++ code for the procedure.
    The following code implements the FV procedure:
    INF_RESULT TxINF_BankSoft::FV() {   // Input port values are mapped to the m_pInParamVector array in   // the InitParams method. Use m_pInParamVector[i].IsValid() to check   // if they are valid. Use m_pInParamVector[i].GetLong or GetDouble,   // etc. to get their value. Generate output data into m_pOutParamVector.   //  TODO: Fill in implementation of the FV method here.     ostrstream ss;     char* s;     INF_BOOLEAN bVal;     double v;     TINFParam* Rate = &m_pInParamVector[0];     TINFParam* nPeriods = &m_pInParamVector[1];     TINFParam* Payment = &m_pInParamVector[2];     TINFParam* PresentValue = &m_pInParamVector[3];     TINFParam* PaymentType = &m_pInParamVector[4];     TINFParam* FV = &m_pOutParamVector[0];     bVal =       INF_BOOLEAN(         Rate->IsValid() &&         nPeriods->IsValid() &&         Payment->IsValid() &&         PresentValue->IsValid() &&         PaymentType->IsValid()       );     if (bVal == INF_FALSE)     {       FV->SetIndicator(INF_SQL_DATA_NULL);       return INF_SUCCESS;     }     v = pow((1 + Rate->GetDouble()), (double)nPeriods->GetLong());     FV->SetDouble(       -(          (PresentValue->GetDouble() * v) +          (Payment->GetDouble() *            (1 + (Rate->GetDouble() * PaymentType->GetLong()))) *          ((v - 1) / Rate->GetDouble())       )     );     ss << "The calculated future value is: " << FV->GetDouble() <<ends;     s = ss.str();     (*m_pfnMessageCallback)(E_MSG_TYPE_LOG, 0, s);     (*m_pfnMessageCallback)(E_MSG_TYPE_ERR, 0, s);     delete [] s;     return INF_SUCCESS; }
    The Designer generates the function profile, including the arguments and return value. You need to enter the actual code within the function, as indicated in the comments. Since you referenced the POW function and defined an
    ostrstream
    variable, you must also include the preprocessor statements:
    On Windows:
    #include <math.h> #include <strstream> using namespace std;
    On UNIX, the include statements would be the following:
    #include <math.h> #include <strstream.h>
  3. Save the modified file.

0 COMMENTS

We’d like to hear from you!