Exercise 7.7: Adding fields to the subfile record

Before you begin, you must complete Exercise 7.6: Creating new screens.

Now you add some columns to the subfile using the Design page. The subfile should be positioned on row eight. You use the cursor to specify the location of the part you want to put on the screen, in this case your subfile.

To add fields on the subfile:

  1. Click the Create named field button and then click somewhere on row 8.

    Six fields appear in a vertical column. This is because the subfile you created, currently specified a SFLPAGE (visible list size) of six.

  2. Click the top field and hold the mouse button down and move it to row 8, column 5.

    Note the current row and column appear just above the field as you move it.
    location of current row and column

  3. Move the cursor over to the right edge of the field. It turns into a double-headed arrow. Hold down the mouse button and move it to the left. The size of the field will be reduced. The current size will appear just above the field. When the size is 3, let go of the mouse button.
    Reduce field

    The toolbar at the top of the Design page is a very convenient place to monitor and manipulate the currently selected parts.

  4. Rename the record from RECORD1 to EMPLSTSFL and the field from FIELD1 to OPCODE by typing over the text in each list.
    Tool bar
  5. Click the Color palette color button button and select pink to change the color of the field.
  6. Click the input button button to change the usage of the field to input.
    input field

    Now you will create an additional column in the subfile.

Creating an additional column

To create an additional column:

  1. Position the cursor at row 8, column 9.
    Note:
    The bottom right of the CODE Designer window shows the current cursor position cursor position.

    If you can't see the field with the cursor position on your screen, click the Maximize button in the top right corner of the screen. You can use the cursor keys or the mouse to move the cursor.

  2. If you are creating a long field with an exact length, the SDA syntax can be easier. Type:
       +O(30) 
    

    and then press the back arrow (not Backspace!) to select the text you created.

    Notice from the Selected DDS page that you have created a text constant containing +O(30).

  3. Click the Convert string to field Convert string to field button button on the toolbar or press F11 to convert the SDA syntax into a character output field of length 30.
    Output field

    Convert string to field button
  4. Rename the new field to ENAME using the toolbar. This will show the name of the employee.
    Rename to ENAME
  5. Position the cursor to 8, 41.
  6. Now you will add a field for the employee's salary. Type
     $666,666.66
    

    and then press the back arrow.

    Now wouldn't it be better if we could just tell the Designer what we wanted the number to look like and then have Designer generate all the cryptic EDTCDEs to make it happen?

  7. Press F11 to convert this field into an output numeric field with comma delimiters, two decimal positions, a currency symbol and no sign. Look at the Selected DDS page to see what was generated for you. Impressive!
    Selected DDS
  8. Rename the field to SALARY and change its color to yellow, using the toolbar.
  9. The subfile seems compacted to the left. It would be better to space it out evenly. Just select a field and click the space horizontally horizontal alignment button button on the far right side of the toolbar. The other alignment buttons will align fields, left, right, center and top.
    Space Horizontally

    Align columns horizontally

    Just below the palette on the left there are three spin buttons. The top one, Subfile size, specifies the total number of entries in the list that will be filled in by the application. The second one, Subfile page size, is how many entries appear on the screen.

  10. In the Subfile size field, type 300.
  11. In the Subfile page size field, type 9.
  12. Click in the Design page.
    Subfile size and Subfile page

    The Design page is updated accordingly.

You have added some columns to the new subfile record screen and now you are ready to begin Exercise 7.8: Switching between multiple records.