|
of_keysync
|
|
Full name
|
pfc_n_cst_dwsrv_linkage.of_keysync
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_keysync(long,string,string,any)
|
Name
|
Datatype
|
lb_detailcolkey
|
boolean
|
li_i
|
integer
|
li_rc
|
integer
|
li_upperbound
|
integer
|
ll_row
|
long
|
ll_rowcount
|
long
|
ls_coldata
|
string
|
ls_detailcolumn
|
string
|
ls_expression
|
string
|
ls_filter
|
string
|
ls_find
|
string
|
ls_value
|
string
|
public function integer of_keysync (long al_row, string as_column, string as_prevvalue, any aa_newvalue);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_KeySync
//
// Access: Public
//
// Arguments:
// al_row The master datawindow row number.
// as_column The master column key that needs to be syncronized.
// as_prevvalue The previous value found on the master column
// aa_newvalue The new value.
//
// Returns: Integer
// 1 = No error found
// 0 = No action taken
// -1 = An error was found
//
// Description:
// Syncronize all detail datawindows to the new key value.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
integer li_i
integer li_rc=0
integer li_upperbound
string ls_detailcolumn=''
string ls_find
string ls_coldata
string ls_filter=''
long ll_row=0
boolean lb_detailcolkey=False
string ls_value
string ls_expression
long ll_rowcount
// Confirm that this master key column is found on this requestor.
li_upperbound = UpperBound (inv_linkargs.is_mastercolarg)
for li_i = 1 to li_upperbound
if as_column = inv_linkargs.is_mastercolarg[li_i] then
// Yes, master key column is connected to this dw.
// Get the corresponding column name for this dw.
ls_detailcolumn = inv_linkargs.is_detailcolarg[li_i]
Exit
end if
next
// Get out now if not found. (nothing to sync.)
if ls_detailcolumn = '' Then
Return 0
end if
// Determine if this detail column is a key to another detail datawindow(s).
lb_detailcolkey = (of_IsKey(ls_detailcolumn))
// Build the find string to match the master data.
for li_i = 1 to li_upperbound
if as_column = inv_linkargs.is_mastercolarg[li_i] then
ls_value = as_prevvalue
else
// Get the current value on the master dw (use the master column).
ls_value = string( idw_master.inv_Linkage.of_GetItemAny &
(al_row, inv_linkargs.is_mastercolarg[li_i]))
end If
// Build the Expresion with the Detail Column.
ls_expression = of_BuildExpression (0, inv_linkargs.is_detailcolarg[li_i], '=', ls_value)
// Build the Find statement.
If IsNull(ls_expression) or Len(Trim(ls_expression))=0 Then Continue
If ls_find <> "" Then ls_find += ' AND '
ls_find += ls_expression
next
//gnv_app.of_debug(idw_requestor.ClassName()+' Linkage.of_SyncKeys '+ &
// ' ls_find{'+ls_find+'} newvalue='+string(aa_newvalue))
// Clear out any filter currently on the dw.
If of_GetStyle() = FILTER Then
ls_filter = idw_requestor.Object.DataWindow.Table.Filter
If ls_filter <> '' And ls_filter <> '?' Then
is_filterexp = ""
idw_requestor.SetFilter("")
idw_requestor.Filter()
End If
End if
// Perform the sync. Loop row by row make the change(s).
ll_rowcount = idw_Requestor.RowCount()
DO
ll_row = idw_Requestor.Find (ls_find, ll_row, ll_rowcount)
if ll_row > 0 then
li_rc = of_SetItem(ll_row, ls_detailcolumn, String(aa_newvalue))
If li_rc <= 0 Then Return FAILURE
if lb_detailcolkey then
of_KeyChanged (ll_row, ls_detailcolumn, as_prevvalue, aa_newvalue)
end if
end if
LOOP WHILE ll_row > 0
Return li_rc
end function