Professional Documents
Culture Documents
Natural Commands A To Z
Natural Commands A To Z
--------------------------------------------------------------------------------------------------------------------------------TABLE OF CONTENTS
1. ACCEPT....................................................................................ERROR! BOOKMARK NOT DEFINED.
2. ADD..............................................................................................................................................................4
3. ASSIGN....................................................................................................................................................... 5
4. AT BREAK..................................................................................................................................................6
5. AT END OF PAGE.....................................................................................................................................7
6. AT TOP OF PAGE......................................................................................................................................8
7. BACKOUT TRANSACTION................................................................................................................... 9
8. CALL.........................................................................................................................................................11
9. CALL FILE...............................................................................................................................................12
10. CALL LOOP...........................................................................................................................................14
11. CALLNAT...............................................................................................................................................15
12. CLOSE CONVERSATION...................................................................................................................17
13. CLOSE PRINTER..................................................................................................................................17
14. CLOSE WORK FILE............................................................................................................................18
15. COMMIT................................................................................................................................................19
16. COMPRESS............................................................................................................................................20
17. COMPUTE..............................................................................................................................................21
18. DECIDE FOR.........................................................................................................................................23
19. DECIDE ON............................................................................................................................................24
20. DEFINE PRINTER...............................................................................................................................27
21. DEFINE SUBROUTINE........................................................................................................................28
22. DELETE..................................................................................................................................................30
23. DISPLAY.................................................................................................................................................31
24. DIVIDE....................................................................................................................................................34
25. DO ... DO END........................................................................................................................................35
26. EJECT.....................................................................................................................................................36
RCI
Page 1 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------27. END..........................................................................................................................................................37
28. END TRANSACTION...........................................................................................................................38
29. ESCAPE..................................................................................................................................................39
30. EXAMINE...............................................................................................................................................40
31. EXAMINE TRANSLATE.....................................................................................................................42
32. FETCH....................................................................................................................................................43
33. FIND............44
34. FOR..........................................................................................................................................................45
35. FORMAT.................................................................................................................................................47
RESTRICTIONS.....................................................................................................................................49
36. GET..66
37. GET TRANSACTION DATA................................................................................................................50
38. GET SAME.............................................................................................................................................52
RESTRICTIONS.....................................................................................................................................53
39. HISTOGRAM.........................................................................................................................................53
40. IGNORE..................................................................................................................................................54
41. IF..............................................................................................................................................................55
42. INCLUDE................................................................................................................................................56
43. INIT(IAL)................................................................................................................................................57
44. INPUT......................................................................................................................................................57
45. INSERT................................................................................................................................................... 59
46. LIMIT......................................................................................................................................................60
47. LOOP.......................................................................................................................................................61
49. MOVE ALL ............................................................................................................................................66
50.MULTIPLY .89
51. NEW PAGE.............................................................................................................................................67
52.OBTAIN91
53. ON ERROR.............................................................................................................................................68
RCI
Page 2 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
RCI
Page 3 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
ACCEPT
Syntax:
ACCEPT [ IF ] logical-condition
Example :
READ EMPLOY-VIEW
ACCEPT IF SEX = 'M' AND MAR-STAT = 'S'
WRITE NOTITLE '=' NAME '=' SEX 3X '=' MAR-STAT
END-READ
The above code reads each record from EMPLOY file and writes NAME,SEX
and MARITAL STATUS if the SEX is M & MARITAL STATUS is S. The records
satisfying this criteria only are accepted and further displayed (or processed).
ADD
FUNCTION :RCI
Page 4 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
1
Result Field (operand2)
If the keyword TO is used, operand2 will be included in the addition
and will contain the result of the addition.
If the keyword GIVING is used, operand2 will be used to store the
result only. If GIVING is used and operand2 is defined with
alphanumeric format, the result will be converted to alphanumeric.
If a database field is used as the result field, the addition only results in
an update to the internal value that is used within the program. The
value of the field in the database is not affected.Operand 2 can be a
Column name or Variable or Array.
ROUNDED
If you specify the keyword ROUNDED, the result will be rounded.
Two arrays can be directly added using ADD fuction, for example
ADD #OLD-VALUES(1:6)
TO
#NEW-VALUES(1:6)
ASSIGN
Syntax :RCI
Page 5 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
ASSIGN [ROUNDED]
ASSIGN [ROUNDED] {Column name or Variable} [= {Column name or Variable }]
.. = constant or System-function(column) or field name
Usage :1) Used to assign a value to one or more variables.
Assign is required keyword unless the assignment operator is used.
2) Rounded allows results to precision of target values.
The Assignment operation can also be accomplished with the operator := but
rounded is not allowed with this operator
Eg :- #temp := 3 results in #temp field having a value of 3
Eg :- assign rounded #target = 1.998
AT BREAK
Syntax :
[AT] BREAK [ ( reference
[/n/]
statement(s)
END-BREAK
Used in loops initiated by FIND, READ, SORT, HISTOGRAM, READ WORK FILE
When value of variable changes
Statement or statements are executed
/n/ indicates select number of positions to be evaluated, left-to-right a byte at a time.
END-BREAK required.
[(reference / label) ] refers to loop initiating statement other than main loop for
control processing during final break evaluation.
Code break statements IN REVERSE SEQUENCE of the sort of data or data
variables. I.e., multiple breaks will be processed in the hierarchy that they are coded
for automatic break processing functionality.
RCI
Page 6 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
Example :
READ EMPLOYEE-VIEW BY CITY
AT BREAK OF CITY
SKIP 1
END-BREAK
DISPLAY NOTITLE CITY (IS=ON) COUNTRY (IS=ON) NAME
END-READ
Important Point to be Noted: For the last record, the control goes to each and every
AT BREAK OF block eventhough there is no break at that record. Hence
necessary action should be implemented in the code of at break block to avoid
this.
AT END OF PAGE
Syntax:
AT END OF PAGE (rep)
statement ...
END-ENDPAGE
Specifies processing to be performed when end-of-page condition is detected, or when
SKIP or NEWPAGE (but not EJECT) statement encountered. The AT END OF PAGE
statement is non-procedural and must not be placed within an inline subroutine. End-ofpage check performed after processing of DISPLAY or WRITE statement.
The end-of-page check is performed after the processing of a DISPLAY or WRITE
statement is completed. Therefore, if a DISPLAY or WRITE statement produces multiple
lines of output, overflow of the physical page may occur before an end-of-page condition
is detected. A logical page size (session parameter PS) which is less than the physical
page size must be specified to ensure that information printed by an AT END OF PAGE
statement appears on the same physical page as the title.
RCI
Page 7 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
(rep) specifies identification of report for which END OF PAGE statement is applicable;
if not used, statement applies to report 0. Logical page size (parameter PS) should be less
than physical page size.
Example:
AT END OF PAGE
WRITE / 28T `Average Salary:` AVER(SALARY(1)) CURR-CODE (1)
END-ENDPAGE
Last-Page Handling
Within a main program, an end-of-page condition is activated when the execution of the
main program terminates via ESCAPE, STOP or END. Within a subroutine, an end-ofpage condition is not activated when the execution of the subroutine terminates via
ESCAPE, RETURN or END.
INPUT Statement with AT END OF PAGE
If an INPUT statement is specified within an AT END OF PAGE statement block, no new
page operation is performed. The page size (session parameter PS) must be reduced to a
value that allows the lines created by the INPUT statement to appear on the same
physical page.
/* EXAMPLE AEPEX1S: AT END OF PAGE (STRUCTURED MODE)
/*********************************************************************
DEFINE DATA LOCAL
1 EMPLOYVIEW VIEW OF EMPLOYEES
2 PERSONNELID
2 NAME
2 JOBTITLE
2 SALARY (1)
2 CURRCODE (1)
ENDDEFINE
/*********************************************************************
FORMAT PS=10
LIMIT 10
READ EMPLOYVIEW BY PERSONNELID FROM 20017000
DISPLAY NOTITLE GIVE SYSTEM FUNCTIONS
NAME JOBTITLE SALARY SALARY(1) CURRCODE (1)
/* *******************************************************************
AT END OF PAGE
WRITE / 28T AVERAGE SALARY: ... AVER(SALARY(1)) CURRCODE (1)
ENDENDPAGE
/* *******************************************************************
ENDREAD
/*********************************************************************
RCI
Page 8 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
END
AT TOP OF PAGE
Syntax:
AT TOP OF PAGE (rep)
statement ...
END-TOPPAGE
The statement AT TOP OF PAGE is used to specify processing which is to be performed
when
a new page is started. A new page is started when the internal line counter exceeds the
page size set with the session parameter PS, or when a NEWPAGE statement is executed.
Either of these events cause a top-of-page condition to be true. An EJECT statement
causes a new page to be started but does not cause a top-of-page condition. An AT TOP
OF PAGE statement block is only executed when the object which contains the statement
is active at the time when the top-of-page condition occurs. Any output created as a result
of AT TOP OF PAGE processing will appear following the title line with an intervening
blank line. This statement is non-procedural (that is, its execution depends on an event,
not on where in a program it is located).
(rep) specifies identification of report for which AT TOP OF PAGE statement is
applicable; if not used, statement applies to report 0. (rep) value may be in range 0-31 or
logical name assigned with DEFINE PRINTER statement.
WRITE TITLE & AT TOP OF PAGE share many similarities in that they appear at the
top of the report, access most Natural System Functions and Variables and Data from
the first record on the page. However, WRITE TITLE only writes a report title whereas
AT TOP OF PAGE signals a condition where multiple programming statements may be
executed, routines called, etc. thus adding to its flexibility in its use as a titling vehicle.
Example:
AT TOP OF PAGE
WRITE `Beginning name:` NAME
END-TOPPAGE
BACKOUT TRANSACTION
Syntax:
BACKOUT TRANSACTION
RCI
Page 9 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
10
---------------------------------------------------------------------------------------------------------------------------------
This statement is used to back out all database updates performed during the current
logical transaction. This statement also releases all records held during the transaction.
The BACKOUT TRANSACTION statement is executed only if a database transaction
under control of NATURAL has taken place. For which databases the statement is
executed depends on the setting of the profile parameter ET .
_ If ET=OFF, the statement is executed only for the database affected by the
transaction.
_ If ET=ON, the statement is executed for all databases that have been referenced
since the last execution of a BACKOUT TRANSACTION or END
TRANSACTION statement.
Considerations for SQL Databases
As most SQL databases close all cursors when a logical unit of work ends, a BACKOUT
TRANSACTION statement must not be placed within a database modification loop;
instead, it has to be placed after such a loop.
Backout Transaction Issued by NATURAL
If the user interrupts the current NATURAL operation with a terminal command
(command
%% or CLEAR key), NATURAL issues a BACKOUT TRANSACTION statement
Example
/* EXAMPLE BOTEX1S: BACKOUT TRANSACTION (STRUCTURED MODE)
/*********************************************************************
DEFINE DATA LOCAL
1 EMPLOYVIEW VIEW OF EMPLOYEES
2 NAME
2 DEPT
2 LEAVEDUE
2 LEAVETAKEN
1 #DEPT (A6)
1 #RESP (A3)
ENDDEFINE
/*********************************************************************
LIMIT 3
INPUT DEPARTMENT TO BE UPDATED: #DEPT
IF #DEPT =
STOP
ENDIF
/*********************************************************************
FIND EMPLOYVIEW WITH DEPT = #DEPT
IF NO RECORDS FOUND
REINPUT NO RECORDS FOUND
RCI
Page 10 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
11
---------------------------------------------------------------------------------------------------------------------------------
ENDNOREC
INPUT NAME: NAME (AD=O) /
LEAVE DUE: LEAVEDUE (AD=M) /
LEAVE TAKEN: LEAVETAKEN (AD=M)
UPDATE
ENDFIND
/*********************************************************************
INPUT UPDATE TO BE PERFORMED YES/NO: #RESP
DECIDE ON FIRST #RESP
VALUE YES
END TRANSACTION
VALUE NO
BACKOUT TRANSACTION
NONE
REINPUT PLEASE ENTER YES OR NO
ENDDECIDE
/*********************************************************************
END
CALL
Syntax:
CALL
Column name
Variable
Constant
Column name
Variable
Constant
Array
group
... 40
Example:
FIND EMPLOY-VIEW WITH BIRTH = 550701 THRU 550731
MOVE COUNTRY TO #COUNTRY
RCI
Page 11 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
12
---------------------------------------------------------------------------------------------------------------------------------
CALL FILE
Syntax:
CALL FILE program-name control-field field-name
Variable name
Constant
Array
FILLER n X
Statement(s)
END-FILE
It initiates a processing loop that calls a user-written program which reads a nondatabase file/record into the NATURAL program.
The parameters passed to the CALLed program:
Control field: passes control information between NATURAL object and CALLed
program.
Field name
Example
Calling Program:
/* EXAMPLE CFIEX1: CALL FILE
RCI
Page 12 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
13
---------------------------------------------------------------------------------------------------------------------------------
/*****************************
DEFINE DATA LOCAL
1 #CONTROL (A3)
1 #RECORD
2 #A (A10)
2 #B (N3.2)
2 #FILL1 (A3)
2 #C (P3.1)
ENDDEFINE
/*****************************
CALL FILE USER1 #CONTROL #RECORD
IF #CONTROL = END
ESCAPE BOTTOM
ENDIF
ENDFILE
/*****************************
/* ... PROCESS RECORD ...
/*****************************
END
The byte layout of the record passed by the called program to the NATURAL program in
the above example is as follows:
CONTROL #A
#B
FILLER
#C
(A3)
(A10) (N3.2)
3X
(P3.1)
Called COBOL Program:
ID DIVISION.
PROGRAMID. USER1.
ENVIRONMENT DIVISION.
INPUTOUTPUT SECTION.
FILECONTROL.
SELECT USRFILE ASSIGN UTSFILEUSR.
DATA DIVISION.
FILE SECTION.
FD USRFILE RECORDING F LABEL RECORD OMITTED
DATA RECORD DATAIN.
01 DATAIN PIC X(80).
LINKAGE SECTION.
01 CONTROLFIELD PIC XXX.
01 RECORDIN PIC X(21).
PROCEDURE DIVISION USING CONTROLFIELD RECORDIN.
BEGIN.
GO TO FILEOPEN.
FILEOPEN.
OPEN INPUT USRFILE
RCI
Page 13 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
14
---------------------------------------------------------------------------------------------------------------------------------
CALL LOOP
Syntax:
CALL LOOP
program-name
variable- name
Statement(s)
END-LOOP
Variable name
Constant
Group
Array
.... 40
The CALL LOOP statement is used to generate a processing loop that contains a call to a
non-NATURAL program. Unlike the CALL statement, the CALL LOOP statement
results in a processing loop which is used to repeatedly call the non-NATURAL program.
See the CALL statement for detailed description of CALL processing.
The fields specified are used to pass data to the CALLed program and receive data when
control is passed back to the NATURAL object.
The name of the program to be called may be specified as a constant or a variable if
different programs are to be called dependent on program logic.
The CALL LOOP statement can have a maximum of 40 parameters. The parameter list is
constructed as described for the CALL statement. Fields used in the parameter list may be
initially defined in the CALL LOOP statement itself or may have been previously
defined.
The processing loop initiated with a CALL LOOP statement must be terminated with an
ESCAPE statement or STOP. The statements associated with automatic break processing
are NOT permitted within the loop.
Example :
CALL LOOP ABC PARAMETER1
RCI
Page 14 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
15
---------------------------------------------------------------------------------------------------------------------------------
IF PARAMETER1 = END
ESCAPE BOTTOM
ENDIF
ENDLOOP
CALLNAT
Syntax:
CALLNAT operand1 USING operand2 (AD=M) ...
(AD=O)
(AD=A)
The CALLNAT statement is used to invoke a NATURAL subprogram for execution.
When the CALLNAT statement is executed, the execution of the invoking object (that is,
the object containing the CALLNAT statement) will be suspended and the invoked
subprogram will be executed. The execution of the subprogram continues until either its
END statement is reached or processing of the subprogram is stopped by an ESCAPE
ROUTINE statement being executed. In either case, processing of the invoking object
will then continue with the statement following the CALLNAT statement.
As operand1, you specify the name of the subprogram to be invoked. The name may be
specified either as a constant of 1 to 8 characters, or if different subprograms are to be
called dependent on program logic as an alphanumeric variable of length 1 to 8. The
subprogram name may contain an ampersand (&); at execution time, this character will
be replaced by the current value of the system variable *LANGUAGE. This makes it
possible, for example, to invoke different subprograms for the processing of input,
depending on the language in which input is provided.
If parameters are passed to the subprogram, the structure of the parameter list must be
defined in a DEFINE DATA PARAMETER statement. The parameters specified with the
CALLNAT statement are the only data available to the subprogram from the invoking
object. By default, the parameters are passed by reference, that is, the data are
transferred via address parameters, the parameter values themselves are not moved.
However, it is also possible to pass parameters by value, that is, pass the actual
parameter values. To do so, you define these fields in the DEFINE DATA PARAMETER
statement of the subprogram with the option BY VALUE or BY VALUE RESULT .
RCI
Page 15 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
16
---------------------------------------------------------------------------------------------------------------------------------
_
If parameters are passed by reference the following applies: The
sequence, format and length of the parameters in the invoking object must match
exactly the sequence, format and length of the DEFINE DATA PARAMETER
structure in the invoked subprogram. The names of the variables in the invoking
object and the invoked subprogram may be different.
_
If parameters are passed by value the following applies: The sequence of
the parameters in the invoking object must match exactly the sequence in the
DEFINE DATA PARAMETER structure of the invoked subprogram. Formats and
lengths of the variables in the invoking object and the subprogram may be
different; however, they have to be data transfer compatible. The names of the
variables in the invoking object and the subprogram may be different. If
parameter values that have been modified in the subprogram are to be passed back
to the invoking object, you have to define these fields with BY VALUE RESULT.
With BY VALUE (without RESULT) it is not possible to pass modified parameter
values back to the invoking object (regardless of the AD specification; see also
below).
For both ways of passing parameters, the following apply:
If a group is specified as operand2, the individual fields contained in that group are
passed to the subprogram; that is, for each of these fields a corresponding field must be
defined in the subprograms parameter data area. In the parameter data area of the
invoked subprogram, a redefinition of groups is only permitted within a REDEFINE
block. If an array is passed, its number of dimensions and occurrences in the
subprograms parameter data area must be same as in the CALLNAT parameter list.
AD=
If operand2 is a variable, you can mark it as non-modifiable (AD=O), as modifiable
(AD=M) or as for input only (AD=A). The default is AD=M. If operand2 is a constant,
AD cannot be explicitly specified. For constants AD=O always
applies.
AD=M
By default, the passed value of a parameter can be changed in the subprogram and the
changed
value passed back to the invoking object, where it overwrites the original value.
Exception: For a field defined with BY VALUE in the subprograms parameter data area,
no
value is passed back.
AD=O
If you mark a parameter with AD=O, the passed value can be changed in the subprogram,
but the changed value cannot be passed back to the invoking object; that is, the field in
the invoking object retains its original value.
Example 1
RCI
Page 16 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
17
---------------------------------------------------------------------------------------------------------------------------------
Invoking Program:
/* EXAMPLE CNTEX1: CALLNAT
/********************************************************************
/* MAIN PROGRAM MAINP1
/********************************************************************
DEFINE DATA LOCAL
1 #FIELD1 (N6)
1 #FIELD2 (A20)
1 #FIELD3 (A10)
ENDDEFINE
/********************************************************************
CALLNAT SUBP1 #FIELD1 (AD=M) #FIELD2 (AD=O) #FIELD3 P4 TEXT
/* ...
END
Invoked Subprogram:
/* SUBPROGRAM SUBP1
/********************************************************************
DEFINE DATA PARAMETER
1 #FIELDA (N6)
1 #FIELDB (A20)
1 #FIELDC (A10)
1 #FIELDD (A7)
ENDDEFINE
/********************************************************************
/* ...
END
CLOSE CONVERSATION
Syntax:
CLOSE CONVERSATION
Operand 1
*CONVID ....
ALL
RCI
Page 17 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
18
---------------------------------------------------------------------------------------------------------------------------------
To close the current conversation, you specify *CONVID. The ID of the current
conversation is determined by the value of the system variable *CONVID. To close all
open conversations, you specify ALL.
CLOSE PRINTER
Syntax:
CLOSE PRINTER
Logical-printer-name
Printer-number
The CLOSE PRINTER statement is used to close a specific printer. With the CLOSE
PRINTER statement, you explicitly specify in a program that a printer is to be closed.
A printer is also closed automatically in one of the following cases:
when a DEFINE PRINTER statement in which the same printer is defined again is
executed;
when the control is returned to the command level(NEXT).
With the logical-printer-name or printer-number you specify which printer is to be
closed. The name and number are the same as in the corresponding DEFINE PRINTER
statement in which you defined the printer. Naming conventions for the logical-printername are the same as for user-defined variables . The printer-number may be a number in
the range from 1 to 31.
Example
/* EXAMPLE CLPEX1: CLOSE PRINTER
/*****************************************************
DEFINE PRINTER (PRT01=1)
REPEAT
INPUT SELECT PERSON INAME (A20)
IF INAME =
STOP
FIND EMPLOYEES WITH NAME = INAME
WRITE (PRT01) NAME : NAME , FIRSTNAME
/ PERSONNELID : PERSONNELID
/ BIRTH : BIRTH
LOOP
CLOSE PRINTER (PRT01)
LOOP
END
19
---------------------------------------------------------------------------------------------------------------------------------
Syntax:
CLOSE WORKFILE [FILE] (work-file-number)
Under normal circumstances,work files are closed when the program EOJs.The CLOSE
WORK FILE statement is used to explicitly close a specific work file. It allows you to
explicitly specify in a program that a work file is to be closed. A work file is also closed
automatically when command mode is reached, or when an end-of-file condition occurs
during the execution of a READ WORK FILE statement. The work-file-number is the
number of the work file (as defined to NATURAL) to be closed.
Example
/* EXAMPLE CWFEX1: CLOSE WORK FILE
REPEAT
READ WORK FILE 1 ONCE WDAT /* READ MASTER RECORD
AT END OF FILE
ESCAPE BOTTOM
ENDENDFILE
INPUT PROCESSING FILE WDAT (AD=O)
/ ENTER RECORDNUMBER TO DISPLAY RECNUM
IF RECNUM = 0
STOP
ENDIF
FOR I = 1 TO RECNUM
READ WORK FILE 1 ONCE WDAT
AT END OF FILE
WRITE RECORDNUMBER TOO HIGH, LAST RECORD IS
ESCAPE BOTTOM
ENDENDFILE
ENDFOR
I := I 1
WRITE RECORD I : WDAT
CLOSE WORK FILE 1
ENDREPEAT
COMMIT
COMMIT is equivalent to the NATURAL for DB2 statement: END TRANSACTION.
END TRANSACTION finalizes, commits and makes permanent all work done to update
DB2 data, in a logical transaction. It generates the equivalent of the DB2 statement :
COMMIT [WORK] for the environment it is executed in. While DB2 under CICS does
not permit the DB2 COMMIT statement, NATURAL for DB2 will generate the
appropriate equivalent for the environment transparent to the programmer. All DB2 locks,
RCI
Page 19 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
20
---------------------------------------------------------------------------------------------------------------------------------
both read and update locks, implicitly acquired are freed except those used in
SELECT..WITH HOLD statement. DB2 changes committed include statements: ALTER,
COMMENT ON, CREATE, DELETE, DROP, EXPLAIN, GRANT, INSERT, LABEL
ON, REVOKE and UPDATE.
Actions taken by DB2 when a logical unit of work ends:
Termination of Logical Transaction,beginning of a new one.
All database changes made during the logical transaction are physically
committed
All open cursors are closed,(SELECT. WITH HOLD being an exception)
Any SQL statements dynamically prepared are lost .
DB2 prohibits an END TRANSACTION or COMMIT inside of a DB2
processing loop or nested DB2 processing loops. It has to be placed outside
database modification loops.
COMPRESS
COMPRESS
Column name
variable
array
group
constant
TO [SUBSTRING]
column name
variable
constant
array
System-varaible
[IN]
21
---------------------------------------------------------------------------------------------------------------------------------
COMPUTE
RCI
Page 21 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
22
---------------------------------------------------------------------------------------------------------------------------------
23
---------------------------------------------------------------------------------------------------------------------------------
RCI
Page 23 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
24
---------------------------------------------------------------------------------------------------------------------------------
DECIDE FOR
Syntax
DECIDE FOR {FIRST/EVERY} CONDITION
WHEN logical-condition(s)
statement(s)
WHEN
ANY
statement(s)
ALL
WHEN NONE
statement(s)
IGNORE
END DECIDE.
Function
The DECIDE FOR statement is used when there are a number of
conditions which must be evaluated at the same point in the
program.It can be used for Logical condition testing using Boolean logic
on values.It can usually replace nested IF.It enhances readibility by
listing possible values together with action taken for respective values.
A DECIDE FOR may be executed as the result of conditional
evaluation within another DECIDE FOR.
Note: If no action is to be performed under a certain condition, you
specify the statement
IGNORE in the corresponding clause of the DECIDE FOR statement.
FIRST/EVERY
With the keyword FIRST or EVERY, you indicate whether only the first or
every true condition is to be processed.
RCI
Page 24 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
25
---------------------------------------------------------------------------------------------------------------------------------
WHEN logical-condition
With this clause, you specify the logical condition(s) to be processed.
WHEN ANY
With WHEN ANY, you can specify the statement(s) to be executed
when any of the logical conditions are true.
WHEN ALL
With WHEN ALL, you can specify the statement(s) to be executed when
all logical conditions are true. This clause is applicable only if EVERY
has been specified.
WHEN NONE
With WHEN NONE, you specify the statement(s) to be executed when
none of the logical conditions are true.
DECIDE ON
Syntax
Column name
DECIDE ON {FIRST/EVERY} [VALUES] [OF]
system variable
variable
VALUE[S]
ANY
variable
variable
constant
constant
[VALUE[S]] statement(s)
ALL
RCI
Page 25 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
26
---------------------------------------------------------------------------------------------------------------------------------
NONE [VALUE[S]]
statement(s)
IGNORE
END DECIDE.
Function
The DECIDE ON statement is used when there are any number of
statements which must be processed depending upon the value(s) in a
single variable. It lets you list all possible values.It forces decision if no
values meet criteria.
A DECIDE ON may be executed as the result of conditional
evaluation within another DECIDE ON
Note: If no action is to be performed under a certain condition, you
specify the statement
IGNORE in the corresponding clause of the DECIDE ON statement.
FIRST/EVERY
With one of these keywords, you indicate whether only the first or
every value that is found is to be processed.
VALUES Clause
With this clause, you specify the value of the selection field, as well as
the
statement(s) which are to be executed if the field contains that value.
You can specify one value, multiple values, or a range of values
optionally preceded by one or more values.
RCI
Page 26 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
27
---------------------------------------------------------------------------------------------------------------------------------
28
---------------------------------------------------------------------------------------------------------------------------------
ANY VALUE
END TRANSACTION
WRITE RECORD HAS BEEN MODIFIED
NONE VALUE
IGNORE
END DECIDE
DEFINE PRINTER
Syntax:
DEFINE PRINTER (logical-printer-name= n)
OUTPUT operand1 PROFILE operand2
FORMS operand2
NAME operand2
DISP operand2
CLASS operand2
COPIES operand3
PRTY operand4
The DEFINE PRINTER statement is used to assign a symbolic name to a report number
and to control the allocation of a report to a logical destination. This provides you with
additional flexibility when creating output for various logical print queues. When this
statement is executed and the specified printer is already open, the statement will
implicitly cause that printer to be closed. To explicitly close a printer, however, you
should use the CLOSE PRINTER statement.
As logical-printer-name, you specify the logical name which is to be allocated to printer
n. This is the name which will be used for the rep notation in a DISPLAY_WRITE
statement. The printer number n may be a value in the range of 1 31. For NATURAL
ADVANCED FACILITIES, the valid range is also 1 31. Multiple logical names may be
assigned to the same printer number. Unlike the output destination (see below), logicalprinter-name=n is evaluated at compilation time and therefore independent of the
program control flow. With operand1, you specify the destination within the online
spooling system. The destination is evaluated at runtime. If operand1 is a variable, its
format/length must be A8.
RCI
Page 28 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
29
---------------------------------------------------------------------------------------------------------------------------------
Any logical printer name may be assigned, provided that it has been defined in the
parameter file/parameter module used, or via parameters or JCL during startup of
NATURAL. Under OpenVMS and UNIX and on workstations, the name must be
specified as LPTnn, where nn may be 1 to 31.
Example:
1. DEFINE PRINTER (1) OUTPUT `TID100`
WRITE (1) `PRINTED ON TID100`
END
2.
3.
DEFINE SUBROUTINE
Syntax
DEFINE [SUBROUTINE] subroutine-name
Statement..
[END-SUBROUTINE/RETURN(REPORTING MODE ONLY)]
Function
The DEFINE SUBROUTINE statement is used to define a NATURAL
subroutine. A subroutine is invoked with a PERFORM statement.
Inline/External Subroutines
A subroutine may be defined within the object which contains the
PERFORM statement that invokes the subroutine (inline subroutine); or
it may be defined external to the object that contains the PERFORM
statement (external subroutine). An inline subroutine may be defined
before or after the first PERFORM statement which references it.
RCI
Page 29 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
30
---------------------------------------------------------------------------------------------------------------------------------
RCI
Page 30 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
31
---------------------------------------------------------------------------------------------------------------------------------
32
---------------------------------------------------------------------------------------------------------------------------------
DELETE
Syntax:
DELETE [RECORD] [IN] [STATEMENT] [(reference)]
Two types of DELETE statements are possible in NATURAL for DB2 :
NATURAL statement syntax for single row deletion (positioned delete)
DB2 statement syntax for potentially Multiple Row Deletion(searched delete)
NATURAL Statement Single Row (Positioned Delete):
The NATURAL language DELETE statement requires that DB2 row is first read with a
READ, FIND or SELECT statement. NATURAL generates a cursor-controlled read
which involves in the sequence DECLARE CURSOR, OPEN CURSOR, FETCH at
CURSOR, DELETE WHERE CURRENT of cursor, CLOSE CURSOR.
Example:
RCI
Page 32 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
33
---------------------------------------------------------------------------------------------------------------------------------
DISPLAY
Syntax:
DISPLAY (rep) options /... output-format output-element ...
output-format:
nX
`text`(attributes) ...
nT
`c`(n)(attributes)
x/y
T*field-name
P*field-name
VERTICALLY AS 'text'(attributes) CAPTIONED /...
CAPTIONED
HORIZONTALLY
RCI
Page 33 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
34
---------------------------------------------------------------------------------------------------------------------------------
The DISPLAY statement is used to specify the fields to be output on a report in column
format. A column is created for each field and a field header is placed over the column.
The notation (rep) may be used to specify the identification of the report for which the
DISPLAY statement is applicable. A value in the range 0 31 or a logical name which
has been assigned using the DEFINE PRINTER statement may be specified. If (rep) is
not specified, the DISPLAY statement will apply to the first report (report 0).
Page Title/NOTITLE
By default, NATURAL generates a single title line for each page resulting from a
DISPLAY statement. This title contains the page number, the time of day, and the date.
Time of day is set at the beginning of the program execution (TP mode) or at the
beginning of the job (batch mode). The default title line may be overridden by using a
WRITE TITLE statement, or it may be suppressed by specifying the keyword NOTITLE
in the DISPLAY statement.
Column Headers/NOHDR
Column headers are produced for each field specified in the DISPLAY statement using
the following rules:
The header text may be explicitly specified in the DISPLAY statement before the
field name.
For example:
DISPLAY EMPLOYEE NAME SALARY SALARY
Suppressing Column Headers
To suppress the column header for a single field, specify the characters / (apostrophe
slashapostrophe) before the field name.
For example:
DISPLAY / NAME SALARY SALARY
To suppress all column headers, specify the keyword NOHDR:
DISPLAY NOHDR NAME SALARY
Output-format field positioning notation:
nX
Insert spaces between columns; may not be set to 0.
nT
x/y
T*field-
P*field-
35
---------------------------------------------------------------------------------------------------------------------------------
'c'(n)
attributes
B
C
D
I
U
V
Display attributes
(blinking)
(cursive/italic)
(default)
(intensified)
(underlined)
(reversed video)
Color attributes
BL (blue)
GR (green)
NE (neutral)
PI (pink)
TU (turquoise)
YE (yellow)
Output-element notation:
nX
Insert spaces between columns; may not be set to 0.
nT
x/y
'text'
'text' '='
'c' (n)
operand1
Field to be displayed.
parameters
Example:
1. DISPLAY NOTITLE 5X NAME 50T JOB-TITLE
2.
3.
/* OVERRIDE STANDARD
RCI
Page 35 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
36
---------------------------------------------------------------------------------------------------------------------------------
DIVIDE
Syntax :-
or variable
or variable
RCI
Page 36 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
37
---------------------------------------------------------------------------------------------------------------------------------
Division by Zero
If an attempt is made to use a divisor (operand1) which is 0, either
an error message or a result equal to 0 will be returned; this depends
on the setting of the session parameter ZD (which is described in the
NATURAL Reference Manual).
REMAINDER Option
If the keyword REMAINDER is specified, the remainder of the division
will be placed into the specified field (operand4).
If GIVING and REMAINDER are used, none of the four operands may be
an array range.
DO ... DO END
Syntax :
DO
Statement(s)
DOEND
The DO and DOEND statements are only valid in reporting mode.
The statements DO and DOEND are used in reporting mode to specify a group of
statements to be executed based on a logical condition as specified in any of the
following statements:
AT BREAK
AT END OF DATA
AT END OF PAGE
AT START OF DATA
AT TOP OF PAGE
BEFORE BREAK PROCESSING
FIND ... IF NO RECORDS FOUND
IF
IF SELECTION
ON ERROR
RCI
Page 37 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
38
---------------------------------------------------------------------------------------------------------------------------------
EJECT
Syntax:
EJECT [ (report-number)]
[ [IF] [LESS] [THAN]
Numeric constant
Numeric variable
[LINES] [LEFT] ]
39
---------------------------------------------------------------------------------------------------------------------------------
/***************************************************************
FORMAT PS=15
LIMIT 9
READ EMPLOYVIEW BY CITY
/***************************************************************
AT START OF DATA
EJECT
WRITE /// 20T % (29) /
20T %% 47T %% /
20T %% 3X REPORT OF EMPLOYEES 47T %% /
20T %% 3X SORTED BY CITY 47T %% /
20T %% 47T %% /
20T % (29) /
EJECT
ENDSTART
EJECT WHEN LESS THAN 3 LINES LEFT
/***************************************************************
WRITE * (64)
DISPLAY NOTITLE NOHDR CITY NAME JOBTITLE 5X *LINECOUNT
WRITE * (64)
ENDREAD
END
END
END marks physical end of NATURAL program. Also currently active processing loop is
closed by an END statement in Reporting Mode.
When END is encountered in main program, final end-page processing and final break
processing for user-initiated breaks is performed.
END returns control to invoking module when coded in a subprogram,an external
subroutine,helproutine,or program invoked using the RETURN clause
If period (".") is used instead of END, it must be preceded by blank if other statements
contained on same line.
RCI
Page 39 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
40
---------------------------------------------------------------------------------------------------------------------------------
END TRANSACTION
Syntax:
END OF TRANSACTION operand1 ...
The END TRANSACTION statement is used to indicate the end of a logical transaction.
A logical transaction is the smallest logical unit of work (as defined by the user) which
must be performed in its entirety to ensure that the information contained in the database
is logically consistent.
Successful execution of an END TRANSACTION statement ensures that all updates
performed during the transaction have been or will be physically applied to the database
regardless of subsequent user, NATURAL, database or operating system interruption.
Updates performed within a transaction for which the END TRANSACTION statement
has not been successfully completed will be backed out automatically. The END
TRANSACTION statement also results in the release of all records placed in hold status
during the transaction. The END TRANSACTION statement can be executed based upon
a logical condition.
Storage of Transaction Data (operand1)
For a transaction applied to an ADABAS database, or to a DL/I database in a batchoriented BMP region (in IMS environments only), you may also use this statement to
store transaction-related information. These transaction data must not exceed 2000 bytes.
They may be read with a GET TRANSACTION DATA statement. The transaction data
are written to the database specified with the profile parameter ETDB.
If the ETDB parameter is not specified, the transaction data are written to the database
specified with the profile parameter UDB except on mainframe computers: here, they
are written to the database where the NATURAL SECURITY system file (FSEC) is
located (if FSEC is not specified, it is considered to be identical to the NATURAL system
file, FNAT; if NATURAL SECURITY is not installed, the transaction data are written to
the database where FNAT is located).
Example 1
/* EXAMPLE ETREX1S: END TRANSACTION (STRUCTURED MODE)
/*******************************************************
DEFINE DATA LOCAL
1 EMPLOYVIEW VIEW OF EMPLOYEES
RCI
Page 40 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
41
---------------------------------------------------------------------------------------------------------------------------------
2 CITY
2 COUNTRY
ENDDEFINE
/*******************************************************
FIND EMPLOYVIEW WITH CITY = BOSTON
ASSIGN COUNTRY = USA
UPDATE
END TRANSACTION
/*******************************************************
AT END OF DATA
WRITE NOTITLE *NUMBER RECORDS UPDATED
ENDENDDATA
/*******************************************************
ENDFIND
END
ESCAPE
Syntax:
ESCAPE
TOP
BOTTOM[(reference/ label)] [ IMMEDIATE]
ROUTINE [IMMEDIATE]
Escape allows the user to exit from the current loop based upon logical condition test. Or
Interrupt linear flow of execution of processing loop or routine. More than one ESCAPE
may be coded in the same processing loop.
TOP - continue processing from top of processing loop.
BOTTOM - continue processing with first statement following processing loop.
ROUTINE - current NATURAL routine (invoked via PERFORM, CALLNAT, FETCH
RETURN
or as a main program) relenquishes control. In case of subroutine, processing continues
with first statement after statement used to invoke subroutine; in case of main program,
NATURAL command mode receives control.
If IMMEDIATE specified, no loop-end processing performed.
Example:
READ DEPARTMENT BY DEPT
STARTING FROM COMP
RCI
Page 41 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
42
---------------------------------------------------------------------------------------------------------------------------------
EXAMINE
Syntax :-
column name
array
variable
[{(beg[,len])}]
constant
FOR [ FULL [VALUE [OF]]] [PATTERN]
column name
variable
variable
ABSOLUTE or WITH [DELIMITER]
constant
RCI
Page 42 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
43
---------------------------------------------------------------------------------------------------------------------------------
POSITION
[IN] variable
LENGTH
INDEX
PS: With DELETE ,only DELETE FIRST option is available
Function
The EXAMINE statement is used to scan the contents of an
alphanumeric field, or a range of fields within an array, for a character
string; to replace and/or count the number of occurrences of that
character string; and to give information about the result of the
EXAMINE operation.
SUBSTRING examines a portion of a field beginning at a user-defined
starting position and scans the variable from left to right for a defined
number of positions(length)
FULL includes trailing blanks in scan/count,i.e,blanks are treated like
any other character with FULL specified
PATTERN provides the capability for testing the target variable and
excluding selected positions from the test .
ABSOLUTE is default option ; examines target variable for character
string regardless of delimiters
WITH DELIMITERS allows definition of delimiter characters
GIVING evaluates the result of the current EXAMINE operation
NUMBER returns count of occurrences to a numeric variable .
POSITION returns resulting length of target variable after deletions or
replacements
RCI
Page 43 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
44
---------------------------------------------------------------------------------------------------------------------------------
INDEX
EXAMINE TRANSLATE
Syntax:
EXAMINE
TRANSLATE
Variable
Array
Substring arguments
[ AND]
Function
The EXAMINE TRANSLATE statement is used to translate the characters
contained in a field into upper-case or lower-case, or into other
characters.
SUBSTRING
Normally, the entire content of a field is translated. With the
SUBSTRING option, you translate only a certain part of the field. After
the field name in the SUBSTRING clause, you specify first the starting
position and then the length of the field portion to be examined.
RCI
Page 44 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
45
---------------------------------------------------------------------------------------------------------------------------------
FETCH
Syntax :
REPEAT
RETURN
FETCH
Program-name
Variable
Column name
constant
.. 40
RCI
Page 45 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
46
---------------------------------------------------------------------------------------------------------------------------------
Load and execute object program (previously stored with CATALOG or STOW
command). Source program in NATURAL source work area won't be overwritten.
REPEAT - suppresses prompt for user input during execution of fetched program.
RETURN - issuing program suspended and re-activated when END or ESCAPE
ROUTINE encountered in fetched program. If RETURN not specified, execution of
issuing program is suspended, and fetched program is activated as main program.
Example:
DECIDE ON EVERY VALUE FOR #FNC
VALUE `A`
FETCH `ADD-RT` #PNUM
VALUE `P`
FETCH `PUR-RT #PNUM
VALUE `U`
FETCH `UPD-RT` #PNUM
VALUE `.`
STOP
NONE
REINPUT `PLEASE ENTER A VALID FUNCTION` MARK *#FND
END-DECIDE
FIND
Syntax :
FIND
ALL
(operand1)
RCI
Page 46 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
47
---------------------------------------------------------------------------------------------------------------------------------
[WITH]
[ LIMIT]
(N)
(FIELD)
basic-search-criteria
IF NO [RECORDS] [FOUND]
ENTER
statement(s)
DO.DOEND
END-NOREC
END-FIND
It selects and reads a set of rows from a DB2 table. Operand 1 indicates a limit to the
number of rows to be processed (FETCHed). It sets the maximum number of rows to be
retrieved to the value represented by operand 1.operand1 ,if specified , is a numeric
constant or a numeric variable name enclosed in parentheses. If a numeric constant,it
cannot be a four digit numeric constant (prefix with a leading zero if necessary) since it
will be confused with a NATURAL statement number reference.
The VIEWNAME is the name of a view named in the GDA or LDA
The FIND statement generates the DB2 statement : SELECT.
FIND(1) syntax is often used to return at most one row,or to test for existence.However,it
initiates a processing loop that generates a positioned cursor,also called CURSORCONTROLLED-SELECT,which
includes
a
DECLARE
CURSOR,OPEN
CURSOR,FETCH
at CURSOR (gets SQLCODE 0 if row found),FETCH at
CURSOR(to get SQLCODE + 100),CLOSE CURSOR.
To return one row , a natural for DB2 SQL SELECT SINGLE statement would be more
efficient than FIND(1) for finding a UNIQUE record , when all column values for the
primary key or unique index are known , particularly in NATURAL Structured Mode
which doesnt allow FIND UNIQUE.
FIND UNIQUE is only allowed in the NATURAL Reporting mode,not Structured
mode,and may be used in reporting mode only against DB2 tables with Primary Keys.
RCI
Page 47 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
48
---------------------------------------------------------------------------------------------------------------------------------
FOR
Syntax
FOR
column name
Column name
EQ
variable
variable
FROM
constant
TO
column name
THRU
variable
constant
column name
STEP
variable
constant
statement(s)
END-FOR.
Function
The FOR statement is used to initiate a processing loop and to control
the number of times the loop is processed. It must have a numeric
control field.
Control Variable
RCI
Page 48 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
49
---------------------------------------------------------------------------------------------------------------------------------
is negative) using the value specified after the STEP keyword each
additional time the loop is processed.
The control variable value may be referenced during the execution of
the processing loop and will contain the current value of the control
variable.
1
TO field indicates end of range;highest number of times the loop can
be executed.It is tested before loop entered. TO/THRU is optional.
STEP indicates value by which control field is increased each time loop
is entered.It may be + or - . The default value is 1.
Consistency Check
Before the FOR loop is entered, the values of the operands are checked
to ensure that they are consistent . If the values are not consistent,
the FOR loop is not entered (however, no error message is output).
FORMAT
Syntax
FORMAT [(rep)] parameter..
Function
The FORMAT statement is used to specify input and output parameter
settings. Settings
specified with a FORMAT statement override (at compilation time)
default settings in effect for the session that have been set by a
GLOBALS command, SET GLOBALS statement, or by the NATURAL
RCI
Page 49 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
50
---------------------------------------------------------------------------------------------------------------------------------
Parameters
The parameters can be specified in any order and must be separated
by one or more spaces. A single entry must not be split between two
statement lines.
Eg.
DEFINE DATA
.
RCI
Page 50 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
51
---------------------------------------------------------------------------------------------------------------------------------
END-DEFINE
FORMAT PS=10 HC = L
UC = %
FC = $ LC = + TC =
+
Sets page size to 10,Headers will be left Justified,Underline
character is now a % sign,First level of Headers will be filled with Dollar
signs,the leading character that will appear immediately before column
value will be a plus sign, the trailing character that will appear
immediately after column value will be a plus sign.
GET
Syntax
GET
Function
The GET statement is used to read a record with a given ADABAS ISN (Internal
Sequence
Number).
The GET statement does not cause a processing loop to be initiated.
Restrictions
The GET statement cannot be used for DL/I and SQL databases.
The GET statement cannot be used with ENTIRE SYSTEM SERVER.
view-name
The name of a view as defined either within a DEFINE DATA statement or in a
separate a
global or local data area. In reporting mode, view-name may also
be the name of a DDM.
PASSWORD and CIPHER
These clauses are applicable only for ADABAS and VSAM databases.
RCI
Page 51 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
52
*ISN / operand3
The ISN must be provided either in the form of a numeric constant or user-defined
variable
(operand3), or via the NATURAL system variable *ISN.
Reference to Database Fields (operand4)
Subsequent references to database fields that have been read with a GET
statement must contain the label or line number of the GET statement.
53
---------------------------------------------------------------------------------------------------------------------------------
END ENDPAGE
/********************************************************************
END READ
END
Column name
Variable
40
Reads data saved by a prior END TRANSACTION. Must be careful with this function
since an END TRANSACTION closes the DB2 CURSOR
System Variable *ETID
The content of the Natural System variable *ETID identifies the transaction data to be
retrieved from the database.Generated by NATURAL Security , therefore, may be set as a
standard across an application or to a group of users ,etc.
Set by NATURAL Security Administrator
Default is 8 character value
Default is user ID
GET TRANSACTION DATA doesnot generate a processing loop
Sequence, format and length of variables read must be identical to sequence , format and
length
as created.
RCI
Page 53 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
54
---------------------------------------------------------------------------------------------------------------------------------
55
---------------------------------------------------------------------------------------------------------------------------------
END
GET SAME
Structured Mode :
GET SAME [(r)]
Reporting Mode Syntax:
GET SAME [(r)]
This statement is only valid for NATURAL users who are using ADABAS or VSAM. This
statement cannot be used with ENTIRE SYSTEM SERVER.
Function
The GET SAME statement is used to re-read the record currently being
processed. It is most frequently used to obtain database array values (periodic
groups or multiple-value fields) if the number and range of existing or desired
occurrences was not known when the record was initially read.
operand1
As operand1, you specify the field(s) to be made available as a result of the GET
SAME
statement.
Note: Operand1 cannot be specified if the field is defined in a DEFINE DATA
statement.
Restrictions
An UPDATE or DELETE statement must not reference a GET SAME statement.
These
statements should instead make reference to the FIND, READ or GET
statement used to read the record initially.
For VSAM databases, GET SAME can only be applied to ESDS and RRDS. For
ESDS, the RBA must be contained in a user-defined variable (numeric format) or be
specified as an integer constant. The same applies for RRDS, except that the RRN
must be provided instead of the RBA.
Example :
MOVE1TOI
READPOSTADDRESSBYNAME
RCI
Page 55 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
56
---------------------------------------------------------------------------------------------------------------------------------
COMPRESSNAMEFIRSTNAMEINTO#NAMEWITHDELIMITER,
WRITE//12T#NAME
WRITE/12TADDRESSLINE(I.1)
IFC*ADDRESSLINE>1
FORI=2TOC*ADDRESSLINE
GET SAME /* READ NEXT OCCURRENCE
WRITE12TADDRESSLINE(I.1)
ENDFOR
ENDIF
WRITE/POSTCODECITY
SKIP3
ENDREAD
HISTOGRAM
Syntax:
HISTOGRAM operand1 VALUE IN FILE view-name
PASSWORD=operand2
SEQUENCE-clause
VALUE FOR FIELD operand4
STARTING/ENDING-clause
WHERE logical-condition
statement ...
END-HISTOGRAM
STARTING/ENDING-clause:
STARTING WITH VALUES operand5 THRU
operand6
FROM
ENDING AT
SEQUENCE-clause:
IN ASCENDING
SEQUENCE
DESCENDING
VARIABLE operand3
The HISTOGRAM statement is used to read the values of a database field which is
defined as a descriptor, subdescriptor, or a superdescriptor. The values are read directly
from the ADABAS inverted lists (or VSAM index). The HISTOGRAM statement causes
a processing loop to be initiated but does not provide access to any database fields other
than the field specified in the HISTOGRAM statement.
RCI
Page 56 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
57
---------------------------------------------------------------------------------------------------------------------------------
STARTING WITH/FROM specifies starting value and if value is not present next higher
value is used. THRU/ENDING AT specifies the end of value range.
Example:
HISTOGRAM EMPLOY-VIEW CITY STARTING FROM 'M'
DISPLAY NOTITLE CITY
`NUMBER OF/PERSONS` *NUMBER *COUNTER
END-HISTOGRAM
/* EXAMPLE HSTEX1S: HISTOGRAM (STRUCTURED MODE)
/******************************************************
DEFINE DATA LOCAL
1 EMPLOYVIEW VIEW OF EMPLOYEES
2 CITY
ENDDEFINE
/******************************************************
LIMIT 8
HISTOGRAM EMPLOYVIEW CITY STARTING FROM M
DISPLAY NOTITLE CITY
NUMBER OF/PERSONS *NUMBER *COUNTER
ENDHISTOGRAM
/******************************************************
END
IGNORE
Syntax :
IGNORE
This IGNORE statement does not perform any function.
During the development phase of an application, you can insert IGNORE temporarily
within statement blocks in which one or more statements are required, but which you
intend to code later. This allows continuing programming in another part of the
application without the as yet incomplete statement blocking or leading to an error.
Example :
AT TOP OF PAGE
IGNORE
END-TOPPAGE
RCI
Page 57 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
58
---------------------------------------------------------------------------------------------------------------------------------
IF
Structured Mode Syntax
IF logical-condition
[ THEN ]
IGNORE
statement(s)
ELSE statement(s)
END-IF.
Reporting Mode Syntax
IF logical-condition
[ THEN ] { statement / DO statement. DOEND}
[ ELSE
{ statement / DO statement.DOEND}
END-IF.
Function
The IF statement is used to control execution of a statement or group
of statements based on a logical condition.
Note: If no action is to be performed if the condition is met, you
specify the statement IGNORE in the THEN clause.
logical-condition
RCI
Page 58 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
59
---------------------------------------------------------------------------------------------------------------------------------
INCLUDE
Syntax :
INCLUDE copycode-member-name [(library)][ [inserted-value] ... 99]
INCLUDE statement includes source lines located in an external source member
(copycode). The INCLUDE statement is evaluated at compilation time. The source lines
of the copycode will not be physically included in the source of the program that
contains the INCLUDE statement, but they will be included during the program
compilation and thus in the resulting object module.
Note: When source of an included member is modified, all programs using that member
must be recompiled.
Additional values may be inserted into the COPYCODE object dynamically.
INCLUDE lists upto 99 insertion values.Each parameter must be enclosed in a set
of apostrophes.Must have an equal number of targets in COPYCODE.
RCI
Page 59 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
60
---------------------------------------------------------------------------------------------------------------------------------
INIT(ial)
INPUT
Syntax:
Dynamic Screen Layout Specification:
INPUT WINDOW='window-name' NO ERASE
(statement-parameters)
WITH TEXT-option
MARK-option
ALARM-option
RCI
Page 60 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
61
---------------------------------------------------------------------------------------------------------------------------------
The INPUT statement is used in interactive mode to create a formatted screen or map for
data entry. It may also be used in conjunction with the NATURAL stack (see the STACK
statement); and on mainframe computers, it may also be used to provide user data for
programs being executed in batch mode. The INPUT statement is used in interactive
mode to create a formatted screen or map for data entry. It may also be used in
conjunction with the NATURAL stack (see the STACK statement); and on mainframe
computers, it may also be used to provide user data for programs being executed in batch
mode.
The INPUT statement may be used for an operation on line-oriented devices or for the
processing of batch input from sequential files. The same map layouts as defined for
screen mode operation can also be processed in non-screen mode.
Forms mode and keyword/delimiter mode are also available to process the input either by
simulating the screen layout in line mode or by just processing the data without any map
layout.
Example:
...
MOVE MESSAGE1 TO #FIELD
...
INPUT WITH TEXT THE ERROR IS :1: ,#FIELD ...
...
Example Using Syntax 1
/* EXAMPLE IPTEX1: INPUT
/******************************************************
DEFINE DATA LOCAL
1 #PNUM (A8)
1 #FNC (A1)
ENDDEFINE
/******************************************************
INPUT 10X SELECTION MENU FOR EMPLOYEES SYSTEM /
10X (54) //
10X ADD (A) /
10X PURGE (P) /
RCI
Page 61 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
62
---------------------------------------------------------------------------------------------------------------------------------
INSERT
The SQL INSERT statement is used to INSERT of a set of rows into DB2 table.
The single row insert behaves like a structured-mode NATURAL STORE statement.
Often Date, Time and Timestamp columns which are defined NOT NULL WITH
DEFAULT, will be left off.
Examples:
1. STORE main_isrt;
2. INSERT INTO main_trng (*)
VAULES (VIEW main_isrt);
3. INSERT INTO main_trng (reg_num, main_cost)
VALUES (VIEW main_isrt);
4. INSERT INTO main_trng ( reg_num, main_cost)
RCI
Page 62 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
63
---------------------------------------------------------------------------------------------------------------------------------
5.
LIMIT
Syntax:
LIMIT n
The LIMIT statement is used to limit the number of iterations of a processing loop
initiated with a FIND, READ, or HISTOGRAM statement. The limit remains in effect for
all subsequent processing loops in the program until it is overridden with another LIMIT
statement. The LIMIT statement does not apply to individual statements in which a limit
is explicitly specified (for example, FIND (n) ...). If the limit is reached, processing stops
and a message is displayed. If no LIMIT statement is specified, the default limit defined
during NATURAL installation will be used.
Limit Specification (n)
The limit n must be specified as a numeric constant in the range from 0 to 99999999
(leading zeros are optional). The processing loop is not entered if the limit is set to 0.
Record Counting
A record that is rejected because of criteria specified in a FIND or READ statement
WHERE clause is not counted against the limit. A record that is rejected as a result of an
ACCEPT/REJECT statement is counted against the limit.
Example 1
RCI
Page 63 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
64
---------------------------------------------------------------------------------------------------------------------------------
LOOP
Syntax
[CLOSE] LOOP [ (r)]
Function
The LOOP statement is used to close a processing loop. It causes processing of the
current pass
through the loop to be terminated and control to be returned to the beginning of the
processing
loop.
When the processing loop for which the LOOP statement is issued is terminated (that is,
when
all records have been processed or iterations have been performed), execution continues
with the statement after the LOOP statement.
Statement Reference Notation (r)
The LOOP statement may be specified with a statement label or reference number, in
which case all inner loops up to and including the loop initiated by the statement
referenced will be closed.
If no statement reference is specified, the innermost active processing loop will be close.
Database Variable References
RCI
Page 64 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
65
---------------------------------------------------------------------------------------------------------------------------------
A LOOP statement, in addition to closing a processing loop, will eliminate all field
references
to FIND, FIND FIRST, FIND UNIQUE, READ and GET statements contained within the
loop. A field within a view may be referenced outside the processing loop by using the
view name as qualifier.
Restrictions
A LOOP statement may not be specified based on a conditional statement such as IF or
AT
BREAK.
Example 1
0010FIND...
0020READ...
0030READ...
0040LOOP(0010)/*closesallloops
Example 2
0010FIND...
0020READ...
0030READ...
0040LOOP/*closesloopinitiatedonline0030
0050LOOP/*closesloopinitiatedonline0020
0060LOOP/*closesloopinitiatedonline0010
MOVE
Syntax 1
ROUNDED
MOVE
BY
NAME
field-name
EDITED
variable
(EM=)
LEFT/RIGHT
JUSTIFIED
constant
SUBSTRING argument
Column name
RCI
Page 65 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
66
---------------------------------------------------------------------------------------------------------------------------------
TO
variable
(EM=)
SUBSTRING argument
Function
The MOVE statement is used to move the value of an operand to one
or more operands (field or array).
ROUNDED
This option rounds to the precision of receiving column or variable.
parameter
As parameter, you can specify the option PM=I or the session
parameter DF:
PM=I
In order to support languages whose writing direction is from right to
left, you can specify PM=I so as to transfer the value of operand1 in
inverse (right-to-left) direction to operand2. For example, as a result of
the following statements, the content of #B would be ZYX:
MOVEXYZTO#A
MOVE#A(PM=I) TO#B
PM=I can only be specified if operand2 has alphanumeric format. Any
trailing blanks in operand1 will be removed, then the value is reversed
and moved to operand2. If operand1 is not of alphanumeric format, the
value will be converted to alphanumeric format before it is reversed.
DF
If operand1 is a date variable and operand2 is an alphanumeric field,
you can specify the session parameter DF as parameter for this date
variable.
SUBSTRING
RCI
Page 66 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
67
---------------------------------------------------------------------------------------------------------------------------------
68
---------------------------------------------------------------------------------------------------------------------------------
2#FIELD(A10/1:10)
1#GROUP2
2#FIELD(A10/1:10)
ENDDEFINE
...
MOVEBYNAME#GROUP1TO#GROUP2
...
In this, example, the MOVE statement would internally be resolved as:
MOVE#GROUP1.#FIELD(*)TO#GROUP2.#FIELD(*)
MOVE BY POSITION
This option allows you to move the contents of fields in a group to
another group, regardless of the field names. The values are moved
field by field from one group to the other in the order in which the
fields are defined (this does not include fields resulting from a
redefinition). The individual fields may be of any format. The number of
fields in each group must be the same; also, the level structure and
array dimensions of the fields must match. The operands can also be
views.
69
---------------------------------------------------------------------------------------------------------------------------------
2#FIELD2A(N5)
2#FIELD2B(A3/1:3)
2REDEFINE#FIELD2B
3#FIELD2BR(A9)
ENDDEFINE
...
MOVEBYPOSITION#GROUP1TO#GROUP2
...
In this example, the content of #FIELD1A is moved to #FIELD2A, and
the content of
#FIELD1B to #FIELD2B; the fields #FIELD1BR and #FIELD2BR are not
affected.
MOVE ALL 1
Syntax
Column name
MOVE ALL
constant
TO
Column name
Constant
Column name
UNTIL
Constant
Function
The MOVE ALL statement moves characters until either receiving
variable is filled or UNTIL limit is reached.The sending column or
variable must be A,N,or B format.Receiving column or variable must be
A format.
RCI
Page 69 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
70
---------------------------------------------------------------------------------------------------------------------------------
The target operand is not reset prior to the execution of the MOVE ALL
operation. This is of particular importance when using the UNTIL option
since data previously in operand2 is retained if not explicitly overlaid
during the MOVE ALL operation.
UNTIL Option
The UNTIL option is used to limit the MOVE ALL operation to a given
number of positions in operand2. Operand3 is used to specify the
number of positions. The MOVE ALL operation is terminated when this
value is reached.
MULTIPLY
Syntax 1
Column name
MULTIPLY [ROUNDED]
Variable
constant
array
System-variable
Column name
Variable
constant
array
System-variable
GIVING
BY
Column name
variable
array
system-variable
Function
The MULTIPLY statement is used to multiply two operands.
Result Field
The result of the multiplication is stored in first operand .GIVING stores
result of arithmetic operation into target variable . If first operand is a
numeric constant, the GIVING clause is required. If a database field is
used as the result field, the multiplication results in an update only to
the internal value of the field as used within the program. The value for
RCI
Page 70 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
71
---------------------------------------------------------------------------------------------------------------------------------
NEW PAGE
Syntax:
NEWPAGE (rep) EVEN IF TOP OF PAGE
WITH TITLE
OBTAIN
Syntax:
OBTAIN operand1.
This statement is valid in reporting mode only.
Function
RCI
Page 71 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
72
---------------------------------------------------------------------------------------------------------------------------------
ON ERROR
Syntax:
ON ERROR
Statement(s)
END-ERROR
This statement allows to intercept execution time errors which would otherwise result in
a NATURAL error message, termination of program execution, and return to command
input mode. When ON ERROR block entered for execution, program is interrupted and
can only be resumed with RETRY. Exit ON ERROR block with FETCH, STOP,
TERMINATE, RETRY, or ESCAPE ROUTINE.
It may be used with ESCAPE ROUTINE to return control to the object that invoked the
module that had the error.If not used , execution time errors issue message and
NATURAL object is terminated.
Each module of subroutine built with CALLNAT, PERFORM, or FETCH RETURN may
contain an ON ERROR statement. If error occurs, NATURAL traces back to select first
ON ERROR statement for processing; if none found, program terminates.
Applicable system variables: *ERROR-NR (number / code of error detected) and
*ERROR-LINE (line number on which error is detected).
Example :
FIND EMP WITH COUNTRY = USA
ON ERROR
RCI
Page 72 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
73
---------------------------------------------------------------------------------------------------------------------------------
IF *ERROR-NR = 3009
WRITE `LAST TRANSACTION NOT SUCCESSFUL`
/ `HIT ENTER TO RESTART PROGRAM`
FETCH `PROGUPD`
END-IF
END-ERROR
---------------END-FIND
PASSW
Syntax
PASSW = Operand1
Function
The PASSW statement is used to specify a password for access to ADABAS or VSAM
files
which have been password-protected.
Password
RCI
Page 73 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
74
---------------------------------------------------------------------------------------------------------------------------------
75
---------------------------------------------------------------------------------------------------------------------------------
Example
/* EXAMPLE PWDEX1: PASSW
/*********************************
DEFINE DATA LOCAL
1 EMPLOY VIEW VIEW OF EMPLOYEES
2 PERSONNEL ID
2 NAME
END DEFINE
/*********************************
PASSW=PASSW1
/*********************************
LIMIT 5
READ EMPLOY VIEW
DISPLAY NOTITLE PERSONNEL ID NAME
END READ
/*********************************
END
76
---------------------------------------------------------------------------------------------------------------------------------
Reference relates final break condition of statement to specific loop; if not used, the
final PERFORM BREAK condition is true at the end of execution of the program,
subprogram or subroutine.
PRINT
Syntax:
PRINT (rep) NOTITLE NOHDR (statement-parameters)
nX 'text'(attributes) ... operand1 (parameter) ...
nT 'c'(n)(attributes)
/... '='
Produce output in free format (vs. columns as in DISPLAY statement).
Default title contains page number, time of day, and date.
(rep) specifies identification of report for which PRINT statement applies; if not used,
statement applies to report 0.
The PRINT statement is used to produce output in free format. The PRINT statement
differs from the WRITE statement in the following aspects:
RCI
Page 76 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
77
---------------------------------------------------------------------------------------------------------------------------------
_ The output for each operand is written according to value content rather than the
length
of the operand. Leading zeros for numeric values and trailing blanks for
alphanumeric values are suppressed. The session parameter AD defines whether
numeric values are printed left or right justified. With AD=L, the trailing blanks
of a numeric value are suppressed. With AD=R, the leading blanks of a numeric
value are printed.
_ If the resulting output exceeds the current line size (LS parameter), the output is
continued on the next line as follows:
An alphanumeric constant or the content of an alphanumeric variable (without
edit mask) is split at the rightmost blank or character which is neither a letter nor
a numeric character contained on the current line. The first part of the split value
is output to the current line, and the second part is written to the next line. For all
other operands, the entire value is written to the next line.
Example:
WRITE NAME ',' FIRST-NAME ':' JOB-TITLE '*' (30)
PRINT NAME 0X ',' FIRST-NAME 0X ':' JOB-TITLE '*' (30)
Result of WRITE Statement:
SMITH
, WILLIE
: PROGRAMMER
******************************
Result of PRINT Statement:
SMITH , WILLIE : PROGRAMMER ******************************
WRITE
Syntax I - Dynamic Formatting:
WRITE (rep) NOTITLE NOHDR
(statement-parameters)
nX
'text'(attributes)
...
nT
'c'(n)(attributes)
x/y
operand1 (parameters)
T*field-name
P*field-name
'='
/...
Syntax II - Using Predefined Map:
WRITE (rep) NOTITLE NOHDR
RCI
Page 77 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
78
---------------------------------------------------------------------------------------------------------------------------------
nT
Position (tabulation) to print position 'n'.
x/y
Place next element x lines below last output, on column y.
T*field-name Position to specific print position of field used in previous
DISPLAY statement.
P*field -name Position to specific print position and line of field used in
previous DISPLAY statement.
Text/attribute assignments:
'text'
'text' is displayed.
'c'(n)
Display character 'c', 'n' times.
Attributes
B
C
D
Display attributes
Color attributes
(blinking)
BL (blue)
(cursive/italic)
GR (green)
(default)
NE (neutral)
RCI
Page 78 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
79
---------------------------------------------------------------------------------------------------------------------------------
I
U
V
'='
/
(intensified)
PI (pink)
(underlined)
TU (turquoise)
(reversed video)
YE (yellow)
Display field heading when placed before a field.
Position to next print line, if placed between fields or text
elements; advance to next line, if placed at end of line.
PROCESS
Syntax
PROCESS View-name USING operand1 = operand2 GIVING operand3
This statement is only available with ENTIRE SYSTEM SERVER.
Function
The PROCESS statement is used in conjunction with ENTIRE SYSTEM SERVER.
ENTIRE
SYSTEM SERVER allows you to use various operating system facilities such as reading
and
RCI
Page 79 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
80
---------------------------------------------------------------------------------------------------------------------------------
PROCESS COMMAND
Syntax
PROCESS
COMMAND
viewname
ACTION
[CLOSE[
CHECK
EXEC
TEXT
HELP
USING PROCESSOR-NAME =
Constant
Variable
Constant
Variable
COMMAND-LINE(index [:index] ) =
RCI
Page 80 ofArray
144
10/7/2016
Group
---------------------------------------------------------------------------------------------------------------------------------
81
---------------------------------------------------------------------------------------------------------------------------------
Constant
variable
Constant
variable
Constant
variable
RCI
Page 81 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
82
---------------------------------------------------------------------------------------------------------------------------------
Example :
PROCESS COMMAND ACTION EXEC
USING PROCESSOR NAME = USER
COMMAND LINE (1) = #COM-MSG
READ
Syntax:
READ
BROWS
E
(n)
variable
Viewname
IN PHYSICAL SEQUENCE
IN LOGICAL SEQUENCE
[ WHERE logical-condition-criteria]
END-READ
The READ or BROWSE statement initiates a processing loop that tells NATURAL
where to begin processing data base values.
Processing loop is terminated by :
End of table
Reaching ENDING AT or THRU value
ESCAPE based on logical condition
LIMIT statement specification
Number of records (n)
READs and DELETEs cannot be executed against READ IN LOGICAL SEQUENCE
processing. It also translates to SQLs SELECT ORDERED BY . If LOGICAL is
specified without a column name , the READ will be processed in the default sequence
column as specified in the DDM.
Example:
1.
RCI
Page 82 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
83
---------------------------------------------------------------------------------------------------------------------------------
3.
REDEFINE
RCI
Page 83 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
84
---------------------------------------------------------------------------------------------------------------------------------
Syntax :
View definition
Group name
Variable name
Level
REDEFINE
Group name
Variable name
FILLER nX
Examples:
DEFINE DATA
LOCAL
1 #CLIENT-NAME
(A20)
1 #CLIENT-ADDRESS
2 #STREET
(A20)
2 REDEFINE #STREET
3 #STREET-NUMBER (N5)
3 #STREET-NAME
(A15)
2 REDEFINE #STREET
3 #P-O-BOX
(A7)
3 #BOX-NUMBER
(N5)
** the remaining positions are ignored
2 #CITY
(A20)
2 #STATE
(A2)
2 #ZIP-CODE
(N5)
END-DEFINE
REINPUT
Syntax:
RCI
Page 84 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
85
---------------------------------------------------------------------------------------------------------------------------------
- all fields will get the values they had at execution time
of REINPUT.
- invoke helproutine defined for first marked field.
- provide text to be displayed in message line.
- indicate field to be marked for cursor positioning.
- specifies cursor position whithin a field.
- sounds alarm when REINPUT statement is executed.
86
---------------------------------------------------------------------------------------------------------------------------------
REJECT
Syntax :
REJECT [IF] logical-condition-criteria
RCI
Page 86 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
87
---------------------------------------------------------------------------------------------------------------------------------
RELEASE
Syntax:
RELEASE STACK
VARIABLES
88
---------------------------------------------------------------------------------------------------------------------------------
RESET
Syntax
Column name
Variable
RESET [INITIAL]
array
length[/index][:index]
group
Function
format
0
blanks
FALSE
T00:00:00
(AD=D)
RETRY
Syntax
RETRY
This statement can only be used when accessing ADABAS databases.
Function
The RETRY statement is used within an ON ERROR statement block (see ON ERROR
statement). It is used to reattempt to obtain a record which is in hold status for another
user.
When a record to be held is already in hold status for another user, NATURAL issues errormessage 3145.
The RETRY statement must be placed in the object that causes the error 3145.
RCI
Page 88 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
89
---------------------------------------------------------------------------------------------------------------------------------
RUN
Syntax :
RUN [REPEAT] Constant
Variable
Constant
Variable
Array
Group
..40
Dynamically reads NATURAL source program into work area, overlaying current
source program, and executes (basically the same functionality as RUN command)
Program name may be coded within a set of apostrophes(constant) or contained in a
user-defined variable
Error message is returned for program not found on current library or SYSTEM
library
REPEAT bypasses INPUT statement prompts
Example :
DEFINE DATA GLOBAL USING GDAWH&O
** WHICH CONTAINS A TABLE VIEW PLUS :
** 1 #GLOBAL-VARIABLES
** 2 #PROGRAM (A8)
.
DECIDE ON FIRST VALUE OF #OPTION
VALUE L
MOVE PERDIS
TO #PROGRAM
VALUE D
MOVE PERDEL TO #PROGRAM
NONE
REINPUT PLEASE ENTER A FUNCTION NOW
END-DECIDE
.
END
SELECT
The SELECT statement is used for retrieval of data from DB2 based on Selection
criteria.
RCI
Page 89 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
90
---------------------------------------------------------------------------------------------------------------------------------
Syntax:
SELECT
INTO
ALL
DISTINCT
Scalarexpression
FROM table-name[correlation-variable]
[WHERE search-condition]
[GROUP BY column-reference ,.]
[HAVING search-condition]
END-SELECT
WHERE Selection Criteria for rows clause specifies the criteria for selecting rows
from the tables.
This clause is similar to the WITH clause in a NATURAL FIND statement.
The selection criteria can consist of a simple relational expression, SQL-expressions,
or a complex expression with Boolean operators of AND, OR and NOT connecting
any other expressions.
Parentheses may be used to alter the order of operation.
The SQL expressions include tests for BETWEEN , IS [NOT] NULL and LIKE
tests.
The IS NULL clause is equivalent to testing a NULL indicator for a value of -1.
The LIKE clause is similar to SCAN or MASK operations. Wildcarding is available
at the beginning,ending,and middle of the string.
The WHERE clause can also include a subordinate SELECT statement(called a SUBSELECT).
RCI
Page 90 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
91
---------------------------------------------------------------------------------------------------------------------------------
Two types of SELECT statements are possible in NATURAL for DB2. SELECT
SINGLE and SELECT SET.
SELECT SINGLE
Natural SELECT SINGLE Statement syntax provides functionality for single row
select.
Also called the Non-Cursor- Oriented selection, because DB2 SELECT INTO is
used , where possible , to implement the functionality instead of the statement
combination: DECLARE CURSOR, OPEN CURSOR , FETCH, CLOSE CURSOR.
NATURAL positioned update and delete statement syntax cannot therefore be used.
Select SINGLE must be used in cases where the result of the select clause is only
one row. Generally if primary key is used in the where clause then the result will
be only one row,in which case it is very efficient to use SELECT SINGLE.
Syntax :
SELECT SINGLE SELECTION
INTO
PARAMETER
VIEW view name [correlation name ] , .
Table expression
[IF NO RECORDS FOUND]
Statement
END-SELECT
LOOP Report Mode Only
SELECT SET
NATURAL for DB2 permits embedding the SELECT / END SELECT statements in
the program in order to set up a Database I/O processing loop. This syntax behaves
similarly to the FIND statement in generating a database processing loop such as :
DECLARE CURSOR, OPEN CURSOR, FETCH, CLOSE CURSOR.
Syntax:
RCI
Page 91 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
92
---------------------------------------------------------------------------------------------------------------------------------
PARAMETER
VIEW viewname [correlation-name ] , .
Integer
ASC
DESC
Column-reference
END-SELECT
LOOP Reporting Mode Only
SELECT Syntax
INTO VIEW
NATURAL for DB2 supports the INTO VIEW clause for both non-cursor singleton
SELECTs and cursor-oriented set retrieval SELECT statements. (DB2 allows INTO
clause only for singleton row retrieval on the DB2 SQL DML SELECT INTO
statement.)
ORDER BY:
ORDER BY is used to specify that you want the result set of rows presented back to
be in a sort sequencing for the rows to be returned , similar to FINDSORTED.
FINDSORTED limits the sort sequencing to three columns.
No such practical limit exists when using SELECT statement.
WITH HOLD :
RCI
Page 92 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
93
---------------------------------------------------------------------------------------------------------------------------------
WITH HOLD will allow the changes in the current unit of work to be committed, but
releases only those locks that are not required to maintain the cursor.
NATURAL for DB2 automatically and transparently manages DB2 cursor logic,
including initial FETCH that is required after a COMMIT before a positioned update
or delete statement can be subsequently executed.
Examples :
1.
2.
Notice the SQL-expression that computes the age in the SELECT statement. YEAR
is a special scalar function. CURRENT DATE is a special register. The expression must be
repeated in both the Selection-list and in the Selection-criteria-for-rows.
IF NO RECORDS
Syntax:
IF NO RECORDS
Statement(s)
END-NOREC
The IF NO ... END-NOREC is used within a SELECT,.. loop. If the executed SELECT
retrieves no records or zero records then the statements within this loop are executed and
RCI
Page 93 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
94
---------------------------------------------------------------------------------------------------------------------------------
SET GLOBALS
Syntax:
SET GLOBALS parameter-key-word = value ...
Function
SET GLOBALS parameters become effective when program is executed.The parameter
settings specified with SET GLOBALS remain in effect until the end of the NATURAL
session, unless they are overridden with a subsequent SET GLOBALS statement (or
GLOBALS system command).
Exception: On mainframe computers, a SET GLOBALS statement in a subordinate
program (that is, a subroutine, subprogram, or program invoked with FETCH RETURN)
only applies until control is returned from the subordinate program to the invoking
object; then the parameter values set for the invoking object apply again.
Parameters
If you specify multiple parameters, you have to separate them from one another by one or
more blanks. The parameters can be specified in any order.
Example
...
SET GLOBALS LS=74 LT=5000
...
SET KEY
Syntax:
SET KEY
ON
OFF
ALL
COMMAND
ON
OFF
NAMED OFF
OFF
NAMED
Function
The SET KEY statement is used to assign functions to video terminal PA (program
attention) keys, PF (program function) keys, and the CLEAR key. When a SET KEY
statement is executed, NATURAL receives control of the keys during program execution
and uses the values assigned to the keys. The NATURAL system variable *PFKEY
identifies which key was pressed last.
RCI
Page 94 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
95
---------------------------------------------------------------------------------------------------------------------------------
RCI
Page 95 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
96
---------------------------------------------------------------------------------------------------------------------------------
97
---------------------------------------------------------------------------------------------------------------------------------
1 #FCT (A8)
ENDDEFINE
/*****************************************************************
MOVE LIST FILES TO #PF4
/*****************************************************************
SET KEY PF1 PF2
SET KEY PF3 = MENU
PF4 = #PF4
PF5 = LIST FILE EMPLOYEES
/****************************************************************
INPUT 10X THE FOLLOWING FUNCTION KEYS ARE AVAILABLE: //
10X PF1: EMPLOYEES UPDATE PROGRAM /
10X PF2: EMPLOYEES READ PROGRAM /
10X PF3: RETURN TO MENU /
10X PF4: LIST FILES /
10X PF5: LIST FILE EMPLOYEES ///
10X OR YOU MAY ENTER A PROGRAM TO BE EXECUTED: #FCT
/****************************************************************
IF #FCT NE
FETCH #FCT
ENDIF
IF *PFKEY = PF1
FETCH UPDPERS
ENDIF
IF *PFKEY = PF2
FETCH READPERS
ENDIF
/****************************************************************
END
SET CONTROL
Syntax:
SET CONTROL
variable
constant
The SET CONTROL statement is used to perform terminal commands from within a
program. The terminal commands (operand1) are specified without the control character
and can be specified as a text constant or as the content of an alphanumeric variable.
Example 1
...
SET CONTROL L
RCI
Page 97 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
98
---------------------------------------------------------------------------------------------------------------------------------
...
Switches to lower case (equivalent to the terminal command %L).
Example 2
...
SET CONTROL HDEST
...
Activates hardcopy output to destination DEST (equivalent to the terminal command
%HDEST).
Example 3
.
SET CONTROL MT
..
Sets the message line on the top line on the screen
SET TIME
Syntax :
SET TIME
Function
The SETTIME statement is used in conjunction with the NATURAL
system variable *TIMD to measure the time it takes to execute a
specific section of a program. The SETTIME statement is placed at a
specific position in the program, and *TIMD will contain the amount of
time elapsed since the execution of the SETTIME statement.
*TIMD must always contain a reference to the SETTIME statement, either by using the
source-code line number of the SETTIME statement or by assigning a label to the
SETTIME statement which can then be used as a reference.
WHEN using this statement and System Variable together, the elapsed time represents the
wall clock time between the beginning of the execution and the logical arrival at the AT
END OF DATA statement.
If the end-user had to press the ENTER Key to arrive at the ending condition, the time it
takes to press the ENTER key is included in the final elapsed time value-so press the
ENTER key quickly for more accurate results.
Example
/* EXAMPLE STIEX1: SETTIME
/*****************************************************************
RCI
Page 98 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
99
---------------------------------------------------------------------------------------------------------------------------------
SKIP
Syntax:
SKIP (rep) operand1 LINES
The SKIP statement is used to generate one or more blank lines in an output report.
(rep) specifies identification of report for which SKIP is applicable; if not used,
statement applies to report 0. May be specified in range 1-31 or with name assigned in
DEFINE PRINTER statement.
Operand1 - number (1-250) of blank lines to be generated; specified as numeric constant
or content of numeric variable. If operand1 exceeds page size, SKIP results in
NEWPAGE condition.
If execution of SKIP causes page size to be exceeded, page eject is performed (except in
end-page condition).
Example:
READ EMPLOYEES BY CITY STARTING FROM `W`
AT BREAK OF CITY
SKIP 2
END-BREAK
DISPLAY NOTITLE CITY (IS=ON) COUNTRY (IS=ON) NAME
END-READ
RCI
Page 99 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
100
---------------------------------------------------------------------------------------------------------------------------------
SORT
Syntax
END-ALL
[AND]
SORT
RECORDS
THEM
USING
[BY]
Field
ASC[ENDING]
DESC[ENDING]
..10
Field
KEY[S]
Example 1:
RCI
Page 100 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
101
---------------------------------------------------------------------------------------------------------------------------------
102
---------------------------------------------------------------------------------------------------------------------------------
SORT BY YEAR
USING MAKE COLOR REG_NUM
DISPLAY MAKE COLOR YEAR REG_NUM
END-SORT
END
Example 3 :
DEFINE DATA
LOCAL USING XXEMPLDA
END-DEFINE
*
FIND EMPLOYEE WITH CITY = BOSTON AND COUNTRY = MA
END-ALL
SORT BY JOB_TITLE LEAVE_TAKEN NAME
USING KEYS
* INTERMEDIATE SORT RECORDS WILL HAVE JOB_TITLE LEAVE_TAKEN,
* NAME
DISPLAY JOB_TITLE LEAVE_TAKEN NAME
AT BREAK OF JOB_TITLE
WRITE T*NAME COUNT(JOB_TITLE) //
END-BREAK
END-SORT
END
Notes
1 #SALARY (P9/1:6)
END-DEFINE
END-ALL
SORT JOB_TITLE #AVER-SALARY
USING NAME #SALARY(*)
Or
SORT JOB_TITLE #AVER-SALARY
USING NAME #SALARY(1) #SALARY(2) #SALARY(3)
#SALARY(4) #SALARY(5) #SALARY(6)
But not
RCI
Page 102 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
103
---------------------------------------------------------------------------------------------------------------------------------
use
AT START [OF DATA] following the SORTUSING.
STOP
Syntax :
STOP
STOP involves in termination of the program under execution immediately and return to
command input
prompt.
STOP in subroutine invokes end-page condition specified in main program for final endpage processing (regardless of position of STOP in subroutine.)
Example:
IF #RSP = `F`
STACK TOP COMMAND `LIST VIEW *`
STOP
END-IF
STORE
Syntax :
(*) VALUES (VIEW view-name )
STORE table-name
[(column-list)]
VALUES
Select-expression
RCI
Page 103 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
104
---------------------------------------------------------------------------------------------------------------------------------
Example :
* ADD THE RECORD
*
STORE RECORD IN EMPLOYEES
WITH PERSONNEL-ID = #PERSONNEL-ID
NAME
= #NAME
FIRST-NAME = #FIRST-NAME
MAR-STAT = #MAR-STAT
BIRTH
= #BIRTH
CITY
= #CITY
END OF TRANSACTION
WRITE NOTITLE `RECORD HAS BEEN ADDED`
SUBTRACT
Syntax
constant
column name
SUBTRACT [ROUNDED]
variable
array
group
system-variable
FROM
constant
column name
variable
array
GIVING
constant
column name
variable
array
Function
The SUBTRACT statement is used to subtract the values of two or more
operands.
RCI
Page 104 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
105
---------------------------------------------------------------------------------------------------------------------------------
Operands
As for the formats of the operands. If a database field is used as the
result field, the SUBTRACT operation only results in an update to the
internal value that is used within the program. The value for the field in
the database remains unchanged.
Result Field
Result is stored in second operand (FROM)
If the second operand is a constant,GIVING must be specified.
GIVING stores result of arithmetic operation into target variable.If
numeric constant is used for second operand ,following FROM,GIVING
is required.
ROUNDED
If you specify the keyword ROUNDED, the result will be rounded to be
precision of result variable.
Example :
DEFINE DATA
.
RCI
Page 105 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
106
---------------------------------------------------------------------------------------------------------------------------------
END-DEFINE
SELECT .. WHERE .
SUSPEND IDENTICAL SUPPRESS
DISPLAY (IS=T) /* SOME FIELDS
END-SELECT
END
OUTPUT:
NAME
---------ADKINSON
AUTO
---------ALPHINE A=3000
CHRYLSPHER EMPERIAL
ADKINSON
PETERSON
HJHJHKJH S=4000
HJDHJDFHJFHLLLK
TERMINATE
Syntax:
TERMINATE operand1 operand2
The TERMINATE statement is used to terminate a NATURAL session. A TERMINATE
statement may be placed anywhere within a NATURAL program. When a TERMINATE
statement is executed, no end-of-page or end-loop processing will be performed.
Operand1 may be used to pass a return code to the program receiving control when
NATURAL
terminates. For example, a return code setting may be passed to the operating system
(under UNIX, via argc,argv; on workstations, via the operating-system function
ERRORLEVEL; on mainframe computers, via register 15). The value supplied for
operand1 must be in the range 0 255.
Operand2 may be used to pass additional information to the program, which receives
control after the termination.
Program Receiving Control after Termination
After the termination of the NATURAL session, the program whose name is specified
with the profile parameter PROGRAM will receive control. Under Open VMS and
RCI
Page 106 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
107
---------------------------------------------------------------------------------------------------------------------------------
UNIX, NATURAL passes the three following parameters (if specified) to that program:
operand1, operand2 and the value of the profile parameter PRGPAR .Under Open VMS,
if the PROGRAM parameter is not set, the Open VMS DCL will receive control after the
termination, and operand1 (if specified) will be passed to the DCL. Under UNIX, if the
PROGRAM parameter is not set, the UNIX command shell will receive control after the
termination, and operand1 (if specified) will be passed to the command shell.
Example
/* EXAMPLE TEREX1: TERMINATE
/*******************************************
DEFINE DATA LOCAL
1 EMPLOYVIEW VIEW OF EMPLOYEES
2 PERSONNELID
2 NAME
2 SALARY (1)
1 #PNUM (A8)
1 #PASS (A8)
ENDDEFINE
/*******************************************
INPUT ENTER PASSWORD: #PASS
IF #PASS NE USERPASS
TERMINATE
ENDIF
/*******************************************
INPUT ENTER PERSONNEL NUMBER: #PNUM
FIND EMPLOYVIEW WITH PERSONNELID = #PNUM
DISPLAY NAME SALARY (1)
ENDFIND
/*******************************************
END
UPDATE
Syntax :
UPDATE view-name
Scalarexpression
NULL
RCI
Page 107 of 144
10/7/2016
--------------------------------------------------------------------------------------------------------------------------------Column name =
108
---------------------------------------------------------------------------------------------------------------------------------
WINDOWS
RCI
Page 108 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
109
---------------------------------------------------------------------------------------------------------------------------------
DEFINE WINDOW
Syntax:
DEFINE WINDOW window-name
SIZE
AUTO
QUARTER
Constant
variable
BASE
Constant
variable
CURSOR
TOP
BOTTOM
Constant
variable
TOP
BOTTOM
/
Constant
variable
[REVERSED [(CD=)]
[TITLE
Constant
variable
[CONTROL
WINDO
W
SCREEN
FRAMED
The DEFINE WINDOW statement is used to specify the size, position and attributes of a
window.
Multiple DEFINE WINDOW statements may be defined,activated by:
A SET WINDOW statement,Using INPUT WINDOW = window-name.
A window is that segment of a logical page, built by a program, which is displayed on the
terminal screen. There is always a window present, although you may not be aware of its
existence: unless specified differently, the size of the window is identical to the physical
size of your terminal screen. DEFINE WINDOW statement does not activate a window;
this is done with a SET WINDOW statement or with the WINDOW clause of an INPUT
RCI
Page 109 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
110
---------------------------------------------------------------------------------------------------------------------------------
RCI
Page 110 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
111
---------------------------------------------------------------------------------------------------------------------------------
REVERSED
REVERSED will cause the window to be displayed in reverse video (if the screen used
supports this feature; if it does not, REVERSED will be ignored).
REVERSED (CD=background-color)
This will cause the window to be displayed in reverse video and the
background of the window in the specified color (if the screen used
supports these features; if it does not, the respective specification will
be ignored).
TITLE, you may specify a heading for the window. It is valid with FRAME option.The
title is centered on top line of window.The title is truncated if it is wider than frame
defined.
CONTROL
With the CONTROL clause, you determine whether the PF-key lines, the message line
and the statistics line are displayed in the window or on the full physical screen.
CONTROL WINDOW causes the lines to be displayed inside the window.
CONTROL SCREEN causes the lines to be displayed on the full physical screen
outside the window. If you omit the CONTROL clause, CONTROL WINDOW
applies by default.
FRAMED
By default, i.e. if you omit the FRAMED clause, the window is framed. If you specify
FRAMED OFF, the framing and everything attached to the frame (window title and
position information) will be switched off. The top and bottom frame lines are cursorsensitive. FRAMED controls several display options.DEFAULT frame characters are a
plus sign in each corner , vertical bars on the left and right , dashes across the top and
bottom. %F = TERMINAL command changes the frame characters.
FRAMED (CD=frame-color)
This causes the frame of the window to be displayed in the specified color (if the screen
used is a color screen; if it is not, the color specification will be ignored).
DEFINE WINDOW WIND1
SIZE QUARTER
BASE TOP RIGHT
FRAMED ON POSITION SYMBOL AUTO
*
RCI
Page 111 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
112
---------------------------------------------------------------------------------------------------------------------------------
SET WINDOW
Syntax
SET WINDOW
window-name
OFF
Function
The SET WINDOW statement is used to activate and de-activate a window.
With SET WINDOW window-name, you activate the specified window, which means
that all
subsequent statements refer to that window until either the window is de-activated or
another
window is activated. The specified window must have been defined with a DEFINE
WINDOW statement.
With SET WINDOW OFF, you de-activate the currently active window.
Any SET WINDOW window-name or INPUT WINDOW=window-name statement
de-activates the window which has currently been active and activates the window
specified in
the statement. This means that only one window can be actived at a time.
Note: If you use SET WINDOW to activate a window which is defined with SIZE AUTO,
the data on the screen before the window is activated determine the size of the window.
WRITE TITLE
Syntax:
WRITE (rep) TITLE LEFT JUSTIFIED UNDERLINED
(statement-parameters)
nX
'text'(attributes) operand1 (parameters) ...
nT
'c'(n)(attributes)
x/y
'='
/
SKIP operand2 LINES
RCI
Page 112 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
113
---------------------------------------------------------------------------------------------------------------------------------
The WRITE TITLE statement is used to override the default page title with a page title of
your own. It is executed whenever a new page is initiated.This statement is nonprocedural (that is, its execution depends on an event, not on where in a program it is
located). There are some restrictions regarding WRITE TITLE.
WRITE TITLE may be specified only once per report.
WRITE TITLE cannot be specified within a special condition statement block.
WRITE TITLE cannot be specified within a subroutine.
If multiple reports are to be produced, the notation (rep) may be used to specify the
identification of the report for which the WRITE TITLE statement is applicable. A value
in the range 0 31 or a logical name which has been assigned using the DEFINE
PRINTER statement may be specified. If (rep) is not specified, the WRITE TITLE
statement applies to the first report (report 0).
By default, page titles are centered and not underlined. LEFT JUSTIFIED and/or
UNDERLINED may be specified to override these defaults. If UNDERLINED is
specified, the underlining character (system default or specified with the UC parameter in
a FORMAT statement) is printed underneath the title and runs the width of the line size
(LS parameter). NATURAL first applies all spacing or tab specifications and creates the
line before centering the whole line. For example, a notation of 10T as the first element
would cause the centered header to be positioned five positions to the right.
Example:
WRITE TITLE LEFT JUSTIFIED UNDERLINED
*TIME 3X `PEOPLE LIVING IN NEW YOUR CITY`
11X `PAGE:` *PAGE-NUMBER
SKIP 1
WRITE TRAILER
Syntax:
WRITE (rep) TRAILER LEFT JUSTIFIED UNDERLINED
(statement-parameters)
nX
'text'(attributes) operand1 (parameter) ...
nT
'c'(n)(attributes
x/y
'='
/
SKIP operand2 LINES
RCI
Page 113 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
114
---------------------------------------------------------------------------------------------------------------------------------
When WRITE TRAILER is coded in a NATURAL program, the condition only becomes
true after the PS (Page Size) parameter has been met.
Make sure that there is enough room on the page for your WRITE TRAILER
statement.
Subtract titles, AT TOP statements, headers, data and any AT END OF DATA
statements from PS parameter to determine number of lines available to
WRITE TITLE.
Adjust PS accordingly.
WRITE TITLE LEFT JUSTIFIED UNDERLINED
*TIME 3X `PEOPLE LIVINE IN BARCELONA`
14X `PAGE:` *PAGE-NUMBER
SKIP 1
/***************
WRITE TRAILER LEFT JUSTIFIED UNDERLINED
/ `CITY OF BARCELONA REGISTER`
COLUMN name
Constant
Group
Array
FILLER nX
....
Writes to one of 20 sequential output files indicated by output file number (n)
Uses DD statement:
// CMWKFnn DD DSN= . . . .
VARIABLE creates variable length output records. Is used with multiple WRITE
WORK to same (n).
Work file written in a program can be read in the same NATURAL object as long as
READ and WRITE are performed in different processing loops.
RCI
Page 114 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------
115
---------------------------------------------------------------------------------------------------------------------------------
Example :
READ EMPLOYEE WHERE JOB_TITLE = SCAN MANAGER
WRITE WORK FILE 1 PERSONNEL_ID
NAME
JOB_TITLE_DEPT
END-READ
RCI
Page 115 of 144
10/7/2016
---------------------------------------------------------------------------------------------------------------------------------