AS400
AS400
org/__Suppose-I-have-3-jobs-A-B-and-C-I-want-to-submit-B-after-
successful-completion-of-A-and-want-to-subm
http://as400qa.blogspot.com/2010/01/how-many-ways-you-can-copy-records-cpyf.html
4) Product library – when IBM product is used it is added to the library and removed
automatically.
Source Physical file – this will have the source of different types of objects.
Physical file:
1) File level entries – gives the information about the file.
Unique – a new record cannot be entered if that have the key value same as that of the existing
key value.
FIFO – the duplicate records will be retrieved in First in first out order.
LIFO – the duplicate records will be retrieved in Last in first out order.
FCFO – the duplicate records will be retrieved in First changed first out order.
REF – to specify the name of the file from which fields are taking definition.
2) Record format level entries
3) Field level entries
4) Key field level entries
Logical file:
This selects data dynamically. It refers to the data present in the physical file.
1) Non-join logical file – it can be single member/ multi member. DYNSLT keyword is used at file
level identifier in order to use select/omit condition in the logical file. DYNSLT occurs when the
program reads the file.
2) Join logical file –
JFILE – files need to be joined
JOIN – the order in which the files need to be joined
JFLD – common field in both file
JDUPSEQ – the field in which the duplicate data needs to be organized
JREF – reference field of primary file
Command in AS400:
CRTLIB
DSPLIB – This will give the list of objects present in library and within this we can check each
objects size, journaling details.
DSPLIBL – this will give the list of libraries. Here it will also show the type of that library.(whether
user or system, etc)
EDTLIBL – to edit the library list order.
ADDLIBLE – here we can directly specify whether to add our library. (whether first or last)
CRTSRCPF
DSPFD – this will have all the details regarding the source physical file. This will have details like
access path details, file level identifier, record level identifier, no. of records present, no. of
members present, etc.
DSPFFD – this will have only the file level information like record format, number of fields,
record length.
CRTPF
CHGPF
CHGPFM
DSPPFM – we can see the data present in that member.
ADDPFM
RGZPFM – the data in the file is inserted sequentially. So when records in between is deleted,
then that spaces will be left un-used, until we use RGZPFM which re-organize the space.
CHGLF
ADDLFM
DSPDBR – displays dependent member of the file.
CPYF – the below operations can be done using this command.
1) The fields from one file will be copied to another file.
2) The to file can be created even during the copy operation.
3) We can even specify the condition while copying records. (We can specify that
data with emp no 1 to 3 alone should be copied to a new file)
4) Record format field mapping –
*MAP & *DROP – if the to-file have a field which is not present in from-file,
then these keywords are used to specify default values or null values to the
fields in to-file. Map and drop come together.
*NOCHK – if the record formats are not matching for from and to file, then just
to copy data from from-file to to-file without any regard to field types, we will
use this function.
RTVMBRD – with this we can retrieve the details of a member. This also helps in retrieving the
record count of a file in CLLE.
CPYFRMIMPF
CPYTOIMPF – a file will be stored as a stream file which will have delimiter which can be
specified.
CPYF Vs CRTDUPOBJ:
With the use of CPYF, we can even select data based on fields or RRN and even we can copy data
between files which do not have the same format. CRTDUPOBJ just create a duplicate version of the
from object as it is.
Access Path:
It describes the order in which record is to be read. It can be either permanent (logical or
physical file) or Temporary (OPNQRYF).
Arrival sequence access path – based on the RRN number file will be read
Keyed sequence access path – based on the contents in the key field. Three ways to maintain it.
When emp1 field is key field in file1 and file2. When a change is made to emp1 field in file 1
and during that time file2 is not open. In that case how the access path will be maintained:
1) *Immed – this will update the changes irrespective of the file2 being open or closed.
2) *Re-Build – this will wait until the file2 is being opened and once it is opened, the data
will be updated. The system will stop collecting the data if the file is closed.
3) *Delayed – this will wait until the next time when the file is opened and it should be
remains open. In this, the system will collect all the data in between the file being closed
and opened again and make the changes after it is being opened.
Arrays:
Compile time array – the elements in the array is loaded before execution.
The keywords used are DIM – Dimension of the array
CTDATA – represents that it is Compile time array
PERRCD – no. of entries in one array record.
Run time array – the value will be loaded during the run-time.
Eg: Darr1 S 3P 0 DIM(5)
Pre-run time array – we will have array element in a separate file. This file should be declared in
F spec with T as File designation entry.
Eg: FFile1 IT F 5 DISK -------- 5 defines the length of the record. ie. col * size of 1 elmnt.
Darr1 S 3P 0 DIM(5) FROMFILE(FILE1) PERRCD(1)
Dim – row*col
Perrcd – col
RPGLE Opcodes:
XFOOT – to sum the array elements
Data structure:
Structure of different data types.
1) Program described
2) Externally described
3) Multiple occurrence
4) Indicator
5) Data area
6) Program status
7) File information
Jobs:
System jobs – the system itself runs job to generate spool file
User jobs –
FTP steps:
To transfer data between two AS400 systems
Journaling:
It is a process of recording activity.
Steps:
CRTJRNRCV
CRTJRN
STRJRNPF
Types of subfile:
1) Load all subfile – SFLSIZ > SFLPAG
2) Single page – SFLSIZ = SFLPAG
3) Expandable
Cursor:
A temporary set created in the system when embedded SQL is used. It can hold more than one
rows but can only process one row at the time.
Sequential cursor – defined without SCROLL keyword and each row is fetched only once.
Scrollable cursor – defined with SCROLL keyword and rows can be fetched many times.
Interview Questions:
1) What is decimal data error
Decimal data error occurs when any junk data is moved to the numeric field. When we use
eval for the same, it will throw compilation error. If we use move then it shows decimal data
error.
2) What will happen if we don’t give *INLR in RPGLE
LR – Last Record. This just a way to tell the program that last line of the program have
reached and when i exit the program, it can close all the files.
When we write any code lines after *INLR, even then it will execute those lines.
If we don’t give *INLR in the program, it will not throw any error, instead program keeps running
infinite times without knowing when it should end.
On the other hand Return opcode will just return to the calling program without releasing any
files used. Any code after this function will not be processed.
3) What is the difference between %CHECK and %SCAN
%Scan – this will find the position of the string given in the first field is present in the second
field.
%Check – this will check the position of where the string in first field is not matching with the
second field.
Eg: fld1 = ‘abcdef’
%scan(‘bcd’:fld1) – o/p – 2
%check(‘bcd’:fld1) – o/p – 1
Here %check returns 1 bcoz, it will start checking for the string bcd in fld1. It will find in frst
position it’s a and it does not match with bcd. So it returns the first position which does not
match.
4) What is session device error
When we try to load empty subfile, when we try to load more than 9999 records for load all
subfile, the system throws session or device error.
5) Dynamic/Embedded SQL
Steps:
Exec SQL
Declare the cursor – Declare C1 cursor for SQL statement
Open the cursor – Open C1
Fetch the value – Fetch C1 into :fields to which data needs to be loaded
Validating the SQL records – SQLCOD=0/100/negative
Fetch the next record
Close the cursor – Close C1
End Exec
6) Difference between Move and Eval
Move – it just moves data from one variable to another irrespective of the data type.
Eval – it moves the data from one data type to another only when both are of same data
type. And this initializes the variable and then it moves the values.
7) Difference between CPYF and CRTDUPOBJ
With the use of CPYF, we can even select data based on fields or RRN and even we can copy
data between files which do not have the same format. CRTDUPOBJ just create a duplicate
version of the from object as it is.
DSPFD
11) What are the 2 commands used to debug a program and one of the command can be used in
interactive debug alone
12) How to read file in CL
Declare – DCLF
Read – RCVF
SETLL – We can use OVRDBF to specify the position of the pointer
Write – RUNSQL
When we need to use multiple files in CL, then we declare the file with OPNID and use this
OPNID during reading the files.
25) Can we read a file in RPG without using SETLL, READ and CHAIN
Yes. We have multiple ways to do it.
We can use pre-run time array.
File information data structure
Primary file as file designation
26) Difference between bind by copy and bind by reference
27) What is the importance of MAPFLD in OPNQRYF
28) Difference between ITER and DO
29) What is parsing
30) Scripting language
31) Impact analysis of a program
32) If prg a calls prg b and then prgm c in one activation group, and prg b calls prg c in another
activation group. In which activation group does prgm c runs first
33) How to display empty subfile
34) What is level check means
35) If a file has the data as below
Shrey
Shrey
Shrey
John
John
Kaviya
Kaviya
Here, how to write a code in RPGLE where it only reads the file three times.
READ
READ
JOHN SETGT
READ