Professional Documents
Culture Documents
Application System/400
Layered machine architecture Distributed Processing Object orientation Single-level storage Hierarchy of microprocessors Security levels
OPERATING SYSTEM
Operating system used in AS/400 is OS400 Object-Based Programming Languages - RPG400, CL400, Cobol400, Java 400, SQL 400, etc.
SECURITY
Various Security provided by the system No security Password security Resource security OS security C2 level security
LIBRARY
A library is a system object that serves as a directory to other objects. Libraries provide a method for organizing objects. Libraries themselves are objects. CRTLIB command is used to create a library.
LIBRARY LIST
System library- 15 (QSYSLIB) QSYS QHLPSYS QUSRSYS Product library 2 Current library 1 User library - 25 (QUSRLIB) QGPL QTEMP
JOB
There are two types of jobs
Interactive jobs Batch jobs
How batch Job works? Submit the job Job enters the job queue Job enters the subsystem The memory pool allocates memory to the subsystem The job finishes and moves to the output queue
COMMANDS
WRKACTJOB Used to find jobs in the system WRKSBMJOB Used to work with the Batch jobs DSPJOB Used to display the job CHGJOBD, DLTJOBD, DSPJOBD, WRKJOBD used to Change, Delete, Display, Work with Job Description
DATABASE
DATABASE FILES
Source File Physical File Logical File
NAMING CONVENTIONS
file name, record format name, and field name can be as long as 10 characters Field names must be unique in a record format Record format names and member names must be unique in a file File names must be unique in a library
SOURCE FILE
Source physical file is a file, which has one, or more files included in it. It is just like a directory and it contains many members. CRTSRCPF command is used to create a source file
PHYSICAL FILE
A physical file contains one record format and one or more members. It s type PF. Maximum number of fields -> 8000. Maximum no of key fields -> 120. CRTPF command is used to create physical file.
TEXT
Example: TEXT ( description )
// physical filename : CUSTOMER 0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 A UNIQUE A R RCUST A CUSNO 5S 0 TEXT( CUSTOMER NO ) A CUSNM 30A A CUSAD 30A A K CUSNO ****************** End of data ********************
LOGICAL FILE
One or more logical file can be derived from a single physical file. A logical file can contain up to 32 record formats. It cannot exist without a physical file. Type is LF. CRTLF command is used to create a Logical file.
// Logical filename : example1 *************** Beginning of data ********************* 0001.00 R RECSEL PFILE (EXAMPLE) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 10003) 0004.00 O EMPNAME CMP (EQ 'SHYAM') ****************** End of data ************************** // Logical filename : example2 *************** Beginning of data ************************** 0001.00 R EMP JFILE (SAMPLE SAMPLE) 0002.00 J JOIN (1 2) 0003.00 JFLD (MGRID EMPID) 0004.00 EMPID JREF (1) 0005.00 EMPNAME JREF (1) 0006.00 MANAGER RENAME (EMPNAME) JREF (2) 0007.00 COLHDG ('MANAGER') ****************** End of data *****************************
COMMANDS
1. DSPFFD used for listing details about individual fields. 2. DSPFD used to display the details about the file when it is created. 3. DSPDBR used to list all the files, which are related to a PF. 4. DSPOBJD used to know library name, object name and the source PF where it is residing.
ACCESS PATH
An access path describes how records in a database file are retrieved Types of Access Path
Arrival Sequence Access Path Keyed Sequence Access Path
Query selection
OPNQRYF FILE (LIB / PF) QRYSLT ( EMPNO *EQ*BCAT &A )
Delete override
DLTOVR FILE (OPNPF)
LOCK
It helps to give the access permission for database file. Types of lock Share lock Exclusive lock
CONTROL LANGUAGE
Control language (CL) is the primary interface to the operating system. CL can be used at the same time by users at different workstations, in batch and interactive jobs and in CL programs and procedures
PARAMETERS IN CL
Parameter is a value that is passed to a command or program to provide user input or control the actions of the command or program Parameter can be a single value or a list of values.
PARAMETER SPECIFICATION
Keyword form:
DCL VAR(&QTY) TYPE(*DEC) LEN(5) VALUE(0)
Positional form:
DCL &QTY *DEC 5 0
EXPRESSIONS IN CL COMMANDS
Types of expressions supported in CL programs
Arithmetic (&VAR + 15)
+,- ,*,/
SAMPLE CL PROGRAM
// SAMP9CL PGM DCL VAR(&CHOICE) TYPE(*DEC) LEN(1) DCLF FILE(SAMP9) TOP: SNDRCVF RCDFMT(MAINMENU) IF COND(&CHOICE *EQ 5) THEN(GOTO CMDLBL(EXIT)) /* CALL THE ADDITION PROGRAM*/ IF COND(&CHOICE *EQ 1) THEN(DO) CALL PGM(SAMP9ADD) ENDDO GOTO CMDLBL(TOP) EXIT: Endpgm //SAMP9ADD CL FILE PGM DCL VAR(&NUM1) TYPE(*DEC) LEN(4) DCL VAR(&NUM2) TYPE(*DEC) LEN(4) DCLF FILE(SAMP9) RCDFMT(ADDITION) SNDRCVF RCDFMT(ADDITION) CHGVAR VAR(&SUM) VALUE(&NUM1 + &NUM2) SNDRCVF RCDFMT(ADDITION) Endpgm
DATA AREA
A data area is an object used to store data for access by any job running on the system. It is permanent storage It is of limited size and independent of the existence of the programs or files Data area created by the system 1. Local Data Area 2. Group Data Area
COMMANDS
CRTDTAARA Used to create a general data area RTVDTAARA Used to retrieve values from data area. CHGDTAARA Used to change the value of data area DSPDTAARA Used to display the current value of data area DLTDTAARA Used to delete a data area
COMMANDS
Accessing Local Data Area
CHGVAR VAR (%SST (*LDA 3 5)) VALUE(123) RTVDTAARA DTAARA (*LDA (3 5)) RTNVAR (&ROLNO)
SAMPLE PROGRAM
PGM CRTDTAARA DTAARA(MYLIB/DA1) TYPE(*CHAR) LEN(5) VALUE(ABCDE)
. . .
MESSAGE
Message is the interface between operating system and the programs or user and program. Immediate message Predefined message Monitor message(MONMSG)
IMMEDIATE MESSAGE
Immediate messages are created by the program or system user when they are sent and are not permanently stored in the system.
SNDUSRMSG, SNDBRKMSG, SNDMSG Ex: SNDUSRMSG HELLO
PREDEFINED MESSAGE
Predefined messages are created before they are used. These messages are placed in a message file (queue) when they are created, and retrieved from the file when they are used.
MONMSG
The monitor message (MONMSG) command monitors the message send to the program message queue for the conditions specified in the command. If condition exists, the CL command specified on the MONMSG command is run.
Ex: MONMSG MSGID (MCH1211) CMPDTA (LIB)
COMMANDS
SNDUSRMSG - Send a message to a user SNDPGMMSG - Send a message to a message queue SNDBRKMSG - Send Break Message
RPG SPECIFICATIONS
Seven kinds of specifications are 1. Control specifications 2. File description specifications 3. Extension specifications 4. Line counter specifications 5. Input specifications 6. Calculation specifications 7. Output specifications.
CONTROL SPECIFICATION
The control specification provides the RPG/400 compiler with information about your program and your system. This includes: 1. Name of the program 2. Date format for the program 3. If an alternative collating sequence or file translation is used. Control Specification is optional
EXTENSION SPECIFICATIONS
Extension specifications describe all record address files, table files, and array files used in the program. The information includes:
1. 2. 3. 4. Name of the file, table, or array Number of entries in a table or array input record Number of entries in a table or array Length of the table or array entry.
INPUT SPECIFICATIONS
Input specifications describe the records, fields, data structures and named constants used by the program The information in the input specifications includes:
Name of the file Sequence of record types Name and Type of each field in the record Named constants.
CALCULATION SPECIFICATIONS
Calculation specifications describe the calculations to be done on the data and the order of the calculations. The information includes:
1. Control-level and conditioning indicators for the operation specified 2. Fields or constants to be used in the operation
OUTPUT SPECIFICATIONS
Output specifications describe the records and fields in the output files and the conditions under which output operations are processed. The information includes
Name of the file Spacing instructions for Printer files Name and location of each field in output record
Entry H F D I C O P
Specification Type Control File description Definition Input Calculation Output Procedure
ARRAY
Array is a collection of data of similar data type and length. Types of arrays
Run Time Array Compile Time Array Pre run Time Array
//Example code *************** Beginning of data *********** c*runtime array darr1 s 10 dim(12) di s 2p 0 inz(1) da s 3p 0 dj s 2p 0 inz(1) c i do 12 c eval arr1(i)=a c dsply arr1(i) c add 1 i c enddo c seton lr ****************** End of data **************
//Example code *************** Beginning of data****************** c*compile time array darr1 s4 dim(3) ctdata perrcd(1) di s 2p 0 inz(1) c i do 3 c arr1(i) dsply c add 1 i c enddo c eval *InLr = *On **ctdata arr1 1001 20 1000 ****************** End of data ********************
//Example
DARE D DARH D D C eval S 5A DIM(250) PERRCD(12) ASCEND FROMFILE(DISKIN) S 5A DIM(250) PERRCD(12) ASCEND FROMFILE(DISKOUT) TOFILE(DISKOUT) *InLr = *On
OPCODE
ADD (Add) C ADD 1 RECNO ADDDUR (Add Duration) C ADDDUR YY:*MONTHS DUEDATE DIV (Divide) C FACT1 DIV FACT2 RESULT EVAL (Evaluate Expression) C EVAL EMPNO = 5001 MULT (Multiply) C FACT1 MULT FACT2 RESULT
OPCODE
MVR (Move remainder) C FACT1 MVR FACT2 RESULT SUB (Subtract) C SUB 1 RECNO SUBDUR (Subtract Duration) C SUBDUR YY:*MONTHS LOANDATE Z-ADD (Zero and Add) C Z-ADD 1 SCR1 Z-SUB (Zero and Subtract) C Z-SUB 1 SCR1
OPCODE
CHECK (Check Character) C CHECK String Num COMP (Compare) C FLDA COMP FLDB 111213 CAT (Concatenate two Strings) C NAME CAT FIRST RESULT DSPLY (Display) C DSPLY Num
OPCODE
CALL (Call a program) C CALL PROGA EXFMT (Write/ Then Read Format) C EXFMT EMPDTL EXTRCT(Extract Date / Time / Timestamp) C Extrct ISODate:*M MonthD EXCEPT (Calculation Time Output) C EXCEPT HDG
OPCODE
PARM (Identify Parameters) C FieldA PARM FieldB FieldC PLIST (Identify Parameter List) C PLIST1 PLIST RETURN (Return to Caller) C RETURN 7 C RETURN Parm * 15
DISPLAY FILE
Display files are DDS files that enable us to create menus and screens to interact with the user. It can have several records Records may or may not overlap each other SDA application is used for creating the Display Files Subfile is a type of display file.
SUBFILES
SUBFILES
It is used in display file programming to allow the users to handle lists of columnar data in a easier way. It makes the program designing simple. It is a two step process
Loading Data into a Subfile Displaying the Subfile data. It consists of two Record Formats Subfile Format Subfile Control Format
SUBFILES
Subfile Format holds the Records that has to be displayed Subfile Control Format defines how many records it can contain and display. It is of three types
Load All Expanding Single Page.
EXPANDING SUBFILE
SFLSIZE > SFLPAGE A Specific number of records are loaded into the subfile format and then displayed. Roll back option has to be programmed by the user.
KEYWORDS
SFLCTL Subfile control format SFLDSPCTL Subfile Display Control SFLDSP Subfile Display SFLPAGE This describes how many records that can be displayed in the screen. SFLSIZE - This describes how many records the Subfile can hold. SFLCLR To clear a subfile.
SPOOL FILE
It helps to manage data targeted for externally attached devices. Holds output data until it can be printed.
BUILT-IN FUNCTIONS
%ADDRESS
IF COND(&P1 *NE %ADDRESS(&C1)
%BINARY
DCL VAR(&N) TYPE(*DEC) LEN(5 0) VALUE(107) DCL VAR(&B4) TYPE(*CHAR) LEN(4) CHGVAR %BIN(&B4) &N
%SUBSTRING
DCL &A *CHAR VALUE(ABC) DCL &B *CHAR VALUE(DEF) IF (%SST(&A 1 2) *EQ %SUBSTRING(&B 1 2)) + CALL CUS210
%SWITCH
IF (%SWITCH(11XXXXXX)) CALLPRC PROCA IF (%SWITCH(10XXXXXX)) CALLPRC PROCB