Pass Record as function parameter

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

iseewebpeople
Posts: 1
Joined: Thu May 23, 2019 11:08 am

Pass Record as function parameter

Postby iseewebpeople » Thu May 23, 2019 11:19 am

In my scenario I have the need to set default identical yet dynamic values on multiple output tables.

I have a global ctl file which I import into transformations.
Within this I have set up a number of maps for the fields to be written depending on type and I can then check the output metadata for those fields and write them where found with the relevant setValue function.

Now, the issue comes where I want to write these on multiple output ports as I cannot reference the ports if they don't exist on the particular reformat I'm using.

For instance:
ReformatA has 2 output ports
ReformatB has 1 output port

If my method sets $out.0 and $out.1 then Clover will throw an error initializing as ReformatB does not have 2 output ports.

So I want to pass the record itself into the method as a parameter rather than specifically write to the output port in the code, that way I can do it dynamically... problem being CTL doesn't seem to support the datatype of "record" as an input parameter.

The other option is being able to dynamically check for the connected ports within the function and handle it accordingly.

Does anyone have an idea as to how I can achieve this or am I just banging my head against a brick wall here?

For now I have created a ctl file for each input port with the exact same function in it (allbeit referencing different ports) and I then just include the ones I need but this is far from ideal as I need to import multiple ctl files each time and then use a different method name for each output port.

Any and all help much appreciated.

Cheers

Simon

andras.csore
Posts: 24
Joined: Wed Oct 24, 2018 2:38 pm

Re: Pass Record as function parameter

Postby andras.csore » Fri May 24, 2019 11:01 am

Hi Simon,

Can you add a little more details (or sample graph)... I read thru 4 times, but in don't get it ... :(
Anyhow, may GetrecordProperties helps?
https://doc.cloverdx.com/latest/designer/field-access-functions-ctl2.html#ctl2-getRecordProperties

Andrase,
Forum member (not Clover support)

cholastal
Posts: 134
Joined: Tue Sep 01, 2015 1:22 pm

Re: Pass Record as function parameter

Postby cholastal » Wed May 29, 2019 2:05 pm

Hi,

Unfortunately, there is no CTL function to dynamically detect number of component ports.

However, it is possible to work around this by using a SimpleCopy component. If you put this component behind your Reformat component, the code can be more generic and pass the output to only one record every time and the SimpleCopy will distribute it to as many edges as needed. In other words you'll detach the code from the actual graph design.

You can also send a record as a CTL function parameter. However, there is no keyword like record,therefore, you need to use metadata name to declare a record datatype as every record in CloverDX have to be described by metadata.

Both of the above is shown in the attached example project. Please try to import it into your Designer and review. Let me know if it helped you with your use case. If this is not what you're looking for, please get back to me with more details.

Best regards.
Attachments
PassRecordAsParameterInCTL.zip
(5.31 KiB) Downloaded 37 times

---
Lukas Cholasta
CloverCARE Support
CloverDX

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