Saturday 9 July 2011

article in Data Buffer Classes

Data Buffer Classes
In PeopleCode there are four data buffer classes
  1. Rowset Class
  2. Row Class
  3. Record Class
  4. Field Class
These four classes are used for accessing Component Buffer data.
Below is the Traversing Order of these classes:
Rowset -> Row -> Record -> Field
Now lets have a detail overview of these classes one by one.
  1. Rowset Class : A rowset object, instantiated from a Rowset class, is a collection of rows associated With buffer data. A component scroll is a rowset. You can also have a level 0 rowset.
If a rowset object is instantiated using the CreateRowset function, the rowset object that’s instantiated is a standalone rowset. Any records and field references created by this function are initialized to null values, that is, they do not contain any data. You can populate this rowset object using the CopyToFill, or FillAppend methods.
Built-in Functions for Rowset Class:
  1. CreateRowset
  2. GetLevel0
  3. GetRowset
The CreateRowset function creates an unpopulated, standalone rowset.
Syntax:
CreateRowset ({RECORD.recname | &Rowset} [, {FIELD.fieldnameRECORD.recname |&Rowset}] . . .)
Example : Local Rowset &RS;
&RS = CreateRowset (RECORD.QA_INVEST_DTL);
GetLevel0 creates a rowset object that corresponds to level 0 of the component buffer. This function returns a rowset object that references the base rowset. For a component, this is the level 0 of the page. For a PeopleSoft Application Engine program, this is the state record rowset. For a message, this is the base rowset.
Examle : The following code sample returns the level one rowset.
Local Rowset &ROWSET
&ROWSET = GetLevel0()(1).GetRowset(SCROLL.LEVEL1_REC);
The GetRowset function to get a rowset object based on the current context. That is, the rowset is determined from the row containing the program that is running.
Syntax :
GetRowset ([SCROLL.scrollname])
Example: In the following example, RS1 is a level 1 rowset, and RS2 is a child rowset of RS1.
Local Rowset &RS1, &RS2;
&RS1 = GetRowset();
&RS2 = GetRowset(SCROLL.EMPL_CHKLST_ITM);
With no parameters, GetRowset returns a rowset object for the rowset containing the currently running program. If a parameter is specified, it returns a rowset for that child scroll. scrollname must be the name of the primary record for the scroll.
2) Row Class: A row object, instantiated from the Row class, is a single row of data that consists of one to records of data. A single row in a component scroll is a row.
A row may have one to child rowsets. For example, a row in a level two scroll may have level three child rowsets.CopyTo and GetRecord are two commonly use methods for this class.
Visible and IsChanged are two commonly used properties for this class.
Built-in Functions :
i) GetRow
Methods :
i) CopyTo
ii) GetRecord
The GetRecord method creates a record object that references the specified record within the current row object.
Example:
&REC = &ROW.GetRecord(RECORD.QEPC_LEVEL1_REC);
Properties:
  1. Visible
  2. Ischanged
  3. Childcount
Ischabged property returns True if any field value on the primary database record of the row has been changed.
Example :
&tmp = &ROW.IsChanged;
if &tmp = True then
Warning("A Field on this row has been changed");
End-If;
ChildCount property returns the number of child rowsets of the row. It is defined by the "structure" of the scroll, so it is the same for all rows of the rowset.
It might be used, in conjunction with the GetRowset method, to write code that examines all child rowsets.
Example
For &I = 1 to &ROW.ChildCount
&ROWSET = &ROW.GetRowset(&I);
/* do processing */
End-For;
3)Record Class : record object, instantiated from the Record class, is a single instance of a data With in a row and is based on a record definition. A record object consists of one to n fields.
CopyFieldsTo is a commonly used method for the record class. NameIsChanged, and FieldCount are commonly used properties.
Built-in Functions :
  1. GetRecord
  2. CreateRecord
CreateRecord creates a standalone record definition and its component set of field objects. The specified record must have been defined previously, that is, it must have a record definition.
Example :
Local Record &REC2;
&REC2 = CreateRecord(RECORD.OPC_METH);
Methods :
  1. CopyFieldsTo
  2. CompareFields
The CopyFieldsTo method copies all like-named field values from the record object executing the method to the specified record object recordobject. This copies all field values. To copy only changed field values, use the CopyChangedFieldsTo method.
Example :
Local Record &REC, &REC2;
&REC = GetRecord(RECORD.OPC_METH);
&REC2 = CreateRecord(RECORD.OPC_METH_WORK);
&REC.CopyFieldsTo(&REC2);
The CompareFields method compares all like-named fields of the record object executing the method with the specified record object recordobject.
Example:
&REC = GetRecord(RECORD.OP_METH_VW);
&REC2 = GetRecord(RECORD.OPC_METH);
If &REC2.CompareFields(&REC) Then
WinMessage("All liked named fields have the same value");
End-If;
4)Field Class : field object, instantiated from the Field class, is a single instance of data with in a record object, and is based on a field definition.
SetDefault is a frequently used method. Name, Enabled, and Type are several commonly used field properties.
Built-in Functions :
i) GetField
GetField creates a reference to a field object for the current context; that is, from the row containing the currently executing program.
Example :
&FIELD = GetRow().recname.fieldname;
Methods :
i) SetDefault
SetDefault sets the value of the field to a null value, or to a default, depending on the type of field.
Example :
&CHARACTER.SetDefault();
Properties :
  1. Name
  2. Enabled
  3. Type
Data Buffer Classes
In PeopleCode there are four data buffer classes
  1. Rowset Class
  2. Row Class
  3. Record Class
  4. Field Class
These four classes are used for accessing Component Buffer data.
Below is the Traversing Order of these classes:
Rowset -> Row -> Record -> Field
Now lets have a detail overview of these classes one by one.
  1. Rowset Class : A rowset object, instantiated from a Rowset class, is a collection of rows associated With buffer data. A component scroll is a rowset. You can also have a level 0 rowset.
If a rowset object is instantiated using the CreateRowset function, the rowset object that’s instantiated is a standalone rowset. Any records and field references created by this function are initialized to null values, that is, they do not contain any data. You can populate this rowset object using the CopyToFill, or FillAppend methods.
Built-in Functions for Rowset Class:
  1. CreateRowset
  2. GetLevel0
  3. GetRowset
The CreateRowset function creates an unpopulated, standalone rowset.
Syntax:
CreateRowset ({RECORD.recname | &Rowset} [, {FIELD.fieldnameRECORD.recname |&Rowset}] . . .)
Example : Local Rowset &RS;
&RS = CreateRowset (RECORD.QA_INVEST_DTL);
GetLevel0 creates a rowset object that corresponds to level 0 of the component buffer. This function returns a rowset object that references the base rowset. For a component, this is the level 0 of the page. For a PeopleSoft Application Engine program, this is the state record rowset. For a message, this is the base rowset.
Examle : The following code sample returns the level one rowset.
Local Rowset &ROWSET
&ROWSET = GetLevel0()(1).GetRowset(SCROLL.LEVEL1_REC);
The GetRowset function to get a rowset object based on the current context. That is, the rowset is determined from the row containing the program that is running.
Syntax :
GetRowset ([SCROLL.scrollname])
Example: In the following example, RS1 is a level 1 rowset, and RS2 is a child rowset of RS1.
Local Rowset &RS1, &RS2;
&RS1 = GetRowset();
&RS2 = GetRowset(SCROLL.EMPL_CHKLST_ITM);
With no parameters, GetRowset returns a rowset object for the rowset containing the currently running program. If a parameter is specified, it returns a rowset for that child scroll. scrollname must be the name of the primary record for the scroll.
2) Row Class: A row object, instantiated from the Row class, is a single row of data that consists of one to records of data. A single row in a component scroll is a row.
A row may have one to child rowsets. For example, a row in a level two scroll may have level three child rowsets.CopyTo and GetRecord are two commonly use methods for this class.
Visible and IsChanged are two commonly used properties for this class.
Built-in Functions :
i) GetRow
Methods :
i) CopyTo
ii) GetRecord
The GetRecord method creates a record object that references the specified record within the current row object.
Example:
&REC = &ROW.GetRecord(RECORD.QEPC_LEVEL1_REC);
Properties:
  1. Visible
  2. Ischanged
  3. Childcount
Ischabged property returns True if any field value on the primary database record of the row has been changed.
Example :
&tmp = &ROW.IsChanged;
if &tmp = True then
Warning("A Field on this row has been changed");
End-If;
ChildCount property returns the number of child rowsets of the row. It is defined by the "structure" of the scroll, so it is the same for all rows of the rowset.
It might be used, in conjunction with the GetRowset method, to write code that examines all child rowsets.
Example
For &I = 1 to &ROW.ChildCount
&ROWSET = &ROW.GetRowset(&I);
/* do processing */
End-For;
3)Record Class : record object, instantiated from the Record class, is a single instance of a data With in a row and is based on a record definition. A record object consists of one to n fields.
CopyFieldsTo is a commonly used method for the record class. NameIsChanged, and FieldCount are commonly used properties.
Built-in Functions :
  1. GetRecord
  2. CreateRecord
CreateRecord creates a standalone record definition and its component set of field objects. The specified record must have been defined previously, that is, it must have a record definition.
Example :
Local Record &REC2;
&REC2 = CreateRecord(RECORD.OPC_METH);
Methods :
  1. CopyFieldsTo
  2. CompareFields
The CopyFieldsTo method copies all like-named field values from the record object executing the method to the specified record object recordobject. This copies all field values. To copy only changed field values, use the CopyChangedFieldsTo method.
Example :
Local Record &REC, &REC2;
&REC = GetRecord(RECORD.OPC_METH);
&REC2 = CreateRecord(RECORD.OPC_METH_WORK);
&REC.CopyFieldsTo(&REC2);
The CompareFields method compares all like-named fields of the record object executing the method with the specified record object recordobject.
Example:
&REC = GetRecord(RECORD.OP_METH_VW);
&REC2 = GetRecord(RECORD.OPC_METH);
If &REC2.CompareFields(&REC) Then
WinMessage("All liked named fields have the same value");
End-If;
4)Field Class : field object, instantiated from the Field class, is a single instance of data with in a record object, and is based on a field definition.
SetDefault is a frequently used method. Name, Enabled, and Type are several commonly used field properties.
Built-in Functions :
i) GetField
GetField creates a reference to a field object for the current context; that is, from the row containing the currently executing program.
Example :
&FIELD = GetRow().recname.fieldname;
Methods :
i) SetDefault
SetDefault sets the value of the field to a null value, or to a default, depending on the type of field.
Example :
&CHARACTER.SetDefault();
Properties :
  1. Name
  2. Enabled
  3. Type

No comments:

Post a Comment