Natural Programming Essentials
Natural Programming Essentials
Natural Programming
Essentials
E307-7BE
© 2022 Software AG. All rights reserved.
Copyright
Software AG and all Software AG products are either trademarks or registered trademarks of Software AG. Other product or
company names mentioned herein may be the trademarks of their respective owners.
5 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
6 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Natural - A Procedural
Language
7 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Procedural vs. OOP
8 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Natural Object Types with
Naming Conventions
9 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Natural ´Folder´ Structure
10 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Programming Objects
▪ Modules
▪ Program
▪ Subprogram
▪ Subroutine
▪ Function
▪ CopyCode
▪ Helproutine
▪ Text
11 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Programming Objects
▪ Data areas
▪ Local data area
▪ Parameter data area
▪ Global data area
▪ Database access
▪ DDM
▪ Others
▪ Map, Helproutine,
▪ Error Message Text,
▪ Resource, Adapter, …
12 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Naming Conventions
▪ Object Name
▪ First character
− Upper-case alphanumeric
− A number or plus sign (#,+)
▪ Can include special characters
▪ 1-8 characters
▪ Library
▪ 1-8 characters
▪ Must not start with ´SYS´
13 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Basic Structure of Modules
14 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Basic structure of a module
Variables
James 2015-05-01
Application System
Meier
defined defined
1991-05-01
24
Statements ..
15 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Two Programming Modes
▪ Structured Mode
▪ All variables are defined on top
▪ Reporting Mode
▪ Variable definition is within program logic
16 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Syntax
17 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Syntax used in this Course
| Separates alternatives
18 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
02
19 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
20 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Define Data Types
21 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Field Definition and DEFINE Statement
22 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Local Data Definition
Naming conventions
Elementary field
Format, length
Group
23 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Simple Data Definitions
24 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
DEFINE DATA
25 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Initialization of Variables
26 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Implicit Default Value
Unless initialized explicitly, each variable has an implicit, format-specific default value
Type Value
A or U <blank>
N 0.0
I 0
F/P 0.0
Use RESET D 0000-01-01
statement to reset
T [Link]
to implicit value
L <false>
27 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Variable definition with CONST and INIT
CONST
28 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example for Explicit Initial Value Assignment with INIT
Use
RESET INITIAL
to reset
29 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
INPUT, WRITE and MOVE
30 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
INPUT and WRITE Statement
INPUT operand1
31 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
INPUT and WRITE Statement
32 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
MOVE Statement
Assignment by :=
33 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
MOVE Statement
34 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
WRITE and INPUT
35 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Edit Masks
36 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Edit Masks – Example for Numeric Variables
Statements like
- INPUT
- WRITE
- MOVE EDITED
37 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Supported Formats and Some Mask Definitions
Alphanumeric Binary
Numeric Time and Date
and unicode (Hexadecimal)
9 - position X – character
to be to be
displayed displayed
Period –
decimal
separator
38 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Date, Time and System
Variables
39 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Format D – Date and T- Time
40 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
System Variables
Value is provided
by Natural
System variables
are predefined Start with ´*´
variables
Can be used at
Example: *DATX
any time
41 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
System Variables – Extract from Documentation
42 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
System Variables
43 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Arithmetic Statements
44 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
ADD Statement to Add One or More Operands
operand2 := operand1 + ..
45 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
ADD example
46 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
SUBTRACT Statement to Subtract Two or More Operands
47 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example SUBTRACT
48 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
MULTIPLY Statement
49 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example MULTIPLY
50 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DIVIDE Statement
51 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example DIVIDE
52 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
COMPUTE Statement for Arithmetic Operation
53 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example COMPUTE
54 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
Exercise Environment
55 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Preparation and First Natural Program
56 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
First Natural Program with variables
57 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
03
Conditional Processing
58 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
▪ DECIDE Statement
59 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
IF … THEN … ELSE
Statement
60 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
How does it work ?
false
IF
true
ELSE code
THEN code
After IF
61 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
IF Statement
Control processing based on a logical condition
IF logical-condition Control the number of times the loop is
processed based on a condition
• UNTIL
THEN clause
THEN statement …
until
logical a logicaliscondition
condition true becomes true
WHILE
• must include at least 1 statement
[ ELSE statement …] •as long as the logical
i.e., IGNORE condition is true
statement
ELSE clause
END-IF • Position of UNTIL or WHILE
logical condition is false
• at the beginning
optional
• at the end
IF statements can be nested
62 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example IF… THEN … ELSE
63 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Comparison Operators
THRU
THRU … BUT NOT … THRU ..
64 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example Comparison operators
65 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Relational Expressions
Logical operators
Bracketing ´(´
NOT
AND
OR
Simplified syntax
A = B OR = C
A = B OR = D THRU E
SCAN and MASK
Arithmetic expressions
IF var1 + 3 GT var2 - 5
66 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Relational Expressions
67 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Checking and Conversion of Data
Logical condition criteria
MASK upon
IS option
Notes
If the input value for the VAL function cannot be extracted to
a number a runtime error will occur.
68 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DECIDE statement
69 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
How does it work ?
Decide
70 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DECIDE ON Statement
Conditional processing based on the content of a variable
DECIDE ON FIRST | EVERY [VALUE] [OF] operand1
EVERY check all VALUE clauses
VALUE operand2 statement ….. FIRST stop after the first true VALUE clause
VALUE clause
[ ANY statement …]
• check operand1 EQ operand2
[ ALL statement …]
multiple values
71 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example DECIDE ON
72 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DECIDE FOR Statement
Conditional processing based on a logical condition
DECIDE FOR FIRST | EVERY [CONDITION]
73 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example DECIDE FOR
74 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
DECIDE Statement
75 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Loops and Conditions – DECIDE
Statement
76 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Loops and Conditions – DECIDE
Statement Alternative
77 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
04
Loop Processing
78 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
▪ Statement Reference
▪ Label Definition
▪ ESCAPE Statement
79 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Loop Processing – FOR
Statement
80 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
How does it work?
No Yes
Exit loop Decide Perform task
81 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
FOR Statement
FOR operand1 [:]= | EQ | FROM operand2 The number of times the loop is processed is based on the
Control the number of times the loop is
value of operand1
processed based on a condition
TO | THRU operand3 [ STEP operand4 operand2, operand3 or operand4 can be any
• UNTIL
arithmetic expression
]
Processinguntil a logical condition becomes
steps
statement … true
Initialize operand1 := operand2
• WHILE
END-FOR Check IF operand1 GT (LT*) operand3
as long as the logical condition is
IF truetrue
terminate the loop
‘Check operand1 GT operand3’ Execute the statements
IF operand4 is negative: check LT IF not true operand1 := operand1 +
• Position of UNTIL or WHILE
operand4
• at the beginning
Restart loop with check
• at the end
* IF operand4 (STEP value) is negative the
check is LT
82 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example FOR
83 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
FOR Statement
84 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Loops and Conditions – FOR Statement
85 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
[Link]
REPEAT UNTIL/WHILE
LOOP
86 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
REPEAT Statement
REPEAT [UNTIL | WHILE logical -condition] Control the number of times the loop is processed based on a
condition
UNTIL a logical condition gets
statement … true UNTIL
87 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example REPEAT
88 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
[Link]
Statement Reference
89 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Statement Reference / Label
90 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example of label Definition
91 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
[Link]
ESCAPE Statement
92 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
ESCAPE Statement
93 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
ESCAPE Statement Example
94 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
REPEAT Statement With ESCAPE
95 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Loops and Conditions – REPEAT
Statement
96 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
05
INPUT-OUTPUT-Maps
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Non-Graphical User
Interface
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
A Typical Screen Output
Message
Line
Output Field
Customer ID: 950001
Lastname: Hunt
Pagesize
Firstname: James
Birthday: 1991-06-30
Linesize
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
INPUT Statement
INPUT [WINDOW='window-name‘]
[ NO ERASE ] Support of window concept
[ (statement-parameters) ]
[ WITH-TEXT-option ] [ MARK-option ] Parameters /attributes
Formatting
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example INPUT
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Parameters - Field Attribute Definitions
(AD=xyz)
Others, i.e.
Presentation (CD=xyz)
B - blinking (AL=n)
C - italic (IP=)
D - default intensity
I - intensified
N - non-display
U - underlined
V - reverse video
Y - dynamic
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Parameters - Field Attribute Definitions (AD=xyz)
Input/Output
A – input (or *IN)
O – output (or *OUT)
M – input/output (or *OUTIN)
P – temporarily write-protected
Other examples
T – translate lower case to upper case
W – accept lower case (default, related to LC)
E – value mandatory
F – value optional
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example Attribute Definition
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
Input Statement with Field Attribute
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
REINPUT and
SET CONTROL Statement
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
SET CONTROL Statement
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example SET CONTROL – Message on Top
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example SET CONTROL – Message on Bottom
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FORMAT Statement
FORMAT parameter
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
REINPUT Statement
REINPUT [ FULL ]
Re-position to previous INPUT
[ [WITH] [TEXT] operand1 ]
Re-execute previous INPUT
[ MARK-option ]
No Write or Display allowed
between INPUT and REINPUT
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example REINPUT
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
REINPUT
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Dynamic Field Attributes
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
CONTROL Variables for Dynamic Field Attributes
Definition
Assignment
Usage
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Dynamically Modifiable Attributes
Presentation
B - blinking
C - italic
D - default intensity
I - intensified
N - non-display
U - underlined
V - reverse video
Input/Output
P – temporarily write-protected
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Checking Changes with MODIFIED Option
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
Dynamic Field Attributes
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
WRITE and PRINT Statement
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
WRITE Statement
operand1 (parameter) ….
Editmask
(EM=xyz)
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example WRITE
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
PRINT Statement
PRINT [ NOHDR ]
[ (statement-parameters)
operand1 (parameter)
Difference to WRITE:
▪ Output length is value content
▪ Continued on next line
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
PRINT Statement
PRINT [ NOHDR ]
[ (statement-parameters)
operand1 (parameter)
Difference to WRITE:
▪ Output length is value content
▪ Continued on next line
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example PRINT
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Natural Maps Overview
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
The MAP object
DEFINE DATA …
*
INPUT USING MAP 'ABCMAP'
DECIDE ON …
PERFORM ….
CALLNAT …
END
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example of a MAP
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Processing Rules For a MAP
A processing rule
Defined in a map
Executed before the processing is passed back to the calling object
Related to Processing order is
determined by
Map
▪ rank and
Field ▪ position of the field
▪ In a rule ‘&’ represents the actual field for which the rule is defined
Function key
Multiple rules are possible
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Help Routines For a MAP
In the inverted list is stored: the value, the number of values and a list of ISNs
The Address Converter (AC) is a table which maps the ISN to a RABN
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
INPUT USING MAP
Statement
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
INPUT USING MAP Statement
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example Map and INPUT USING MAP
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example MAP and INPUT USING MAP
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
SET KEY Statement
ALL
For all keys: ALL, ON, OFF
SET KEY ON
Individual keys
OFF
Operand2
program
ON
Customer specific
SET KEY PFn = OFF NAMED op4}
command
op2
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
EXAMPLE Function Keys
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Formatted Screen Output
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
WRITE USING Statement
NAME
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example WRITE USING FORM
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
AT TOP OF PAGE Statement
statement …
END-TOPPAGE
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example AT TOP OF PAGE
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
AT END OF PAGE Statement
statement …
END-ENDPAGE
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example AT END OF PAGE
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Screen I/O –
INPUT and REINPUT statement
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Screen I/O – INPUT and REINPUT
statement with Control Variable
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
06
147 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
148 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DEFINE & CLOSE
149 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DEFINE WORK FILE STATEMENT
DEFINE WORK FILE
DEFINE WORK FILE n
Assign a file name to work file number
n– ident number
Open the file
1-32 If already open: implicitly close
and reopen
{operand1 | TYPE operand2 }
“n” - number of the work file (1-32)
filename ASCII, SAG, CSV
Operand1 - file name
[ATTRIBUTES {operand3}…]
TYPE: ASCII, SAG, CSV, others
150 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
[NO]APPEND ATTRIBUTES
DELETE/KEEP No APPEND
DELETE/KEEP
152 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ WORK FILE STATEMENT
Read data sequentially from a
sequential work file with automatic loop
processing
READ WORK [FILE] work-file-number Work file number
[ONCE] Same number as in DEFINE WORK
Read only one record
NO END-WORK Operand1
Target field(s) or group
[ RECORD] operand1 Giving LENGTH
[GIVING LENGTH operand3] Length of record
Number of fields(TYPE CSV)
153 statement …
© 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
END-WORK ONCE
Read only one record
No END-WORK allowed
Example READ WORK FILE
154 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
WRITE WORK FILE
155 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
WRITE WORK FILE STATEMENT
VARIABLE
Enables writing of record
Having different structures
Example READ & WRITE WORK FILE
157 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
READ/WRITE
158 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
07
String Processing
159 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
▪ SUBSTRING Function
▪ SEPARATE Statement
▪ COMPRESS Statement
▪ EXAMINE Statement
160 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
SUBSTRING() Function
161 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
SUBSTRING() option used in statements
MOVE
MOVE, COMPRESS, COMPUTE
COMPRESS
Optional in a relational expression etc.
COMPUTE
Value format
In relation expression… Alphanumeric
Binary
162 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example SUBSTRING() Option
163 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
SUBSTRING() Function
164 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
SEPARATE Statement
165 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
SEPARATE Statement
SEPARATE operand1
INTO operand2…
IGNORE
REMAINDER operand3
DELIMITERS operand4
166 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example SEPARATE
167 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
SEPARATE statement
168 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
COMPRESS Statement
169 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
COMPRESS statement
INTO operand2
LEAVING [SPACE]
LEAVING NO [SPACE]
170 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example COMPRESS
171 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
COMPRESS statement
172 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
EXAMINE Statement
173 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
EXAMINE Statement
EXAMINE
[FOR] operand2
DELETE-REPLACE-clause
GIVING-clause
DELETE-REPLACE-clause GIVING-clause
174 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
EXAMINE TRANSLATE Statement
EXAMINE operand1
[AND] TRANSLATE
LOWER
175 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
EXAMINE statement
176 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
String Processing
177 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
08
Modularization Part-I
178 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
▪ Why Modularization
▪ Local Data Area
▪ User Defined Function
▪ Natural System Functions
▪ Subprogram
▪ CALLNAT Parameter Transfer
▪ Parameter Data Area
179 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Why Modularization
180 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Why Modularization
181 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Local Data Area - LDA
182 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Object Type : Local Data Area
Reuse of local
data definitions
DEFINE DATA
Program
LOCAL
Referenceable in
Subprogram
various objects
Referenced with
Function etc.
USING Statement
183 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Local Data Area
END-DEFINE
….
READ YACHT-DATA BY YACHT- DEFINE DATA
TYPE LOCAL USING VIEWLDA
FROM START-VALUE TO END-
VALUE LOCAL
DISPLAY YACHT-NAME YACHT- 01 START-VALUE (A30)
TYPE 01 END-VALUE (A30)
END-READ END-DEFINE
/*
READ YACHT-DATA B
184 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
User Defined Function
185 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Function
[ return-data-definition ]
186 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example- Calling & Callee Function
Caller
5000 5.00
Callee
NCFUNC07
5250
187 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
System Function
188 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Subprogram
189 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Subprogram Concept
webMethods
Java .NET
IS
EntireX Integration
Natural
190 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Natural Subprogram
191 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
CALLNAT Statement
CALLNAT operand1
Subprogram to be invoked
[USING]
operand2
nX
192 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Parameter Definition
External
Functions Subprograms
subroutines
193 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example-CALLNAT and Subprogram
Calling
PROGRAM
Called
SUBPRO
GRAM
194 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
CALLNAT Parameter
Transfer
195 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
CALLNAT Parameter Transfer by “Reference”
Caller Subprogram
DEFINE DATA PARAMETER
DEFINE DATA LOCAL *
* 01 P-PERSON-ID (A10)
01 #PERSONNEL-ID (A10) *
* 01 P-PERSON
01 #PERSON 02 LASTNAME (A50)
02 LASTNAME (A50) 02 FIRSTNAME (A50)
02 FIRSTNAME (A50) 02 BIRTHDAY (D)
02 BDAY (D) 02 SEX (A10)
02 SEX (A10) *
* LOCAL
… *
by
END-DEFINE …
* reference END-DEFINE
… *
CALLNAT ‘GETPERSN‘ MOVE ‘Smith’ TO LASTNAME
USING #PERSONNEL-ID …
#PERSON
196 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
CALLNAT Parameter Transfer by “Value”
Caller Subprogram
DEFINE DATA LOCAL DEFINE DATA PARAMETER
* *
01 #OPERATOR (A1) 01 P-OPERATOR (A5) BY VALUE
01 #OPERAND1 (I2) 01 P-OPERAND1 (I4) BY VALUE
01 #OPERAND2 (I2) 01 P-OPERAND2 (I4) BY VALUE
01 #RESULT (I4) 01 P-RESULT (I4) BY VALUE RESULT
* *
END-DEFINE END-DEFINE
* *
… P-RESULT := P-OPERAND1 + P-OPERAND2
CALLNAT ‘CALC‘ …
USING #OPERATOR
#OPERAND1 by value
#OPERAND2
#RESULT
…
197 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
CALLNAT Parameter Optional
Caller Subprogram
198 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Parameter Data Area
(PDA)
199 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Object Type : Parameter Data Area
Reusable
parameter data
definition
DEFINE DATA
Subprogram
PARAMETER
Referenceable in
Function etc
various objects
Referenced with
Program in LOCAL
USING Statement
area
200 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example- How to use PDA
PDA ‘NCCALL1A’
201 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
09
Modularization Part- II
202 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
▪ Inline Subroutine
▪ External Subroutine Object
▪ Copy Code Object
▪ Global Data Area
▪ Example- FETCH Program
203 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Inline Subroutine
204 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
INLINE SUBROUTINE
Exiting via
• END-SUBROUTINE (mandatory)
• ESCAPE ROUTINE
205 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Inline Subroutine
DEFINE DATA
LOCAL USING VIEWS
LOCAL
1 P-PERSONNEL-ID (N5)
1 P-LASTNAME (A10)
1 ERROR (N3)
1 ERROR-TEXT (A30)
END-DEFINE
*
…
PERFORM ACCESS-EMPLOYEE-DATA
IF ERROR = 0 THEN
P-LASTNAME := [Link]
ELSE
ERROR-TEXT := ‘No employee found’
END-IF
...
DEFINE SUBROUTINE ACCESS-EMPLOYEE-DATA
*
FNDEMPL.
FIND EMPLOYEE
WITH [Link]-ID = P-PERSONNEL-ID
*
IF NO RECORDS FOUND
ERROR := 999
ESCAPE ROUTINE
END-NOREC
…
END-FIND
END-SUBROUTINE
END
206 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
External Subroutine
Object
207 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
External Subroutine Concept
Call via
PERFORM
Parameter Global Data
DEFINE DATA
PARAMETER
*
01 P-PERSONNEL-ID (A10)
01 P-PERSON
02 LASTNAME (A50)
02 FIRSTNAME (A50)
*
LOCAL …..*
END-DEFINE
DEFINE SUBROUTINE READ-PERSON
*…
*
END-SUBROUTINE
END
208 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
External Subroutine
209 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example- PERFORM with an External Subroutine
210 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
CopyCode Object
211 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Copy Code Concept
212 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
INCLUDE Statement
INCLUDE copycode-name
[operand1] … [operand99]
213 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example- INCLUDE COPYCODE
NCCOPY1C
214 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Global Data Area (GDA)
215 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Object Type : Global Data Area
216 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example- How to use GDA GDA LDA
GLOBGDA VIEWLDA
YACHT-ID
YACHT-NAME …
217 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Summary Data Area Overview
Description of the interface, share data definition and storage (by reference, by value)
218 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Call a Program with
FETCH
219 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Program Concept
Call via
FETCH
Natural Stack Global Data
220 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FETCH Statement
221 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example- FETCH and Natural Stack Transfer
DEFINE DATA LOCAL /* program NCFETC1P
01 YACHT
02 YACHT-ID (A8)
02 YACHT-NAME (A10)
END-DEFINE
/*
MOVE '12348765' TO [Link]-ID
Write
/*
FETCH 'NCFETC2P' YACHT
/*
END
NCFETC2P
DEFINE DATA LOCAL
01 YACHT
Natural Stack 02 YACHT-ID (A8)
02 YACHT-NAME (A10)
END-DEFINE
/*
INPUT YACHT
DISPLAY YACHT
Read /*
END
222 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
STACK Statement
223 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
RELEASE Statement
RELEASE STACK
Deletes all data/commands on the stack
*DATA
- # of data elements
- ´-1´ next element is command
224 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example- STACK Program
Write to
stack
NCSTACK2
Read from
stack
225 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
10
226 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
227 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Group and Operation
Statements
228 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Group – Combination of Data Elements
Yacht
Id
Name
Length
Width
Data Elements
- Variable
- Array
- Group
229 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example - Group Definition
Level Number
Group n / Element
n+1
Fully Qualified
Group Name Name
230 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Group operation – MOVE BY NAME
#Bunk #Bunk
Type
231 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example MOVE BY NAME
232 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Group operation – MOVE BY POSITION
MyYacht YourYacht
Name Y-Name
Id Ident
Color Colour
#Bunk Bunks
233 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example MOVE BY POSITION
234 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
Group Statements
235 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
REDEFINE Data Definition
236 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
REDEFINE Data Definition
237 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example - REDEFINE
DATE
238 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example - REDEFINE
239 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Static Arrays
240 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Static Arrays
Array definition
▪ Up to 3 dimensions
▪ Initialization
Can be addressed by
▪ Single cell
▪ Index range
241 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Array Definition
var-name (format&length/array-definition)
array-definition:
index [:index ] [,index [:index] [,index [:index ] ]
242 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Addressing Arrays
243 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Array Definition- Initial values
*
index [:index ] , ..3 FULL LENGTH <character-string, …>
V LENGTH n
244 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Array Definition – Initial values
245 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
1D Array with INIT
246 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Multi-Dimensional Arrays
247 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Multi-Dimensional Array Definition
248 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example – Elementary Field Level
249 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example – Group Field Level
250 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example-Combination Elementary and Group Field Level
251 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Operations on Array
252 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Addressing ARRAYs
MOVE BY NAME
TO Operand2 (index)
Operand1 (index)
253 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example- Addressing ARRAYs
254 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Arithmetic Operations on ARRAYs
Dimensions must
be of equal size
255 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Arithmetic Operations on ARRAYs and Scalars
256 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example Arithmetic Operations on ARRAYs and Scalars
257 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Dynamic Variables
258 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Dynamic Variables and X-Arrays
ABCD
259 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Dynamic Variables
260 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Dynamic Variables
261 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
String Processing with Dynamic Variables
262 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Performance Considerations
263 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Dynamic Arrays
264 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
X-Arrays
265 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
2D on Elementary Field Level
266 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Multi-Dimensional Arrays
267 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Multi-Dimensional Arrays and Arithmetic
Operations
268 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
11
Error Handling
269 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
▪ Error Processing
▪ Logging of Events
270 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Error Processing
271 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Error Processing
DEFINE
…
ON ERROR… For the creation of robust applications, Natural
END-ERROR
offers the following error handling methods:
FETCH * ERROR-TA
RETURN
END Use of an ON-ERROR statement block
…
…
END
272 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Overview Exception Handling
2. Application related
273 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
ON ERROR Statement
Intercepts runtime time errors
274 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Error Processing Statement and Error Program
ON ERROR statement
ON ERROR
statement block can be exited with
statement(s)…
RETRY
END-ERROR ESCAPE ROUTINE
FETCH
STOP
TERMINATE
275 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Error Transaction and Profile Parameter
276 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example of Error Processing in Subprogram
277 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example of Caller‘s Reaction to an Error
278 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Sunny Islands – Handling Errors and Writing Log Files
Adabas
279 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
Sunny Islands – Implementation of Error Handling
ON ERROR statement
Extract from service subprogram Intercept execution time error without
termination of program execution
Natural error codes
Adabas response codes
CopyCode
Log file → see next slide
Application error handling program CAMSG-N
Handle exceptions with
user defined error codes
language specific text messages
CopyCode ERRLOG-I
Parameter data area NCCOMM-P
Pass error data back to frontend
280 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Logging of Events
281 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Sunny Islands – Handling Errors and Writing Log Files
As a service provider I want to have an overview of activities going on in my services and in error cases
detailed information.
Adabas
282 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
Instrumentation of Services
Instrumentation
Event logging for
exception handling to diagnose errors
security events
Application
Application for performance reasons
wM ESB and Service
Service
and
monitoring
monitoring used for debugging
EntireX
283 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Sunny Islands – Implementation of Log Files
Timestamp conversion
Natural Application Programming
Interface program USR1009N is used
284 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Application Programming
Interface (API)
285 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Natural Application Programming Interfaces (API)
286 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Natural Application Programming Interfaces (API)
▪ Texts / USRnnnnT
description for each API
287 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Natural System API - Categories
System Products/Features
Error Profiler
System commands
System files
Database Error Messages Optimize for Infrastructure
288 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
List of APIs for Error Handling
API Purpose
USR0040N Get type of last error
USR1016N Get error level for error in nested copy codes
USR1037N Get information on Natural ABEND data
USR1041N Install error transaction program (*ERROR-TA).
USR2001N Get information on last error
USR2006N Get information from error message collector
USR2007N Get or set data for RPC default server
USR2010N Get error information on last database call
USR2026N Get TECH information
USR2030N Get dynamic error message parts from the last error
289 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
12
Natural DML
Cruises
READ, FIND,…
STORE, UPDATE, …
Cruises
The ‘Sunny Islands’
Sample Application
Booking a cruise for the summer vacation
© Software AG Training
Home of „Sunny Islands“
The OK
and
CANCEL
button
Register as a (new) customer, change your data and logout
All Cruises – display all cruises and book one
Some technical insides
302 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
▪ Adabas Indices
303 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Adabas File Structure
304 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Database Table -> File
ISN Field
File
305 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
ISN – Internal Sequence Number
Assignment automatically
Usable by programmer
Performance reasons
306 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Fields and their definition
Filenumber
Group
307 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Flexible record layout
“ An employee has vacation with a start and an end date. And the
employee speaks several languages”
LEAVE-
BOOKED
LEAVE
LEAVE LEAVE
LEAVE
ISN …… …
… LANG
LANG …
…
START
START END
END
1 20190101
20160101 20190131
2010131 GER
GER …
…
20190701
20160101 20190707
2010131 ENG
ENG
FRE
FRE
Periodic Multiple-value
Group Field
309 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Multiple Value field in Periodic Group
“ A cruise has several sailors and each of them speaks several languages”
310 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Adabas Indices
311 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Inverted list / descriptor in Adabas
Inverted List
312 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Descriptor access via Address Converter
ASSOCIATOR DATA
RABN
313 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Summary index access
314 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Data Definition Module
(DDM) and Views
315 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
View, DDM and FDT
DDM
Natural
VIEW
Adabas
FDT
316 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Data Definition Module (DDM)
Definition of fields
Definition of descriptors
Independent of FDT
Field selection
Field sequence
317 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DDM attributes
1/2
Type - Structure definition:
Empty Elementary field
G Group
P Periodic group
M Multiple-value field
* comment
318 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DDM attributes
2/2
Suppression - type of compression
Empty Standard compression
N Null value suppression
F Fixed length
M SQL null-value
319 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Natural data view – DDM
320 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
NaturalONE: Editor, Outline and Properties View
321 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
DDM access in NaturalONE
322 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
NaturalONE Data Browser
323 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
14
324 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
325 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Design a Service in
Natural
326 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Service application design
Devices
Front-
end
Back-
end
Service
327 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Service characteristics
Encapsulated and
stateless
Structured interface
Independent of
Location (distributed)
Infrastructure
Calling sequence
328 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Defining a service interface
Common structure
Expandable
Specific Part
Object, function specific data,
sub function, …
329 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Defining a service in Natural
RUN
330 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Scenarios using Natural services
wM API Management
wM Integration
EntireX
Natural
CUI, NJX
„CALLNAT Interface“
331 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ Statement
332 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
List function
“The user wants to display all cruises with cruise-Id, start-date, start-harbor
and destination-harbor.“
CRUISE
333 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
Overview READ statement
Sequence
READ
Physical
[RECORDS] [IN] [FILE] view-name
ISN
[sequence/range-specification ]
Logical by descriptor
statement…
Range-specification
END-READ
Equal
334 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DISPLAY statement
Header
Customizable
335 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example READ
336 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
READ PHYSICAL
337 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ PHYSICAL
338 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ physical sequential - how Adabas processes it
EMPLOYEES-FILE
339 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ PHYSICAL
READ
Range Specification - only ISN
[RECORDS] [IN] [FILE] view-name
STARTING WITH ISN
[IN] [PHYSICAL] [SEQUENCE]
END-READ
340 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Interesting systemvariables
Systemvariable Description
341 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example READ PHYSICAL
342 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ BY ISN
343 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ in ISN sequence - how Adabas processes it
Address
Converter
4312 EMPLOYEES-FILE
4313 FLETCHER
4312 1 5 SAMMET
344 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ BY ISN
WITH EQ ENDING AT
FROM
Range Specification - only ISN
statement…
Starting with ISN – greater equal
END-READ
Ending ISN – less equal
345 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example READ BY ISN
346 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ BY DESCRIPTOR
347 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ in logical sequence - how Adabas processes it
Address
Converter
4312 EMPLOYEES-FILE
Inverted List
4313 FLETCHER
4312 1 5 SAMMET
348 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ BY DESCRIPTOR
349 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example READ BY descriptor
‘=‘
350 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example READ BY descriptor with start value
351 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ with defined end value
The descriptor field used for the range must be defined in the The descriptor field used for the range is not required in the Natural
Natural data view data view
At termination of the loop the view contains the first record ‚out of At termination of the loop the view contains the last record of the
range‘ specified range
The end-value can be changed during processing loop The end-value is sent to Adabas once at the start of the READ-loop.
Modifications of the end-value during loop-processing have no
effect
DESCENDING: the start-value has to be higher than the end-value to ASCENDING and DESCENDING: the end-value is always the higher
get into the loop-processing value to get into the loop-processing
If an incorrect range is defined, the READ-loop will not be processed An incorrect range results in an error, because the value-range must
and no record will be returned be defined in ascending order
MU-field or sub-/super-/hyper-descriptor are not allowed and will MU-field and sub-/super-/hyper-descriptor can be used
lead to syntax error NAT0160 at compilation time
352 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Limit Number of Records
and Direction
353 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Limit number of records for loop processing
READ ALL
Constant or numeric variable
(operand1)
Evaluated at beginning of loop
[RECORDS] [IN] [FILE] view-name
[sequence/range-specification ]
statement…
END-READ
354 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ direction - how Adabas processes it
Address
Converter
4312 EMPLOYEES-FILE
Inverted List
4313 FLETCHER
4312 1 5 SAMMET
355 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ direction
statement…
END-READ
356 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example READ direction
357 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
READ DESCENDING
358 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
WHERE Clause and
further Selection Criteria
359 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
WHERE clause
[WHERE logical-condition ]
All Logical operators possible
statement…
Complex logical condition
END-READ
Not necessarily descriptors
360 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
ACCEPT / REJECT statement
361 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
AT START OF DATA statement
READ view-name
statement …
Used only once
END-START
statement …
END-READ
362 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
AT END OF DATA statement
READ view-name
statement …
Used only once
END-ENDDATA
statement …
END-READ
363 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example START & END OF DATA
364 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
List with Repositioning
365 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
List - more records than client can handle at once
CRUISE
call
2158 2016-09-29 Santorini Rhodos
366 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
List with repositioning READ – variant I
Inverted List
1st call
START-DATE
READ (10) CRUISE BY START-
DATE 20160824 5 3, 19,20,27,247
STARTING FROM 20160824 20160825 3 7, 9,45
20160831 19 1, 4, 7,24,25,…
2nd call 20160901 9 5,12,49,…
367 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
List with repositioning READ – variant II
Inverted List
1st call
START-DATE-UNIQUE-CRUISE-ID
READ (3) CRUISE BY START-DATE
STARTING FROM
201608245101 1 3
201608240000
201608245107 1 19
201608245108 1 20
2nd call
201608245112 1 27
READ (3) CRUISE BY START-DATE 201608245300 1 247
STARTING FROM 201608315109
Adabas Systemfield
TIME with CR option
can be used
368 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Provide the list of available cruises
369 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
HISTOGRAM Statement
370 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
HISTOGRAM function
“The user wants to have a list of harbors where the cruises start,
and how many cruises start in Lefkas.”
CRUISE CRUISE
371 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
HISTOGRAM - how Adabas processes it
Inverted List
Start-Harbor
Lefkas 2 1, 4
Samos 1 5
Santorini 3 2, 6, 7
372 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
HISTOGRAM statement
373 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Systemvariables & additional criteria
Systemvariable Description
*NUMBER For a HISTOGRAM statement the number of records for the actual selected
descriptor value
374 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Additional Criteria
ASCENDING / DESCENDING
ACCEPT / REJECT
AT START OF DATA
AT END OF DATA
375 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example HISTOGRAM
376 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
HISTOGRAM statement
377 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
15
378 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
▪ FIND Statement
▪ Complex FIND and more Options
▪ FIND NUMBER and GET Statement
▪ Access in Portions with Repositioning
▪ Access Several Files
▪ When to use READ and when to use FIND
379 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND Statement
380 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Selective function
“The user identifies himself via his CustomerID and wants to see it´s name, birthday, and
other data´.
CUSTOMER
381 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND statement
FIND
[RECORDS] [IN] [FILE] view-name
[WITH] basic-search-criterion
statements….
END-FIND
382 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example Simple FIND – one selected record
383 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example Simple FIND – list of selected records
384 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Interesting systemvariables
Systemvariable Description
*NUMBER For a HISTOGRAM statement the number of records for the actual selected
descriptor value
*NUMBER For a FIND statement the number of records which were selected
385 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
IF NO RECORDS FOUND clause
statements…
END-NOREC
statements….
END-FIND
386 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example FIND – no record
Change
Changeitit
to
to333
333
387 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
FIND IF NO RECORDS FOUND clause
388 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Complex FIND and more
options
389 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Selective function – many selection values
“The HR manager wants to see which employees work in the sales department
of Region 20 and are born before 1970.“
EMPLOYEE
390 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND - how Adabas processes it
BIRTH
19690505 1 2
Inverted Lists 19960224 1 4 Address DATA Storage
19650704 1 6 Converter
DEPTARTMENT 19991222 1 7
MGMT10 1 1 19950422 1 1 4312
MGMT40 2 3, 8 19771113 1 3
4314
SALE20 3 2, 6, 7 19690905 1 8
4313 4312 1 FLETCHER 5 SAMMET
TECH10 1 4, 5 19740219 1 5
4315 4313 3 SMITH 7 EVANS
391 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Complex search criteria
Many Operators
OR / AND / NOT
392 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example complex FIND
393 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND STARTING WITH ISN
[WITH] basic-search-criterion
statements….
END-FIND
394 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND SORTED BY
statements….
Significant performance overhead
sorting many values
END-FIND -> use SORT statement
395 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example FIND SORTED
396 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Additional Criteria
WHERE clause
ACCEPT / REJECT
AT START OF DATA
AT END OF DATA
397 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
NON-DESCRIPTOR search
398 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND - how Adabas processes it
Address
Converter
BIRTH
19690505 1 2 4312
Inverted Lists 19960224 1 4 4314
19650704 1 6 4313 1 FLETCHER 5 SAMMET
DEPTARTMENT 19991222 1 7
4315 3 SMITH 7 EVANS
MGMT10 1 1 19950422 1 1
4312 2 WELKE 8 SMITH
MGMT40 2 3, 8 19771113 1 3
4 FLETCHER 6 PREMO
SALE20 3 2, 6, 7 4315
19690905 1 8
TECH10 1 4, 5 4313
19740219 1 5
4314
2
6
7
2
Resulting ISN List 6
399 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DDM definition for NON-DE FIND
S Sub- or superdescriptor
H Hyperdescriptor
P Phonetic descriptor
400 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example NON-DE search
401 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
Complex FIND
402 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND NUMBER and
GET Statement
403 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND NUMBER statement without loop processing
FIND NUMBER
First phase
acess to record
[WITH] [LIMIT (operand1) ] basic-search-criterion
END-FIND
IF NO RECORDS FOUND
404 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example FIND NUMBER
405 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
GET statement
USAGE
*ISN
Part of transaction
406 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example GET
407 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Get the correct price of a cruise
408 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Access in Portions with
Repositioning
409 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
List - more records than client can handle at once
CRUISE
call
2158 2016-09-29 Santorini Rhodos
410 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
List with repositioning FIND – variant I
1st LIST
CRUISE-ID Date
FIND (4) CRUISE WITH START- 23, 6, 45, 2012 20160824
9,12,17,21,3,
DATE > 20160824 and CRUISE-ID 23,5,.. 2043 20160929
GT 0 SORTED BY CRUISE-ID 2054 20161012
2059 20160929
2060 20160829
2nd LIST
2071 20161001
2088 20160829
FIND (4) CRUISE WITH START- 12,17,21,3,
2099 20160913
DATE > 20160824 and CRUISE-ID 23,5,..
GE 2059 SORTED BY CRUISE-ID..
STARTING WITH ISN = 9
411 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
List with repositioning FIND – variant II
CRUISE-ID Date
FIND CRUISE WITH START-DATE > 23, 6, 45, 2012 20160824
9,12,17,21,3,
20160824 RETAIN AS FINDLIST 23,5,.. 2043 20160929
2054 20161012
2059 20160929
FINDLIST 2060 20160829
2nd LIST
2071 20161001
23, 6, 45,
2088 20160829
FIND CRUISE WITH FINDLIST 9,12,17,21,3,
23,5,.. 2099 20160913
STARTING WITH ISN = 9
412 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Access Several Files
413 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Selective function – selection values in different files
“The booking agent wants to see for a specific contract the name of the yacht
and the name of the customer who has booked.“
CRUISE
CONTRACT
YACHT
Contract-ID Price Date-Reservation ID-Customer ID-Cruise YACHT-ID Yacht-Name Yacht-Type
985 5985.00 20160904 605 2095 105 Kassandra Pacific 34
CUSTOMER
414 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
Example for nested FIND
415 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
List for selection values in different files
“The booking agent wants to see all contracts which have been created within
a certain period and for each of them the yacht names and the customer
names. “
CRUISE
CRUISE-ID Date Start-Harbor ID-YACHT
1319 2016-11-24 Lefkas 105
2095 2016-09-29 Santorini 105
2043 2016-09-29 Syros 114
CONTRACT
CUSTOMER
416 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
Example for nested FIND nested in a READ loop
417 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Selection values in different files – result from one file
“The booking agent wants to see all contracts with the contract details which
were created this year for cruises with a specific start-date and from a specific
start-harbor.”
CONTRACT
CRUISE
Contract-ID Price Date-Reservation ID-Customer ID-Cruise CRUISE-ID Date Start-Harbor ID-YACHT
985 5985.00 20160904 605 2099 2095 2016-11-24 Lefkas 69
1319 2016-02-11 Samos 105
1151 21036.00 20160801 590 1319
2043 2016-09-29 Syros 114
1147 14476.00 20160801 530 2043
CRUISE
418 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
FIND with Coupling-clause
FIND view-name WITH basic-search-criteria Only data fields from base view are
available
{AND | OR} COUPLED [TO] [FILE]
Not same file in two couple clauses
view-name2
Physical / Logical coupling
[VIA descriptor1 = descriptor2 ] Logical Coupling
WITH basic-search-criteria VIA clause
419 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example FIND COUPLED
420 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
When to use READ and
when to use FIND?
421 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Differences between READ and FIND
READ FIND
One descriptor Complex criteria with many descriptors and non-descriptors
One record at a time Resulting ISN list is generated, afterwards one record at a time
If specific record is not there the next record in sequence If specific record is not there (*NUMBER=0) NO RECORDS found
will be passed back (or end of list) clause available
422 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
When to use READ or FIND
READ FIND
If selection criterion is not to complex and post-selection Complex selection criteria, use WHERE clause only for non-
criterion satisfy and applies to most records descriptors
If ´end user´ typically does not scroll down Bigger effort in phase I when creating the ISN list, afterwards only
access via ISN, keep contention in mind
In outer loop, for inner loop use FIND To find one specific record
Preferable for re-posititioning For small intermediate and resulting ISN lists, avoid HUGE ISN lists
-> think about using HISTOGRAM to find more out about the data
423 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example FIND COUPLED and alternative I
424 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example FIND COUPLED and alternative II
425 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
Data access using READ or FIND
426 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Access one record to list a customer
427 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
16
428 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
What we will cover
▪ Transaction Processing
▪ DELETE Statement
▪ UPDATE Statement
▪ STORE Statement
▪ Contention Access / Modification
▪ Contention Modification / Modification
▪ Transaction with Multiple Updates
429 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Transaction Processing
430 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Data Manipulation Statements
CRUISE
431 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
Database transaction definition
Database in a
Transfer of data from a consistent state into
consistent state
Start of transaction another consistent state
Indivisible
Database in
Execution of
inconsistent
transaction Single unit of work which must succeed or fail
state
as complete unit
time
432 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Database transaction in Adabas
Called HOLD
Update
Customer #1
implicit when UPDATE / DELETE
FIND CUSTOMER #1
statement is used in
DISPLAY
CUSTOMER
READ/FIND/GET processing
Type-in
changes
433 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
END TRANSACTION and BACKOUT TRANSACTION
BACKOUT [TRANSACTION]
434 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hold Logic
435 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Contention definition
436 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hold logic and contention
Session parameter
WH (Wait on Hold) = ON/OFF
time time
437 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DELETE Statement
438 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
DELETE statement
with a label to
▪ GET statement
▪ STORE statement
439 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example DELETE Statement
440 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
UPDATE Statement
441 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
CHANGE - one record of the customer file
CUSTOMER
442 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
UPDATE statement
UPDATE [RECORD] [IN] [STATEMENT [(r)] Fields which are not changed remain as they
are
Index values are updated
Maybe AC entry (RABN) is changed, but ISN is
same
The statement refers to
with a label to
▪ GET statement
▪ STORE statement
443 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example UPDATE statement
444 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Demo:
UPDATE Statement
445 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
STORE statement
446 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
NEW – add a record to the customer file
“The user adds a new record with all his data including his email address
and will get internally an unique customer Id.“
CUSTOMER
447 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
STORE statement
STORE [RECORD] [IN] [FILE] Assign values to fields before the STORE
448 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example STORE Statement
449 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Contention handling
STORE
STORE
END TRANSACTION
END TRANSACTION
450 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Example STORE with unique customer-id
451 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Add a new customer record
452 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Contention
Access / Modification
453 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Contention access / modification
454 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ with UPDATE contention
Address
Converter
4312 EMPLOYEES-FILE
4313
Inverted List 4312 1 FLETCHER
TYLER 5 SAMMET
TYLER 1 1
455 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
READ with UPDATE contention
Address
Converter
4312 EMPLOYEES-FILE
Inverted List
4313 FLETCHER,10
4312 1 5 SAMMET,7
456 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Solution for READ and UPDATE contention
LIST
Add a ‘pseudo’ update in the READ
Customer loop to put each record in hold
READ CUSTOMER
Modify
Customer
´pseudo´ Side effects
UPDATE FIND CUSTOMER #1
UPDATE Longer wait times (more rsp-145), not
Move data to an
array END TRANSACTION only for update but also for parallel
access
END-READ
Maybe Adabas Holdqueue needs to be
END TRANSACTION
longer
457 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND with UPDATE contention
19740219 1 5
6 4312 4314 2 WELKE 8 SMITH
458 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Contention access / modification
Move data to an array DELETE -> remove record -> remove ISN
END-FIND Modify
Customer STORE -> new record -> new ISN
FIND CUSTOMER #1
UPDATE
2nd END TRANSACTION
LIST Customer Anomaly - Phantom read
FIND CUSTOMER from
ISN_list a selection list becomes ´invalid´
Move data to an array
due to parallel updates
END-FIND
459 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Solution
Solution
1st
LIST Customer
FIND CUSTOMER
checking the selection criteria again, if
RETAIN ISN_list
invalid
Move data to an array skip this record
Modify
END-FIND Customer re-do the whole FIND
FIND CUSTOMER #1
UPDATE
2nd END TRANSACTION
LIST Customer
FIND CUSTOMER from
ISN_list
END-FIND
460 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND/READ with SHARED HOLD
461 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
SHARED HOLD options
FIND view-name ‘C’ : check if some other user has this record in
hold – will not set a record into shared hold
WITH basic-search-criteria
[[IN] SHARED HOLD [MODE=option]]
‘Q’ : set a shared hold until next record in
END-FIND sequence is read, or end of loop or ET or BT
462 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
FIND/READ with SKIP RECORDS
WITH basic-search-criteria
User tries to lock a record which is locked by
[SKIP [RECORDS] IN HOLD] another user
END-FIND
Instead of rsp-145 the record will be skipped
and the next record will be read and locked
READ view-name
[SKIP [RECORDS] IN HOLD]
END-READ
463 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Contention
Modification /
Modification
464 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Competition for a record
465 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Contention modification / modification
Modify Modify
Customer Modify Customer
Pessimistic Locking Optimistic Locking
FIND CUSTOMER #1 Customer FIND CUSTOMER #1
Modify
FIND CUSTOMER #1 END-FIND
Customer
FIND CUSTOMER #1
Type-in changes
END-FIND
..waits.. Type-in changes
UPDATE
END-FIND
Type-in changes END TRANSACTION GET / FIND
CUSTOMER #1
END-FIND
UPDATE
UPDATE
END TRANSACTION
END TRANSACTION
END-FIND
END-FIND
466 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Locking strategy
Longer wait time, or more rsp-145 Less wait time, lesser contention situations
No additional effort by checking again Additional effort for second check, including handling when check
´fails´
467 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Optimistic locking approach
GET CUSTOMER
Add a field for a timestamp which is changed
Customer every time the record is updated
Surname timestamp
FIND CUSTOMER #1
END-FIND
Weise ……. 56756758 First access: get the timestamp and keep this
Bares …….59875869
Dietrich …….19876584
Second access: get the timestamp and check
this against the previous timestamp
Type-in changes
CUSTOMER
Same timestamp
Surname timestamp
Modify No contention, continue
Customer Weise ……. 86112113
Bares …….59875869
GET CUSTOMER #1
Dietrich …….19876584
Different timestamp
Check timestamp
update contention, pass back error
UPDATE
END TRANSACTION
´56756758´ = ´86112113´ ? Use Natural variable *TIMESTMP or Adabas
END-FIND systemfield TIME
468 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Optimistic Locking
Hand-on Lab description
Surname timestamp
GET
Frontend Customer
RDCRUISP [Link] [Link] Weise ……. [Link]
[Link]
Surname timestamp
Modify
P-SELECTION.P-TIMESTAMP Customer [Link]
Weise ……. [Link]
same?
Surname timestamp
yes
Weise ……. [Link]
[Link]
Update incl.
*TIMESTMP
[Link]
469 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Modify an existing customer
470 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Transaction with Multiple
Updates
471 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
NEW and MODIFY – Update of several files
CONTRAC
T
CRUISE
472 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
© Software AG Training
Create Contract – two services
Create Contract
STORE CONTRACT
UnSucessfull ? END TRANSACTION If the rollback from the caller does not work,
then there is no easy solution to solve this.
473 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Business Function ´Book Cruise´
List Cruise
List all cruises and display it
READ CRUISE
474 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Create Contract – one service
Modify Cruise
Encapsulated & self-contained & independent
FIND CRUISE
Modify Cruise and Create Check availability
Contract Update Transaction is handled by database, incl. roll-
back
Create Contract
The time between the first access to the Cruise
STORE CONTRACT
and the store of the contract is much longer.
END TRANSACTION
It might come more often to a failure of booking.
Unsucessfull
Database will
handle this
475 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Business Function ´Book Cruise´
476 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.
Hands-On Lab:
Book a cruise
477 © 2024 Software AG. All rights reserved. For internal use only and for Software AG Partners.