23 Data block- Guidelines and Best Practices

This topic provides a list of guidelines and best practices for creating data blocks.

Below are points to be noted while creating data blocks:
  1. All Block Names Should start with BLK_ and the remaining portion of the block name should be the same as the XSD node of the Block Name in Upper case and _ replaced with -. Avoid naming the block name the same as that of the table name.
  2. Blocks also would have a hierarchy and has to be chosen correctly.
  3. Block Types are similar to data source types with an additional type Control.
  4. After adding a block, ODT defaults the XSD node. Node name would be Block name without BLK_ and in Sentence case. Also, _ will be replaced with -.
  5. Parent block should be chosen from the list based on the hierarchy.
  6. Similar to data sources, block also can be either Multi-Record or single record type.
  7. Block Title has to be selected from the LOV.
  8. Relation type has to be mentioned as One to One or One to Many.
  9. One and only one block should be selected as Master Block.

Keypoints for attaching Data Sources to Data Block

Below are some of the important points to be noted while attaching data sources to a data block:
  1. The same data source can be selected in multiple blocks. However, in the case of Multi record data sources, ODT allows the developer to attach the data source to only one block.
  2. One Multi Record block can have multiple data sources provided all of these data sources have strict one-to-one relation.
  3. In case of multiple data sources in a single data block, it is important to ensure that the data in the attached data sources is functionally related and more importantly, a row in one table would definitely have a row in other attached data sources as well. Otherwise the generated code inserts records in all the tables always and this would result in lot of dummy records in the database.
  4. Parent data block has to be above its child data block in the browser tree. Developer has the option to rearrange the order of the blocks in the tree (by drag and drop).

    Note:

    If block or block fields are rearranged, all units will have to be regenerated.

Keypoints for specifying Field Properties

Below are some of the important points to be noted while specifying field properties:
  1. Avoid using UI fields as LOV bind variables.
  2. Avoid using separate Query data sources for single description fields. Use Description type UI fields for Description fields.
  3. Ensure that Related Block and Field are given for Amount Fields. Ensure that related currency fields are placed above the amount fields in the browser tree.
  4. In case the field is not required in XSD, check not Required XSD. There are cases where the field is a primary key field in a child block and does not need to be repeated in Child block. For example, the field PRODUCT_CODE in Product forms is not required in any Block other than once in the master block.