Hello,
I have tried a few combinations and I don't know why I am missing this but I am a trying to populate a field from the table and have it output to a file. It (vorigitem) does not get a value. This is a really striped down example. Thank you for any tips you can provide.
test\myfile.i}
FIND FIRST oe_items NO-LOCK WHERE
oe_items.order = 12345
NO-ERROR.
DEF VAR vorigitem AS CHAR NO-UNDO.
CREATE tt_it.
ASSIGN vorigitem = oe_items.myitem.
in the .i file
DEFINE TEMP-TABLE tt_it NO-UNDO
FIELD vorigitem like oe_items.myitem
.
ASSIGN sv_out_string =
TRIM(STRING(tt_it.vorigitem))
.
When working with include-files it is often a good idea to compile the program with preprocess, which shows how the program looks when all include-files and preprocessor variables have been textually replaced before the actual compile. (or with LISTING option, which shows the preprocessors and include references, too, in addition to the replaced text).
It looks that you are assigning the value of the temp-table field to a variable (sv_out_string) before you even create a record. I think you should get a compile error, that tt_it record is referenced before it's being read. the assign of the sv_out_string needs to come after the assign of vorigitem...
Secondly, I would strongly suggest to use a prefix to all variable names (something like lcVorigItem if inside of a procedure or function, and gcVorigItem if scoped to the whole .p). This is to avoid ambiguity between table columns and variables - you have a vorigitem as both tt-field and variable. I think it would use the variable, but I am not sure, as I started using prefixes many, many years ago, after encountering really hard to find bugs due to such ambiguities.
In your case, you are (most likely) assigning a value to the variable, not the tt-field, thus the tt-field remaining with its initial value.
Why have you got a variable and a tt field with the same name? You need to qualify the assign for the tt field to tt_it.vorigitem or else Progress will just assign it to the variable not the tt.
Another point whilst I'm typing - FIND FIRST should only be used in cases where there are multiple results and you don't care which result you get. If the result is truly unique then a simple FIND without the first will return the result, and will also fail if for some reason you get multiples. FIND FIRST will not necessarily return the same result every time depending on the scenario and you might get unexpected results.
When working with include-files it is often a good idea to compile the program with preprocess, which shows how the program looks when all include-files and preprocessor variables have been textually replaced before the actual compile. (or with LISTING option, which shows the preprocessors and include references, too, in addition to the replaced text).
It looks that you are assigning the value of the temp-table field to a variable (sv_out_string) before you even create a record. I think you should get a compile error, that tt_it record is referenced before it's being read. the assign of the sv_out_string needs to come after the assign of vorigitem...
Secondly, I would strongly suggest to use a prefix to all variable names (something like lcVorigItem if inside of a procedure or function, and gcVorigItem if scoped to the whole .p). This is to avoid ambiguity between table columns and variables - you have a vorigitem as both tt-field and variable. I think it would use the variable, but I am not sure, as I started using prefixes many, many years ago, after encountering really hard to find bugs due to such ambiguities.
In your case, you are (most likely) assigning a value to the variable, not the tt-field, thus the tt-field remaining with its initial value.