I have been trying to solve this for a couble of days.
Can anyone help me please?
I create a dynamic temp-table with fields according to the user's selection from a selection-list. The name of these fields are assigned to the same value as the fields of an other temp-table (not dynamic). I need to match the fields in the dynamic temp-table with the ones in the temp-table and assign the value of the temp-table field to the dynamic temp-table field.
The code goes like this:
DEFINE VARIABLE hTable AS HANDLE NO-UNDO.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hBufferField AS HANDLE NO-UNDO.
DEFINE VARIABLE hBrowse AS HANDLE NO-UNDO.
DEFINE VARIABLE hCol AS HANDLE NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
CREATE WIDGET-POOL.
/************ Create a dynamic temp-table object **********/
CREATE TEMP-TABLE hTable.
hTable:ADD-NEW-FIELD( "sino", "char", ?, "x(10)", ?, "CREWID", "CREWID").
hTable:ADD-NEW-FIELD( "lname", "char", ?, "x(20)", ?, "LAST NAME", "LAST NAME").
hTable:ADD-NEW-FIELD( "fname", "char", ?, "x(20)", ?, "FIRST NAME", "FIRST NAME").
hTable:ADD-NEW-FIELD( "nation", "char", ?, "x(5)", ?, "NATION", "NATION").
hTable:ADD-NEW-FIELD( "rank", "char", ?, "x(10)", ?, "RANK", "RANK").
DO cnt = 1 TO NUM-ENTRIES(report-items) WITH FRAME {&FRAME-NAME}:
itm[cnt] = ENTRY(cnt,report-items).
hTable:ADD-NEW-FIELD( ENTRY(cnt,report-items), "char", ?, "x(10)", ?, ENTRY(cnt,report-items), ENTRY(cnt,report-items)).
END.
hTable:TEMP-TABLE-PREPARE('report').
/************** Create the dynamic query object ************/
CREATE QUERY hQuery.
CREATE BUFFER hBuffer FOR TABLE hTable
EFAULT-BUFFER-HANDLE.
hQuery:SET-BUFFERS(hBuffer).
hQuery:QUERY-PREPARE('FOR EACH report no-lock').
/** THE PROBLEM IS DOING THIS **/
FOR EACH mytable,
FIRST srch-table WHERE srch-table.sino = mytable.mtsino:
hBuffer:BUFFER-CREATE().
DO i = 1 TO hBuffer:NUM-FIELDS:
HERE I NEED TO ASSIGN THE VALUES OF MyTable TO THE CORRECT FIELD OF hBuffer .
END.
end.
Then I need to open the data of the hBuffer
Any ideas?
Can anyone help me please?
I create a dynamic temp-table with fields according to the user's selection from a selection-list. The name of these fields are assigned to the same value as the fields of an other temp-table (not dynamic). I need to match the fields in the dynamic temp-table with the ones in the temp-table and assign the value of the temp-table field to the dynamic temp-table field.
The code goes like this:
DEFINE VARIABLE hTable AS HANDLE NO-UNDO.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hBufferField AS HANDLE NO-UNDO.
DEFINE VARIABLE hBrowse AS HANDLE NO-UNDO.
DEFINE VARIABLE hCol AS HANDLE NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
CREATE WIDGET-POOL.
/************ Create a dynamic temp-table object **********/
CREATE TEMP-TABLE hTable.
hTable:ADD-NEW-FIELD( "sino", "char", ?, "x(10)", ?, "CREWID", "CREWID").
hTable:ADD-NEW-FIELD( "lname", "char", ?, "x(20)", ?, "LAST NAME", "LAST NAME").
hTable:ADD-NEW-FIELD( "fname", "char", ?, "x(20)", ?, "FIRST NAME", "FIRST NAME").
hTable:ADD-NEW-FIELD( "nation", "char", ?, "x(5)", ?, "NATION", "NATION").
hTable:ADD-NEW-FIELD( "rank", "char", ?, "x(10)", ?, "RANK", "RANK").
DO cnt = 1 TO NUM-ENTRIES(report-items) WITH FRAME {&FRAME-NAME}:
itm[cnt] = ENTRY(cnt,report-items).
hTable:ADD-NEW-FIELD( ENTRY(cnt,report-items), "char", ?, "x(10)", ?, ENTRY(cnt,report-items), ENTRY(cnt,report-items)).
END.
hTable:TEMP-TABLE-PREPARE('report').
/************** Create the dynamic query object ************/
CREATE QUERY hQuery.
CREATE BUFFER hBuffer FOR TABLE hTable

hQuery:SET-BUFFERS(hBuffer).
hQuery:QUERY-PREPARE('FOR EACH report no-lock').
/** THE PROBLEM IS DOING THIS **/
FOR EACH mytable,
FIRST srch-table WHERE srch-table.sino = mytable.mtsino:
hBuffer:BUFFER-CREATE().
DO i = 1 TO hBuffer:NUM-FIELDS:
HERE I NEED TO ASSIGN THE VALUES OF MyTable TO THE CORRECT FIELD OF hBuffer .
END.
end.
Then I need to open the data of the hBuffer
Any ideas?