Function getHeader(&rec) Returns string Local string &hdr; For &i = 1 To &rec.FieldCount SQLExec("select label_id from psrecfield where recname = :1 and fieldname = :2", &rec.name, &rec.GetField(&i).name, &labelId); &label = &rec.GetField(&i).GetLongLabel(&labelId); If None(&label) Then &label = &rec.GetField(&i).GetLongLabel(&rec.GetField(&i).name); If None(&label) Then &label = &rec.GetField(&i).name; End-If; End-If; &header = &header | """" | &label | """"; If &i < &rec.FieldCount Then &hdr = &hdr | ","; End-If; End-For; Return &hdr; End-Function; /* main */ Local Record &recRpt = CreateRecord(Record.MCM_ADSDD_RPT); Local File &ExportFile; &ExportFile = GetFile("c:\temp\myfile.csv", "W", %FilePath_Absolute); If &ExportFile.IsOpen Then &ExportFile.WriteLine(getHeader(&recRpt)); While ... End-If;
This will first check if there is a specific label set on the record version of the field. If that value is blank it will attempt to get the label with the same name as the field itself. If there still is no value just use the field name.
No comments:
Post a Comment