Description
PowerBuilder provides four functions for synchronizing DataWindows and DataStores in a distributed application:
-
GetFullState
-
SetFullState
-
GetChanges
-
SetChanges
These four functions use a BLOB (Binary Large Object) parameter to store the state information of a DataWindow or DataStore, but Web applications that use JavaScript, such as Appeon, do not support the BLOB data type.
Workaround
To work around the unsupported features (the BLOB parameter) in GetFullState, SetFullState, GetChanges and SetChanges, Appeon has provided two standard user objects: the appeondatawindow that inherits from the PowerBuilder system DataWindow control, and the appeondatastore that inherits from the PowerBuilder system DataStore object.
These two objects have user-defined functions (GetFullState, SetFullState, GetChanges and SetChanges) that override the original DataWindow/DataStore GetFullState, SetFullState, GetChanges and SetChanges, with a parameter of the String data type.
When coding distributed DataWindow/DataStores for Appeon Web migration, always use the descendants of appeondatawindow and appeondatastore, and the overriding GetFullState, SetFullState, GetChanges and SetChanges functions that take the String data type as the parameter.
Here are detailed steps on how to perform this workaround.
Example
The following workaround for the GetFullState, SetFullState, GetChanges and SetChanges functions used in the application assumes that the distributed application to be migrated is application_distribute.
Step 1: Build a new application called application_datastore in PowerBuilder to include server DataStores in application_distribute.
Step 2: Add the appeon_workarounds.pbl file to the Library Search Path of application_datastore.
Step 3: Copy the EonAXNVO.dll from the %AppeonDeveloper%\appeon_workaroundsxxxe directory (xxx indicates the corresponding PowerBuilder version) to the same directory as application_distribute.
Step 4: Search in application_distribute for the DataWindow controls that use GetFullState, SetFullState, GetChanges or SetChanges. Change the declarations of these DataWindows to make them inherit from the appeondatawindow user object.
In the following example, the unsupported SetFullState function is called in the Constructor event of the dw_1 DataWindow in the w_main Window:
long ll_rc blob lbob_1 nvo_update lnvo_1 ll_rc = myconnect.CreateInstance(lnvo_1,"p_nvo_update1/nvo_update") IF ll_rc <> 0 THEN MessageBox("Create instance failed", ll_rc) END IF lbob_1 = lnvo_1.of_getdata1("d_order_master_four") IF not IsNull(lbob_1) THEN dw_1.SetFullState(lbob_1) ELSE MessageBox("", "Getting data failed.") END IF
To re-write the previous unsupported code:
Change the declaration of dw_1 DataWindow by editing the source code of the w_main Window.
Right-click on w_main in the System Tree and choose Edit Source from the context menu. The Source Editor window opens and displays the source code of the w_main Window.
Replace the script “type dw_1 from datawindow within w_main” with “type dw_1 from appeondatawindow within w_main”.
Save the source code and close the Source Editor window for the w_main Window object.
Step 5: Search in appeon_datastore for the DataStore objects that use GetFullState, SetFullState, GetChanges or SetChanges. Change the declarations of these DataStores to make them inherit from the appeondatastore user object.
The following is the script for the of_getdata1 function of the nvo_update user object that is called in Step 3. The function creates a DataStore, retrieves data, and uses the unsupported GetFullState function to get and return the state of the DataStore:
public function blob of_getdata1 (string as_dataobject); blob lbob_1 long ll_return datastore lds_1 lds_1 = Create datastore lds_1.DataObject = as_dataobject lds_1.SetTransObject(sqlca) lds_1.Retrieve() ll_return = lds_1.GetFullState(lbob_1) IF IsNull(ll_return) or ll_return < 0 THEN SetNull(lbob_1) END IF Destroy lds_1 Return lbob_1 end function
Modify the function return value to be the String data type, and re-declare the lds_1 DataStore as appeondatastore. The changed code is shown as follows:
public function string of_getdata1 (string as_dataobject); string ls_fullstate long ll_return appeondatastore lds_1 lds_1 = Create appeondatastore lds_1.DataObject = as_dataobject lds_1.SetTransObject(sqlca) lds_1.Retrieve() ll_return = lds_1.GetFullState(ls_fullstate) IF IsNull(ll_return) or ll_return < 0 THEN SetNull(ls_fullstate) END IF Destroy lds_1 Return ls_fullstate end function
After applying this workaround, migrate the entire application to the Web using Appeon. For detailed steps, refer to the the section called “Migrating distributed applications with distributed DataWindows” in Migration Guidelines for Appeon Web (Web only).