How to use dataset as INPUT-OUTPUT to dialog form?

Posted by Tung on 15-Feb-2011 11:11

Hi

I want a form that populates two datasets, a job header and its orders, so it can display data from both datasets. Since the orders dataset isn't the primary data, I want to use another form to update that dataset and also show it as a dialog. One reason why I want the orders form to return an updated dataset, instead of committing any changes, is in case the user decides to cancel changes to both datasets.


I can pass the orders dataset as an INPUT-OUTPUT parameter and it displays the records but it doesn't pick up any changes. I know the reason why (it returns the same dataset that it got in its constructor), my question is can I do what I want to do? Or should I make changes to the datasets independent of each other?

Thanks

Tung

All Replies

Posted by MGreenwood on 25-Oct-2013 08:42

Try passing the dataset BY-REFERENCE  

. .   AS  .  . . THIS

Specifies whether to pass a TABLE, TABLE-HANDLE, DATASET, or DATASET-HANDLE parameter by value, by reference, or by binding. The default is BY-VALUE. . . . That is, the calling routine and the called routine each have their OWN INSTANCE of the object, and the parameter is deep-copied from the calling routine’s instance to the called routine’s instance.

. . .

Passing one of these parameters to a local routine using the BY-REFERENCE option allows the calling routine and the called routine to access THE SAME OBJECT INSTANCE That is, both routines access the calling routine’s instance and ignore the called routine’s instance. Since the called routine’s object instance is ignored, you should define the static object as reference-only by specifying the REFERENCE-ONLY option in the DEFINE statement for the object.

Posted by MGreenwood on 25-Oct-2013 09:51

HOWEVER . . .

Having just written something to pass a dataset as INPUT-OUTPUT

The very first time this is executed the dataset temp-table is received empty ?

Press the button to call the dialogue a second time and the dataset is populated !

Now I am looking for some help . . .

Or I can go straight to plan B and I could INPUT a temp table, OUTPUT a different  temp table and do my processing in the client window

Posted by MGreenwood on 28-Oct-2013 09:25

So here's how we solved this issue.

IS THERE A BETTER WAY ?  Youy would think so but this is the solution that we got working

Since INPUT-OUTPUT does not work under Progress when executing a Dialogue box.

What does work is to pass a temp-table as an input to the Dialogue

on OK invoke a method in the  calling "Parent" window which accepts as an input a temp-table.  

i.e.

Parent.cls

==========

   MyDialogue = NEW Dialogue(INPUT THIS-OBJECT,  /* our base object */

                                                    /* This is the object we will DYMAMIC-CAST to  Parent.cls*/

                                                    INPUT ENTRY(1, THIS-OBJECT:ToString(),","),

                                                    INPUT   TABLE tt-InputTable ).

   METHOD PUBLIC VOID DialogueUpdateComplete(INPUT TABLE  ttReturnTable  ).

   FOR EACH ttReturnTable:

               DoStuff().    /*Update data in the parent*/

     END.

     doRefreshAGrid().    /*Display updated data in the parent*/

   RETURN.

 END METHOD.

Dialogue.cls

=========

 DEFINE PRIVATE VARIABLE lvsThisCallingProgram AS Parent.cls NO-UNDO.  

CONSTRUCTOR PUBLIC Dialogue

                                                (INPUT       lvsCallingProgram AS CLASS Parent.cls,

                                                 INPUT       lvcCallingObjectReference AS CHARACTER,

                                                 INPUT TABLE InputTable ):

  SUPER().

   /*Get a handle to the Parent window that called this Dialogue*/

   THIS-OBJECT:lvsThisCallingProgram  = DYNAMIC-CAST(lvsCallingProgram, lvcCallingObjectReference).

    InitializeComponent ( ).

   . . .

END CONSTRUCTOR.

. . .

/*------------------------------------------------------------------------------

     Purpose:                                      

     Notes:                                      

 ------------------------------------------------------------------------------*/

  METHOD PRIVATE VOID okButton_Click (sender AS System.Object, e AS System.EventArgs):

   doSendTempTableToCallingProgram().

 THIS-OBJECT:DialogResult = System.Windows.Forms.DialogResult:Ok.

 THIS-OBJECT:Close ( ).

END METHOD.

/*------------------------------------------------------------------------------

 Purpose: A call to a Method in the Parent program that called this dialogue which accepts the updated temp table

------------------------------------------------------------------------------*/

METHOD PUBLIC VOID doSendTempTableToCallingProgram(  ).

   lvsThisCallingProgram:DialogueUpdateComplete(INPUT TABLE ttBO_SuGrDefaultValues).

 END METHOD.

Posted by Frank Meulblok on 28-Oct-2013 11:34

Going off the top of my head here, but it looks like what you want to do is to pass the dataset/table as an INPUT ... BIND parameter to the dialog's constructor.

That way, the dialog will refer to the instance of the calling form for it's entire lifetime.

This thread is closed