5.3 Manually Create New Files with LANSA

Before you can create a new file using LANSA, the fields in the file must first be defined in the Repository. This process is described in Building the LANSA Repository - Fields.

The steps in manually creating a new LANSA file are:

Step 1. Create the New LANSA File Definition

Step 2. Select the fields for the File

Step 3. Review the Definition  (This step is optional, but it is strongly recommended that you add these facilities to your files.)

Step 4. Make the file Operational.

Step 1. Create the New LANSA File Definition

1.  Start from the Main System Menu.

 

 PppSYSMENU                 Main System Menu                           

                                                                       

 Enter number of function or place cursor on same line and press Enter.

                                                                       

  4  1. Use a process                                  

     2. Submit a process to batch                                      

     3. Field control menu                                             

    4. File control menu                                              

     5. Process control menu                                           

     6. Housekeeping menu                                              

     7. Display submitted jobs - workstation                           

     8. Display submitted jobs - user                                  

     9. Display workstation message queue                              

    10. Exit from LANSA                                    

 

 

 F1=Help  F3=Exit   F12=Cancel  F14=Messages          

 

 

2.  Select the File Control menu option.

     Notify LANSA of the initial details of the file.

3.  From the File Control Menu select the Create a new file definition option.

 

 PppFILMENU                  File Control Menu                         

                                                                       

 Enter number of function or place cursor on same line and press Enter.

                                                                       

  1  1. Create a new file definition                                

     2. Review or change a file definition                             

     3. Delete a file definition                                       

     4. Make new or amended file definition operational                

     5. Print file definitions                                         

     6. Bulk Load of OTHER files                                       

     7. Exit from LANSA                                                

                                                                       

                                                                       

                                                                       

                                                                       

 F1=Help  F3=Exit  F12=Cancel  F14=Messages           

 

 

4.  Press Enter and the Create New File Definition screen is displayed.

 

CRTFILE                  Create New File Definition                    

                                                                       

 New file name . . . . . . . __________                                

 Library of residence  . . . __________                                

 Description . . . . . . . . ________________________________________  

 Initial public access . . . NORMAL    NORMAL, ALL, NONE               

 To be maintained by . . . . LANSA     LANSA,  OTHER                   

                                                                       

 Copy file definition  . . . __________                                

   Residing in library . . . __________                                

 

 

 F1=Help  F3=Exit  F12=Cancel  F14=Messages           

 

 

5.  Enter the new File's Name, the Library and Description. The file name must be unique.

     Initial public access specifies the access other users are to be given to the file. NORMAL allows other users to add, change and delete records but not modify the file's definition. ALL allows other users to add, change and delete records as well as modify or delete the file's definition. NONE prevents other users any access to records in this file.

     Specify LANSA in the To be maintained by . . option, to indicate that the file will be maintained by LANSA.

     The Copy file definition option allows you to create a new LANSA file definition from another LANSA file definition. It does not allow you to copy files defined outside of LANSA.

     When you copy from an existing file definition, the following will be copied: fields (including virtual fields), file level validations & triggers, batch control and access routes. Logical views will not be copied.

6.  When you have specified your entries, press Enter to start the creation of the new file definition.

Commit Amendments

     Whenever you create or make modifications to a file definition, you will be prompted to commit the amendments.

 

 COMMITAMD                  Commit File Amendment(s)                   

                                                                       

                                                                       

 Commit amendment(s) . . . . . . . . . YES   YES, NO                   

                                                                       

                                                                       

                                                                       

 Fnn=Help  Fnn=Exit  Fnn=Cancel  Fnn=Messages                          

                                                                       

 

 

     Enter YES and Enter, to save the new file's definition. The File Definition Menu (Create) screen is displayed.

     Note: If you are using Task Ids, then the relevant Task Identifier is displayed on this screen.

For further details about these entries, refer to Creating a New File Definition in the LANSA for i User Guide.

Go to Step 2. Select the fields for the File.

Step 2. Select the fields for the File

After you have committed your new file definition, the File Definition Menu (Create) is displayed for you to select the fields which make up the record layout.

Before you can do this, your fields must have been defined using the procedures described in Building the LANSA Repository - Fields.

1.  Select the Define fields in file definition option and press Enter.

 

 pppFILREV              File Definition Menu (Create)                  

                                                                       

 Enter number of function or place cursor on same line and press Enter.

                                                                       

  1  1. Define fields in file definition                               

     2. Define logical views of file                                   

     3. Define file validation checks                                  

     4. Define access routes to other files                            

     5. Define virtual fields                                          

     6. Define batch control logic                                     

     7. Review or change data base file attributes                     

     8. Review or change file multilingual attributes                  

     9. Load definition of file not maintained by LANSA                

    10. Exit from LANSA                                                

                                                                       

                                                                       

 File being worked with is . . . . : File Description                  

 Name and library are  . . . . . . : FileName    Library               

                                                                       

 F1=Help  F3=Exit  F12=Cancel  F14=Messages                            

 

 

     The Display Fields in File Definition screen is presented.

 

 DC@P200501              Display Field Definition                      

                                                                       

 File :  FileName   Library    File Description             (Language) 

                                                                       

                                                        Primary        

  Seq   Name       Description                          Key order Src  

 

 

 

 

 

 

  File FileName from Library currently has no fields defined in it.    

 

  F1=Help  F3=Exit  F6=Add/Create  F12=Cancel  F4=Messages  

 

 

     As this is a new file, there are no fields displayed.

2.  Select F6 (Add/Create) and the Add Field Definition screen is displayed.

 

 DC@P200501                Add Field Definition                        

                                                                       

 File :  FileName   Library    File Description             (Language) 

                                                                       

                                                        Primary        

  Seq   Name       Description                          Key order Src  

  ___   ________                                             __        

  ___   ________                                             __        

  ___   ________                                             __        

  ___   ________                                             __        

  ___   ________                                             __        

  ___   ________                                             __        

  ___   ________                                             __        

  ___   ________                                             __        

 

  File FileName from Library currently has no fields defined in it.    

 

  F1=Help  F3=Exit  F12=Cancel  F4=Messages    

 

 

3.  You can choose to either:

     or

     If you choose to enter the field names, LANSA will attempt to find the matching field details. If a name that you have entered happens to be a partial name of another field, all the other fields containing the partial name will be displayed with a message telling you what has been displayed.     To request a list of fields to choose from, in Name, enter:

     DEM has been used as the partial name in this example:

 

 DC@P800501           Select Field from Data Dictionary                

                                                                       

 

 

 

                                                                       

 Either Choose field required from list below,                         

 Or     Enter a new full or partial search name : DEM                  

                                                              

 Sel  Field      Description                             Typ Len  Dec  

  __  NAMCDE     Name and Address Code                    A   11       

  __  DEMAD1     Address Line 1                           A   25       

  __  DEMAD2     Address Line 2                           A   25       

  __  DEMAD3     Address Line 3                           A   25       

  __  DEMCAT     Product Category                         A   13     + 

                                                                       

                                                                       

 F1=Help  F12=Cancel  F14=Messages              

 

 

     Select the fields for the file by entering a sequence number in the Sel column. If you want different fields listed, use the Page Down key or re-enter the selection criteria.

     The fields you select are displayed immediately in the top half of the screen.

 

 DC@P800501           Select Field from Data Dictionary               

                                                                      

Type option, press enter         4=Delete from current list

Act Seq   Field          Description                    Typ  Len  Dec

     10   NAMCDE         Name and Address Code           A    11     

     20   DEMAD1         Address Line 1                  A    25      

     30   DEMAD2         Address Line 2                  A    25      

     40   DEMAD3         Address Line 3                  A    25      

 

 

 

Full/Partial name of fields to be displayed from Data Dict ____________

Type option, press enter  1 to 99999=Select to add to current list     

  Sel Field       Description                            Typ  Len  Dec 

  __  NAMCDE      Name and Address Code                   A    11      

  __  DEMAD1      Address Line 1                          A    25      

  __  DEMAD2      Address Line 2                          A    25      

  __  DEMAD3      Address Line 3                          A    25      

  __  DEMCAT      Product Category                        A    13    + 

 

  F1=Help   F12=Cancel   F14=Messages           

 

 

     Continue selecting fields until you have selected all the fields that are required for the file.

     Press Enter when you have completed your selection.

4.  The Display Field Definition screen is now displayed with a list of your selected fields:

 

 DC@P200501              Display Field Definition                      

                                                                       

 File : File Name   Library   File Name                     (Language) 

                                                                       

                                                        Primary        

  Seq   Name       Description                          Key order Src  

   10   NAMCDE     Name and address code                      1        

   20   DEMAD1     Address line 1                                      

   30   DEMAD2     Address line 2                                      

   40   DEMAD3     Address line 3                                      

                                                                       

                                                                       

  F1=Help  F3=Exit  F12=Cancel  F14=Messages  F21=Change  F22=Delete   

 

 

5.  Nominate the key fields by adding a sequence number in the Key Order column.

     You can delete fields from this list or change the sequence. If you have duplicated a sequence number, the fields will be sorted alphabetically within the sequence number.

6.  Press Enter when you have completed the list. The File Definition Menu (Review) is displayed.

Go to Step 3. Review the Definition.

Step 3. Review the Definition

Add the file validation rules and triggers, define virtual fields, add batch control logic, specify logical views, as required, selecting the options from the File Definition Menu (Review).

 

 pppFILREV              File Definition Menu (Review)                  

                                                                       

 Enter number of function or place cursor on same line and press Enter.

                                                                       

  2  1. Define fields in file definition                               

     2. Define logical views of file                                   

     3. Define file validation checks                                  

     4. Define access routes to other files                            

     5. Define virtual fields                                          

     6. Define batch control logic                                     

     7. Review or change data base file attributes                     

     8. Review or change file multilingual attributes                  

     9. Load definition of file not maintained by LANSA                

    10. Exit from LANSA                                                

                                                                       

                                                                       

 File being worked with is . . . . : File Description                 

 Name and library are  . . . . . . : FileName    Library               

 

 F1=Help  F3=Exit  F12=Cancel  F14=Messages                        

 

 

A description of some of these functions is provided in 5.4 Review the File Definitions.

Commit Amendments

Whenever you have made modifications to the file definition, you will be prompted to commit the amendments.

 

 COMMITAMD                  Commit File Amendment(s)                   

                                                                       

                                                                       

 Commit amendment(s) . . . . . . . . . YES   YES, NO                   

                                                                       

                                                                       

                                                                       

 Fnn=Help  Fnn=Exit  Fnn=Cancel  Fnn=Messages        

 

 

Enter YES, otherwise you will lose all the changes that you have made.

Go to Step 4. Make the file Operational.

Step 4. Make the file Operational

Having defined the file and its fields and added the required Repository features, you need to create the I/O module.

1.  Return to the File Control Menu.

 

 pppFILMENU                  File Control Menu                         

                                                                       

 Enter number of function or place cursor on same line and press Enter.

                                                                       

  4  1. Create a new file definition                                   

     2. Review or change a file definition                             

     3. Delete a file definition                                       

     4. Make new or amended file definition operational                

     5. Print file definitions                                         

     6. Bulk Load of OTHER files                                       

     7. Exit from LANSA                                                

                                                                       

                                                                       

                                                                       

                                                                       

 F1=Help  F3=Exit  F12=Cancel  F14=Messages          

 

 

2.  Select the option to Make new or amended file definition operational.

3.  Nominate the file you wish to work with via the Select File to Work With screens.

4.  When you have selected your file, the Create/Recreate a File from its Definition screen is displayed. The Job Name defaults to the File Name.

 

  DC@P200201         Create/Recreate a File from its Definition      

 

   File   :    FileName   Library   File description                 

 

   Submit this job as described below  . . . . . YES YES,NO          

   Using      Job name . . . . . . . . . . . . . FileName___         

              Job description . . . . . . . . .  *LIBL/QBATCH        

              Job queue. . . . . . . . . . . . . *JOBD               

              Output queue  . . . . . . . . . .  *LIBL/QPRINT        

  Produce file and I/O module source listings. . NO      YES,NO      

  Ignore decimal error/strip debug data options  NO  YES  YES,NO    

  User program to call at completion . . . . . . ..                 .

  Object         Library     Type      Action to be taken / reason(s)

 

 

 

 

   F1=Help   F3=Exit   F12=Cancel   F14=Messages                     

 

 

5. Press Enter to submit the job.

     When the job has been completed successfully, the I/O module created will include all the file and field validations, default values, batch control logic, triggers and so on, that you have specified.

     When LANSA creates a file it will make the record format name the same as the file name. If you intend to write RPG programs to access files created using LANSA, you can either:

     or

You will find more information about creating files in the LANSA for i User Guide:

  • Creating a New File Definition 
  • Fields in the File Definition
  • Database File Attributes 
  • Logical Views/Files Associated with a File Definition
  • Tips and Techniques for Defining Files Using LANSA