Consultor Eletrônico



Kbase P58788: Dyn 2.1A: How to report entity Fields that have not a given attribute at master level
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/15/2008
Status: Verified

GOAL:

How to report the entity Fields that do not have a defaultValue attribute defined at the master level

GOAL:

How to report the entity Fields that do not have a given attribute defined at the master level

FACT(s) (Environment):

Dynamics 2.1A

FIX:

The following code has been used successfully in 2.1A. By default, it reports all the entity fields of all tables that have no defaultValue attribute, but you can run it for another attribute and filter the table and field name.

DEFINE BUFFER rycso FOR ryc_smartObject.
DEFINE BUFFER rycAttDataType FOR ryc_attribute_value.

DEFINE VARIABLE entity AS CHARACTER NO-UNDO FORMAT "X(15)" INITIAL "*".
DEFINE VARIABLE entityField AS CHARACTER NO-UNDO FORMAT "X(15)" INITIAL "*".
DEFINE VARIABLE attrLabel AS CHARACTER NO-UNDO FORMAT "X(25)" INITIAL "defaultValue".
DEFINE VARIABLE ExportToFile AS CHARACTER NO-UNDO FORMAT "X(20)".
DEFINE VARIABLE cDataType AS CHARACTER NO-UNDO.

UPDATE
entity LABEL "Entity" HELP "* => all entity"
entityField LABEL "Field" HELP "* => all fields"
attrLabel LABEL "Attr" HELP "write the attirube label to check"
ExportToFile HELP "If blank then screen, else file name"
WITH SIDE-LABELS THREE-D FRAME WhatObject.

IF ExportToFile "" THEN
DO:
IF INDEX(ExportToFile,".") = 0 THEN
ASSIGN ExportToFile = ExportToFile + ".txt".
OUTPUT TO VALUE(ExportToFile).
END.

FOR EACH gsc_entity_mnemonic NO-LOCK WHERE entity_mnemonic MATCHES entity,
EACH ryc_smartObject NO-LOCK WHERE ryc_smartObject.object_filename = entity_mnemonic_description,
EACH ryc_object_instance NO-LOCK WHERE ryc_object_instance.container_smartObject_obj = ryc_smartObject.smartObject_obj,
FIRST rycso NO-LOCK WHERE rycso.smartObject_obj = ryc_object_instance.smartObject_obj AND rycso.object_filename MATCHES entity + "." + entityField:

FIND FIRST rycAttDataType NO-LOCK WHERE rycAttDataType.smartObject_obj = ryc_object_instance.smartObject_obj AND
rycAttDataType.object_instance_obj = 0 AND
rycAttDataType.attribute_label = "DATA-TYPE" NO-ERROR.

/* no rycAttDataType for DATA-TYPE means inherit from default 'character' */

ASSIGN cDataType = IF AVAIL rycAttDataType THEN rycAttDataType.character_value ELSE "character".

IF AttrLabel = "defaultValue" AND cDataType = "character" THEN
NEXT. /* character field have no defaultValue if blank */

/* so, is the wanted attribute registered for this entity field */

FIND FIRST ryc_attribute_value NO-LOCK WHERE ryc_attribute_value.smartObject_obj = ryc_object_instance.smartObject_obj AND
ryc_attribute_value.object_instance_obj = 0 AND
ryc_attribute_value.attribute_label = attrLabel NO-ERROR.

IF AVAIL ryc_attribute_value THEN
NEXT. /* yes it is registered */

DISPLAY rycso.object_filename LABEL "Entity Field" FORMAT "X(60)" cDataType FORMAT "X(10)" LABEL "DATA-TYPE".
END.

IF ExportToFile "" THEN
OUTPUT CLOSE.