|
of_Register
|
|
Full name
|
pfc_n_cst_lvsrv_datasource.of_Register
|
Access
|
protected
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
protected function integer of_Register(string,string,n_tr,string,string,powerobject[],datawindow,datastore,string)
|
Name
|
Datatype
|
lds_test
|
n_ds
|
li_rc
|
integer
|
ls_empty
|
string[]
|
ls_sqlerr
|
string
|
lw_parentwindow
|
window
|
protected function integer of_Register (string as_labelcolumn, string as_dwobjectname, n_tr atr_obj, string as_method, string as_sql, powerobject apo_data[], datawindow adw_control, datastore ads_control, string as_importfile);//////////////////////////////////////////////////////////////////////////////
// Protected Function: of_Register
// Arguments: as_LabelColumn The column in the DataWindow object to display as the label.
// as_DWobjectname The DataWindow object to be used for the data source.
// atr_obj The transaction object for this data source .
// as_method The Method we will use to populate the data source
// as_sql The SQL Statement to be used for the data source (if specified).
// apo_data[] The data to be used for the data source (if specified).
// adw_control The datawindow control to be used for the data source (if specified).
// ads_control The datastore control to be used for the data source (if specified).
// as_importfile The import file from which to be used for the data source (if specified).
// Returns: Integer
// 1 = the data source was added successfully
// -1 = argument validation error
// -2 = the DataWindow object did not have any key columns assigned
// -3 = no DataWindow object was provided
// -4 = one of the columns provided did not exist
// -5 = SetTransObject failed for the data source
// -6 = Error from Cache Registration
// Description: Register a data source for the ListView. The data source is a DataWindow
// object that will be linked to the ListView level and used to populate.
//////////////////////////////////////////////////////////////////////////////
// Rev. History: Version
// 6.0 Initial version
//////////////////////////////////////////////////////////////////////////////
// Copyright © 1996-1999 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_rc
string ls_sqlerr, ls_empty[]
window lw_parentwindow
n_ds lds_test
// Check arguments
if Len (as_labelcolumn) = 0 or IsNull (as_labelcolumn) or Len(as_DWobjectname) = 0 &
or IsNull (as_DWobjectname) or Len(as_method) = 0 or IsNull (as_method) then return -1
// create temporary datastore
lds_test = Create n_ds
if as_method = inv_Cache.SQL then
lds_test.Create( as_DWobjectname, ls_sqlerr )
if Len(ls_sqlerr) > 0 then
Destroy lds_test
return -1
end if
else
lds_test.DataObject = as_DWobjectname
end if
// Set data source values. label column must be in datawindow
if Trim(as_LabelColumn) <> "" And lds_test.Describe(as_LabelColumn + ".Band") = "!" then
Destroy lds_test
return -4
end if
// do not need this anymore
Destroy lds_test
// set the values in the array structure
inv_Attrib.is_DataObject = as_DWobjectname
inv_Attrib.itr_obj = atr_obj
inv_Attrib.is_Method = as_method
inv_Attrib.is_LabelColumn = as_LabelColumn
// register with cache service
li_rc = of_RegisterDataSource(as_method, as_DWobjectname, atr_obj, &
as_sql, apo_data, adw_control, ads_control, as_importfile)
if li_rc < 1 then
return -6
end if
// create a new dataobject
if IsNull(inv_Attrib.ids_Source) or not IsValid(inv_Attrib.ids_Source) then
inv_Attrib.ids_Source = Create n_ds
end if
if as_method = inv_Cache.SQL then
inv_Attrib.ids_Source.Create( as_DWobjectname, ls_sqlerr )
else
inv_Attrib.ids_Source.DataObject = as_DWobjectname
end if
// make sure transaction object is valid
if IsValid(atr_obj) then
if inv_Attrib.ids_Source.of_SetTransObject(atr_obj) <> 1 then return -5
end if
// Set parameters for the DataStore
inv_Attrib.ids_Source.of_SetBase(true)
ilv_requestor.of_GetParentWindow(lw_parentwindow)
inv_Attrib.ids_Source.of_SetParentWindow(lw_parentwindow)
// if method is dataobjectdata then we already will have the data in the datastore
// so we will delete the data and wait for it to be added by populate
if as_method = inv_Cache.DATAOBJECTDATA then inv_Attrib.ids_Source.Reset()
// Delete the columns if already exists in listview and clear column array
of_UnRegisterReportColumn()
// Add a column to the ListView for the Label
of_RegisterReportColumn(inv_Attrib.ids_Source, as_LabelColumn)
return 1
end function