Hi,
Could you to guide me how can I built a code but applying variable values to &GLOBAL-DEFINE?
As far I understood &GLOBAL-DEFINE works in a Static concept but why this peace of code works?
/*** Works OK *****/
def var yvar as int .
def var zvar as int.
def var vdepo as int.
def var tmp-start-date as date initial 04/01/08.
def var tmp-end-date as date initial 04/30/08.
find first depot no-lock no-error.
disp depo.
assign vdepo = int(depot.depo).
&GLOBAL-DEFINE last-value vdepo
yvar = {&last-value}.
zvar = {&last-value}.
message vdepo yvar zvar.
/*** Works OK *****/
Note: the values for yvar and zvar comes with the value of vdepo. That's great.
But when I try to go forward using :
&IF ( INT({&last-value}) = vdepo )
Brings me the message: Invalid use of nonconstant elements in preprocessor expression. (2965)
/*** It does NOT work Ok ****/
FOR EACH ledger WHERE ledger.ledger-ind = "s" and
ledger.co-code = 'bwg' no-lock:
disp ledger.co-code
ledger.ledger-code.
&IF ( INT({&last-value}) = vdepo )
&THEN
FOR EACH sltran WHERE sltran.co-code = ledger.co-code
AND sltran.ledger-code = ledger.ledger-code
AND sltran.doc-date GE tmp-start-date
AND sltran.doc-date LE tmp-end-date NO-LOCK
USE-INDEX doc-date:
message "first for each".
pause.
&ELSE
FOR EACH sltran WHERE sltran.co-code = ledger.co-code
AND sltran.ledger-code = ledger.ledger-code
AND sltran.entry-date GE tmp-start-date
AND sltran.entry-date LE tmp-end-date NO-LOCK
USE-INDEX entry-date1 :
message "second for each".
pause.
&ENDIF
END.
/*** It does NOT work Ok ****/
Although the message:
Brings me the message: Invalid use of nonconstant elements in preprocessor expression. (2965)
is a warning message, the second piece is ignored...
This is needed because I want to make different conditions and indexes for for each depending of variable vdepo.
Thanks in advance,
Regards,
Could you to guide me how can I built a code but applying variable values to &GLOBAL-DEFINE?
As far I understood &GLOBAL-DEFINE works in a Static concept but why this peace of code works?
/*** Works OK *****/
def var yvar as int .
def var zvar as int.
def var vdepo as int.
def var tmp-start-date as date initial 04/01/08.
def var tmp-end-date as date initial 04/30/08.
find first depot no-lock no-error.
disp depo.
assign vdepo = int(depot.depo).
&GLOBAL-DEFINE last-value vdepo
yvar = {&last-value}.
zvar = {&last-value}.
message vdepo yvar zvar.
/*** Works OK *****/
Note: the values for yvar and zvar comes with the value of vdepo. That's great.
But when I try to go forward using :
&IF ( INT({&last-value}) = vdepo )
Brings me the message: Invalid use of nonconstant elements in preprocessor expression. (2965)
/*** It does NOT work Ok ****/
FOR EACH ledger WHERE ledger.ledger-ind = "s" and
ledger.co-code = 'bwg' no-lock:
disp ledger.co-code
ledger.ledger-code.
&IF ( INT({&last-value}) = vdepo )
&THEN
FOR EACH sltran WHERE sltran.co-code = ledger.co-code
AND sltran.ledger-code = ledger.ledger-code
AND sltran.doc-date GE tmp-start-date
AND sltran.doc-date LE tmp-end-date NO-LOCK
USE-INDEX doc-date:
message "first for each".
pause.
&ELSE
FOR EACH sltran WHERE sltran.co-code = ledger.co-code
AND sltran.ledger-code = ledger.ledger-code
AND sltran.entry-date GE tmp-start-date
AND sltran.entry-date LE tmp-end-date NO-LOCK
USE-INDEX entry-date1 :
message "second for each".
pause.
&ENDIF
END.
/*** It does NOT work Ok ****/
Although the message:
Brings me the message: Invalid use of nonconstant elements in preprocessor expression. (2965)
is a warning message, the second piece is ignored...
This is needed because I want to make different conditions and indexes for for each depending of variable vdepo.
Thanks in advance,
Regards,