Re: Is it possible to create fields in a loop in DataFlux Data Management Studio?

To close the loop on this thread, I got the following response from one of our architects:

It is not possible to dynamically create fields at run-time inside an Expression node in a Data Management Platform Data Job. Even a construction like the sample code below does not work as declarations of fields are handled at “compile-time” and not at run-time:

if condition

begin

// only create this field if the condition is true

string special_field

special_field=value

end

There are functions though that allow you to interact dynamically with the set of fields that are available and allows you to loop through the list of defined fields, find data type and value of a field on an index, and set values. These functions would allow you to accomplish what is described in the blog posting. More details can be found in the Expression Language Reference Guide (see http://support.sas.com/documentation/onlinedoc/dfdmstudio/index.html), and look for functions like fieldcount(), fieldname(), fieldvalue(), fieldtype() and setfieldvalue() functions.

Here is a code snippet (taken from the above mentioned reference guide):

// Declare a hidden integer for the for loop,initializing it to 0

hidden date field

hidden integer i

i = 0

hidden date Date_Field

// Checks each field to see if it is a date field

for i = 1 to FieldCount()

if FieldType(i) == 'Date' then

begin

Date_Field= FieldValue(i)

// If the date is in the future, then useSETFIELDVALUE to set the value to null

Re: Is it possible to create fields in a loop in DataFlux Data Management Studio?

To close the loop on this thread, I got the following response from one of our architects:

It is not possible to dynamically create fields at run-time inside an Expression node in a Data Management Platform Data Job. Even a construction like the sample code below does not work as declarations of fields are handled at “compile-time” and not at run-time:

if condition

begin

// only create this field if the condition is true

string special_field

special_field=value

end

There are functions though that allow you to interact dynamically with the set of fields that are available and allows you to loop through the list of defined fields, find data type and value of a field on an index, and set values. These functions would allow you to accomplish what is described in the blog posting. More details can be found in the Expression Language Reference Guide (see http://support.sas.com/documentation/onlinedoc/dfdmstudio/index.html), and look for functions like fieldcount(), fieldname(), fieldvalue(), fieldtype() and setfieldvalue() functions.

Here is a code snippet (taken from the above mentioned reference guide):

// Declare a hidden integer for the for loop,initializing it to 0

hidden date field

hidden integer i

i = 0

hidden date Date_Field

// Checks each field to see if it is a date field

for i = 1 to FieldCount()

if FieldType(i) == 'Date' then

begin

Date_Field= FieldValue(i)

// If the date is in the future, then useSETFIELDVALUE to set the value to null