- Reasonable Date Range (Is the date contained within the specified reasonable date range?)
- Required fields are present
- Validates all 1/0 fields contain only a 1 or a 0
- Validates all translate fields have a valid value
- Validates all YesNo fields contain a Y or an N
- Validates all prompt edit fields have a valid value
This kind of validation is useful in Application Engine programs or if you executing Component Interfaces (CI) via PeopleCode.
One way of doing this is before you assign values to the real record (SQL record) you can create a copy of the real record as a derived/work record. Then you can invoke ExecuteEdits method with the derived record to check any standard system edits.
As an example;
Function executePromptTableEdit() Returns boolean; Local number &msgnum, &msgset; Local integer &i; Local string &msgtxt; &WorkRec = CreateRecord(Record.MY_DERIVED_RECORD); &WorkRec.SetDefault(); /* Copying like-named field values from SQL record to the derived record */ &REC = GetRecord(RECORD.MY_SQL_RECORD); &REC.CopyFieldsTo(&WorkRec); /* all system edits are executed */ &WorkRec.ExecuteEdits(); /* If edit error found */ If &WorkRec.IsEditError Then For &i = 1 To &WorkRec.FieldCount If &WorkRec.GetField(&i).EditError Then &msgnum = &WorkRec.GetField(&i).MessageNumber; &msgset = &WorkRec.GetField(&i).MessageSetNumber; &msgtxt = MsgGetText(&msgset, &msgnum, "Message not found", ""); /* here you can push this informaton to an Array and later you can use this array to populate error information to a Message Record for further lookup*/ End-If; End-for; Return False; end-If; Return True; end-function;
This way, you can use ExecuteEdit method to get the field edit error information for your next application.
0 comments :
Post a Comment