Hi There. I would like to use PROGRAM-NAME in my server code to determine a definition during run time for later processing. For example:
IF PROGRAM-NAME(2) = ? THEN DO:
CREATE TEMP-TABLE tt1 ...
END.
ELSE DO:
CREATE TEMP-TABLE tt2 ...
END.
...
But I get a duplicate definition error when compiling. Is there a way around this error?
Sorry. That was not quite right. I really am trying to define a dataset such as:
IF PROGRAM-NAME(2) = ? THEN DO:
DEFINE TEMP-TABLE thettemptable ...
DEFINE TEMP-TABLE anothertemptable1 ...
DEFINE DATASET thedataset FOR thetemptable, anothertemptable1.
END.
ELSE DO:
DEFINE TEMP-TABLE thettemptable ...
DEFINE TEMP-TABLE anothertemptable2 ...
DEFINE DATASET thedataset FOR thetemptable, anothertemptable2.
END.
The dataset is then used in a parameter definition.
But I get a duplicate name error on thetemptable.
xternalresearch wrote:
Sorry. That was not quite right. I really am trying to define a dataset such as:
IF PROGRAM-NAME(2) = ? THEN DO:
DEFINE TEMP-TABLE thettemptable ...
DEFINE TEMP-TABLE anothertemptable1 ...
DEFINE DATASET thedataset FOR thetemptable, anothertemptable1.
END.
ELSE DO:
DEFINE TEMP-TABLE thettemptable ...
DEFINE TEMP-TABLE anothertemptable2 ...
DEFINE DATASET thedataset FOR thetemptable, anothertemptable2.
END.
The dataset is then used in a parameter definition.
But I get a duplicate name error on thetemptable.
Take a look at the dynamic creation of temp-tables and ProDatasets, together with passing these structures around as handles (or dataset-handles).
create temp-table hTT.
hTT:Add-field().
hTT:temp-table-prepare('mytt').
You can also create or add tables to a PDS on the fly/dynamically, so you can define the 2 (or more) TTs and construct your ProDataSet dynamically. Note that this can be somewhat expensive (static definitions are done at compile-time, dynamic ones at runtime), so you might also want to evaluate why you need to do this in 1 procedure/class.
-- peter