as-400
TRANSCRIPT
![Page 1: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/1.jpg)
AS/400 or IBM i-series or System i
![Page 2: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/2.jpg)
Application System/400
• Layered machine architecture• Distributed Processing• Object orientation• Single-level storage• Hierarchy of microprocessors• Security levels
![Page 3: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/3.jpg)
OPERATING SYSTEM
• Operating system used in AS/400 is OS400• Object-Based • Programming Languages - RPG400, CL400, Cobol400, Java 400, SQL 400,
etc.
![Page 4: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/4.jpg)
SECURITY
Various Security provided by the system• No security• Password security• Resource security• OS security• C2 level security
![Page 5: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/5.jpg)
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.
![Page 6: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/6.jpg)
LIBRARY LIST
System library- 15 (QSYSLIB)– QSYS– QHLPSYS– QUSRSYS
Product library –2 Current library –1 User library - 25 (QUSRLIB)– QGPL– QTEMP
![Page 7: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/7.jpg)
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
![Page 8: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/8.jpg)
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
![Page 9: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/9.jpg)
DATABASE
![Page 10: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/10.jpg)
DATABASE FILES
• Source File • Physical File• Logical File
![Page 11: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/11.jpg)
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
![Page 12: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/12.jpg)
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
![Page 13: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/13.jpg)
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
![Page 14: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/14.jpg)
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.
![Page 15: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/15.jpg)
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‘)
![Page 16: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/16.jpg)
LEVELS OF ENTRIES IN PHYSICAL FILE
• Field level entriesCHECK, COLHDG, DATFMT, REFFLD, VALUES, VARLEN,
etc.
• Key field level entriesDESCEND, SIGNED, ABSVAL, UNSIGNED, ZONE, etc.
![Page 17: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/17.jpg)
VALID DATA TYPES
A CharacterP Packed decimal S Zoned decimal B Binary F Floating point H Hexadecimal L Date T TimeZ Timestamp
![Page 18: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/18.jpg)
// 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 ********************
![Page 19: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/19.jpg)
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.
![Page 20: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/20.jpg)
TYPES OF LOGICAL FILE
• Non-Join logical file• Join logical file
![Page 21: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/21.jpg)
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)
![Page 22: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/22.jpg)
LEVELS OF ENTRIES IN LOGICAL FILE
• JOIN Level entriesIt is not applicable to NON JOIN LOGICAL FILES• Select / Omit level entries
![Page 23: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/23.jpg)
// 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 *****************************
![Page 24: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/24.jpg)
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.
![Page 25: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/25.jpg)
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
![Page 26: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/26.jpg)
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.
![Page 27: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/27.jpg)
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)
![Page 28: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/28.jpg)
LOCK
• It helps to give the access permission for database file.
• Types of lock —Share lock—Exclusive lock
![Page 29: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/29.jpg)
CONTROL LANGUAGE (CL)
![Page 30: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/30.jpg)
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
![Page 31: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/31.jpg)
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
![Page 32: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/32.jpg)
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.
![Page 33: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/33.jpg)
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.
![Page 34: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/34.jpg)
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.
![Page 35: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/35.jpg)
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)
![Page 36: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/36.jpg)
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,&,|,¬
![Page 37: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/37.jpg)
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
![Page 38: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/38.jpg)
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
![Page 39: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/39.jpg)
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.
![Page 40: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/40.jpg)
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.
![Page 41: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/41.jpg)
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
![Page 42: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/42.jpg)
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)
![Page 43: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/43.jpg)
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
![Page 44: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/44.jpg)
MESSAGE
• Message is the interface between operating system and the programs or user and program.
• Immediate message• Predefined message• Monitor message(MONMSG)
![Page 45: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/45.jpg)
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’
![Page 46: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/46.jpg)
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.
![Page 47: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/47.jpg)
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
![Page 48: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/48.jpg)
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
![Page 49: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/49.jpg)
COMMANDS
• SNDUSRMSG - Send a message to a user• SNDPGMMSG - Send a message to a message queue• SNDBRKMSG - Send Break Message
![Page 50: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/50.jpg)
REPORT PROGRAM GENERATOR(RPG)
![Page 51: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/51.jpg)
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
![Page 52: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/52.jpg)
RPG SPECIFICATIONS
Seven kinds of specifications are 1. Control specifications2. File description specifications3. Extension specifications4. Line counter specifications5. Input specifications6. Calculation specifications7. Output specifications.
![Page 53: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/53.jpg)
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
![Page 54: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/54.jpg)
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
![Page 55: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/55.jpg)
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.
![Page 56: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/56.jpg)
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.
![Page 57: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/57.jpg)
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.
![Page 58: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/58.jpg)
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
![Page 59: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/59.jpg)
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
![Page 60: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/60.jpg)
Entry Specification Type H Control F File description D Definition I Input C Calculation O Output P Procedure
![Page 61: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/61.jpg)
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
![Page 62: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/62.jpg)
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
![Page 63: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/63.jpg)
//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 **************
![Page 64: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/64.jpg)
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
![Page 65: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/65.jpg)
//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 ********************
![Page 66: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/66.jpg)
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.
![Page 67: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/67.jpg)
//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
![Page 68: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/68.jpg)
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
![Page 69: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/69.jpg)
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
![Page 70: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/70.jpg)
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
![Page 71: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/71.jpg)
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
![Page 72: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/72.jpg)
WRITE,UPDATE, DELETE OPCODE
• DELETE (Delete record)– C Delete EMPDT
• UPDATE (Modify Existing Record)– CUPDATERECFMT
• WRITE (Create New Records)– C WRITE FILE1
![Page 73: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/73.jpg)
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
![Page 74: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/74.jpg)
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
![Page 75: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/75.jpg)
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
![Page 76: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/76.jpg)
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
![Page 77: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/77.jpg)
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
![Page 78: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/78.jpg)
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
![Page 79: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/79.jpg)
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
![Page 80: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/80.jpg)
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.
![Page 81: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/81.jpg)
SUBFILES
![Page 82: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/82.jpg)
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
![Page 83: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/83.jpg)
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.
![Page 84: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/84.jpg)
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.
![Page 85: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/85.jpg)
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.
![Page 86: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/86.jpg)
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
![Page 87: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/87.jpg)
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.
![Page 88: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/88.jpg)
SPOOL FILE
• It helps to manage data targeted for externally attached devices.
• Holds output data until it can be printed.
![Page 89: As-400](https://reader034.vdocuments.us/reader034/viewer/2022050623/54515883b1af9f6b1a8b48e1/html5/thumbnails/89.jpg)
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