Getting label attribute from a field

whwar9739

Member
I am exporting select fields in a 'FOR EACH' statement and was wondering if anyone new of a way to get print the label on the first row of the export file.
 
Try something like this:

Code:
output to c:\myfile.txt.
PUT UNFORMATTED "Name,Address,Address2,City" SKIP.
FOR EACH customer NO-LOCK:
    EXPORT DELIMITER "," Customer.NAME Customer.Address Customer.Address2 Customer.City.
END.
output close.

If you wanted the first line to look like the others, then use EXPORT rather then PUT UNFORMATTED, so your code would then be:

Code:
output to c:\myfile.txt.
EXPORT DELIMITER "," "Name" "Address" "Address2" "City".
FOR EACH customer NO-LOCK:
    EXPORT DELIMITER "," Customer.NAME Customer.Address Customer.Address2 Customer.City.
END.
output close.
 
Would there be a way to use the information from the database, such as _field._label other than doing multiple find statements?
 
Try this:

PUT UNFORMATTED BUFFER customer:BUFFER-FIELD("cust-num"):LABEL.

or
def var a as handle.

a = BUFFER customer:handle.

put unformatted a:buffer-field("cust-num"):label.

-Parul.
 
Use the Display Statement

OUTPUT TO myfile.txt.

FOR EACH customer:
DISPLAY customer.custnum customer.name customer.city.
END.

OUTPUT CLOSE.

This way it will display the column labels at the top of the file and and also take care of the formatting.

-Sunil.
 
Back
Top