Monday, March 14, 2011

Changing/Selecting Grid value based on Condition

The following PeopleCode can be used to change the grid value based on condition.

Local Rowset &rsGrid, &rsDataSource;

&rsGrid = GetLevel0().GetRow(1).GetRowset(SCROLL.TEST_VW);
&rsGrid.Flush();

&rsDataSource = CreateRowset(Record.TEST_VW);
&rsDataSource.Flush();
&rsDataSource.Fill(" WHERE EMPLID = :1 AND EMPL_RCD = :2 " &sEmplId,&nEmplRcd);
&rsDataSource.CopyTo(&rsGrid);

 


The following code can be used to Select grid value based on FieldChange(any condition) event.

&LVL1 = GetLevel0().GetRow(1).GetRowset(Scroll.PER_CHECKLIST);
&LVL2 = &LVL1(CurrentRowNumber()).GetRowset(Scroll.PER_CHKLST_ITM);

If &LVL2.ActiveRowCount = 1 And
&LVL2(1).IsNew And
Not &LVL2(1).IsChanged Then
Else
For &i = &LVL2.ActiveRowCount To 1 Step - 1
&LVL2.DeleteRow(&i);
End-For;
End-If;

If All(PER_CHECKLIST.CHECKLIST_CD) Then

&LVL2.SelectNew(Record.CHECKLIST_ITEM, "WHERE CHECKLIST_CD = :1 and EFFDT = (SELECT MAX(A.EFFDT) FROM PS_CHECKLIST_ITEM A WHERE A.CHECKLIST_CD = PS_CHECKLIST_ITEM.CHECKLIST_CD AND A.EFFDT <= %DateIn(:2))", PER_CHECKLIST.CHECKLIST_CD, PER_CHECKLIST.CHECKLIST_DT);

End-If;

0 comments:

Post a Comment