Dynamically Assign Fields

Serge

New Member
Hello,

Can somebody please help me ... :confused:

I need to fill-up static-fields in a static-temp-table. But I want to use the static-fields dynamically. E.g:

DEF TEMP-TABLE ttTemp
FIELD supplier AS CHAR
FIELD product AS CHAR
FIELD threatm AS CHAR
FIELD dm2005 AS DEC
FIELD dm2006 AS DEC
FIELD dm2007 AS DEC.

FOR EACH Supplier WHERE ... NO-LOCK:

CREATE ttTemp.
ASSIGN ttTemp.supplier = "supplier1"
ttTemp.product = "product x"
ttTemp.threatm = "Threatm x".

ASSIGN ttTemp.dm + STRING(Supplier.Year) = ttTemp.dm + STRING(Supplier.Year) * Supplier.ndeliver.

END.

Is it possible to achieve something like this (marked in red)? I'm using Progress 10.1B.

I would appreciate any help...

Thanks in advance.
 

KrisM

Member
define variable hBuffer as handle.
hBuffer = temp-table ttTemp:default-buffer-handle.


Now you can use this buffer to do any dynamic access you like.
 

Serge

New Member
Thanks a lot KrisM for the quick respons... It's working :D:D:D

Result:

DEF VAR hBuffer AS HANDLE.

DEF TEMP-TABLE ttTemp
FIELD supplier AS CHAR
FIELD product AS CHAR
FIELD threatm AS CHAR
FIELD dm2005 AS DEC
FIELD dm2006 AS DEC
FIELD dm2007 AS DEC.

ASSIGN hBuffer = TEMP-TABLE ttTemp: DEFAULT-BUFFER-HANDLE.

FOR EACH Supplier WHERE ... NO-LOCK:

CREATE ttTemp.
ASSIGN ttTemp.supplier = "supplier1"
ttTemp.product = "product x"
ttTemp.threatm = "Threatm x".

ASSIGN hBuffer:BUFFER-FIELD("dm" + STRING(Supplier.Year)):BUFFER-VALUE = hBuffer:BUFFER-FIELD("dm" + STRING(Supplier.Year)):BUFFER-VALUE * Supplier.ndeliver.

END.
 
Top