Mainframe & Natural Documentation

49
Mainframe & Natural Training Documentation  Mainframe & Natural Training Documentation Version 1.5 6 August, 1999  Document Written and Compiled By  Jane Candlin  Nicola Danson Tristan Gaffney  Daniel Hapgood Mainframe & Natural Documentation.doc Page 1 / 49 e

Transcript of Mainframe & Natural Documentation

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 1/49

Mainframe & Natural Training Documentation

 Mainframe & Natural 

Training Documentation

Version 1.5

6 August, 1999

 Document Written and Compiled By

 Jane Candlin Nicola DansonTristan Gaffney

 Daniel Hapgood 

Mainframe & Natural Documentation.doc Page 1 / 49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 2/49

Mainframe & Natural Training Documentation

Contents

Reporting Structured ................................................................................9DEFINE DATA...........................................................................................................................10END-DEFINE..............................................................................................................................10END.............................................................................................................................................10

Define Data..........................................................................................................................................10Global...................................................................................................................................................10In this section you define data and variables that is to be accessible to all parts of your program andits objects..............................................................................................................................................10Parameter.............................................................................................................................................10Local.....................................................................................................................................................10

DEFINE DATA ..........................................................................................................................10Example...................................................................................................................................................11

British Steel Standards.........................................................................................................................12Multi-dimensional arrays.............................................................................................13Two Dimensional Array Example...............................................................................13

Date..........................................................................................................................................................28Variable....................................................................................................................................................28Explanation..............................................................................................................................................28Timestamp................................................................................................................................................29Format......................................................................................................................................................29Example...................................................................................................................................................29

MOVE EDITED .................................................................................................................................29Example 1................................................................................................................................................30Example 2................................................................................................................................................30

British Steel Standards.........................................................................................................................32

Good.........................................................................................................................................................36Bad...........................................................................................................................................................36Delimiters ................................................................................................................................................42Layout .....................................................................................................................................................43Program syntax ......................................................................................................................................44PF keys in the map editor ........................................................................................................................44Incorporating data ...................................................................................................................................44

Field commands ......................................................................................................45Extended Field Editing.............................................................................................................................45Stowing and Saving.................................................................................................................................46Attaching to a program............................................................................................................................46REMEMBER...........................................................................................................................................47

Mainframe & Natural Documentation.doc Page 2 / 49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 3/49

Mainframe & Natural Training Documentation

 Introduction to the Environment 

You will be using an IBM 3090 mainframe running the MVS operating system. The environments you

are going to be using are supplied by IBM, for use with the British Steel Mainframe. There are manyenvironments that provide different facilities through tailored menus. Some are used for thedevelopment of programs or applications, while others provide end users with access to theseapplications.

Below are the environments that you are likely to come in contact with :

1. Commercial 

• CICSO Strategic Services Development

• CICSS QA

• CICSU Production

2. Manufacturing • CICSG Manufacturing Development• CICSD Production

3. Tinplate

• CICSE Tinplate Development• CICS6 Production

On the menu you will see other non-CICS environments which you may be required to use in thefuture, such as:

• CICS4 Cap Gemini time recording

• OPCHG Used for transferring programs between production and development• ESFA/ESFB Checking jobs (programs running in production) and print queues• TSOA/TSOB Used to develop, run and monitor JCL (job control language) jobs

These will be discussed in the Mainframe Utilities booklet.

Development is used for writing and developing programs, and users have no access to thisenvironment.

QA is a development/testing environment that is accessible to the users. New programs or changes can be demonstrated here without the possibility of affecting production data.

Production is where the programs are accessible to the user and run with live data.

(Procedures must be followed for transferring programs between environments)

Mainframe & Natural Documentation.doc Page 3 / 49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 4/49

Mainframe & Natural Training Documentation

 Introduction To Natural 

 Natural is a production-oriented-fourth-generation language. Fourth generation languages (4GL’s)were designed to make programming more accessible and quicker by making the commands more

"English like" in there structure.

Examples of other 4GL's include Microsoft Access and Microsoft FoxPro.

The idea was to make learning the language as easy as possible so that you didn’t require speciallytrained staff to write your systems.

British steel uses a number of different products alongside Natural, which create a completeinformation system.

ADABAS Relational-like database management systemDB2 Relational database management systemENTIRE Link between the mainframe and personal computersCONSTRUCT  Natural code generator (talked about later)PREDICT Integrated, active data dictionarySUPER  NATURAL End user component that allows database inquiries

While training you will be using DB2, which is a fully relational database.

Some of you however, will be working with ADABAS, which has more restrictions, but you will beshown any differences when you come to use it.

 Natural can operate in two modes, Online or Batch.

ONLINE Processes actions as they occur 

BATCHProcesses actions at scheduled times (applications with high hit rates)

Mainframe & Natural Documentation.doc Page 4 / 49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 5/49

Mainframe & Natural Training Documentation

Getting Started 

To get into the Natural Editor

• Go into CICS (session depends on department) You can either do this through super-session(option 1) or from option 3 on the main menu.

Choose DevelopmentŸLog in (depends on session) Choose option D - Development You are now in the Natural Editor 

• Once in the Natural Editor you have a number of options

Available Codes

C Create Object Create a new program

E Edit Object  Edit an existing programR Rename Object  Rename an existing program or change type

D Delete Object  Delete an existing program

X Execute Program  Run program

T DB Command Log FacilityB Debugging Facility Starts NATURAL debugging facility

L List Objects, X-Ref   Lists NATURAL objects or X-Ref 

G Global Environment  Displays current global environment profile

? Development Facilities Help  Help on prompts. Exit Development Facilities  Exit Screen

• You also have a "Type" field, this is because you can create and maintain a number of differenttypes of programs. The types are :

M Map Screen design

G Global Global data area

L Local  Local data area

A Parameter   Parameter data area

P Program  Program

  N Subprogram Subprogram

S Subroutine Subroutine

H Helproutine  Help Routine

C Copycode Used to include set code (setting keys)

K Server T TextZ Recording

D DescriptionV View View of a table . Exit  Exit screen

• So if you wanted to create a program called IZY003P you would type in :

Code .. C Type .. P Name .. IZY003P

Mainframe & Natural Documentation.doc Page 5 / 49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 6/49

Mainframe & Natural Training Documentation

Changing Library

Type ‘LOGON <library-name>’ and press ENTER or 

• Move the cursor to the top right hand corner where the current library is displayed. Enter therequired library name and press ENTER 

Create a program

 ŸEnter a code of C - Create Enter the program type (see standards document), to create a program, the program type is P

 ŸEnter the name of the required program (remembering the standards) Press ENTER  This gives you a blank screen where you can add and modify code for your program.

Edit an existing program

From the main menu

 ŸEnter a code of E - Edit The program type is optional, if you do enter it, make sure you enter the correct program type for the

 program you wish to edit.

 ŸEnter the program name

 ŸPress ENTER 

 ŸThis will then bring the program into the program editor where you can modify it as required.

From the command line - this can mean the command line of the NATURAL editor or the commandline (at the top) of the program editor 

 ŸType ‘ E <program name> ‘ and press ENTER,

alternatively ‘ E <program-type> <program-name> ‘ and press ENTER 

If the program is already in the edit buffer (look at the top right hand corner, after the Library and theMode it says what is currently in the buffer)

Type E on the command line or in the code field and press ENTER 

Mainframe & Natural Documentation.doc Page 6 / 49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 7/49

Mainframe & Natural Training Documentation

The Program Editor 

Command Line

The program editor is the editor, which you use to modify programs. At the top of the editor is thecommand line.

The left-hand side of the command line is available for you to use to edit the program or run other  programs.

At the top right hand side of the command line are three fields:Direction indicator ModifiableProgram Name Not modifiableLibrary Not modifiable

The Direction Indicator can contain values ‘+’ or ‘-’ and these show the direction that commands will be processed. Therefore, if the direction indicator is ‘+’ and you try inserting a line. Then the line(s)will be inserted AFTER the line which you have entered the command.If the direction indicator is ‘-’ and you try inserting a line, then the line(s) will be inserted BEFORE theline. The Direction indicators affect all of the editing commands in the same way. The default is ‘+’

The Ruler Line

The Ruler Line is the line immediately after the command line and before the actual editor.This line contains three pieces of information:Position in the program - contains ‘TOP’, ‘ALL’, ‘ ‘ or ‘BOTTOM’ which show where in the programthe editor is showing.

Mainframe & Natural Documentation.doc Page 7 / 49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 8/49

Mainframe & Natural Training Documentation

Mode

This shows the mode of NATURAL which the program is written in. Two types of NATURAL exist.These are : STRUCTURED and REPORTING. Only legacy systems are written in REPORTINGmode. All new programs must be written in STRUCTURED mode. If the Mode says‘REPORTING’ and you wish to change it to STRUCTURED, then on the command line type

‘GLOBALS SM=ON’

Program Editor

The actual program editor on the screen contains the program line numbers on the left-hand side andthen the editor which contains the program code.

Before the Line Number

To the left of the program line numbers, there are a few blank characters. You cannot type anythinginto this column. This is used to mark lines. It is also used to show that a line is too long for the editor.

In this case the line will appear like this

L 0772 IF #COUNT = 1 THEN /* in the first instance do something differe

The Line Number

The next four characters show the program line number. Initially, the program editor marks all fields insteps of 10 and then when it inserts lines it uses the trailing character.

Therefore a program has four lines:0010002000300040

If you then insert lines between 0010 and 0020, they will be called 0011, 0012 and so on.

When you then stow the program, the line numbers are recalculated so that 0011 becomes 0020 and soon.

If there are more lines in the program than can be stored in steps of 10, then the editor willautomatically start storing them in steps of 5 (then 4, 3, 2 and finally 1). In which case, you will only beallowed to insert 4 lines at a time.

The program editor line number exists to allow line numbers to be identified in error messages, or alternatively to allow movement of the program within the editor.

Between the line number and the program code

 A character exists between the line number and program code which merely separates the two parts. Noediting can be done here. If you try to enter anything in this field the screen will lock and you will haveto reset the screen using the RESET key (different on each keyboard). With the Rumba default profilethis is <CTRL+R>.

Mainframe & Natural Documentation.doc Page 8 / 49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 9/49

Mainframe & Natural Training Documentation

 Libraries

Libraries are directories, they are where you store your work when you have created or modified anobject. It holds both the source and/or the object code.

Examples of libraries are

IZBWSystemGeneral

 Programming Modes

There are two styles of programming available to users of Natural :

REPORTING Original programming mode, easy to use not able to cope with complexapplications.

STRUCTURED Has more syntax rules for more complex applications

Reporting Structured

FIND CAR-FILE WITH CAR-MAKE = ‘VOLVO’ DEFINE DATASORTED BY NAME LOCAL

DISPLAY NAME CAR-MAKE 01 CAR VIEW OF CAR-FILECAR-MODEL YEAR 02 NAME

LOOP 02 CAR-MAKEEND 02 CAR-MODEL02 YEAR 

END-DEFINEFIND CAR WITH CARE-MAKE = ‘VOLVO’

SORTED BY NAMEDISPLAY NAME CAR-MAKE

CAR-MODEL YEAR END-FINDEND

 Natural Objects

There are three major groups of object types within Natural :

 Programmatic Objects Programs, Sub-programs Data Areas Global, Parameter, LocalScreen Layouts Maps

Each group performs different functions, and has it’s own editor. Programmatic and data objectscontain the statements/instructions for the computer about what it should do execution. Data objectsalso define the data that the programs are operating on. Map objects define the screen, and the report

layouts, as well as holding validation rules.

Mainframe & Natural Documentation.doc Page 9 / 49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 10/49

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 11/49

Mainframe & Natural Training Documentation

 Natural Syntax 

 Program Layout This is the basic structure of a NATURAL program, variables are declared in the DEFINE DATALOCAL section, which is closed with the END-DEFINE statement. Followed by the program logicthen the END statement.

DEFINE DATALOCAL

< Declarations >

END-DEFINE< Program Logic >

END

 Defining Variables

01 #POSTCODE (A8)

This is a standard variable declaration which declares a variable named #POSTCODE to be data typeA8. A8 is an Alphanumeric with a length of 8, basically a string of 8 in length.

It is also possible to REDEFINE variables into sub variables as follows.

01 #POSTCODE (A8)01 REDEFINE #POSTCODE

02 #CITY-CODE (A4)02 #STREET-CODE (A4)

Defined as above it allows us individual access to the separate parts of the postcode. While the entirestring remains accessible as #POSTCODE, the first 4 can be accessed as #CITY-CODE and the last 4as #STREET-CODE.

If you wish to assign a value to a variable when you define it you can use the INIT statement toinitialise it.

Example

01 #AUTHOR (A20) INIT <’Fred Bloggs’>01 #BOOK-NUMBER (N6) INIT <123456 >

Mainframe & Natural Documentation.doc Page 11 / 

49e

#POSTCODE

#CITY-CODE #STREET-CODE

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 12/49

Mainframe & Natural Training Documentation

British Steel Standards

Although not required within the NATURAL language and therefore not syntactically necessary,

it is part of the British Steel standards to precede variable names with a hash (#). Therefore you

should make this common practice.

Control Variables

A control variable allows a variables attributes to be altered during the program execution. Controlvariables can be assigned values in the same format as INPUT statements. These can also be used todecide whether the field has been modified by the user. You use IF <control-field> is MODIFIED, tocheck to see whether a field has been modified.

The control variable, is normally called the same as the field name, but with ‘-CV’ as a suffix.

A control variable is attached to a field in the input statement. Therefore, it is either attached on themap (within the CV field), or within the INPUT:

Definition Example

01 #FIELD-CV (C)

INPUT Example

INPUT ‘A Number’ (AD=O CD=NE) #NUMBER (CV=#NUMBER-CV)

MAP Examples

{ This will change the attributes of the field to Underlined and Turquoise }#ACTION-CV := (AD=U CD=TU)INPUT USING MAP ‘EXAMPLE’

 Logical Variables (Boolean)A logical variable has two values TRUE and FALSE.

A logical variable can be used within an IF statement in two ways:

IF #LOGIC = TRUE< statements >

END-IF

IF #LOGIC< statements >

END-IF

This becomes useful when you call logical variables interesting names.

Definition Example

01 #LOGIC (L)

Example

01 #ERROR (L)

IF #ERROR THEN<process error routine>

END-IF

Mainframe & Natural Documentation.doc Page 12 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 13/49

Mainframe & Natural Training Documentation

 Arrays

Arrays are defined using the following format:

01 #TEMP (A5/1:10)

This will define a 1 dimensional array with 10 occurrences of type A5. This can be accessed using#TEMP(1) which looks at occurrence 1 or #TEMP(*) which looks at all occurrences of #TEMP.

Multi-dimensional arrays Two dimensional and three dimensional arrays are also possible and are definedas follows.

Two Dimensional Array Example01 #TWO-DIM-ARRAY (A5/1:10,1:10) This will define a 2 dimensional array with 10x10 occurrences of type A5. A ccessing the firstitem in the array can be done using #TWO-DIM-ARRAY (1,1), or to access thewhole array use #TWO-DIM-ARRAY(*,*)

Three Dimensional Array Example01 #THREE-DIM-ARRAY (A5/1:10,1:10,1:10) This will define a 3 dimensional array with 10x10x10 occurrences of type A5. Accessing the firstitem in the array can be done using #THREE-DIM-ARRAY (1,1,1), or to access the

whole array use #THREE-DIM-ARRAY(*,*,*).

Variable Levels

Within a data area you may have many levels of variables.

Example

01 #TEMP02 #A (A1)

02 #B (A1)01 #TEMP2 (A5)01 REDEFINE #TEMP2

02 #C (N5)

This says that #A and #B can be grouped together and referred to group #TEMP. Or that #TEMP2 is analpha 5 character field but which can be redefined and accessed using #C which is numeric 5.Therefore if #TEMP2 = ‘12345’ then #C := 12345.

Mainframe & Natural Documentation.doc Page 13 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 14/49

Mainframe & Natural Training Documentation

 Defining Views

Views are similar to queries, they are collections of data from database tables. When you manipulatedata it is usually through a view. The closest data structure to a view is a an array of records, however only sequential access is possible.

Views must be defined in the DEFINE DATA section.

Example 1

{ This example will define a local version of the view CUSTOMER as MY-VIEW }

DEFINE DATA LOCAL01 MY-VIEW VIEW OF CUSTOMER 

02 CUSTOMER_ID

02 CUSTOMER_NAME02 CUSTOMER_ADDRESS

END-DEFINE

It is not necessary to always include all of the fields from a view when you define a local version. If aview has three fields for example as above, it could also be defined as below, but if it wereCUSTOMER_ADDRESS would not be defined in the program and therefore not accessible. Thiswould not be a concern however if CUSTOMER_ADDRESS was not needed by the code.

Example 2

{ This example will define a local version of the view CUSTOMER as MY-VIEW, but will not define theCUSTOMER_ADDRESS field of the view }

DEFINE DATA LOCAL

01 MY-VIEW VIEW OF CUSTOMER 02 CUSTOMER_ID02 CUSTOMER_NAME

END-DEFINE

Defining Views

The quickest way of defining views is with the .g(view,…) command. If you type this at the beginningof a line in the NATURAL editor, it will import the entire view into the editor. This is much quicker when using views that have hundreds of fields!

0010 DEFINE DATA LOCAL0020 .g( view, < viewname > )003000400050 END-DEFINE0060 END00700080

Listing the Definitions of a View

On the command line type L V <view-name>, this will then list all fields on <view-name> with their descriptions, formats and status (i.e. descriptors or not)

Mainframe & Natural Documentation.doc Page 14 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 15/49

Mainframe & Natural Training Documentation

 INPUT 

The input statement allows the displaying of and input of data. The data can also be formatted withcolours and properties.

Example 1 Example 2

{ This will take the input of the variable #NUM } { This will display a prompt and take the input of 

the variable #NUM }DEFINE DATA LOCAL DEFINE DATA LOCAL

01 #NUM (N5) 01 #NUM (N5)END-DEFINE END-DEFINE

INPUT #NUM INPUT ‘Enter number’ (AD=O) #NUMEND END

Properties can be defined in brackets after the variable/value to be displayed/inputted. AD is theattribute definition and is used to assign basic attributes.

You can also use this command to input external maps.

INPUT USING MAP ‘IZIN18M’

IF #ERROR THENREINPUT ‘Error’

END-IF

This will re-input #ERROR and show at the bottom of the screen, the error message ‘Error’.

If you use a REINPUT statement, it is often useful to show the user the exact location of the error. For example, if the error was that the user did not enter a value into a mandatory field then the user should

 be directed to the field they must enter. To do this you can use MARK and ALARM statements.

Example

REINPUT ‘Please enter a valid code’ MARK *#CODE (AD=V CD=RE) ALARM

MARK *#CODE places the cursor at the beginning of the field #CODE. *#CODE contains the positionon the screen of the field #CODE. Therefore to mark any field you must use *<field-name>

(AD=V CD=RE) highlights the field #CODE in red reverse video.

The statement ALARM, will sound a ‘beep’ when the error message is displayed. This further directsthe user’s attention to an error.

Mainframe & Natural Documentation.doc Page 15 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 16/49

Mainframe & Natural Training Documentation

 INPUT Attributes

You can set the attributes for the displaying of text or variables within an INPUT statement. You canset the attributes of individual components within the INPUT by setting them after each component, or you can set the attributes for the entire statement at the beginning..

 Attributes (AD)U UnderlinedM ModifiableP ProtectedO OutputT Translates text into upper case

Colours (CD)BL BlueGR Green

 NE NeutralRE RedTU TurquoiseYE Yellow

Example 1

{ This will display #COUNT with attribute O }

INPUT #COUNT(AD=O)

Example 2

{ This will display ‘Enter a number’ with attribute O and ask for the input of #COUNT as it has the

attribute U, displaying it as green (GR). }

INPUT ‘Enter a number’(AD=O) #COUNT(AD=U CD=GR) Example 3

{ This will display all of the INPUT statement with the attribute O }

INPUT (AD=O) ‘The current date is’ #DATE.

Standards exist at this site which must be used. See the Standards document.

Mainframe & Natural Documentation.doc Page 16 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 17/49

Mainframe & Natural Training Documentation

 Edit masks

Edit masks can be used to ensure data input to a field are of the correct format. They can be used witheither alphanumeric or numeric fields.

IF NOT (#DATEFIELD =MASK(YYYYMMDD))REINPUT 'Invalid date format ' (CD=RE) MARK *#DATEFIELD

END-IF

Where #DATEFIELD is an (A8), this edit mask will ensure that #DATEFIELD has the correct formatof year, month, day, if it doesn’t the user will be prompted to enter it again.

There are a number of values which can be checked

Character Meaning

. Position not to be checked.

A Position to be checked for alphabetical characters (upper or lower case).

‘c’ One or more positions to be checked for characters bounded by apostrophes(a double apostrophe indicates that a single apostrophe is the value .

C Position to be checked for alphanumeric content .

DD Two positions to be checked for a valid day notation(01-31) dependent on thevalues of MM and YY/YYYY, if specified.

H Position to be checked for hexadecimal content (A-F,0-9).

L Position to be checked for lowercase alphabetical content.

MM Positions to be checked for valid month (01-12).

 N Position to be checked for a numeric digit.

n… Position(s) to be checked for a numeric value (in the range 0 – n).

n1-n2 Positions to be checked for numeric value in the range n1<= value n2.

P Position to be checked for a printable character (U,N,L or S).

S Position to be checked for special characters.

U Position to be checked for uppercase alphabetical content (A-Z).

X Position to be checked against the equivalent position in the value followingthe MASK definition.

YY Two positions to be checked for a valid year (00-99).

YYYY Four positions to be checked for a valid year (0000-2099)

Mainframe & Natural Documentation.doc Page 17 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 18/49

Mainframe & Natural Training Documentation

WRITE 

Write is a basic screen display command to output text or variables to the screen.

Write statements wait for either the specified page size to fill up or the end of the program to displaydata.

Example 1

{ This example would not as you would expect display Hello then display world, but would display both at the same time, when the program terminates. If the program remained running, the page wouldneed to be filled up before the data was displayed. }DEFINE DATA LOCALEND-DEFINE

WRITE ‘HELLO’WRITE ‘WORLD!’

END

Example 2

{ This example will not display data to the screen until the page buffer fills up, therefore if the page buffer was 25 and no headings were being displayed, the program would display data when #X reachedthe value 25. You would then need to press enter to continue. }DEFINE DATA LOCAL

01 #X (N5)END-DEFINE

FOR #X = 1 to 100WRITE #X

END-FOR END

 IF 

The IF statement is a standard iteration statement that allows a set of statements to be performed only if a given set of logical expressions are true.

IF < logical expression >< statements >

ELSE< statements >

END-IF

ELSE is an optional part of the statement, if not required it is not necessary to use it.The IGNORE statement can also be used if you wish part of the IF statement to perform no function.

Example1 Example2

IF #CURRENT-YEAR = 2000 MILLENIUM := TRUEMILLENIUM := TRUE IF #CURRENT-YEAR = 2000

ELSE IGNORE

MILLENIUM := FALSE ELSEEND-IF MILLENIUM := FALSEEND-IF

Mainframe & Natural Documentation.doc Page 18 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 19/49

Mainframe & Natural Training Documentation

 Logical Conditions

 NATURAL uses Boolean Algebra in its Logical Conditions. Keywords are:

ANDOR 

 NOTTRUEFALSE

Other predicates are:

Letters Symbols Means

EQ = Equal To

 NE ¬= Not Equal ToGT > Greater ThanLT < Less ThanGE >= Greater Than or Equal ToLE <= Less Than or Equal To

 The Letters and Symbols can be used in your code interchangeably.

It is always a good idea to use brackets in your logical conditions to remove any ambiguity and makeyour code more readable.

 DECIDE FOR

A decide statement negates the need for multiple IF statements.

DECIDE FOR { FIRST/EVERY } CONDITIONWHEN < logical expression > < statements >

WHEN ANY < statements >

WHEN ALL < statements >

WHEN NONE < statements >/ IGNOREEND-DECIDE

This method of iteration can be used if there are many conditions that can result in different actions.

Example

( #VARIABLE defined as N1 and #VARIABLESTRING defined as A5 )

DECIDE FOR FIRST CONDITIONWHEN #VARIABLE = 1

#VARIABLESTRING := ‘ONE’WHEN #VARIABLE = 2

#VARIABLESTRING := ‘TWO’WHEN #VARIABLE = 3

#VARIABLESTRING := ‘THREE’WHEN NONE

#VARIABLESTRING := ‘ZERO’END-DECIDE

Mainframe & Natural Documentation.doc Page 19 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 20/49

Mainframe & Natural Training Documentation

 DECIDE ON Another version of the decide statement allows expressions on specified variables only as shown

 below.

DECIDE ON { FIRST/EVERY } VALUES OF operand1

VALUE < condition > < statements >

ANY VALUES < statements >

ALL VALUES < statements >

 NONE VALUES < statements >/IGNOREEND-DECIDE

Example( #VARIABLE defined as N1 and #VARIABLESTRING defined as A5 )

DECIDE ON FIRST VALUE OF #VARIABLEVALUE 1

#VARIABLESTRING := ‘ONE’VALUE 2

#VARIABLESTRING := ‘TWO’VALUE 3

#VARIABLESTRING := ‘THREE’ NONE VALUES

#VARIABLESTRING := ‘ZERO’END-DECIDE

 Loops

There are three versions of loops :- FOR, REPEAT and FIND

Each of these loops are covered below.

Any loop can be given a label to identify it precede the loops first statement with a label name followed by a full stop and a space.

REPEAT Label Example FOR Label Example

MYLABEL. REPEAT MYLABEL. FOR #COUNT = 1 to 10END-REPEAT END-FOR  

FOR Loop

A FOR loop will allow you to repeat a set of statements x amount of times.

FOR #COUNT = 1 to 10< statements >

END-FOR 

Mainframe & Natural Documentation.doc Page 20 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 21/49

Mainframe & Natural Training Documentation

As the loop processes, each parse will increment the #COUNT variable by 1, ending the loop with afinal parse where #COUNT equals 10.

 REPEAT Loop

REPEAT Loops allow the looping of a set of statements UNTIL a given logical expression is true or WHILE a given logical expression is true.

REPEAT< statements >

END-REPEAT

A basic REPEAT loop like the one above will simply loop infinitely, the UNTIL or WHILE commandcan be used as a means of exiting.

The statements can either be immediately after the REPEAT statement or immediately before theEND-REPEAT statement, depending upon when the check is needed.

WHILE Example UNTIL Example

#X := 1 #X := 1REPEAT REPEAT

#X := #X + 1 #X := #X + 1WHILE #X < 10 UNTIL #X = 10

END-REPEAT END-REPEAT

FIND Loop

A FIND loop is used to query a database table or view in order to find specific records.

FIND < viewname > WITH < search criteria >< statements >

END-FIND

A find loop will scan the specified view for a record matching the search criteria. Every time a recordis found, the statements inside the loop will be executed. When no more matching records can be foundthe loop will exit.

Example

{ If we wished to find a record in the view COLD-STOCK with the field AA12CIDN = 12345 then we

would format the find as follows }FIND COLD-STOCK WITH AA12CIDN = 12345END-FIND

We can also limit the amount of record that we look for, i.e. if we were only interested in finding onerecord we could specify it, which would stop the program searching the rest of the view or table andincreasing wasted processor usage.We can specify the amount of records to find by placing it in brackets after the FIND statement.

Limited Example

FIND(1) COLD-STOCK WITH AA12CIDN = 12345END-FIND

Mainframe & Natural Documentation.doc Page 21 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 22/49

Mainframe & Natural Training Documentation

If we give the FIND loop a label and use the command NUMBER in the statement then we can returnthe amount of matching records within a table or view. A END-FIND is not required if we use thecommand in this way. The number found can then be utilised with the *NUMBER statement.

Count Example{ #AMOUNT defined as N5 }

MYLABEL. FIND NUMBER COLD-STOCK WITH AA12CIDN = 12345#AMOUNT := *NUMBER( MYLABEL. )

The sorted by statement can be used to return records matching the criteria sorted by a specific field.The statement can be used to sort ascending or descending.

Ascending Sorting Example

FIND CUSTOMER WITH CUSTOMER_ID NE ‘ ‘SORTED BY CUSTOMER_NAME

END-FIND

Descending Sorting ExampleFIND CUSTOMER WITH CUSTOMER_ID NE ‘ ‘

SORTED BY CUSTOMER_NAME DESCENDINGEND-FIND

 IF NO RECORDS FOUND

A FIND statement is a loop around all the records on the database matching the given search criteria. If no records are found, then the loop collapses and no statements within the FIND - END-FIND are

 processed. There are some cases when it is useful to carry out some processing if no records match thesearch criteria. In this case we can use a NO RECORDS clause:

Example

FIND-AN-ORDER.FIND GW-VGW03351 WITH SUPPLY_ORDER_NUMBR = ‘123456789’

IF NO RECORDS FOUNDINPUT ‘Error, order does not exist’ESCAPE BOTTOM (FIND-AN-ORDER.) IMMEDIATE

END-NOREC<process-order>

END-FIND

In this example, if the order number does not exist, then an error message is displayed and the loop isescaped.

If you have an IF NO RECORDS FOUND clause, you should always have an ESCAPE BOTTOM(LABEL.) IMMEDIATE, since you have now entered within the FIND - END-FIND loop andtherefore the statements before the END-FIND will be carried out.

The same functionality is used when using a FIND (1).

If you use a FIND NUMBER, then checking for no records is slightly different.

CHECK-EXISTENCE.

FIND NUMBER GW-VGW03351 WITH SUPPLY_ORDER_NUMBR = ‘123456789’IF *NUMBER(CHECK-EXISTENCE) = 0INPUT ‘Order does not exist’

Mainframe & Natural Documentation.doc Page 22 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 23/49

Mainframe & Natural Training Documentation

END-IF

  Notice that the FIND NUMBER has no END-FIND (since it is not a loop) but the IF*NUMBER(CHECK-EXISTENCE) = 0 requires an END-IF because it is just a simple IF statement.

 ESCAPE 

The escape statement is used to escape from any loop. Placed inside a loop there are four variations of the statement.

ESCAPE BOTTOM Exits the current loop continuing from bottom.ESCAPE TOP Exits the current loop continuing from top, therefore re-entering the loop.ESCAPE ROUTINE Exits the current Sub Routine.ESCAPE Same as ESCAPE BOTTOM.STOP This could be used instead of ESCAPE ROUTINE in a program. The STOP command stops

 processing any more Natural.

Any of the statements can be succeeded with a label name to specify which loop to escape.

Normal Example

REPEATIF #OPTION = ‘EXIT’ ESCAPE BOTTOMEND-IF

END-REPEAT

Label Example

MYLABEL. REPEATIF #OPTION = ‘EXIT’ ESCAPE( MYLABEL. )END-IF

END-REPEAT

 MOVE 

There are many different statements which cause the value of one field to be moved to another. Themain ones are:

MOVE <operand1> to <operand2>

Example

{ which will move the value of 5 into #COUNT }

MOVE 5 TO #COUNT

 ASSIGN 

ASSIGN <operand1> = <operand2><operand1> := <operand2>

Example 1

{ This will assign the value of 5 to #COUNT }

Mainframe & Natural Documentation.doc Page 23 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 24/49

Mainframe & Natural Training Documentation

ASSIGN #COUNT = 5

Example 2

{ Assignments can also be made with the following syntax }

#COUNT := 5

COMPRESS 

Compress is used to construct a string from various components.

COMPRESS <String 1> <String 2> <String X> INTO <Destination String>

Example

{ This example will COMPRESS #FIRST-NAME #MIDDLE-NAME and #LAST-NAME into the

variable #FULL-NAME }

DEFINE DATA LOCAL

01 #FIRST-NAME (A10) INIT <’Billy’>01 #MIDDLE-NAME (A10) INIT <’Jo’>01 #LAST-NAME (A10) INIT <’Jones’>01 #FULL-NAME (A30)

END-DEFINECOMPRESS #FIRST-NAME #MIDDLE-NAME #LAST-NAME INTO #FULL-NAMEWRITE #FULL-NAME

END

COMPUTE Compute will solve a mathematical equation on the right and store the result in the variable given onthe left.

COMPUTE <operand 1> = <operand2>

Example

{ This will calculate the value of #VARIABLE-ONE plus #VARIABLE-TWO and store the result in#TOTAL }

COMPUTE #TOTAL = #VARIABLE-ONE + #VARIABLE-TWO

UPDATE 

When a change has been assigned to a view the UPDATE command must be used to actually make thechanges to the view.

Example 1

{ This example would not actually change the CUSTOMER_NAME as UPDATE has not been used }

DEFINE DATA LOCAL01 CUSTOMER VIEW OF CUSTOMER 

02 CUSTOMER_ID

02 CUSTOMER_NAMEEND-DEFINE

Mainframe & Natural Documentation.doc Page 24 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 25/49

Mainframe & Natural Training Documentation

LABEL.FIND (1) CUSTOMER WITH CUSTOMER_ID = ‘00001’

CUSTOMER_NAME := ‘Jeffs Solid Structures’END-FIND

END

Example 2

{ This example would make the changes to the view }

DEFINE DATA LOCAL01 CUSTOMER VIEW OF CUSTOMER 

02 CUSTOMER_ID02 CUSTOMER_NAME

END-DEFINE

LABEL.FIND (1) CUSTOMER WITH CUSTOMER = ‘00001’

CUSTOMER_NAME := ‘Jeffs Solid Structures’UPDATE (LABEL.)

END-FIND

END

You cannot UPDATE the value in a primary key field. As the primary key is the unique identifier of arecord, updating it is actually creating a new record .

 STORE 

The store command will create a new record containing the current records details.

STORE < view name >

Example

{ This example will search for the record with CUSTOMER_ID = 12345 and change the ID to 11111,

it will not actually change in the tables because an UPDATE has not been issued. The STORE  statement will then create a new record with the same details as this record including any that have

been changed. }

FIND(1) CUSTOMER WITH CUSTOMER_ID = ‘12345’CUSTOMER_ID := ‘11111’STORE CUSTOMER 

END-FIND

 DELETE 

The delete command removes the current record from the specified find label.

DELETE < label name >

Label name is optional, but keeps your program more readable, therefore more easily maintainable.The label also makes it obvious what records are to be deleted.

Example

{ This example will delete the record with CUSTOMER_ID = 00000 }

Mainframe & Natural Documentation.doc Page 25 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 26/49

Mainframe & Natural Training Documentation

MYLABEL. FIND(1) CUSTOMER WITH CUSTOMER_ID = 00000DELETE ( MYLABEL. )END-FIND

 END TRANSACTION 

This statement will make all changes made to views since the last end transaction permanent. They will be updated in the database tables. In the above programs ( Examples for Update, Store and delete ), theend of the program is reached and this has the same effect as end transaction. Once an end transactionhas been reached the data can not be backed out with backout transaction.

Example

{ This example would make the changes to the view as above }

DEFINE DATALOCAL

01 CUSTOMER VIEW OF CUSTOMER 02 CUSTOMER_ID02 CUSTOMER_NAME

END-DEFINE

LABEL.FIND (1) CUSTOMER WITH CUSTOMER_ID = ‘00001’

CUSTOMER_NAME := ‘Jeffs Solid Structures’UPDATE(LABEL.)

END-FIND

END TRANSACTIONEND

The END TRANSACTION must appear outside the FIND loop.

If screen I/O occurs, it has the same effect as an End Transaction being issued.

 BACKOUT TRANSACTION 

This statement allows all data that has been altered on views to be reverted to its previous values unlessan end transaction has already been issued.

Example

{ This example would make the changes to the view but then revert them to their previous values }

DEFINE DATALOCAL01 CUSTOMER VIEW OF CUSTOMER 

02 CUSTOMER_ID02 CUSTOMER_NAME

END-DEFINE

LABEL.FIND (1) CUSTOMER WITH CUSTOMER_ID = ‘00001’

CUSTOMER_NAME := ‘Jeffs Solid Structures’UPDATE (LABEL.)

END-FIND

Mainframe & Natural Documentation.doc Page 26 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 27/49

Mainframe & Natural Training Documentation

BACKOUT TRANSACTION

END

 PERFORM 

The perform statement is used to call sub routines

Example

{ This example will call the sub routine MY-SUBROUTINE with #MY-PARAMETER1 and #MY-PARAMETER2 as parameters. }

PERFORM MY-SUBROUTINE #MY-PARAMETER1 #MY-PARAMETER2

 Subroutines

External and Internal subroutines can exist. If you call an internal subroutine then you don’t pass any parameters because it immediately has access to all the variables defined within the calling routine. Butexternal subroutines must be passed parameters:

Internal Syntax

DEFINE SUBROUTINE <subroutine-name><subroutine-logic>

END-SUBROUTINE

External SyntaxDEFINE DATAPARAMETER 

<parameter-list>

LOCAL<local list>

END-DEFINEDEFINE SUBROUTINE <subroutine-name> 

<program logic>

END-SUBROUTINEEND

The <subroutine-name> as defined within the DEFINE SUBROUTINE statement must match exactlythe name called in the PERFORM. This becomes an issue in external subroutines which have the codename as, say, IZSUB1S, but are defined as DEFINE SUBROUTINE PROCESS-RECORD, in whichcase, to PERFORM the subroutine you would

Example

PERFORM PROCESS-RECORD

FETCH RETURN 

The Fetch Return statement is used to call programs.FETCH RETURN <program-name> <parameter-list>

Mainframe & Natural Documentation.doc Page 27 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 28/49

Mainframe & Natural Training Documentation

The program being called is a standard natural program.

To receive parameters in a program you must check the stack to see whether and exist and then processthem. This is done in the receiving/called program.

IF *DATA GT 0INPUT <parameter-list >

END-IF

Example

{ This example will call the program STUD1 with #MY-PARAMETER as a parameter }

FETCH RETURN ‘STUD1’ #MY-PARAMETER 

CALLNAT 

The CALLNAT statement is used to call sub programs.

CALLNAT ‘<subprogram-name>’ <parameter-list>

The subprogram layout is :

DEFINE DATAPARAMETER 

<parameter list>

LOCAL<local data list>

END-DEFINE<program logic>

END

Example

{ This example will call the sub program STUDSUB with #MY-PARAM as a parameter }

CALLNAT ‘STUDSUB’ #MY-PARAM

 Date and Time system variables

The following date and time system variables may be specified in an ASSIGN, COMPUTE,DISPLAY, MOVE, WRITE statement and in logical criteria:

Date

Variable

Format/

Length

Explanation

*DATD A8 Current date in format DD.MM.YY.

*DATE A8 Current date in format DD/MM/YY.

*DATG A15 Current date in format DdmonthnameYYYY(Gregorian format).

*DATI A8 Current date in formatYY-MM-DD.

Mainframe & Natural Documentation.doc Page 28 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 29/49

Mainframe & Natural Training Documentation

*DATJ A5 Current Julian date in format YYDDD.

*DATN N8 Current date in format YYYYMMDD.

*DATU A8 Current date in format MM/DD/YY.

*DATX D Current date in internal date format.

Time

Variable

Format/

Length

Explanation

*TIMD(r) N7 May only be used in conjunction with a previous SETTIME statement and contains theelapsed time difference between the time baseestablished by SETTIME and the current time(in format HHMMSST).

*TIME A10 Time of day in format HH:MM:SS.T.

*TIME-OUT N5 Specifies the number of seconds remaining before the current transaction will be timed out(only available with NATURAL SECURITY).*TIME-OUT is reset to zero with theexecution of an END TRANSACTION or BACKOUT TRANSACTIONstatement.

*TIMESTMP B8 Machine internal store clock value.

*TIMN N7 Time of day in format HHMMSST

*TIMX T Time of day in internal format

Timestamp

There is a British steel subroutine called BSSTMPS which will return the current timestamp, a field of A26 must be used when calling this routine.

Format

YYYY-MM-DD-HH.MM.SS.TTTTTT

Example

{ To move the current timestamp into #TIMESTAMP(A26) }

PERFORM BSSTMPS #TIMESTAMP

MOVE EDITED

When processing date and time fields it may be necessary to use the MOVE EDITED command along

with an edit mask (EM)

Mainframe & Natural Documentation.doc Page 29 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 30/49

Mainframe & Natural Training Documentation

Example 1

{ This example moves a date from a date field in the format YYYYMMDD to another field in the format 

 DDMMYYYY. }01 #DATE (D)02 #DATE2 (A8)

MOVE EDITED #DATE(EM=DDMMYYYY) TO #DATE2

Example 2

{ This example will move the contents from #DATE2 to #DATE in format YYYYMMDD }

MOVE EDITED #DATE2 TO #DATE(EM=YYYYMMDD)

Windows

Sometimes a program calls for a window to be used for error or warning messages. To do this you firstof all need to define the window at the start of the program, then you need to input the window with therequired information at the required point in the code.

Definition

DEFINE WINDOW < window-name >

SIZE {AUTO | QUARTER | operand1 * operand2}BASE {CURSOR | {TOP | BOTTOM} {LEFT | RIGHT} | operand3 / operand4 }TITLE <title-text>

FRAMED ON | OFF

Example 1

{ This defines the window called ‘ERROR’, which when it appears will have the title ‘Error’ at the top

of it. It’s size adjusts to the size of the information contained in it and the base appears at row 8column 15. The frame is switched on }

DEFINE WINDOW ERROR SIZE AUTOBASE 8/15TITLE ‘Error’FRAMED ON

To use the window which has been defined:

INPUT WINDOW = ‘<window-name>’ 

You then use the statement like an ordinary INPUT statement and use input attributes as before.

Example 2

{ This example will display the window and display the text inside it }

INPUT WINDOW = ‘ERROR’// ‘ Error, you do not have security to this function’ (CD=NE)

British Steel Standards

The window frame should always be set on

Mainframe & Natural Documentation.doc Page 30 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 31/49

Mainframe & Natural Training Documentation

Comments

As you know it is good practice to put comments in your programs. There are three ways you can usethese in Natural:

* An asterisks with a space after it** Two asterisks, there is no need for a space on this one./* Use this one when the comment starts after some Natural code and appears in the middle of 

the screen.

Example

{ The following is a code listing containing valid comments }

0010 DEFINE DATA LOCAL0020 * This is a comment

0030 END-DEFINE0040 ** This is a comment0050 END /* This is a comment00600070

 PF-Keys

PF-Keys must be set so that they display the correct data at the bottom of the screen and so they are“available” for use.

To enable key naming use the FORMAT KD. This will display the PF-Key bar at the bottom of thescreen.

Example 1

{ This will display the PF-Key bar at the bottom of the screen with ‘Exit’ underneath the PF3 key, PF3

will also be available for use. }

FORMAT KD=ONSET KEY PF3 NAMED ‘EXIT’

Although we have set the key name and made it visible on the screen, PF3 will still perform nofunction until we check which key has been pressed and perform a function for that key.

Example 2

{ This will allow a specific function to be performed after a PF-Key has been pressed }

FORMAT KD=ONSET KEY PF3 NAMED ‘Exit’SET KEY PF7 NAMED ‘Up’SET KEY PF8 NAMED ‘Down’DECIDE ON FIRST VALUE OF *PF-KEY

VALUE ‘PF3’STOP

VALUE ‘PF7’PERFORM SCROLL-UPVALUE ‘PF8’

Mainframe & Natural Documentation.doc Page 31 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 32/49

Mainframe & Natural Training Documentation

PERFORM SCROLL-DOWN NONE VALUES

REINPUT ‘Invalid Key’END-DECIDE

British Steel Standards

British Steel have standards regarding the use of PF-Keys and their functions and these

standards need to be followed.

 Log Counter 

All views in DB2 which can be updated have a field called LOG_COUNTER. This is used to stopcorruption of the information.

ExampleUser A, who works in New York, retrieves a record of Coating Code ‘AA’ and displays it to the screen.He notes that the description is ‘Coating AA’. He then goes to lunch. Meanwhile, User B, who lives inSydney, retrieves Coating Code ‘AA’ and modifies the description to be ‘Another Coating Type’. User B updates the record and continues with his job. User A then returns from lunch and looks at his screenwhere Coating Code ‘AA’ is still displayed as it was before lunch with description ‘Coating AA’. Heremembers what he was doing before lunch and modifies the description to be ‘Coating AADescription’, presses ENTER, updates the record and goes about his afternoon’s work. Now who hascreated the right description? User A or User B?

To stop cases of this occurring the LOG_COUNTER is used.

When you display a record, a note is made of the LOG_COUNTER. When you then try to update the

record a check is made to see that the LOG_COUNTER on the file is the same as the one you havenoted. If it isn’t then the update is not allowed.

Therefore in our example, User A displays Coating ‘AA’ and the LOG_COUNTER is 1. User Bupdates the LOG_COUNTER to 2. User A comes back from lunch and tries to modify the record butthe LOG_COUNTER is now different. He must redisplay the record to be allowed to then modify it.

The LOG_COUNTER exists on all views in DB2 which can be updated but the checking and

updating of it is done within the program. You are therefore responsible to check and update it

within your own program. 

Mainframe & Natural Documentation.doc Page 32 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 33/49

Mainframe & Natural Training Documentation

 Program editing commands

To use any of the editing commands described below, you must start the command on the firstcharacter of the line. The ‘.’ in the first character then tells the editor that this is a command and notsimply text or part of the program.

Insert a line .i on the line you wish to insert lines at. This inserts 9 lines at the cursor position. If you do not use all 9lines then the program editor will simply collapse all of the blank lines. If you require less than 9 linesinserted then either type .i(n) where n is the number of lines to be inserted.

Inserting lines from another program

The program which you wish to copy lines from, must exist in the same library and also be inDevelopment.

At the place in the code where you wish to copy the lines, type

.i( <program-name>, <starting-line>, <number-of-lines> )

< program-name > must be in capitals.

< starting-line > is the first line of the program which you wish to copy.

This is not the line which appears at the left of the program editor (0010,0020). It is the LINE NUMBER. Therefore, the line marked 0010 in the program editor, is actually line 1. The line marked0530 is actually line 53, and so on. The complication comes when the program editor marks line s inmultiples of 5 or less, then you have to work out that the line marked as 0005 is line 1 and the linemarked 0010 is line 2, and so on.< number-of-lines > is the number of lines (including the first line) which you want to copy.

If you type .i(< program-name >), then the whole of <program-name> will be inserted.

Mark a line

.x on the line to be marked with a X

.y on the line to be marked with a Y

Delete a line

.d on the line to be deleted. This command can be used on many lines at once if more than one line isrequired for deletion. To delete a number of lines type .d(X) where X is the number of lines you wishto delete.

To delete a block of lines then mark the first line to be deleted with an X and the last line to be deletedwith a Y and then on the command line type dx-y

Mainframe & Natural Documentation.doc Page 33 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 34/49

Mainframe & Natural Training Documentation

Copy a line

.c on the line to be copied.

To copy a line to another place within the program. Mark the line with an X and then on the line where

you wish the line to be copied to and then type .cx

To copy a block of lines, then mark the first line to be copied with an X and the last line to be copiedwith a Y and then move the cursor to the line you wish the lines to be copied to and type .cx-y

Move a line

.mx on the line where you wish the line marked with an X to be moved to.To move a block of lines, then mark the first line of the block with an X and the last line of the block with a Y and then move the cursor to the line you wish the lines to be moved to and type .mx-y

Split a line

.s on the line to be split and the WITHOUT PRESSING ENTER move the cursor to the position theline is to be split at and then press ENTER.

Join two lines

.j on the line and press ENTER and this will join the line with the one immediately below it.

Scroll through code

PF7 scrolls up. PF8 scrolls down

Reposition screen at a particular point

Either type a line number on the command line to move that line to the top of the program editor.Alternatively, type .p on the line which is to be moved to the top of the program editor and pressENTER.

Scan for a particular value

Type sc on the command line and a window appears which allows you to scan and replace information.Leave the replace value field blank if you just want to scan. Remember that scanning is case sensitive.The scan looks at all words and checks them exactly for the scan value. If you require a scan whichlooks at part of words then check the ‘Absolute scan’ field in the scan window.

Alternatively, on the command line, you can type sc < scan-value > and press ENTER. This will not bring up the scan window.

When the program has found a match for  < scan-value >, press PF11 to scroll back to the previousmatch and PF12 to find the next match.

Mainframe & Natural Documentation.doc Page 34 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 35/49

Mainframe & Natural Training Documentation

 Standards

Variable Naming

All user defined variables within a program should begin within a #. Therefore a variable used to

represent a year should be #YEAR.

Program Naming

 XX_ _ _ _ _ _ Project Code

Example IZ

 _ _XXXX_ _ Program Code

Example MCSM/T004

 _ _ _ _ _ _X_ Program Type

P Program N SubprogramS Subroutine

M MapA Parameter Data Area (PDA)L Local data areaG Global Data AreaC Copy codeT TextH Help Routine

 _ _ _ _ _ _ _X Unique Suffix

1 Unique suffix, can be blank, 0-9 or A-Z

Screens

PF-Key Function Text Type Colour

PF1 Help Optional Modifiable Yellow and UnderlinedPF3 Exit Mandatory Modifiable Green and UnderlinedPF6 Confirm Text WhitePF7 Scroll Backwards Output Only TurquoisePF8 Scroll Forwards

PF12 CancelPF19 Page LeftPF20 Page RightPF24 Main Menu

Screen Text 

Instruction on a screen or prompts for input are classed as text and should be displayed with standardattributes.

Mainframe & Natural Documentation.doc Page 35 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 36/49

Mainframe & Natural Training Documentation

Modifiable Fields

All modifiable fields should be underlined. A modifiable field is one which you want a user to enter avalue into.

Mandatory Modifiable Fields

A field is mandatory when it is compulsory for the user to enter a value.

 Output Fields

If a field is to display information to the user then it is an output field. These are fields which the user has no ability to modify.

All text must be correctly punctuated.

All fields on a screen must line up with each other. The only exception to this rule is that the actionfield must be left in the default position. 

Action……:Code…………..:Description……:

Standards say that if there is space for the full description then it should be used, otherwise replacedwith a sensible alternative:

Good

Coating Code………:Coating Description..:

Or Coating Code....:Coating Desc…:

Full field descriptors andcorrectly aligned.

‘Coating Description’ shortened but still understandable andfields remain correctly Aligned.

Bad

Code…………………:

Coating Description…:

Or C…..:

D…..:

On the left we can see that‘Coating Code’ has beenshortened but there was spacefor the full field descriptor.

 Not very descriptive!

For modifiable fields there should be no colon (:), these should only appear for output fields.

Mainframe & Natural Documentation.doc Page 36 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 37/49

Mainframe & Natural Training Documentation

 DB2 Query Efficiency Issues

You should always make DB2 do the work rather than NATURAL. When coding FIND’s and loopswhich interrogate views you should be very careful about how they are coded. It is always better to getDB2 to do as much of the work as possible. When DB2 is accessed SQL code is generated to performthe query, This code is only generated once for Options 2 & 3 whilst being generated on each parse for 

Option 1.

Example

Consider a time when you may wish to interrogate all orders from Toyota (A1234). You could do thisin three ways.

Option 1 - All NATURAL

FIND GW-VGW03351 WITH SUPPLY_ORDER_NUMBR NE ‘ ‘IF CUSTOMER NE ‘A1234’ THEN

ESCAPE TOP IMMEDIATE

END-IFEND-FIND

This will find all the orders on the order file and then NATURAL (or the program) will disregard allthe orders not belonging to TOYOTA.

THIS OPTION IS HIGHLY INEFFICIENT AND IS NOT RECOMMENDED OR 

SUPPORTED BY CAP GEMINI.

Option 2 - Some NATURAL and some DB2

FIND GW-VGW03351 WITH CUSTOMER = ‘A1234’

END-FIND

This will find all the orders on the order file belonging to TOYOTA. In this example, DB2 is doing thework, since the search only finds TOYOTA orders. This is usually the most efficient method of searching for data, but on occasion where a specific view exists it is more efficient to use Option 3.

Option 3 - All DB2

FIND GW-VGW0335EG WITH SUPPLY_ORDER_NUMBR NE ‘ ‘END-FIND

This will find all the orders on the view of the order file GW-VGW0335EG which has been previously

 been set up to show only TOYOTA orders.

Mainframe & Natural Documentation.doc Page 37 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 38/49

Mainframe & Natural Training Documentation

This option is highly efficient when TOYOTA orders are treated differently many times. It is notusually the case to create new views for occasions when the view will only be used once. However, thisis sometimes the case. It is best to seek advice on this matter. Normally the analyst will tell you whichview to use and the decision in the matter of new views being created has already been taken.

An official CAP GEMINI document has been created as to DB2 and SQL best practices

 Example Code

For the examples, I have used the following views. These views are fictional, so don’t try and usethem!

ORDER CUSTOMER  

ORDER_ID ( Primary Key ) CUSTOMER_ID ( Primary Key )ORDER_DATE CUSTOMER_NAMEORDER_DESCRIPTION CUSTOMER_ADDRESSCUSTOMER_ID

1) A program to change the name of a customer, using a FIND loop with UPDATE and END-

TRANSACTION statements.

Spec: A program to change the name of customer with CUSTOMER_ID equal to 12345 to Bobs

 Jobs Inc.

DEFINE DATA LOCAL

01 CUSTOMER VIEW OF CUSTOMER 02 CUSTOMER_ID02 CUSTOMER_NAME02 CUSTOMER_ADDRESS

END-DEFINE

LABEL.FIND(1) CUSTOMER WITH CUSTOMER_ID = ‘12345’CUSTOMER_NAME := ‘Bobs Jobs Inc’UPDATE (LABEL.)END-FIND

END TRANSACTION

END

2) A program that changes the name of a customer for a specific order, using a nested FIND

loop.

Spec: A program to change the name of the customer who placed the order with ORDER_ID =54321 to Teds Freight Company.

DEFINE DATA LOCAL01 CUSTOMER VIEW OF CUSTOMER 

Mainframe & Natural Documentation.doc Page 38 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 39/49

Mainframe & Natural Training Documentation

02 CUSTOMER_ID02 CUSTOMER_NAME02 CUSTOMER_ADDRESS

01 ORDER VIEW OF ORDER 02 ORDER_ID02 ORDER_DATE

02 ORDER_DESCRIPTION02 CUSTOMER_ID

END-DEFINE

FIND(1) ORDER WITH ORDER_ID = 54321

LABEL.FIND(1) CUSTOMER WITH CUSTOMER_ID = ORDER.CUSTOMER_IDCUSTOMER_NAME := ‘Teds Freight Company’UPDATE (LABEL.)END-FIND

END-FIND

END TRANSACTION

END3) A program that displays customer information for an inputted order, using a nested FIND

and using statements WRITE and INPUT. Also IF NO RECORDS FOUND should be used

to display an error message if the order does not exist.

Spec : A program that displays all customer details for a particular order. The program should 

 prompt for the order id and display an error message if it does not exist.

DEFINE DATA LOCAL01 CUSTOMER VIEW OF CUSTOMER 

02 CUSTOMER_ID02 CUSTOMER_NAME02 CUSTOMER_ADDRESS

01 ORDER VIEW OF ORDER 02 ORDER_ID02 ORDER_DATE02 ORDER_DESCRIPTION02 CUSTOMER_ID

01 #ORDER-CRITERIA (N5)END-DEFINE

INPUT ‘Enter Order Id : ‘ (AD=O) #ORDER-CRITERIAFIND(1) ORDER WITH ORDER_ID = #ORDER-CRITERIA

IF NO RECORDS FOUNDINPUT (AD=O) ‘Error – Order does not exist with order id ‘

#ORDER-CRITERIAESCAPE ROUTINE

END-NORECFIND(1) CUSTOMER WITH CUSTOMER_ID = ORDER.CUSTOMER_IDEND-FIND

END-FINDWRITE CUSTOMER_ID CUSTOMER_NAME CUSTOMER_ADDRESS

END

4) A program that copies a record using the STORE statement and deletes a record using the

DELETE statement.

Mainframe & Natural Documentation.doc Page 39 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 40/49

Mainframe & Natural Training Documentation

Spec : A program that will copy the contents of customer record with CUSTOMER_ID = 10101 to a

new record and give it a customer name of ‘Aluns Crowbars Ltd’ and a customer id of 99999,

then deleting the old record with CUSTOMER_ID = 10101.

DEFINE DATA LOCAL01 CUSTOMER VIEW OF CUSTOMER 

02 CUSTOMER_ID02 CUSTOMER_NAME02 CUSTOMER_ADDRESS

END-DEFINE

CUSRCH.FIND(1) CUSTOMER WITH CUSTOMER_ID = 10101CUSTOMER_ID := 99999CUSTOMER_NAME := ‘Aluns Crowbars Ltd’STORE CUSTOMER DELETE (CUSRCH. )END-FIND

END TRANSACTION

END

5) A program that retrieves the date of the most recent order for a particular customer and

displays how many days it has been since that order. This program should use variables of 

type D and incorporate EDIT MASKS.

Spec : Find the date of the most recent order for an inputted CUSTOMER_ID and calculate the

number of days between that date and the current date on the system.

DEFINE DATA LOCAL01 CUSTOMER VIEW OF CUSTOMER 

02 CUSTOMER_ID02 CUSTOMER_NAME02 CUSTOMER_ADDRESS

01 ORDER VIEW OF ORDER 02 ORDER_ID02 ORDER_DATE02 ORDER_DESCRIPTION02 CUSTOMER_ID

01 #ORDER-CRITERIA (N5)01 #MOST-RECENT-ORDER-DATE (D)01 #DAYS (N8)

END-DEFINE** NB* 01 / 01 / 1582 is the earliest valid date accepted by NATURAL variables of type D.*MOVE EDITED ‘15820101’ TO

#MOST-RECENT-ORDER-DATE (EM=YYYY’/’MM’/’DD)INPUT (AD=O) ‘Enter Customer ID : ‘ #ORDER-CRITERIAFIND ORDER WITH CUSTOMER_ID = #ORDER-CRITERIA

IF NO RECORDSINPUT (AD=O) ‘This customer has never placed an order.’ESCAPE ROUTINE

END-NORECIF ORDER_DATE > #MOST-RECENT-ORDER-DATE

#MOST-RECENT-ORDER-DATE := ORDER_DATE

Mainframe & Natural Documentation.doc Page 40 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 41/49

Mainframe & Natural Training Documentation

END-IFEND-FINDSUBTRACT #MOST-RECENT-ORDER-DATE FROM *DATX GIVING #DAYSINPUT (AD=O) ‘Customer ID =’ #ORDER-CRITERIA

/ ‘Most Recent Order Date =’ #MOST-RECENT-ORDER-DATE/ ‘Current Date =’ *DATX (EM=DD’/’MM’/’YYYY)

/ ‘Number of days since last order =’ #DAYSEND

 Map editor 

To get into the map editor go into Development Facilities then create a Map, giving it a suitable name.Press enter and you should be at the map editor menu. Call the map TE_ _MAP1 (blanks are your initials)

Code .. C Type .. M Name .. TE_ _MAP1__________________ 

Ensure the profile is DOMMI, then choose to initialise the map.

Code .. I Name .. TE_ _MAP1 Profile .. DOMMI_________  

On pressing ENTER the map settings screen will now be displayed showing the delimiters, format, etc.

Mainframe & Natural Documentation.doc Page 41 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 42/49

Mainframe & Natural Training Documentation

Delimiters

Delimiters control the class, attributes and colour of the fields on the map.

Cls (class)

A Input FieldM Output field (modifiable)O Output field (not modifiable)T Text constant  Attr (attributes)

B BlinkingD Default IntensityI intensified

 N Non-DisplayU underlinedC Cursic/ItalicV Inverse VideoY Dynamic (Controlled from calling program, by using control variables)

CD (Colour Definition)

BL Blue

GR green NE Neutral (white)

Mainframe & Natural Documentation.doc Page 42 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 43/49

Mainframe & Natural Training Documentation

PI Pink  RE RedTU TurquoiseYE Yellow

Layout

Standard map layouts have been provided to aid development of programs.

The layouts are as follows:BSLAY Basic map (heading and field only)BSLAYFM1 File maintenance (heading, command and action)BSLAYFM2 File maintenance (as above with scrolling)BSLAYFM3 File maintenance (new model with action array)BSLAYMN1 MenuBSLAYMP1 Multi purpose screen with action code fieldBSLAYOM1 Object maintenance (heading, command and action)BSLAYOM2 Object maintenance (as above with scrolling)

BSLAYSC1 Primary key inputBSLAYSL1 Browse (heading, command, key-input and action array)BSLAYSL2 Browse (as above minus action array)

These layouts may be used by setting the profile to DOMMI. For training purposes the layout has beenleft blank (you will need to blank in out on your map)

Pressing Enter should take you through to the map editor.

Mainframe & Natural Documentation.doc Page 43 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 44/49

Mainframe & Natural Training Documentation

The map editor allows screens to be created and related processing to be performed independently fromthe object that will invoke the screen.

All aspects of map and form definition can be handled by the map editor :

Screen layout

Data communicationValidation

Program syntax

The data (fields) used within the map must already have been defined within the define data statementat the start of your program. If you use one of the layouts, they have pre-defined fields, which you willhave to declare in your program.

Control will only be returned to the invoking object when all map processing has been completed.

PF keys in the map editor

PF2 Return to map settings screenPF3 QuitPF4 See what the user will seePF9 Flip between full and split screen viewPF6,7,8,10,11 Screen positioning on large mapsPF12 Ignore all changes since last ‘Enter’ key

Incorporating data

Data can be incorporated into the map by typing a module code followed by its name into thecommand line at the top left of the screen. The modules that can be incorporated are:

A Parameter Data AreaG Global Data AreaH Help RoutineL Local Data Area

  N SubprogramP ProgramS SubroutineV View

For example, to incorporate fields from view AWTRN-VEHICLES into a map, enter ‘V AWTRN-VEHICLES’ on the command line after ‘Ob’. To scroll up and down the list of fields use ‘-‘ and ‘+’ onthe command line.

The same can be done for programs.

Ob : P TE_ _01P

As long as these are declared in you program, you map will know where to get the information from.

Mainframe & Natural Documentation.doc Page 44 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 45/49

Mainframe & Natural Training Documentation

To get a fields onto the map from the view enter the delimiter required followed by the correspondingnumber of the field.

Enter ‘:3’ on the screen after the prompt, to get the field PERSONNEL_ID in modifiable output, of default underlined and green in colour.

Field commands

Field commands allow manipulation of the screen , they begin with a period ‘.’ , this being entered over the delimiter character of the field in question.

.A Array definition

.C Centre Field

.D Delete Field

.E Invoke Extended field editing

.M Move field to cursor  

Extended Field Editing

This is where field attributes and length displayed on screen are altered and help routines can beattached.

To get to the extended editing screen, go to the first space on the field you wish to edit and press “PF5”

Mainframe & Natural Documentation.doc Page 45 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 46/49

Mainframe & Natural Training Documentation

To attach a Help Routine to a field, the name of the routine and the parameters it takes must be enteredin the HE field.

E.g. “ ’BWER02H1’,#customer-name”

If more room is needed in the help field type ‘+’ to open up more space.

The AL attribute field will limit the length of a displayed variable on the map, for instance if a field isan A40, it can be shortened to make it fit neatly on a map.

The CV attribute field is used for attaching control variables to the field (they will need to be declaredin your program)

Stowing and Saving

Once the map is complete, PF3 out of the map editor back to the map editor menu and choose to stowor save the map. You will need to stow the map if you wish to run it.

The program that uses the map will need to be stowed after any changes are made to the map.

Attaching to a program

To attach a map to a program, you must declare a data area in your program. This area is a pre-definedroutine, which validates the map. It is called CDGETDCA.

DEFINE DATALOCAL USING CDGETDCA

LOCAL  <Declarations>

Mainframe & Natural Documentation.doc Page 46 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 47/49

Mainframe & Natural Training Documentation

END-DEFINE

To call the map you use an input statement:

INPUT USING MAP ‘TE_ _MAP1”

 REMEMBER

• When using a map set the profile to DOMMI.

• Use British Steel standards for map layout and attribute definitions.

• STOW the map before you try to run it.

• All fields in the map need to be declared in the program.

• Call the map using an INPUT statement.

• Re-stow the program that calls a map if you make any changes to that map.

Test Programs

The following are some simple test programs to get you familiar with Natural. These programs should be written in the Natural environment accessible from the CICSO menu as option 3. The test views areavailable in this environment. Answers to the programs are held in the Solutions section. Whennaming your programs you should use the following structure:

TE_ _XXP

The two blanks should be filled in with your initials and the X’s replaced with the program number (01 – 09. Sub-programs should end with an N in place of a P and maps with an M).

Mainframe & Natural Documentation.doc Page 47 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 48/49

Mainframe & Natural Training Documentation

1. Write / Input

1.1. Write a program that displays ‘Hello World!’ to the screen.1.2. Modify the program so that it accepts a string from the user and displays it to the screen.1.3. Modify the program so that the string is displayed 3 times, first in blue, second in red and

third in green.

2. IF / Decide2.1. Write a program that accepts a number from the user. If the number is greater than 10 display

the message ‘Number is greater than 10’ Otherwise display the message ‘Number is less thanor equal to 10’.

2.2. Modify the program so that it uses a decide statement and displays different message for eachof the following conditions :-

 Number is less than 10. Number equals 10. Number is greater than 10.

3. For / Repeat

3.1. Write a program that will display the numbers 1 to 10 to the screen using a “for” loop.3.2. Modify the program so that it will display the numbers 10 to 1 to the screen using a “for”

loop.3.3. Modify the program so that it uses a repeat loop to display the numbers 1 to 10, use a until

condition to exit the loop when the counter equals 10.3.4. Modify the program so that it uses a repeat loop to display the numbers 1 to 10, use a while

condition to exit the loop when the counter equals 10.

4. Find

4.1. Write a program to find the number of records in the view AWTRN-VEHICLES and displaythe result to the screen.

4.2. Modify the program so that it finds 20 records from the view AWTRN-VEHICLES. Makesure you limit the search to 20 otherwise you will spend the next 15 minutes scrollingthrough records as there are over 1000. For each record display the REG_NUM andMODEL.

4.3. Modify the program so that the data is sorted in descending order.4.4. Modify the program so that it accepts a REG_NUM from the user and displays the record

matching that REG_NUM. Type the command ‘l v AWTRN-VEHICLES’ on the commandline to find out the data type for the REG_NUM field. Remember to limit the search to 1 asthere will only be one matching record.

4.5. Modify the program so that it incorporates an IF NO RECORDS FOUND condition, anddisplay an error message within the statement.

4.6. Modify the program so that it will display the owner’s employee details along with thevehicle details. The view for employees is AWTRN-EMPLOYEES. PERSONNEL_ID on thevehicle view should be used as a foreign key. Again use an IF NO RECORDS FOUNDcondition.

5. Compute / Escape

5.1. Write a program that will prompt for the user to enter a number. The number should then beadded to a running total, and the program should loop adding all numbers and displaying therunning total until the user enters 0. At this point the running total should be displayed beforethe program ends.

6. Assign / Store / End Transaction

6.1. Write a program that will add a record to the view AWTRN-VEHICLES with REG_NUMequal to your initials succeeded by a 1. If for example your initials were TCG theREG_NUM should equal TCG1. Prompt the user to enter the records details and also check to see if a record already exists with that REG_NUM. Fill in the record details as you wish,and add the record to the view.

7. Update

Mainframe & Natural Documentation.doc Page 48 / 

49e

8/3/2019 Mainframe & Natural Documentation

http://slidepdf.com/reader/full/mainframe-natural-documentation 49/49

Mainframe & Natural Training Documentation

7.1. Write a program that will search for the vehicle record created in 6.1 and display it to thescreen. If the record is not found, an error message should be displayed to the screen.

7.2. Modify the program so that it will allow you to modify the colour field. The program shoulddisplay an ”Are you sure?” prompt before saving the data. You should use Update and EndTransaction. Remember Screen I/O has the same effect as an End Transaction being issued.

8. Delete8.1. Write a program that will delete the record created in 6.1. The program should display an

“Are you sure?” prompt before completing the action.

9. Sub-programs

9.1. Write a sub-program that accepts 2 parameters and returns 1. It should accept 2 numbers of data type N2 and return 1 with the data type N3. The numbers are to be added and returned asthe third parameter.

9.2. Write a sub-program that accepts 2 parameters and returns 1. It should accept 2 numbers of data type N2 and return 1 with data type N3. The numbers should be subtracted and returnedas the third parameter.

9.3. Write a program that will accepts two numbers as input and store them in separate variables.The program should then prompt the user to enter whether they wish to add or subtract the

numbers. Depending on which option is chosen, the appropriate  sub-program written aboveshould be called to perform the calculations.

10. Maps

10.1. Create new program TE_ 10P. This program will use a map ( TE_ _10M ) to input a number  between 1 and 26. The program will then return the equivalent letter (i.e. user enters 1, program returns A and so on). Remember standard colours and map names.

11. PF-KEYS / Maps / Control Variables

11.1.Create a map to display the registration number, make, model and colour of a vehicle fromthe view AWTRN-VEHICLES. Write a program, which will displays the first record in theview AWTRN-VEHICLES, ordered by REG_NUM. When the user presses enter the nextrecord should be displayed, and the program should loop performing this function. PF3

should exit the program.11.2.Modify the program and map so that it displays the owner of the vehicle’s details on the

screen (AWTRN-EMPLOYEES). You will need to use the field PERSONNEL_ID as aforeign key to link to the AWTRN-EMPLOYEES view. Display the PERSONNEL_ID,

 NAME, FIRST NAME and COUNTRY along with the existing vehicle details.11.3. Allow users to scroll forward using the enter key or PF8 and scroll backward using PF7.11.4. Place a field on the map called #action. The allowable actions should be First, Previous, Next

and Last. If anything other than these is entered input a suitable error message to the screen.If the action field is empty and enter is pressed another error message should be displayed.Create a control variable for this field called #action-cv and make it Green and underlined.

11.5. Modify the map so it has another field called #REG-NUM-CRITERIA. If the user tabs to thisfield and enters a registration number, the program should search the views for thatREG_NUM and display it if it exists, otherwise an error message should be displayed.