project BLF > class BCustomField > method ValidateLength

validation procedure

Description

Validation mask for maximum length entered on string custom fields.


Parameters


iiTargetFieldinputintegerValue of the business field to validate.
icTargetFieldNameinputcharacterName of the business field to validate.
icRowidinputcharacterContents of field tc_Rowid, if the target field is a field of a component temp-table.
icBusinessFieldNameinputcharacterbusiness field
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
validation on tCustomField.CustomFieldDisplayLength


program code (program1/bcustomfield.p)

assign vcField = entry(2, icBusinessFieldName, ".").

if not vcField begins "Custom"
then assign vcField = substr(vcField, 3, -1, "CHARACTER").

if vcField begins "CustomShort" or
   vcField begins "CustomCombo"
then assign viMaxLength = 20.
else
if vcField begins "CustomLong" or
   vcField = "QADC02"
then assign viMaxLength = 255.
else
if vcField begins "QADC0"
then assign viMaxLength = 40.
else
if vcField begins "CustomNote"
then assign viMaxLength = 4000.
else
if vcField begins "CustomInteger"
then assign viMaxLength = 9.
else
if vcField begins "CustomDecimal"
then assign viMaxLength = 18.

if viMaxLength > 0 and
   viMaxLength < iiTargetField
then do:
    <M-1 run SetMessage
       (input  #T-2'Defined field length exceeds maximum allowed length ($1).':100(478)t-2# (icMessage), 
        input  string(viMaxLength) (icArguments), 
        input  icTargetFieldName (icFieldName), 
        input  string (iiTargetField) (icFieldValue), 
        input  'E' (icType), 
        input  3 (iiSeverity), 
        input  icRowid (icRowid), 
        input  'BLF-63':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCustomField>

    assign oiReturnStatus = -1.
end.