11.7
Is it not possible to use &scop like this? :
THis one Works:
ProcedureA
&scop StatusNew 1
&scop StatusInWork 2
&scop StatusFinished 3
for each ..... where xxx = {&StatusNew}:
end.
__________________
THis one does not work:
myinclude.i
&scop StatusNew 1
&scop StatusInWork 2
&scop StatusFinished 3
procedureA:
for each ..... where xxx = {&StatusNew}:
end.
end.
What am I doing wrong?
In an include you must use global-defines if they should be valid outside the include file.
Does not work as in doesn't compile or doesn't run as expected?
It would be helpful to provide examples that actually compile against the sports2000 database.
This compiles for me. How is your code different? Are the contents of myinclude.i important?
ProcedureA: &scop StatusNew 1 &scop StatusInWork 2 &scop StatusFinished 3 for each customer WHERE creditlimit = {&StatusNew}: end. /*******************************/ //myinclude.i &scop StatusNew2 1 &scop StatusInWork2 2 &scop StatusFinished2 3 procedureB: for EACH customer WHERE creditlimit = {&StatusNew2}: end.
I am putting the &Scop definitions in an include file, and the including that file into my procedure...
THis is put into an includefile:
&scop StatusNew 1
&scop StatusInWork 2
&scop StatusFinished 3
&scop TypeFakturer 1
&scop TypeLagBevis 2
&Scop TypeFlyttVismaXML 3
you need global not scope define, the later work only for code in same file as far as I remember… what is wrong with it is the abbreviated form though ;)
In an include you must use global-defines if they should be valid outside the include file.
Thanks !!!!
&SCOPED-DEFINE was designed to be valid only in the file you define it in, so if you define it in an include, it is not valid outside of that include. &GLOBAL-DEFINE is valid throughout the whole compilation unit.
Besides that, I would like to urge you to restrain yourself from overusing includes. They seem very handy and they are for defining stuff like datasets or temp-tables and the like, but don't use them for real code. With that I mean with that is constructions like this:
{ find.i &table=customer &where="cust-id = 12" &lock=exclusive }
find.i
FIND {&table} WHERE {&where} {&LOCK}-LOCK NO-ERROR.
They create an unnecessary coupling of programs. By using includes in this way, you couple all programs that use it to each other, even though those programs have nothing to do with each other.
I noticed that you used it for statuses and that is OK (consider using enums!) but I just wanted to point it out.