Question regarding a transformation

Support/help with CloverETL (4.9) and CloverDX (5.0 or newer) implementation problems

evangeloslef
Posts: 3
Joined: Tue Mar 12, 2019 4:11 am

Question regarding a transformation

Postby evangeloslef » Tue Mar 12, 2019 4:31 am

Hello,

I am trying to create a unique ID using a specific Date format.
In my graph I use a reformat component.
In my reformat component I have some inputs 2 of them are:
- $in.0.Total --> This is the total number of records that I am passing through.
- $in.0.ID --> This record is null

What I did I created a While statement that I wanted to create a unique value in very spicific way and in that while loop to assign a each ID to the record.

The following is the while statement is what I used in the reformat:


integer i;
integer a;
integer b=getMillisecond(today(),"GMT");
integer c = $in.0.Total;
while (i != c) {

$out.0.ID =""+ getYear(today(),"GMT")+getMonth(today(),"GMT")+getDay(today(),"GMT")+getHour(today(),"GMT")+getMinute(today(),"GMT")+getSecond(today(),"GMT")+b;
i++;
b++;
};


The logic into this is that I create an ID using the format (Year,Month,Day,Hour,Minutes,Seconds,Milliseconds)

I set a parameter b that is the Milliseond.

A parameter i that will start from - and go increment by 1 until I get all the values inserted into my IDs.

A parameter c that is equal into the number of records I have so I can run the while statement that many times.

My expectation is that if I had 20 records it will get the first id = 201931232756954 and then it will increment by 1 for all the other records.

My problem is that when I use this while statement is that is assigning the same value (first ID) into all the records.

How to change this transformation in order to make it work as I want?

I attached an example of my output.
Attachments
ID.JPG
ID.JPG (14.7 KiB) Viewed 247 times

bartonv
Posts: 117
Joined: Wed May 03, 2017 12:10 pm

Re: Question regarding a transformation

Postby bartonv » Tue Mar 12, 2019 4:05 pm

Hello Evangeloslef,
I might be missing some crucial parts of your use case but from what you described, it seems there might be an easier way of how to approach this challenge. I am also a little bit on the fence as to how exactly the input data looks like. Therefore, I took the liberty of manufacturing a set of examples demonstrating various scenarios:
  1. incrementID.grf
    I assume that there is a set of data without IDs and the goal is to set the ID on each record with an incremental number at the end. Worth noting is that I took advantage of the sequences feature in CloverDX.
  2. incrementID2.grf
    This is the same idea but without using sequences but a simple incrementing variable inside the Reformat component instead.
  3. incrementID3.grf
    I don't assume the set of data and I only work with the total count. I am using the Normalizer component to create multiple IDs with the desired format based just on the input count of records.
  4. incrementID4.grf
    This is the fourth scenario that I perceived as possibly desired from your question. Again, I assume a set of data without IDs and I also assume that you would want to increment the millisecond "suffix" at the end of the ID. Worth noting is the transformation code of the Reformat component where I resolve the milliseconds separately and then add up an incremental number for each record.
Kind regards,
Attachments
incrementID4.grf
(3.35 KiB) Downloaded 20 times
incrementID3.grf
(4.17 KiB) Downloaded 21 times
incrementID2.grf
(3.23 KiB) Downloaded 21 times
incrementID.grf
(3.3 KiB) Downloaded 20 times
---
Vladimir Barton
CloverCARE Support
CloverDX

Visit us online at http://www.cloverdx.com

evangeloslef
Posts: 3
Joined: Tue Mar 12, 2019 4:11 am

Re: Question regarding a transformation

Postby evangeloslef » Wed Mar 13, 2019 8:24 pm

Hello Vladimir Barton,

That was really helpful.
Actually incrementID2 is what I needed and I now understand better how to use it next time.

Thank you for the help,

Evangelos Lefkonikiatis


cron