When "Page data is inconsistent with database"

How we hate this one. PeopleSoft politely tells you that there is some data (being updated) that is inconsistent with what is in the database. It is not polite enough to tell you which data however.

Here is some code to give you a clue. It returns all data that has changed on the Component.


/* Place in the Component.SavePreChange event.
Finds all data that is being updated in a component when saved. */

Local integer &i, &j, &k, &r, &f;

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

Function CheckRowset(&level as integer, &rs As Rowset)

For &i = 1 to &rs.ActiveRowCount

/* Loop through all Records in the RowSet. */
For &r = 1 To &rs(&i).RecordCount

/* Find Records that have changed. */
Local Record &rec = &rs(&i).GetRecord(&r);
If &rec.IsChanged Then

/* Loop through all the Fields in the Record. */
For &f = 1 To &rec.FieldCount

/* Find Fields that have changed. */
If &rec.GetField(&f).IsChanged Then

Local Field &fld = &rec.GetField(&f);
WinMessage("FIELD CHANGED - Level: " | &level | ", Row: 1, Record: " | &rec.Name | ", Field: " | &fld.Name | ", OriginalValue= " | &fld.OriginalValue | ", Value= " | &fld.Value,0);

End-If;

End-For;

End-If;

End-For;

End-For;

End-Function;

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

/* Level 0. */
Local Rowset &rowset0 = GetLevel0();
CheckRowset(0,&rowset0);

/* Level 1. */
For &i = 1 To &rowset0(1).ChildCount

Local Rowset &rowset1 = &rowset0(1).GetRowset(&i);
CheckRowset(1,&rowset1);

/* Level 2. */
For &j = 1 To &rowset1(1).ChildCount

Local Rowset &rowset2 = &rowset1(1).GetRowset(&j);
CheckRowset(2,&rowset2);

/* Level 3 (maximum). */
For &k = 1 To &rowset2(1).ChildCount

Local Rowset &rowset3 = &rowset2(1).GetRowset(&k);
CheckRowset(3,&rowset3);

End-For;

End-For;

End-For;

0 comments: