Customer Portal

CTL1 to CTL2 Conversion: Function 'Today' is not declared

Comments 4

  • Avatar
    imriskal
    0
    Comment actions Permalink
    Hello, wavodavo,

    firstly, I would like to recommend you using CTL2 syntax for variables in CTL2 code ($0.BirthDate vs. $out.0.BirthDate) to prevent any potential name collisions. But regarding your question, I can see possible issue in randomDate argument types. random_date in CTL1 uses dates while randomDate in CTL2 uses strings. You can find more information here:

    http://doc.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/date-functions-ctl1.html
    http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.gui.docs/docs/date-functions-ctl2.html

    Function today() is unchanged and returns date type value so to be able to use it in CTL2, you should wrap it in date2str function. By the way, randomSeed as the fourth argument exists no more in CTL2, see the second link.

    Best regards,
  • Avatar
    wavodavo
    0
    Comment actions Permalink
    Thank you for your speedy reply. I'll check the links. Consider my problem solved. If not, I'll be ba-a-a-ack. 8)
  • Avatar
    wavodavo
    0
    Comment actions Permalink
    I'm ba-a-a-ack.

    In spite of yur expert advice, I still can't complete my conversion from CTL1 to CTL2 because I'm still getting the error: Function 'today' is not declared

    I have now made my transform function as simple as possible (see below). I declare a date variable and try to assign today's date to it.

    Am I missing an import statement to point me to global date variables?

    Here is the code:

    //CTL2


    // Transforms input record into output record.
    function int transform() {

    date Tday = today();

    return 0;
    }

    // Called to return a user-defined error message when an error occurs.
    // function getMessage() {}

    // Called during component initialization.
    // function init() {}
    // Called after the component finishes.
    // function finished() {}


    I'm using the Transform Editor of IBM Initiate Workbench 9.7.0.

    The Properties for this transformer is generic (perhaps my problem)
    Basic
    Transform: //CTL2//Transforms input...
    Transform URL:
    Transform class:
    Transform source charset: ISO-8859-2 (from Dataparser DEFAULT_CHARSET_DECODER in default Properties)

    Advanced
    Error actions:
    Error log

    Visual
    Component name: MASK PII
    Description: Mask PII - Birthdate is randomized
    Location: Point(294,188)
    Size: (Dimension(0,0)

    Common
    ID: REFORMAT2
    Component type: REFORMAT
    Specification: Recevies data through input port, transforms them in a user specific way,...
    Phase: 1
    Enabled: enabled
    Pass through Input port:
    Pass through Output port:

    I appreciate your help. Thanks
  • Avatar
    imriskal
    0
    Comment actions Permalink
    Hello again,

    content of your transform() function seems OK, you do not miss anything here. But try to use integer instead of int in function signature:

    function integer transform() {
    date Tday = today();
    return 0;
    }

    If this does not help you, please, try to create some new test project (already in CTL2) and to type exactly the same code as above. It may be possible that some strange relicts persisted from the previous modifications of your CTL code.

    Best regards,

Please sign in to leave a comment.