Identifying a Logical View: Redefining a Segment

The segments that you define usually correspond to underlying groups in your data source. For example, a segment could be a table in a relational data source.

However, you are not limited to using the segment as it was originally defined in the native data source. You can define a logical view which includes only a subset of the fields in a segment fields (similar to a relational view), or define the unwanted fields as one or more filler fields. This technique can be helpful if, for example, you only want to make some of the fields in the segment available to an application or its users.

Use these methods with the following types of data sources:

To restrict access explicitly at the file, segment, or field level based on user ID, field values, and other characteristics, use the DBA facility as described in Providing Data Source Security: DBA.

Example: Omitting a Field: Creating a Segment Subset

Define a logical view for a relational data source by omitting the unwanted fields from the segment description in the Master File. Consider the following Master File for an Oracle table named EMPFACTS:

FILENAME = EMPFACTS, SUFFIX = SQLORA ,$
 SEGNAME = EMPFACTS, SEGTYPE = S0 ,$
  FIELDNAME= EMP_NUMBER, ALIAS= ENUM,  USAGE= A9,     ACTUAL= A9   ,$
  FIELDNAME= LAST_NAME,  ALIAS= LNAME, USAGE= A15,    ACTUAL= A15  ,$
  FIELDNAME= FIRST_NAME, ALIAS= FNAME, USAGE= A10,    ACTUAL= A10  ,$
  FIELDNAME= HIRE_DATE,  ALIAS= HDT,   USAGE= I6YMD,  ACTUAL= DATE ,$
  FIELDNAME= DEPARTMENT, ALIAS= DPT,   USAGE= A10,    ACTUAL= A10  ,$
  FIELDNAME= SALARY,     ALIAS= SAL,   USAGE= D12.2M, ACTUAL= D8   ,$
  FIELDNAME= JOBCODE,    ALIAS= JCD,   USAGE= A3,     ACTUAL= A3   ,$
  FIELDNAME= OFFICE_NUM, ALIAS= OFN,   USAGE= I8,     ACTUAL= I4   ,$

If you develop an application that refers to only the employee ID and name fields, and you want this to be reflected in the application view of the segment, you can code an alternative Master File that names only the desired fields:

FILENAME = EMPFACTS, SUFFIX = SQLORA ,$
  SEGNAME = EMPFACTS, SEGTYPE = S0 ,$
    FIELDNAME= EMP_NUMBER, ALIAS= ENUM,  USAGE= A9,  ACTUAL= A9   ,$
    FIELDNAME= LAST_NAME,  ALIAS= LNAME, USAGE= A15, ACTUAL= A15  ,$
    FIELDNAME= FIRST_NAME, ALIAS= FNAME, USAGE= A10, ACTUAL= A10  ,$

Example: Redefining a Field: Creating a Filler Field

Define a logical view for certain data sources, such as a sequential or FOCUS data source, by defining the fields excluded from the view as one or more filler fields. Define the field format as alphanumeric, its length as the number of bytes making up the underlying fields, and its name and alias as blank. Field declarations and length are discussed in detail in Describing an Individual Field.

Consider the EMPINFO segment of the EMPLOYEE data source:

SEGNAME = EMPINFO, SEGTYPE = S1 ,$
  FIELDNAME = EMP_ID,       ALIAS = EID,  USAGE = A9     ,$
  FIELDNAME = LAST_NAME,    ALIAS = LN,   USAGE = A15    ,$
  FIELDNAME = FIRST_NAME,   ALIAS = FN,   USAGE = A10    ,$
  FIELDNAME = HIRE_DATE,    ALIAS = HDT,  USAGE = I6YMD  ,$
  FIELDNAME = DEPARTMENT,   ALIAS = DPT,  USAGE = A10    ,$
  FIELDNAME = CURR_SAL,     ALIAS = CSAL, USAGE = D12.2M ,$
  FIELDNAME = CURR_JOBCODE, ALIAS = CJC,  USAGE = A3     ,$
  FIELDNAME = ED_HRS,       ALIAS = OJT,  USAGE = F6.2   ,$

If you develop an application that refers to only the employee ID and name fields, and you want this to be reflected in the application view of the segment, you can code an alternative Master File that explicitly names only the desired fields:

SEGNAME = EMPINFO, SEGTYPE = S1 ,$
  FIELDNAME = EMP_ID,     ALIAS = EID, USAGE = A9  ,$
  FIELDNAME = LAST_NAME,  ALIAS = LN,  USAGE = A15 ,$
  FIELDNAME = FIRST_NAME, ALIAS = FN,  USAGE = A10 ,$
  FIELDNAME =,            ALIAS =,     USAGE = A29 ,$

The filler field is defined as an alphanumeric field of 29 bytes, which is the combined internal length of the fields it replaces: HIRE_DATE (4 bytes), DEPARTMENT (10 bytes), CURR_SAL (8 bytes), CURR_JOBCODE (3 bytes), and ED_HRS (4 bytes).