Monday, November 18, 2019

Code to identify data type and generate the data template

The below code will help you to generate the data template with field data type in csv file

public static void main(Args _args)
{
DictTable dictTable = new DictTable(tableNum(HcmEmployeeEntity));
FieldId fieldId = dictTable.fieldNext(0);
DictField dictField;
DictType dictType;
DictEnum dictenum;
CommaIo file;
container line;
str help;
str helpdefined;
#define.filename(@”C:\Temp\employee.csv”)
#File
file = new CommaIo(#filename, #io_write);
if (!file || file.status() != IO_Status::Ok)
{
throw error(“File cannot be opened.”);
}
while(fieldId)
{
dictField = dictTable.fieldObject(fieldId);
line = [dictField.name(), enum2Str(dictField.baseType()), dictField.label(), enum2Str(dictField.mandatory()), dictField.displayLength(),dictField.stringLen()];
file.writeExp(line);
fieldId = dictTable.fieldNext(fieldId);
}
}

No comments:

Post a Comment