Академический Документы
Профессиональный Документы
Культура Документы
Vinay.S
Agenda
Natural Overview PART 1 - ESSENTIAL CONCEPTS PART 2 - ESSENTIAL SYNTAX PART 3 - ESSENTIAL TOOLS
Page 1
Natural Overview
PART 1 - ESSENTIAL CONCEPTS Programs and subprograms Subroutines - in-line subroutines & external subroutines Copycode Data definitions Local data Local Data Areas (LDAs) Parameter data Parameter Data Areas (PDAs) Global data Global Data Areas (GDAs) Maps PF keys Help routines Libraries
Page 2
Natural Overview
PART 2 - ESSENTIAL SYNTAX Structure of executable modules
Data definition
Report - Edit masks , write, display, newpage, at top of page, page number Data manipulation Input and output Flow control Sequential files Exiting a routine or loop System variables
Page 3
Natural Overview
PART 3 - ESSENTIAL TOOLS
NATURAL environment
Page 4
What is NATURAL?
NATURAL is a programming language developed and marketed
by Software AG.
NATURAL supports Rapid Application Development to RDBMS
environments with applications that are portable, scaleable and interoperable across multiple computing platforms.
Applications developed using NATURAL are modular, which
contributes to its success as a tool for Rapid Application Development. In general, each module is created, maintained and stored independently of any others.
Page 5
Data definition
DEFINE DATA . END-DEFINE READ Control logic
IF
PERFORM subroutine_1 END-IF END-READ DEFINE subroutine_1. ** Comments END-SUBROUTINE
Page 6
Page 7
Subroutines Subroutines are used to code discreet sub-functions to simplify logic and improve the readability and maintainability of the code. There are 2 types of subroutines: in-line subroutines external subroutines In-line subroutines A program or subprogram will typically contain one or more in-line subroutines. External subroutines An external subroutine is the same as an in-line subroutine, except that it exists independently (in a module of type subroutine) and can be called from any other module.
Page 8
.
END-DEFINE
READ Control logic IF PERFORM POPULATE-AUDIT-FIELDS. END-IF END-READ DEFINE SUBROUTINE POPULATE-AUDIT-FIELDS
...
END-SUBROUTINE END END statement
Page 9
Copycode Copycode modules contain lines of source code that can be invoked at compilation time into programs, subprograms or external subroutines by means of an in-line INCLUDE statement.
Page 10
Copycode example
INCLUDE IVAUDTC1 UPDATE-VIEW ** COPYCODE IVAUDTC1 ************************************** BEGIN &1&.AUDIT-TIME := *TIMX &1&.AUDIT-PROGRAM := *PROGRAM &1&.AUDIT-USER := *USER ADD 1 TO &1&.AUDIT-COUNTER ** COPYCODE IVAUDTC1 **************************************** END ** COPYCODE IVAUDTC1 ************************************** BEGIN UPDATE-VIEW.AUDIT-TIME := *TIMX UPDATE-VIEW.AUDIT-PROGRAM := *PROGRAM UPDATE-VIEW.AUDIT-USER := *USER ADD 1 TO UPDATE-VIEW.AUDIT-COUNTER ** COPYCODE IVAUDTC1 **************************************** END *
Page 11
Defining data
In NATURAL there are 2 ways to define data: in-line data definitions data definition modules There are 3 types of data definition modules: local data areas (LDAs)
Page 12
DEFINE DATA Record structures LOCAL 1 CLNT-REC /* CLIENT RECORD 2 CLIENT-ID (N8) 2 LAST-NAME (A20) 2 FIRST-NAME (A20) 2 MIDDLE-INITIAL (A1) END-DEFINE
Page 13
DEFINE DATA LOCAL . 1 #DAYS (P3) INIT<60> 1 #MESSAGE (A50) INIT<WE APPRECIATE YOUR BUSINESS> 1 #FOLLOW-UP (L) INIT<TRUE> . END-DEFINE
Page 14
DEFINE DATA LOCAL . 1 #DAYS (P3) CONST<60> 1 #MESSAGE (A50) CONST<WE APPRECIATE YOUR BUSINESS> 1 #SUPPRESS-FOLLOW-UP (L) CONST<TRUE> . END-DEFINE
Page 15
DEFINE DATA LOCAL 1 CLNT-REC /* CLIENT RECORD 2 CLIENT-ID (N8) 2 LAST-NAME (A20) 2 FIRST-NAME (A20) 2 MIDDLE-INITIAL (A1) . END-DEFINE
** PROGRAM EXAMPLE DEFINE DATA LOCAL USING CLNT-PDA /* PDA FOR SUBPROGRAM CLIENT . END-DEFINE CALLNAT CLIENT CLNT-PDA END /* EXAMPLE
Page 16
Data definition modules LDA DEFINE DATA . LOCAL USING CLNT-PDA /* PDA FOR SUBPROGRAM CLIENT LOCAL 1 #SUBTOTAL (P7.2) . END-DEFINE
Page 17
Data definition using a PDA Any data required by a subprogram must be passed as a parameter. DEFINE DATA PARAMETER USING CLNT-PDA /* PDA FOR SUBPROGRAM CLIENT LOCAL 1 #INDEX (P3) END-DEFINE
Page 18
Data definition using a GDA DEFINE DATA GLOBAL USING INVDATA /* GDA FOR INVOICING APPLICATION LOCAL USING INVREDEF /* LDA REDEFINING INVOICING GDA . END-DEFINE For global data there is nothing equivalent to in-line definition.
Programs and external subroutines (including any in-line subroutines within them) have direct access to global data, whereas subprograms (including any in-line subroutines within them) do not. An application, batch or on-line, can utilize a global data area (GDA) to store common data that is needed throughout the application. Since the data is stored in memory, access is very efficient.
Page 19
Page 21
In on-line applications, INPUT USING MAP is the normal way to display data to the user and to receive input data, using a pre-defined screen layout represented by a map module.
INPUT
Page 22
PF keys
User input via a map is terminated by pressing ENTER or a function
key (also known as a program function key, or PF key for short). These are so called because the function (i.e. purpose) of each key varies depending on the program. Generally they are known as PF1 through PF24 and PA1 through PA3.
PF1 invokes help PF3 terminates PF7 scrolls up PF8 scrolls down
Page 24
VALUE PF7
PERFORM SCROLL-UP VALUE PF8 PERFORM SCROLL-DOWN
VALUE ENTR
PERFORM PROCESS-INPUT NONE END-DECIDE
Page 25
Helproutines A helproutine may take the form of a map module or a special kind of executable module, similar to a subprogram. Helproutines are used only in on-line applications and are only executed if invoked by the user. Invocation occurs when the user enters a help character (? by default) into the first character position of a map field or presses the help key (PF1 by convention).
Page 26
Libraries
NATURAL modules are arranged in libraries. Any
number of libraries can exist and generally each application will have its own library.
Page 27
SUMMARY
Page 28
Page 29
Data manipulation
Page 30
Flow control
IF IF #CORP-NBR = 1 ... END-IF DECIDE ON DECIDE ON FIRST VALUE OF #CORP-NBR VALUE 1 #CORP-NAME := Northern Enterprises VALUE 2 NONE IGNORE END-DECIDE
Page 31
END-SUBROUTINE /* CALC-AMOUNTS-DUE
Page 32
IVINSTA1.TOTAL-PRICE := RECEIVABLE.TOTAL-PRICE
IVINSTA1.NBR-INSTALLMENTS := RECEIVABLE.C*BILL-DATE CALLNAT 'IVINSTN1' IVINSTA1
Page 33
Page 35
#DOLLARS(#DEPT-NBR) (EM=Z,ZZZ,ZZ9.99)
Page 36
At top of page AT TOP OF PAGE (0) WRITE (0) 57X Processing Report END-TOPPAGE
Page number AT TOP OF PAGE (0) WRITE (0) 57X Processing Report 23X Page *PAGE-NUMBER(0) END-TOPPAGE
Page 37
.
END-WORK
Page 38
2 PRODUCT-ID
2 QUANTITY 2 TOTAL-PRICE END-DEFINE.
Page 39
RESET INVOICE MOVE BY NAME RECEIVABLE TO INVOICE WRITE WORK FILE 1 INVOICE
END-READ
Page 40
Page 41
Page 42
Page 43
Page 44
Page 45
Page 46
Page 47
Page 48
//
// //
SPACE=(CYL,(5,2),RLSE),
DISP=(NEW,CATLG,DELETE), UNIT=SYSDA
//CMSYNIN DD *
VORD0669
Page 49
FIN /*
Version control
PAC (PREDICT APPLICATION CONTROL) For version control.
Page 50
Page 51
Imagination
Action
Joy