as-400

Post on 30-Oct-2014

275 Views

Category:

Documents

25 Downloads

Preview:

Click to see full reader

TRANSCRIPT

AS/400 or IBM i-series or System i

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

CREATING AND DESCRIBING DATABASE FILES

Different ways of creating Database file• Interactive data definition utility (IDDU)• Control Language (CL)• Structured Query Language (SQL)• i-series navigator

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.

LEVELS OF ENTRIES IN PHYSICAL FILE

There are four levels of entries.• File level entries (optional)

UNIQUE, LIFO, FIFO, FCFO, REF

• Record format level entriesFORMAT

Example: FORMAT (LIB-NAME / FILE-NAME)TEXT

Example: TEXT (‘description‘)

LEVELS OF ENTRIES IN PHYSICAL FILE

• Field level entriesCHECK, COLHDG, DATFMT, REFFLD, VALUES, VARLEN,

etc.

• Key field level entriesDESCEND, SIGNED, ABSVAL, UNSIGNED, ZONE, etc.

VALID DATA TYPES

A CharacterP Packed decimal S Zoned decimal B Binary F Floating point H Hexadecimal L Date T TimeZ Timestamp

// physical filename : CUSTOMER 0001.00 A UNIQUE

0002.00 A R RCUST

0003.00 A CUSNO 5S 0 TEXT(‘CUSTOMER

NO’) 0004.00 A CUSNM 30A

0005.00 A CUSAD 30A

0006.00 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.

TYPES OF LOGICAL FILE

• Non-Join logical file• Join logical file

LEVELS OF ENTRIES IN LOGICAL FILEThere are six levels of entries.• File level entries (optional)– JDFTVAL, DYNSLT, etc

• Record format level entries– JFILE

• Field level entries (Optional)– JREF, ALL, CONCAT, RENAME, SST

• Key field level entries (Optional)• JOIN Level entries– JOIN, JFLD, JDUPSEQ

• Select / Omit level entries (Optional)

LEVELS OF ENTRIES IN LOGICAL FILE

• JOIN Level entriesIt is not applicable to NON JOIN LOGICAL FILES• Select / Omit level entries

// Logical filename : example1 *************** Beginning of data *********************0001.00 R RECSEL PFILE (EXAMPLE)0002.00 K EMPNO0003.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

OPEN QUERY FILE

• It acts as a filter between the processing program and the database records.

• OPNQRYF command creates only a temporary file for processing the data.

• The typical use of the OPNQRYF command is to select, arrange, and format the data.

STEPS FOR CREATING OPNQRYF• override database file– OVRDBF FILE (file PF) TOFILE (LIB/ PF) SHARE (*Yes)

• Query selection– OPNQRYF FILE (LIB / PF) QRYSLT (‘EMPNO *EQ*BCAT &A’)

• Calling RPG program– CALL PGM (LIB/NAME) PARM ()

• Delete override– DLTOVR FILE (OPNPF)

• Closing the file– CLOF OPNID (OPNPF)

LOCK

• It helps to give the access permission for database file.

• Types of lock —Share lock—Exclusive lock

CONTROL LANGUAGE (CL)

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

CL PROGRAMS & PROCEDURE

• CL programs and procedures are created from source statements that consist entirely of CL commands

• Using CL programs and procedures is faster than entering and running the commands individually

• CL programs and procedures provide consistent processing of the same set of commands

• Parameters can be passed to CL programs and procedures

TYPES OF CL PROGRAMS AND PROCEDURES

• CL procedure – It is a set of statements that performs a particular

task and then returns to the caller. • CL module – It is the object that results from compiling high-

level language source statements using an Integrated Language Environment (ILE) compiler.

TYPES OF CL PROGRAMS AND PROCEDURES

• CL program – It is a program that is created from source

statements consisting entirely of CL commands. • Service program – A service program is an object that contains one

or more modules.

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

• Positional and keyword forms together: – DCL &QTY *DEC VALUE(0)

EXPRESSIONS IN CL COMMANDS

• Types of expressions supported in CL programs – Arithmetic (&VAR + 15) • +,- ,*,/

– Character string (SIX || TEEN) • *CAT,*BCAT,*TCAT

– Relational (&VAR > 15) • =, >, <, >=, <=, *EQ, *GT, *LT, *GE, *LE, *NE,etc.

– Logical (&VAR *OR &TEST)• *AND,*OR,*NOT,&,|,¬

SAMPLE CL PROGRAM// SAMP9CLPGM 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 Area2. Group Data Area

LOCAL DATA AREA

• A local data area is created for each job in the system automatically, when a job is submitted.

• Only One Data Area is created when a job is submitted

• initially filled with blanks, with a length of 1024 and type *CHAR.• No library is associated with the local data area.

GROUP DATA AREA

• System creates a group data area when an interactive job becomes a group job.

• Only one group data area can exist for a group• Initially filled with blanks, has a length of 512 and

type *CHAR.• No library is associated with a 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)

• Accessing Group Data Area– CHGDTAARA DTAARA (*GDA) VALUE (‘DECEMBER 1996‘)– RTVDTAARA DTAARA (*GDA) RTNVAR (&GRPARA)

SAMPLE PROGRAM PGMCRTDTAARA DTAARA(MYLIB/DA1) TYPE(*CHAR) LEN(5) VALUE(ABCDE)...

DCL VAR(&CLVAR1) TYPE(*CHAR) LEN(3) RTVDTAARA DTAARA(MYLIB/DA1 (3 3)) RTNVAR(&CLVAR1) ENDPGM

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)

• Two levels of MONMSG command– Program level– Specific command level

PROGRAM LEVEL MONMSG:PGM PARM(&CALLER &PGM) DCL VAR(&CALLER) TYPE(*CHAR) LEN(10) DCL VAR(&PGM) TYPE(*CHAR) LEN(10) DCL VAR(&MSGKEY) TYPE(*CHAR) LEN(4) DCL VAR(&SENDER) TYPE(*CHAR) LEN(80) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))

ERROR: CHGVAR VAR(&CALLER) VALUE(' ') ENDPGM

SPECIFIC COMMAND LEVEL MONMSG:PGM MONMSG MSGID(CPF0001) EXEC(GOTO ERROR) CALL PROGA CALL PROGB RETURN

ERROR: SNDPGMMSG MSG(’A CALL command failed’) MSGTYPE(*ESCAPE) ENDPGM

COMMANDS

• SNDUSRMSG - Send a message to a user• SNDPGMMSG - Send a message to a message queue• SNDBRKMSG - Send Break Message

REPORT PROGRAM GENERATOR(RPG)

DISADVANTAGES OF CL OVER RPG

• Records can be read but can’t able to write or update or delete records.

• Only one file can be used in a CL program• Printer files can’t be used in CL• Subfile can’t be used in a CL program

RPG SPECIFICATIONS

Seven kinds of specifications are 1. Control specifications2. File description specifications3. Extension specifications4. Line counter specifications5. Input specifications6. Calculation specifications7. 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 program2. Date format for the program3. If an alternative collating sequence or file translation

is used.• Control Specification is optional

FILE DESCRIPTION SPECIFICATION

• File description specifications describe all the files that your program uses.

• The information for each file includes:1. Name of the file2. How the file is used3. Size of records in the file4. Input or output device used for the file

EXTENSION SPECIFICATIONS

• Extension specifications describe all record address files, table files, and array files used in the program.

• The information includes:1. Name of the file, table, or array2. Number of entries in a table or array input record3. Number of entries in a table or array4. Length of the table or array entry.

LINE COUNTER SPECIFICATIONS

• Line counter specifications describe the page or form on which output is printed.

• The information includes:1. Number of lines per page2. Line of the page where overflow occurs.

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 specified2. 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 Specification Type H Control F File description D Definition I Input C Calculation O Output P 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

RUN TIME ARRAY

• It is loaded by the program while it is running• The values will be dynamic• Keywords like ALT, CTDATA, EXTFMT, FROMFILE,

PERRCD, and TOFILE cannot be used for a 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 **************

COMPILE TIME ARRAY

• It is loaded when your program is created.• The initial data becomes a permanent part of your

program.• The value will be static• The array data will be present after the last

instruction of the RPG program

//Example code*************** Beginning of data******************

c*compile time arraydarr1 s 4 dim(3) ctdata perrcd(1)di s 2p 0 inz(1)c i do 3c arr1(i) dsplyc add 1 ic enddo c eval *InLr = *On

**ctdata arr11001201000****************** End of data ********************

PRE RUN TIME ARRAY

• It is loaded from an array file when your program begins running, before any input, calculation, or output operations are processed

• The data will be present in a file and using pre-run time array we can retrieve the data.

//Example

DARE S 5A DIM(250) PERRCD(12) ASCENDD FROMFILE(DISKIN)DARH S 5A DIM(250) PERRCD(12) ASCENDD FROMFILE(DISKOUT)D TOFILE(DISKOUT)C eval *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

READ RELATED OPCODE • READ (Read a Record)– C READ FILEA

• READC (Read Next Changed Record)– C READC SFCUSR

• READE (Read Equal Key)– C KEYFLD READE FILEA

• READP (Read Prior Record)– C READP FILEA

• READPE (Read Prior Equal)– C FieldA READPE FileA

READ RELATED OPCODE • CHAIN (Random Retrieval From a File)– C DEMPNO CHAIN EMPDTLPF

• IN (Retrieves Data Area) OUT (Write a data area)C *DTAARA DEFINE DATA1 SC *LOCK IN SC EVAL S=GC OUT S

• SETGT (Set Greater Than)– C KEY SETGT FILEA

• SETLL (Set Lower Limit)– C ORDER SETLL ORDFIL

WRITE,UPDATE, DELETE OPCODE

• DELETE (Delete record)– C Delete EMPDT

• UPDATE (Modify Existing Record)– CUPDATERECFMT

• WRITE (Create New Records)– C WRITE FILE1

CONDITION BASED OPCODE• DO(do),DOU(Do Until),DOW(Do While) end with ENDDO

(ending do)C DO 10 C FLDA DOUEQ FLDBC ENDDOC ENDDO

• FOR (For) will end with ENDFOR (end for)C for i = 1 to nC Eval factorial = factorial * iC endfor

• GOTO (Go To)– C GOTO END

CONDITION BASED OPCODE• IF(If) ELSEIF(Else If) ELSE(Else) ENDIF(Endif)

C FLDA IFEQ FLDBC ELSE C ENDIF

• ITER (Iterate) LEAVE (Leave a DO / FOR Group)C NUM DOWLT 10C *IN01 IFEQ *ONC EVAL *IN30 = *ONC LEAVEC ELSEC ITERC ENDIFC ENDDO

CONDITION BASED OPCODE

• SELECT (Begin a Select Group)C SELECTC WHEN X = 1* Sequence 1C WHEN ((Y = 2) AND (X < 10))* Sequence 2C OTHER* Sequence 3C ENDSL

SUBROUTINE RELATED OPCODE

• BEGSR (Begin Sub Routine)– C SUBRTB BEGSR

• LEAVESR (Leave a Sub Routine)– C LEAVESR

• ENDSR (End Sub-Routine)– C ENDSR SUBRTB

• EXSR (Invoke Sub-Routine)– C EXSR @CMD

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.

LOAD ALL SUBFILE

• SFLSIZE > SFLPAGE • All the records are loaded into the Subfile in

one shot and displayed.• Rolling options are taken care by the system.

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.

SINGLE PAGE SUBFILE

• SFLSIZE = SFLPAGE • The number of records that can be displayed

only is loaded into the subfile and then displayed.

• Roll back and Roll Forward is 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)

• %BINARYDCL VAR(&N) TYPE(*DEC) LEN(5 0) VALUE(107) DCL VAR(&B4) TYPE(*CHAR) LEN(4) CHGVAR %BIN(&B4) &N

• %SUBSTRINGDCL &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

top related