Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Modified Java Script Step: Generation number

  1. #1

    Default Modified Java Script Step: Generation number

    Hi
    Say I get 3 fields from the DWH
    startDate
    endDate
    ReportName

    Is it possible using the Modified Java Script step to create another field that increases a number by one each time the transformation is run? Lets call this ReportRef. This will be output to Ms Excel so you'd have, for example, the first run as:

    startDate: 2011-09-01
    endDate: 2011-09-07
    ReportName: test Report Operational name
    ReportRef: TRO9200

    and, the second run as:
    startDate: 2011-09-07
    endDate: 2011-09-14
    ReportName: test Report Operational name
    ReportRef: TRO9201

    At the moment, the ReportRef is defined in the Add Constant step as equals to 1. So, in short, how does one increment this value for each time the transformation is run?

    Your advise is much appreciated! Looking forward! Thanks!

  2. #2
    Join Date
    Nov 2008
    Posts
    271

    Default

    Hi dat789,
    I don't think you can do this entirely on the fly, because you need to store somewhere this reference. For this purpose you can either access the excel file and retrieve the last transformation data (included your ReportRef) and do some manipulating to increment it by one (via MJSV or User Defined Java Expression, or Calculator...) or
    exploiting kettle's logging features: CTRL+T in the transformation screen and choose the logging tab; configure it and select at least ID_BATCH. It will be incremented by 1 for each run.

    HTH
    Andrea Torre
    twitter: @andtorg

    join the community on ##pentaho - a freenode irc channel

  3. #3

    Default

    Hi,
    Say we'll go for the latter -- kettle's logging feature. The ID_BATCH (Logging tab / Transformation) is checked but the step name is grey out. Can I ask, please, how does one get the ID_BATCH available in the stream for, say, the SELECT step? Would you mind? thanks!



    dat789
    Last edited by dat789; 09-19-2011 at 04:48 AM. Reason: added picture

  4. #4
    Join Date
    Nov 2008
    Posts
    271

    Default

    Hi,
    you can access the ID_BATCH field via Get System Info step. You can find it in Input section. Define a fieldname using, as type, "trasformation batch id".
    You can even monitor the ID_Batch value in Execution Results window, in Trasformation log table (refresh it after execution).

    Cheers
    Andrea Torre
    twitter: @andtorg

    join the community on ##pentaho - a freenode irc channel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.