Subfile for Inquiry with Update
Same as Load All
But the subfile fields will be editable
Use READC and CHAIN to read and update the data into the data base
Show the control format again
SFLNXTCHG
Record-level keyword on the subfile record used to force the workstation user to correct
errors
If a subfile record is written (WRITE or UPDATE) with SFLNXTCHG active :
The MDT for that record is turned on
The record will be retrieved from the subfile by a READC even if the user did not
modify any field in that record on the display
MDT is set off when the changed record is retrieved
Additional routine after EXFMT in the load all pgm
SFLFOLD/SFLDROP
Use these keywords to display the subfile initially in the folded or in the truncated format, if the
subfile record does not fit in one line
Can be toggled to the other state, by associating a function key
Either CA or CF key can be associated.
Use CF key, if the screen has input capable fields
SFLDROP
Initial Look
After Pressing F11
SFLLIN
Use this record level keyword to display a subfile as a horizontal subfile
SFLINZ Subfile for data entry
Program
Arrays
Series or list of variables in computer memory, all of which have the same name but are
differentiated with special number called subscripts
Each array element occupies an area in memory next to, or contiguous to, the others
Types of Arrays
Compile-time:
Loaded when the program is created and it becomes part of the program. The data for
the array elements is supplied within the program
Pre-runtime:
Array is loaded from a file whenever the program is called, before any input, output or
calculation processing started
Run-time:
Loaded while the program is running. The execution of the program loads the array
Example - Runtime
Example Compile time
Example Preruntime
Array Opcodes
LOKUP
SORTA
MOVEA
XFOOT
Data Structures
Continuous stream of bytes
Program crated and internal
Treated as stream of Character data
Globally initialized to blanks
Can be initialized at individual field level
Can be initialized using named constants also at the field level
Uses
To Group fields
To split fields
To re-define the fields
As a parameter list
Types
Basic
Multiple Occurrence
Data Area
Program Status
File Information
Example Redefining
Initialization
Example Parameter list
Multiple Occurrence
Used to implement two dimensional array
OCUR opcode is used to access the specific occurrence
Factor 1 specifies the occurrence of the DS to be positioned
Factor 2 determines the DS name
Result Field captures the occurrence number, if factor 1 is blank
Indicator specified in Low column will be set on if the factor 1 tries to position in DS, which out
of range
Two dimensional Array
Data Area Data Structure
Identified by U in Option Column
The data structure name and the data area name will be the same
Identified by U in Option Column
The data structure name and the data area name will be the same
Using LDA as a DS
Another way
Using multiple Data Areas
When multiple data areas are needed to be read and written:
Define all of them using DEFN
Use IN/OUT with *NAMVAR in factor 2
This will reduce the coding of writing multiple IN and OUT statements
Ex: IN *NAMVAR
OUT *NAMVAR
Subprograms
When to go for a subprogram
Utility used by many Application
Easier Maintenance
Taking advantage of other language
Move the routine, which is infrequently used to a separate program
Passing Parameters
*Entry is a special PLIST to receive parameters sent by calling program
Even though the parameters are passed by reference, the indicator array is unique for each
program
Hence Indicator as such can NOT be passed to the subprogram
Pass it as a 1 byte character variable
Returning from Subprogram
Complete the current cycle, End the subprogram and return to calling program
SETON LR
Return to the calling program immediately without ending the subprogram
RETRN
Complete the current cycle, return to calling program without ending the subprogram
SETON RT
LR Vs RT/RETRN
Subprogram Deactivation
Use FREE Opcode in the calling program
Removes Static Storage (variables and links to ODPs)
Does the first cycle processing during the next call
Does not close the files or unlock Data Area
Use RCLRSC
Frees Static storage and all unused ODPs
Use QCMDEXC
House Keeping
Run-time clearing and resetting of all elements record format, data structure, array, or a
variable (field, subfield, or indicator)
Opcodes:
CLEAR
zero, blank, or '0'
RESET
To their initial values set in DS or in *INZSR
*INZSR
Subroutine name is *INZSR
Invoked
When the program is called for the first time
Ended with SETON LR
FREE opcode executed in calling program
Invoked automatically. Can be executed using EXSR or CASxx
RESET opcode initializes to those specified in *INZSR
Coded as a normal subroutine
Exception/Error Handling
Program and File Exceptions
Examples of program exceptions
division by zero, not valid array index, SQRT of a negative number, Decimal Data Error,
Called program not found
Examples of file exceptions
Device error, undefined record type
File Information Data Structure
Status Codes
Error Handling PSDS
Status Codes
Exception Handling Methods
Default Error Handler
Resulting Indicator Method
Invocation of implicit subroutine
Resulting Indicator Method
Resulting indicator set in the LO column is used for trapping the error
It is set on, if there is an in the opcode associated
Implicit Routine Program Exc
Implicit Routine File Exception
Default Error Handler
Data Base Locks
A program can lock only one record per file
Read record for update
The locked record is released after
UPDATE
CLOSE
WRITE
READ another in the same file for UPDATE
Release
UNLCK
EXCPT
READ with no lock
Test Opcode
Opertion Extender
P in position 53
Result field is padded
Move padded from the left
MoveL or MoveA is padded from the right
For CAT, SUBST or XLATE result field padded from right
Getting Current Date
Executing CL command