# LogiView

## Developing LGV Applications in Parallel Environments

| If the adjustments are made in one environment only (i.e. in a single database), no special rules must be observed. On the other hand, it is neccessary to observe certain rules if a LogiView application is also to be imported into other environments, e.g. in case of customer developments or if the LogiView application is to be installed and implemented in parallel environments. In this case special care must be taken with the unique identification of logic models and procedures/decision tables. The following explains how to develop a LogiView application to enable a subsequent import to other environments.
| For simplification procedures and decision tables are not differentiated in the following. All describtions are valid for LogiView procedures as well as for decision tables.
| ### Unique Identification Logic Models and procedures do not necessarily use the version number. Therefore the version number is always assumed to be 0 (zero). #### Logic Models The name of a logic models must be unique. The unique index LV_LM_MET_IND is defined for the attributes NAME and EDB_VERSION in the database table LV_LM_MET. Since the version number should always be 0, the name of the logic models is unique. Another identification feature for logic models is the field C_NR. This attribut is not contained in the unique index. The integer value C_NR stored in the attribute can be used for future purposes, e.g. in order to assing unique file names independently from the Logic Models names. #### Procedures/Decision Tables The name of a LogiView procedure must be unique in combination with the logic models name. That means: a procedure with the name "Start" can be contained in every Logic Models; however, it is not possible to store two procedures with identical names (and version number) in the same logic models. Since it is impossible to create a unique index for two different database tables, an alternative is provided: the unique index LV_DT_MET_IND for the attributes NAME, EDB_VERSION and C_NR is defined in the table LV_DT_MET. Since the version number should always be 0, the procedure name together with the additional identification must be unique. Moreover, the integer value C_NR in the attribute C_NR should be unique itself. The reason is, that the value C_NR is used within a parts list (in the attribute DTS_REF) when referencing a LogiView procedure. The value can be used for future purposes, e.g. in order to assign unique file names independently from the logic models name and the procedure. In the database table LV_DT_MET no separate and unique index for the attribute C_NR is defined in order to avoid accidental loading of two (separate) procedures with the same integer value C_NR .
| ### Problems with equal values for C_NR #### How to generate C_NR values Using the Agile e6 standard installation, the values for the C_NR attributes in the database tables LV_LM_MET and LV_DT_MET are specified as follows: Whenever a Logic Models or procedure is generated, the maximum value of all values in the corresponding attributes is incremented. This C_NR value is used for the new procedure or the logic models. This mechanism is also used when copying the logic models (or the procedure). If only one environment is used, a unique C_NR value is ensured automatically. This mechanism is also sufficient if a LogiView application is copied to another - provided, that the LogiView procedures originate from the first environment only. Therefore, the second environment cannot contain other LogiView applications than the first environment, and every value of the C_NR attribute valid in the first environment is also valid in the second environment. #### Possible Problems Problems may occur if LogiView procedures are created independently in two or more different Agile e6 environments (at a single or different customer sites). Since the values of the C_NR attributes are valid in only one environment, a multiple value usage may occur when importing procedures from one environment to another. Example: The LogiView procedure 'Proc_1' contained in the 'SMP_APP' logic models has the C_NR value 289 (attribute C_NR) set. This procedure is exported with DataView Loader from the "DEVELOPMENT" environment. The loader file is imported to the "PRODUCTION" environment. There a 'CONFIG/DeterminePos10' LogiView procedure already exists with the same C_NR value! If the C_NR value 289 is used in the "PRODUCTION" environment, e.g. in order to reference the existing procedure 'CONFIG/DeterminePos10' to a parts list, this relationship is not unique anymore. What would happen if a logic Model is copied from one environment to another, which already contains the logic model with the same name but different C_NR values? Since the C_NR value defined for the logic model is not part of the unique key in the database table LV_LM_MET, both logic models are assumed to be identical. If the DataView loader is used for the import in Insert mode, the C_NR value of the logic model is remained. In Update or Overwrite mode, the C_NR value of the imported logic model is retrieved (as well as other attributes like e.g. comments, etc).
| #### The solution It is not very likely that the combination of name and C_NR value of a LogiView pocedure is identical in two environments. Therefore, it is usually possible to import LogiView applications to any environment - even if the same values are generated for C_NR. Otherwise, the loader file must be edited or the C_NR value of the existing LogiView procedure (via SQL) must be updated. There is a simple solution to avoid equal C_NR values:
| Rename the imported logic model (e.g. 'SMP_APP_old') and then create a new logic model with the original name (e.g. 'SMP_APP').
| Copy all variables of the old logic model to the new logic model.
| Then copy all procedures (using Drag & Drop) from the old logic model to the new (still empty) logic model. Thereby, new C_NR values are generated for each procedure. In the last step, all procedures must be deleted from the old logic model and then the logic model must be deleted itself.
| Never change the C_NR value of an imported logic model or procedure if you intend to update it with a new version in the future. If you change the C_NR value of a procedure, additional procedures are created during the upgrade (import of a new version).
| ### Definition of different parts for C_NR Values In order to avoid problems caused by equal C_NR values right from the start, you should use the value generator to define different C_NR value ranges. If you define a value variant for the current user, the value generator is used to generate the C_NR value instead of using and incrementing the highest value. Perform the following steps before creating a new logic model or procedure:
| Create a value variant for the C_NR value of the logic model (e.g. SNP-LM) defining the range of positive integer values (e.g. 1000 to 1100).
| Create a value variant for the C_NR value of the procedure (e.g. SNP-DT) defining the range of positive integer values (e.g. 1000 to 9000).
| Set the DataView default value EDB-LGV-DT-NR for the user GLOBAL to #SMP-DT.
| Set the DataView default value EDB-LGV-LM-NR for the user GLOBAL to #SMP-LM.
| Now the value generator specifies a corresponding C_NR value for every new logic model and for every procedure. In different environments you can use the same value variant; however you must use different ranges. Moreover, it is possible to set multiple value variants within a single environment and allocate the DataView defaults to different users. This mechanism is useful if you intend to develop several LogiView applications in a single environment.
| An example for this solution is contained in the standard installation: The value variant EDB-LM specifies the range of negative C_NR values for procedures (starting with -100). The value variant EDB-DT specifies the range of negative C_NR values for decision tables (starting with -300). The DataView default value EDB-LGV-DT-NR for the user EDBKERNEL is set to #EDP-DT. The DataView default value EDB-LGV-LM-NR for the user EDBKERNEL is set to #EDP-LM. In this example negative values for C_NR are generated whenever the user EDBKERNEL creates new Logic Models or procedures.
| Negative values are reserved for LogiView applications developed by Agile.