Q: How we define Data area that will specify a default date format of *YMD, and a default date separator /
By defining CRTDTAARA keyword, we can create data area. Below is the command for data-area with default data format *YMD and default Separator/ .
CRTDTAARA DTAARA(MYLIB/RPGLEHSPEC)
TYPE(*CHAR)
LEN(80)
VALUE('datfmt(*ymd) datedit(*ymd/)')
Q: How we will check whether job is batch or interactive?
RTVJOBA PARM (&JOBTYPE)
&JOBTYPE is a 1-character field that contains
'0' (zero) means batch or '1' refers to an interactive job.
Q: How can we run a Batch Job?
SBMJOB Command.
Q: Is PGM keyword mandatory?
PGM keyword is an Optional. It becomes mandatory when we need to pass parameter to the CL program.
Q: Use of OVRDBF command with syntax?
Override with Database File (OVRDBF) command is used to
· Replace the file name in the program.
· Override certain parameters of a file that are used by the program.
Syntax:
OVRDBF FILE (overridden-filename) TOFILE (new-filename) MBR (member-name)
Q: What is an OPNQRYF in CL
· OPNQRYF command creates a temporary file access path and will discard the access path after its use.
· It can be used to sort records in order, selecting a subset of available records, grouping records or joining records.
Q: How we can update the records in CL?
·
we cannot update the records in CL.
·
we can do it by RUNSQLSTMT (update).
Q: How we can find out the job name and other job details in CL?
We can find the job name
and other job details by using the RTVJOBA (Retrieve Job Attributes) command.
Q: Why would the PGM line contain a PARM?
PARM is used to pass parameters.
Q: How we read multiple
files in CL?
By using OPNID we can
read multiple files in the CL program.
EX:
DCLF
FILE(LIBNAME/FILENAME1) OPNID(FILE1)
DCLF
FILE(LIBNAME/FILENAME2) OPNID(FILE2)
Q: What does CL stands for in AS400?
CL stands for Control Language, which is used
to call system functions and control operations.
Q: Maximum no of parameter
passed in a CL?
255.
Q: What is
the difference between the DOU and DOW operation codes?
DOW – Checks the condition
before executing the loop
DOU - Checks the condition
After executing the loop
Q: How we declare variables
and files in CL?
DCL, DCLF
EX:
DCL VAR(&VARIABLE1) TYPE(*CHAR) LEN(8)
DCLF FILE(FILENAME1) RCDFMT(*ALL)
Q: What are the data
types available in CL?
*CHAR-Contains character string value
*DEC -Contains decimal value
*LGL- Contains '1'/ '0'
Q: If the field is defined
in DDS, how is it referenced in a CL program?
DCL VAR(&VARNAME)
Q: What are the CL
commands used to process the files, variables used in the program.?
OVRDBF, CHGVAR, SNDPGMMSG
Q: What are logical control
commands used in CL?
IF, THEN,
ELSE, DO, ENDDO, DOWHILE, DOUNTIL, DOFOR, LEAVE, ITERATE, GOTO, WHEN,
OTHERWISE, ENDSUBR.
Q: Can you add a record to
file thru CL?
NO
Q: How do we change the
value of a particular variable in CL?
By using
CHGVAR keyword.
EX: CHGVAR
VAR(&VARIABLENAME) VALUE('VALUE')
Q: Define ITER / LEAVE?
·
ITER: Transfer
the control before do loop.
·
LEAVE: Transfer the control after do loop.
Q: What are the statements, which is
not used in CLLE that is used in CLP?
·
RCLRSC which is replaced by RCLACTGRP
·
TFRCTL
Q: CL processing commands
& program control commands?
PROCESSING
commands are CHGVAR, SNDPGMMSG, OVRDBF, AND DLTF.
PROGRAM
CONTROL commands are CALL, RETURN, TFRCTL
Q: Define indicator in CL?
We can set
on or setoff the indicator by the command.
·
CHGVAR (&IN40) VALUE
(‘0’) ->setoff
·
CHGVAR (&IN40) VALUE
(‘1’) -> seton
Q: What is QCMDEXC command in CL how it helps?
·
QCMDEXC is an API to
Execute Command.
·
This API used to run a
command from within a high-level language.
·
After the command runs,
control returns to your High-level language program.
Q: What are the various stages for a
job after it is submitted?
Job queue, Active job, an OUTQ
is the three stages after the job has been submitted.
Q: How to see active jobs of the
system.
Using WRKACTJOB command
Q: How to see the CPU usage?
WRKACTJOB or WRKSYSSTS
Q: What is JOBQ and PRINTQ?
·
Jobs go into the job queue in order to run in a
subsystem.
·
Print queue where the printer files (report) reside
and wait for their turn to get printed.
Q: Built in function in CL?
·
%SUBSTRING or %SST
The
built-in sub-string function generates a character string which is a subset of
an existing character string and can only be used with a CL program.
%SUBSTRING
(Character-variable-name Starting-position length)
Or
%SST (Character-variable-name
Starting-position length)
·
%SWITCH
Q: What is PWRDWNSYS?
The PWRDWNSYS command used Power down, which
prompts the system to issue ENDJOB * IMMED for all system operations, followed
by System Termination.
Q: String operation in CL?
*CAT ->Concatenate without editing.
*BCAT-> Trailing blanks are truncated in
first string. One blank is
inserted, and the second string is then concatenated. The second operand
lead blanks are not truncated.
*TCAT->All trailing blanks are truncated
in the first string, and the second string is concatenated afterwards. Any
Second Operand leading blanks are not truncated.
Q: What is the
difference between CALL and Transfer Control (TFRCTL)?
CALL |
TFRCTL |
Call transfers the control as per CALL STACK |
Transfer Control (TFRCTL) will disable the CALL
STACK and transfer the control to the calling program. |
The CALL is used to different types of programs. Ex:
RPGILE/400,CL/400,C/400,COBOL/400. |
TFRCTL is used only in the CL programs.
|
Q: What is DSPMSGD?
Display’s
all messages in message file with its basic message description.
Q: What CL command is
used to read a file?
RCVF - Receive File
Q: How can you read a file
in CL?
·
We can read a file by using
RCVF command.
· To read all the records
until we reach EOF, we should use RCVF followed by MONMSG command
with MSGID (CPF0864) followed by GOTO command label to branch and prior to
RCVF command.
Q: What CL command is
used to determine the logical files associated with a physical file?
DSPDBR
(Display Database Relations)
Q: How can you set lower
limit to a file in CL?
·
POSDBF set to '*Start' with
'File Position' parameter.
·
OVRDBF which enables the
file to be set to Key Value, RRN or * START
Q: Which CL command to
write file?
SNDF -
Send File
Q: Which CL command is
equivalent to write/read a display file in RPG?
SNDRCVF -
Send/Receive File
Q: How we can share access path?
To share
the access path we create an open data path in our CL program with OPNQRYF
command and later we share this ODP with the called RPG program.
OVRDBF FILE (FILENAME1)
TOFILE (LIB/ PF) SHARE
(*Yes)
OPNQRYF FILE(libname/filename
+
Member-name +
Record-format-name) +
OPTION(open-option) +
FORMAT(lib
name/database file name +
Record-format
name) +
QRYSLT(query
selection) +
KEYFLD(field
name)
Q: Difference between
logical file and OPNQRY?
·
The main difference between
logical file and OPNQRY is that a logical file is a permanent entity and
OPNQRYF is not.
·
Any time we use the same
sort order it is safe to use LF. If we
need multiple sorting orders / random scanning, then OPNQRY will go.
Q: How will you plan the procedure
for a method of delivering regular, high volume checks that only needs to pick
records that are flagged for processing?
With the help of OPNQRYF command, we can select the
records from database file.
Steps involved:
1. OVRDBF with SHARE (*YES)
2. OPNQRYF
3. CALL the program
4. DLTOVR
5. CLOF
Q: what does Return command do in CL?
The Return
command (RETURN) returns control in call stack to the next higher call stack
entry.
Q: How we retrieve data
area in CL?
The
command RTVDTAARA is used to retrieve the data area and store the value in a CL
Variable.
Syntax:
RTVDTAARA DTAARA(DATAAREANAME) RTNVAR(&CLVAR1)
Q: How we can find out, how
many records in a file through CL.
The command Retrieve Job Attributes (RTVJOBA) is used to
figure out how many records a file holds.
Example to
retrieve the message queue name and library name
RTVJOBA
SBMMSGQ(&MSGQ) SBMMSGQLIB(&MSGQLIB)
Q: Command to retrieve a
specific member in a file?
The
command RTVMBRD retrieves a specific member 's description.
Q: How we retrieve system
date in CL?
We can get values like
date, time, month, year, day, century using RTVSYSVAL Command.
Q: How can you schedule a job to run on a regular basis?
We need to create a job
scheduler to run a job on a regular basis. We can create a job scheduler using
the ADDJOBSCDE command. We can list all job schedulers running by using the
WRKJOBSCDE command, and we can delete a job scheduler by using the RMVJOBSCDE
command, or we can delete a job scheduler by using the RMVJOBSCDE command. We
can reschedule the job by using CHGJOBSCDE.
Q: How can you check the
date in CL?
By using command CVTDAT.
Q: What is command to
convert date format in CL?
CVTDAT
Q: What is command to Write
or update to a database file in CL?
No such command
exists in CL to write / update in CL database File.
Q: What is the command used for retrieving user profile attributes?
RTVUSRPRF
Q: What is data area and
different types of data areas in CL?
·
Data area used to store the
shared data of different jobs running on the system.
·
It is generated/created by
using the command CRTDTAARA.
Q: Different types of data areas in CL?
Types of
data area:
1) User
defined data area
2) System
defined data area
·
Local data area (LDA)
·
Group data area (GDA)
·
Program initialization
parameter (PIP) data area.
Q: What type and length of LDA is?
*CHAR, 1024 bytes
Q: What is GDA?
The system creates a GDA when group jobs become an
interactive job. For group only one GDA may exist.
Q: Command to create the
data area?
CRTDTATARA
Q: How do you access the
local data area in a CL program?
RTVDTAARA
DTAARA (*LDA) RTNVAR (&VAR)
Q: What are the various
steps involved in accessing Data Area in CL?
·
RTVDTAARA Retrieve
data area
·
CHGDTAARA Edit
data area
·
DSPDTAARA To view/ display data area
Q: What is a Message and
types of messages?
Message is
information communicated among users, programs, and workstation. 2 types of
messages:
1) Impromptu/Immediate
message
2) Predefined
message
Q: How can a programmer
send a message from a CL program?
Using
SNDPGMMSG (Send Program Message) command
Q: What is a Message Queue?
·
Message queues can be used
to send & receive messages.
·
We store messages received
by user, system or workstation in the storage pool and take the appropriate
action according to the message and send them back to the user / application /
workstation.
Q: What are different Types
of message queues?
Different
types of message queues:
·
Workstation message queue
·
User profile message queue
·
Job message queue
·
System operator message
queue
·
History log message queue
Q: Explain QSNDDTAQ and QRCVDTAQ?
QSNDDTAQ
• By using this command we can send data same / another program.
• QSNDDTAQ PARM (QUEUENAME LIB &LEN &DAT)
QRCVDTAQ
• By using this command we can receive data same /another program
• QRCVDTAQ PARM(QUEUENAME LIB &LEN &DAT &WAIT)
Q: What are the mandatory parameters for declaring a Data queue?
• QUEUE NAME
• LIB NAME
• LENGTH
• DATA
• WAIT
Q: How we trap
error/exception handling in CL?
MONMSG
command.
Q: What is the MSGID to
know the EOF (end-of-file)?
CPF0864
Q: Specify levels of MONMSG
Command?
Two levels
of MONMSG Command.
1.
Program
level: The MONMSG is
specified in CL program immediately following the last declared command.
2.
Specific
command level: We will write the
MONMSG command immediately and a CL command follows.
Q: MSGID to catch all
generic messages ins CL?
MONMSG MSGID
(CPF0000)
Q: What's a Output queue ( *OUTQ?)
An area, which stores all spooled files waiting to be printed.
Q: What's a Job queue (* JOBQ?)
An area that stores all jobs waiting to be compiled.
Q: Explain parameter
passing.
To pass
variables from a CL or RPG program to another program.
Q: How can programmer exit
out of CL program?
RETURN
command.
Q: Can we perform any
action on trapped MONMSG? Explain with an example.
Yes, we can perform an
action on the trapped error messages
Ex: Whenever we receive an
MSGID CPF9801, we are redirecting to ERROR command Label to execute.
MONMSG MSGID(CPF9801)
EXEC (GOTO CMDLBL(ERROR))
Q: How we get to know check
object is failed, what is the MONMSG ID.
The
command Check Object (CHKOBJ) used to check the existence of an object and
verifies the authority of the user for the object before attempting to access
it. If the object appears and the user does not have the correct authorization
for the object, the user is given error messages.
CPF9801
Object &2 in library &3 not found.
CHKOBJ OBJ(LIBNAME/FILENAME)
OBJTYPE(*FILE) MBR(*FIRST)
MONMSG MSGID(CPF9801)
EXEC (GOTO CMDLBL(ERROR))
Q: Can we reposition file
pointers in CL after reaching EOF? Explain how it works?
Yes, we
can reposition the pointer to the file. Upon reaching EOF, or CLOSE command.
The CLOSE command closes the file but the file is opened when the next RCVF
command is found and the first record from the file is read.
Comments
Post a Comment