Reputation: 5578
I am trying to pass a dataset as a parameter to a class, but the dataset keeps loosing it's values.
The idea is to put a customer number in the dataset, pass the dataset to the server and let the server fill the dataset with all the customer information and then pass it back to the client.
This is a unittest procedure calling the ServiceInterface in the server.
USING OpenEdge.Core.Assert.
BLOCK-LEVEL ON ERROR UNDO, THROW.
{USS/Common/Invoice/Include/dsInvoice.i}
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.
RUN USS/Server/Invoice/ServiceInterfaces.p PERSISTENT SET hProc.
TEMP-TABLE ttInvoice:TRACKING-CHANGES = TRUE.
ttInvoice.CustomerNr = CustomerNr.
TEMP-TABLE ttInvoice:TRACKING-CHANGES = FALSE.
RUN UpdateCustomer IN hProc(INPUT CustomerNr, INPUT-OUTPUT DATASET dsInvoice BY-VALUE).
Assert:Equals("MIDDELLANDBAAN 1 B", ttInvoice.DeliveryStreet).
DELETE PROCEDURE hProc.
At this moment the dataset still contains all the values. These values are passed to a Business Entity where other values should be added.
PROCEDURE UpdateCustomer:
DEFINE INPUT PARAMETER CustomerNr AS INT.
DEFINE INPUT-OUTPUT PARAMETER DATASET-HANDLE phdsInvoice.
USS.Server.Invoice.BusinessEntity.InvoiceEntity:Instance:UpdateCustomer(INPUT CustomerNr, INPUT-OUTPUT DATASET dsInvoice BY-REFERENCE).
RETURN.
END PROCEDURE.
The Business Entity is a singleton, containing an UpdateCustomer method. When the dataset is passed to this method, it is completely empty.
USING Progress.Lang.*.
USING USS.Common.Interfaces.IBusinessEntity.
USING USS.Server.Invoice.DataAccess.InvoiceBE-DA.
BLOCK-LEVEL ON ERROR UNDO, THROW.
CLASS USS.Server.Invoice.BusinessEntity.InvoiceEntity IMPLEMENTS IBusinessEntity:
{ USS\Common\Invoice\Include\dsInvoice.i &CLassAccess = "private" }
DEFINE PRIVATE VARIABLE InvoiceDA AS InvoiceBE-DA NO-UNDO.
DEFINE PRIVATE VARIABLE hDSEventHandlers AS HANDLE NO-UNDO.
DEFINE PUBLIC STATIC PROPERTY Instance AS USS.Server.Invoice.BusinessEntity.InvoiceEntity
GET.
PRIVATE SET.
CONSTRUCTOR STATIC InvoiceEntity ():
USS.Server.Invoice.BusinessEntity.InvoiceEntity:Instance = NEW USS.Server.Invoice.BusinessEntity.InvoiceEntity().
END CONSTRUCTOR.
CONSTRUCTOR PUBLIC InvoiceEntity ():
SUPER().
InvoiceDA = NEW InvoiceBE-DA().
END CONSTRUCTOR.
METHOD PUBLIC VOID UpdateCustomer(INPUT pCustomerNr AS INT, INPUT-OUTPUT DATASET dsInvoice ):
DEF VAR hUpdateCustomerService AS HANDLE NO-UNDO.
RUN USS/Server/Invoice/Services/UpdateCustomer.p PERSISTENT SET hUpdateCustomerService.
RUN UpdateCustomer IN hUpdateCustomerService (INPUT pCustomerNr, INPUT-OUTPUT DATASET dsInvoice BY-REFERENCE).
RETURN.
END METHOD.
END CLASS.
I have been working on this for a while now and I hope someone can help me figure this one out.
Upvotes: 1
Views: 1808
Reputation: 682
Yes, as Tim mentioned, you use 2 different datasets in internal procedure UpdateCustomer
in ServiceInterfaces.p
.
You can change the PARAMETER DATASET-HANDLE
to:
DEFINE INPUT-OUTPUT PARAMETER DATASET FOR dsSelectionList.
Upvotes: 1