I have logical csv file that has been output from a WU and I need to convert it to a flat file. I would like to use the layout associated with the logical file instead of writing it by hand. The layout is stored on the ECL
attribute of the logical file and I can access it like so:
OUTPUT(STD.File.GetLogicalFileAttribute(file,'ECL'),NAMED('ECL'));
Can I parse this result into a Record definition? Or do I have to generate this through some other means. The layout is right there. I am hoping to not have to create a new definition with the same information.
Unfortunately, the straight-forward way to do this won't work. Here's my test code for that approach:
Mac_dsread(csvfilename) := FUNCTIONMACRO
recstr := NOTHOR(STD.File.GetLogicalFileAttribute(csvfilename,'ECL'));
ds := DATASET(csvfilename,#EXPAND(recstr),CSV);
RETURN ds;
ENDMACRO;
csvfile := '~RTTEST::CSVfile';
Mac_dsread(csvfile);
//Error: getlogicalfileattribute does not have FOLD specified, can't constant fold it (48, 36)
The getlogicalfileattribute() function is not designed to be called at compile time, so it generates the error message in the comment line.
If this is a one-off solution, then I suggest you just do it manually. Otherwise, the best approach would be to generate the RECORD structure string and use the NOTIFY() and EVENT() functions to pass that string on to another workunit that's waiting for that event to trigger its action.