I've never used DataMatrix, but a lot of other barcode printers use similar techniques to print labels, so maybe this will help.
Produce the label in LabelView and export to a text file, as you have done but use easily-identifiable data in your fields (numbers are 0000, 1111, 2222 etc, a different number per field, letters as AAAA, BBBB, CCCC, again a different letter per field).
Read the generated text file into Progress one character at a time and store the ASCII values of each character.
Work out the structure of the label and write a program that can emulate producing that structure. Where possible, use well-named variables and functions to describe the different parts of the label.
If your label involves sending all the information to the printer in one go, then try producing a text file using your new program, comparing the text file with the original and sending the new one to the printer.
If your label involves sending a template to the printer then sending data to fill the template, try doing this first with LabelView but save the output as text and examining it to see how it is made up. You then need to generate the template and the data lines in a program, create a text file and compare it with the original before printing out.
When I do this, the first thing I do is to try to generate an exact copy of the original text file using a program. This should then work as a label. The next thing to do is to change the data in the label and produce a label with the new data. If this works, then you can abstract as much of it as possible by using input parameters/shared variables to control what data is produced by the label printing program.
If you can get hold of a manual then that will help enormously, or it should do if you can understand the manual, sometimes label printing manuals are not that clear. The manual may even have some examples that you can use.
Don't be afraid of printing 20 or 30 labels out until you get it right. That's the only real way of experimenting with labels. Try it with 1 label at a time until you get it right, then up to 2 or 3 labels and then 2 or 3 labels with different data.
It's all a bit vague, I'm afraid, but once you have a label program that works, it is fairly easy to modify it/change the data and even design a new label.
The following example is from a label printing program that uses a completely different type of label for a completely different label printer, but the principles are the same.
I'd tend to avoid writing code like this:
def var vcrlf as char no-undo.
vcrlf = chr(13) + chr(10).
put unformatted
"401200000000015" "PART NO." vCrLf
"401200000000035" "(P)" vCrLf
"401200000000135" "DESC" vCrLf.
and instead use something like this:
def var vcrlf as char no-undo.
vcrlf = chr(13) + chr(10).
run p_label_line ("4",0,15,12,"000","PART NO.").
run p_label_line ("4",0,35,12,"000","(P)").
run p_label_line ("4",0,135,12,"000","DESC").
procedure p_label_line:
def input param inp_type as char no-undo.
def input param inp_xcord as int no-undo.
def input param inp_ycord as int no-undo.
def input param inp_font_size as int no-undo.
def input param inp_extra as char no-undo.
def input param inp_info as char no-undo.
put unformatted
substring (inp_type,1,1)
string (inp_font_size,"999")
string (inp_extra,"x(3)")
string (inp_xcord,"9999")
string (inp_ycord,"9999")
string (inp_info)
vcrlf.
end procedure.
as it's easier to read, easier to maintain and easier to change/spot errors/keep consistent.