HP 3000 Manuals

Objectives [ HP ALLBASE/4GL Developer Self-Paced Training Guide ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Self-Paced Training Guide

Objectives 

When you complete this lesson, you will have learned how to:

   *   Define a record layout

   *   Use the record header screen to create a record header

   *   Use the record layout screen to create layout details

   *   Generate a record layout

Record Layouts 

A record layout defines the format of the records in a data file.  A
record can be associated with one or more files and is used in logic
blocks, screens, and reports to qualify a field reference.  The layout
specifies the names of the fields and their sequence in the record.  It
also specifies which fields are used as key fields for accessing records
in the file.  When you create the record layout, HP ALLBASE/4GL defines a
record buffer for reading and writing records. 

Data Manager Rules 

The data manager you use will have certain rules about record layouts,
which you will need to follow within HP ALLBASE/4GL. The KSAM file
manager, for instance, requires at least one key to a record so it can
maintain an index of the records in a data file.

The record layout for an HP ALLBASE/SQL table does not need to have any
fields defined as key fields.  If you do define a field on the record
layout as a key field, HP ALLBASE/4GL uses the field to create an index
for the table.  You cannot use a record layout that contains field
specifications with multiple occurrences.

HP TurboIMAGE/iX data set definitions require that record layouts:

   *   Record layouts must contain no key fields with repeated
       occurrences.

   *   Master data set layouts must contain no keys that allow duplicate
       entries.

   *   Automatic master data sets must contain one key field and no other
       fields.

   *   Manual master data sets must contain one key field and may contain
       other non-key fields.

   *   Detail data sets need not contain any key fields.

Task 1 - Creating a Record Layout Header 

To create a record layout you must first complete the record layout
header screen and then complete the record layout details screen.

Header screens are used for many components of HP ALLBASE/4GL. Logic
blocks, screens, and reports all have header screens.  The information
that you enter in a header screen is used as an index and is recorded in
the index portion of the HP ALLBASE/4GL system files (S-files).  Detail
screen information is stored in the data portion of the HP ALLBASE/4GL
S-files.

Using the Record Layout Header Screen.   

This screen enables you to describe a record for use in the application.

To access the screen: 

   1.  From the main menu, select the Dictionary option

   2.  Choose Record Layouts 

   3.  Choose Header.

	       Click here to view figure.
          Record Layout Header Screen 

The record layout header screen is shown as it will appear after you have
made the entries for the product record header.

To enter the field values: 

        Field                 Entry                         Explanation 

---------------------------------------------------------------------------------------

Record Name           product_rcrd          The name used to refer to the record in a
                                            file definition or file record field
                                            reference.

Secured               Accept the default.   Specifies whether this item is secured
                                            against modification by an unauthorized
                                            developer.

Description           Enter a description
                      for documentation
                      purposes.

To complete and commit the screen: 

   1.  When all of the values on the screen are correct, press the  
       Commit Data  function key to create the record layout header.

This completes the work required to define the values for the record
layout header screen.

Task 2 - Defining Record Layout Details 

Now that you have defined the record layout header, you will define the
details of the record layout.

   1.  Press the  Record Details  function key to go to the record layout
       details screen, or use the  Previous Menu  function key to go to
       the record layout details screen via the menus.

Using the Record Layout Details Screen.   

This screen enables you to define the field specifications making up this
particular record layout.  You can also state whether a field is to be a
key for the file, and if it is, whether duplicate values are permitted in
the field.

As with the process of defining a field specification name, you are not
allocating any physical space.

To access the screen from the main menu: 

   1.  Select the Dictionary option.

   2.  Choose Record Layouts.

   3.  Choose Details.

	       Click here to view figure.
          Record Layout Details Screen 

The screen is shown as it should look when you have completed entering
the values for the first field.

To enter the field values for the first field: 

Use the table below to enter the field values depicted on the screen.

        Field                 Entry                         Explanation 

---------------------------------------------------------------------------------------

Record                Accept the default.   The name of the record layout.  Processing
                                            can only continue if you have already
                                            completed the header for this record
                                            layout.  Enter the name yourself if it is
                                            not displayed.

Field Number          Accept the default.   Defines the order of the fields contained
                                            in the record.  As you define the structure
                                            of the record layout, you must declare each
                                            field in ascending field order.  All the
                                            numbers must be contiguous, but it is
                                            possible to insert an extra field into the
                                            record layout at a later stage.  This is
                                            the first field in the product_rcrd record.

          Table 2-0.  (cont.) 

        Field                 Entry                         Explanation 

---------------------------------------------------------------------------------------

Action                Accept the default.   Defines the action you wish to perform on
                                            this field.  An entry of A indicates Add a
                                            new field.

Field Spec.  Name     Enter product_no      Name of a previously defined field
                                            specification.  If you try to enter the
                                            name of a field that you have not defined,
                                            HP ALLBASE/4GL displays an error message.

                                            HP ALLBASE/4GL uses this entry to determine
                                            how much space to allocate for the data
                                            stored in this field, as well as the valid
                                            data types for the field.

Key Number            Enter 1               Used for keyed file access purposes.

Duplicate Keys        Enter N               Indicates whether duplicate records with
                                            the same key value can occur on the one
                                            file.  An entry of N indicates that a given
                                            key value may occur in only one record in
                                            the file.

To complete and commit the entries: 

   1.  Press  Commit Data .  This displays a scroll area below the data
       entry line.

This scroll area shows the details of your entry.  As you enter more
fields into the record layout, this display reflects the current state of
the record layout.

The display shows the field numbers, names, key numbers, and whether
duplicate keys are permitted.

Completing the Record Layout Details.   

The entries shown below are required to complete the record layout
details.  Only the values that require an entry are shown below.

If you make an error in a field you have committed, you can rectify it
easily.  First, enter the field number of the line that you want to edit,
then accept the action code of C, rectify the error and then press the  
Commit Data  function key.

To complete the entries for KSAM and SQL based applications: 

Field No.  2 

        Field                 Entry 

--------------------------------------------

Field Number          Accept the default of
                      2

Action                Accept the default of
                      A

Field Spec.  Name     Enter description

Field No.  3 

        Field                 Entry 

--------------------------------------------

Field Number          Accept the default of
                      3

Action                Accept the default of
                      A

Field Spec.  Name     Enter supplier_no

Key Number            Enter 2

Duplicate Keys        Enter Y

Field No.  4 

        Field                 Entry 

--------------------------------------------

Field Number          Accept the default of
                      4

Action                Accept the default of
                      A

Field Spec.  Name     Enter lead_time

You will see that one of the fields above has a key number.  In total,
the product file has two keys.  This allows you to read the file (or
print reports) according to the product number or the supplier number.
Only the product number field is defined as a unique key since duplicate
values may occur in the other fields.

The following screen image shows how the record layout screen should
appear when you have entered all the field details.

	       Click here to view figure.
          Completed KSAM and SQL Record Layout Details Screen 

Entry Notes.   

Action Codes 

When defining items there are a number of occasions where you will be
prompted for an action to be performed.  The codes are universal, but
some items use more actions than others.  The codes are:

   *   A = Add

   *   C = Change

   *   I = Insert

   *   D = Delete

If an item does not exist, the default is A; if the item already exists,
the default action is C.

key fields 

The key number defines the index number to be associated with this field.
Every key number in a record must be unique.  Key number 1 is called the
primary key.

The KSAM file manager requires at least one key so it can maintain an
index for the location of a record in a file.  Without a key, no indexed
access to a record via that field is possible.  The key number has no
relationship to the field number.

The HP TurboIMAGE/iX file manager requires one key for master data sets,
but no keys are required for detail data sets.

For the HP ALLBASE/SQL data manager, no key fields are needed.

To complete entries for HP TurboIMAGE/iX based applications: 

Field No.  2 

        Field                 Entry 

--------------------------------------------

Field Number          Accept the default of
                      2

Action                Accept the default of
                      A

Field Spec.  Name     Enter description

Field No.  3 

        Field                 Entry 

--------------------------------------------

Field Number          Accept the default of
                      3

Action                Accept the default of
                      A

Field Spec.  Name     Enter supplier_no

Field No.  4 

        Field                 Entry 

--------------------------------------------

Field Number          Accept the default of
                      4

Action                Accept the default of
                      A

Field Spec.  Name     Enter lead_time

You will see that none of these fields have key numbers.  A manual master
data set may only contain one key field.

The following screen image shows how the record layout screen should
appear when you have entered all the field details.

	       Click here to view figure.
          Completed TurboIMAGE Record Layout Details Screen 

Task 3 - Generating a Record Layout 

Before a record layout can be used in an application, it must be
generated.

Generating the record layout creates a run-time version of the record
layout and performs additional validation and processing.  The generation
process resolves pointers to the field specifications, and produces an
executable form of the record definition.

To generate a record layout: 

   1.  After pressing  Commit Data  to commit the last set of fields,
       Press the  Generate Record  function key.  This starts the
       generation process.

When you use the generate program for the first time, two messages are
displayed.  The first message tells you that generate is being called,
and the second confirms that the record itself is being generated.

	       Click here to view figure.
          Successful Generation 

Generate is a large program and is a separate unit in the HP ALLBASE/4GL
suite of programs.  To avoid the need to call generate repeatedly, it
remains resident in memory until you exit from the developer.  The next
time you use generate in this session, the calling generate message will
not be displayed.

If you receive an error from the generate process, a generate error
screen shows the number of the field that is in error, and the type of
error encountered.  Note these details and use them to assist you in
correcting the record.

If the generate is successful, you will receive a Generation successful 
message indicating that the record layout has been correctly generated.

You have now created and generated a record layout.  In the next lesson
you will use the record layout to create a data file.

While developing an application you may want to look at the details of an
existing record layout.

To look at existing record layout details: 

   1.  Enter the record layout name in the Record field of the Details 
       screen

   2.  Press Return.

The contents of the record layout will then be displayed.



MPE/iX 5.0 Documentation