Filling a ProDataSet - Newbie

Posted by Jeff Ledbetter on 19-Jun-2008 13:29

Hi.

I am venturing into ProDataSets for the first time so please be patient if my questions are completely silly. I have the manual here in front of me but apparently I am missing something.

I want to populate a ProDataSet. However, my query to fill one of the temp-tables seems too complex to simply define a query and use the FILL method. Is it "legal" or appropriate to handle the filling of one of the temp-tables manually?

OE 10.1C.

Thanks.

All Replies

Posted by Admin on 19-Jun-2008 13:37

Absolutyle YES!

It's one of the biggest beauties that you can fill them either way and the consumer will never know the difference... A little overhead in ABL execution is always better than a bad performing query.

Mike

Posted by rstanciu on 24-Jun-2008 09:29

Here you have an simple example to FILL a ProDS.

/* getCustomerOrdersDS.p */

DEFINE TEMP-TABLE ttCust LIKE Customer.

DEFINE TEMP-TABLE ttOrder LIKE Order.

DEFINE TEMP-TABLE ttOrdLin LIKE OrderLine.

DEFINE DATASET CustOrdLin FOR ttCust, ttOrder, ttOrdLin

DATA-RELATION CustOrd FOR ttCust, ttOrder RELATION-FIELDS(custnum, custnum)

DATA-RELATION OrdOrdLin FOR ttOrder, ttOrdLin RELATION-FIELDS (ordernum,ordernum)

.

DEFINE INPUT PARAMETER iCustomerNumber AS INTEGER NO-UNDO.

DEFINE OUTPUT PARAMETER DATASET FOR CustOrdLin.

DEF VAR retok AS LOG.

DEF VAR hCustOrdLin AS HANDLE.

DEF VAR hqCust AS HANDLE.

DEFINE QUERY qCust FOR Customer.

hqCust = QUERY qCust:HANDLE.

retok = hqCust:QUERY-PREPARE("FOR EACH Customer WHERE Customer.CustNum = " + string(iCustomerNumber)).

IF NOT retok THEN DO:

RETURN "QUERY-PREPARE failed".

END.

DEFINE DATA-SOURCE dsCust FOR QUERY qCust.

DEFINE DATA-SOURCE dsOrder FOR Order.

DEFINE DATA-SOURCE dsOrdLin FOR OrderLine.

BUFFER ttCust:handle:ATTACH-DATA-SOURCE(DATA-SOURCE dsCust:HANDLE,?,?,?).

BUFFER ttOrder:handle:ATTACH-DATA-SOURCE(DATA-SOURCE dsOrder:HANDLE,?,?,?).

BUFFER ttOrdLin:handle:ATTACH-DATA-SOURCE(DATA-SOURCE dsOrdLin:HANDLE,?,?,?).

retok = DATASET CustOrdLin:FILL().

IF NOT retok THEN DO:

RETURN ERROR "DATASET FILL failed".

END.

RETURN "OK".

This thread is closed