Hidden Work Scroll Example
In the FieldChange event for the CHECKLIST_CD field on the EMPL_CHECKLIST record, a PeopleCode program does the following:
-
Flushes the rowset and hidden work scroll area.
-
Performs a Select statement on the hidden work scroll area based on the value of the CHECKLIST_CD field and the effective date.
-
Clears the level two scroll area.
-
Copies like-named fields from the hidden work scroll area to the level two scroll area.
The following example shows how to do this using built-in functions.
&CURRENT_ROW_L1 = CurrentRowNumber(1);
&ACTIVE_ROW_L2 = ActiveRowCount(RECORD.EMPL_CHECKLIST,
&CURRENT_ROW_L1, RECORD.EMPL_CHKLST_ITM);
If All(CHECKLIST_CD) Then
ScrollFlush(RECORD.CHECKLIST_ITEM);
ScrollSelect(1, RECORD.CHECKLIST_ITEM, RECORD.CHECKLIST_ITEM,
"Where Checklist_Cd = :1 and EffDt = (Select Max(EffDt) From
PS_Checklist_Item Where Checklist_Cd = :2)",
CHECKLIST_CD, CHECKLIST_CD);
&FOUNDDOC = FetchValue(CHECKLIST_ITEM.CHKLST_ITEM_CD, 1);
&SELECT_ROW = ActiveRowCount(RECORD.CHECKLIST_ITEM);
For &I = 1 To &ACTIVE_ROW_L2
DeleteRow(RECORD.EMPL_CHECKLIST, &CURRENT_ROW_L1, RECORD.EMPL_CHKLST_ITM, 1);
End-For;
If All(&FOUNDDOC) Then
For &I = 1 To &SELECT_ROW
CopyFields(1, RECORD.CHECKLIST_ITEM, &I, 2,
RECORD.EMPL_CHECKLIST, &CURRENT_ROW_L1, RECORD.EMPL_CHKLST_ITM, &I);
If &I <> &SELECT_ROW Then
InsertRow(RECORD.EMPL_CHECKLIST, &CURRENT_ROW_L1,
RECORD.EMPL_CHKLST_ITM, &I);
End-If;
End-For;
End-If;
End-If;The following example performs the same function as the previous code, only it uses the data buffer classes:
-
Flushes the rowset and hidden work scroll area (&RS1H).
-
Performs a Select statement on &RS1H based on the value of the CHECKLIST_CD field and the effective date.
-
Clears the level two rowset (&RS2).
-
Copies like-named fields from &RS1H to &RS1.
Local Rowset &RS0, &RS1, &RS2, &RS1H; &RS0 = GetLevel0(); &RS1 = GetRowset(); &RS2 = GetRowset(SCROLL.EMPL_CHKLST_ITM); &RS1H = &RS0.GetRow(1).GetRowset(SCROLL.CHECKLIST_ITEM); &MYFIELD = CHECKLIST_CD; If All(&MYFIELD) Then &RS1H.Flush(); &RS1H.Select(RECORD.CHECKLIST_ITEM, "where Checklist_CD = :1 and EffDt = (Select Max(EffDt) from PS_CHECKLIST_ITEM Where CheckList_CD = :2)", CHECKLIST_CD, CHECKLIST_CD); For &I = 1 To &RS2.ActiveRowCount &RS2.DeleteRow(1); End-For; &FOUND = &RS1H.GetCurrEffRow().CHECKLIST_ITEM. CHKLST_ITEM_CD.Value; If All(&FOUND) Then For &I = 1 To &RS1H.ActiveRowCount ©FRMROW = &RS1H.getrow(&I); ©TROW = &RS2.getrow(&I); ©FRMROW.CHECKLIST_ITEM.CopyFieldsTo(©TROW.EMPL_CHKLST_ITM); If &I <> &RS1H.ActiveRowCount Then &RS2.InsertRow(&I); End-If; End-For; End-If; End-If;