You are on page 1of 7

Open query file command (OPNQRYF) is

used to open a file that contains records which satisfy a specified request.
some of the requests which can be made on this command are: Query select , Key fields ,
Grouping .
To use open query file ,use the following sequence of commands:
1).OVRDBF : Here specify name of the file being override. Override the file being opened
to SHARE(*YES). IF YOU DO NOT USE share ODP,the file will be reopened by the next
program that uses it (the OPNQRYF results will be ignored) .
2).OPNQRYF: issue the open query file command.
3).CALL :invokes the high-level language that will process the selected records.
The Open Query File (OPNQRYF) command opens a file to a set of Database records that
satisfies a database query request. Once opened, the file looks like a database file
opened using the Open a database File (OPNDBF) command, and the records in the file
are the records in the file are accessed by high level language programs that share the
open data path (OPD).
OPNQRYF : command acts as a Filter between the processing program and the Database
Records. It will Create Open Data Pathway to Access (Retrieve) data file.
How the records are accessed for using OPNQRYF?
By creating ODP to access (retrieve) data file.( open data pathway )
Open Data Path : It Connects the Program to a File.
An Open Data Path is built whenever a file is opened by any particular program.
An Open Data Path doesnt contain any records at all .
Q) How can we Select / Omit records through OPNQRYF?
You can Specify Select criteria in OPNQRY file to select a Record.

JobLog: It is a log of a particular job .


which consists of all the commands executed for the particular job.
CLP : is OPM ( Original Program Model) While
CLLE : is ILE .
In CLP creation of program is one step while
in CLLE it is two step ( we have to create a module and then bind it with program) .
in CLLE activation group concept is available.
Level check error for a File while executing program:
When any file is compiled , it generates a UNIQUE record level identifier . when the
program is compiled it keeps that UNIQUE no. Next time when the file is modified and
compiled , another UNIQUE no is generated. If now the program is not compiled , the
numbers mismatch and gives Level Check error.
MONMSG :
Program-level MONMSG is coded at the beginning of CL pgm .
MONMSG command can be coded after the last DCL statement , or if there are no DCLs ,
right after the PGM statement .
Program-level MONMSGs can only have GOTO in the EXEC parameter .No other
commands are allowed.
Program-level MONMSG can only have GOTO in the EXEC parameter .
Command-level MONMSG dont have any valid parameter on EXEC parameter .
Command-level MONMSG: When the MONMSG command is coded immediately after
another command , the MONMSG applies to that command only.
If both Program-level and Command level MONMSG are coded , the program uses the
Command-level MONMSG . if the error condition is not covered by the Command level
MONMSG , the Program then refers to the Program-level MONMSG.
Syntax :
MONMSG

MSGID(message-id) CMPDTA(comparision-data) EXEC(CL-Command)

Data Area Advantages : 1) CL can change the contents of data area while it cannot
change the contents of PF 2) Programs can access many data areas. 2) Data area need
not exist at program creation time3) Data area need not exist at program creation time4)
No DDS requires created using CRTDTAARA command.5) Needs no declaration.
CHGDTAARA DTAARA(lib/data area-name (sub string-starting-position string length))
VALUE(new value).
RTVDTAARA DTAARA(lib/data area-name (sub string-starting-position string length))
RTNVAR(&CL-var-name).
SBMJOB and LDA
When SBMJOB is used to submit batch job, the submitting jobs *LDA is copied to batch
jobs LDA.
LDA is used to : 1) To pass values from one program to another with in a job.
To pass values from a calling program to a batch job.
Once you submit job by using SBMJOB command, You can be able to find the Job
Running in Batch Jobs and as well you can find the same in WRKSBMJOB(you can find
the latest one at the bottom(Shift+F6)). As soon as you submit the Job, the status will be in
JOBQ(waiting to run), While Job running in BATCH the status will be in ACTIVE(currently
in progress), After the Job finished, The status of the Job will be 'OUTQ' So, You can
consider the Job has finished when the status becomes OUTQ. If you want to see the
details of that Job, You can use option 5(Work with), You can see the Job status Attributes
and Job log in detail. Pradeep.
DSPRCDLCK command is used to know whether the record was locked or not .

Questions & Answers


1) what is OPNQRYF ?
2) JOBLOG mean ?
3) CL vs ILE CL ?

OPNQRYF : command creates a Sharable Open data path to the file through
which data can be accessed by an HLL program .
OPNQRYF produces an Open Data Path but not an Output file.
OPNQRYF command Selects , Sorts, and process data to an HLL program in a
manner specified by the user at program Runtime . it can even create new
fields and summarizes data and passes it to the HLL program for processing as
well .
Uses : 1) Select a subset of available records 2) Order records by the value of
one or more fields
Functions of OPNQRYF: 1) Dynamic Record Selection 2) Dynamic Keyed
Access Path 3) Dynamic Join Function 4) Unique Key Processing 5) Mapped
field definitions 6) Group and final total processing 7) Optimization Options .
SHARE(*YES) :To allow several programs within a single Job to share
the same Open Data Path to a file , specify SHARE(*YES) on the
OVRDBF command .
We can also specify SHARE(*YES) when a database file is created .in this case ,
the file with share its open data path by default and will not require an override
to do so.
If you dont specify SHARE(*YES) iF YOU DO NOT USE share ODP,the file
will be reopened by the next program that uses it(the OPNQRYF results will be
ignored)
JLF Vs OPNQRYF :
An open data path is created when a file is opened. So data retrieving is so
faster compare to JLF. 2)
Dis Advantage of OPNQRYF : Here you create one more data base file to
store data,but it is not necessary in case of JLF.
Open Options : 1. *ALL 2. *INP 3. *OUT 4. *UPD 5. *DLT
*INP :
Open the file for input. *INP is the only value allowed if join processing or
group processing is requested, if UNIQUEKEY processing is specified, or if
all the fields in the open query file record format specified on the Format
specifications prompt (FORMAT parameter) are for input-only use.
*OUT

Open the file for output. It is the combination of input and update
operations.
POSITION keyword : of the OVRDBF command lets us specify where
processing should start when a file opens .
When an error condition occurs during the execution of a program,an
escape
message(*ESCAPE)is sent to the program.escape
messages identifies the specific error that are occurred.

When exception handler is written in the program then such messages


with the
popup of ugly screens can be avoided.

Error messages are stored in a message file. IBM supplied file is


(WRKMSGF)QSYS/QCPFMSG.

Errors that result in escape messages can be monitored using MONMSG


command.
MONMSG command can be specified at command level and a program
level.
Message identifiers have three charter prefix allowed by four position
ID.
CPF0000
RCVMSG message can be used to receive escape message sent to CL
program.the message that can be resent using SNDPGMMSG command.
The monitor message(MONMSG) command is used to monitor escape
messages,notify,and status messages sent to the program message
Queue of the program in which the command being used.
Up to 1000 MONMSG commands can be specified in a program.
When a MONMSG is compiled in a control language (CL) program, it
establishes a monitor for the arrival of the specified messages.
The specific message identifiers or generic message identifiers can be
monitored.
When the action specified in the MONMSG command has been
performed, and that action does not end with a GOTO or RETURN
command,control returns to the command in the program that follows the
command that sent the message.
The action ends with a GOTO command,control branches to the
command in the program specified in the GOTO command.if the action
ends with a RETURN command,control returns to the program that called
the program that contain the MONMSG command.
When using program level MONMSG the EXEC parameter if specified can
contain only GOTO command.

EXAMPLE:

1.

MONMSG

MSGID(CPF0000 CPF0864 ) EXEC(GOTO CMDLBL(END))


OR

/*

MONMSG CPF0864 EXEC(GOTO (END))


OR

/*
MONMSG CPF0864 *N RETURN
DIRECTLY GOES TO THE RETURN )

2.

*/

----

(HERE CONTROL

CHGVAR MSGID(CPF9801) EXEC (CHGVAR (&A) VALUE (1))

*/

3. ADDLIBLE LIB(LIBRARY NAME)


MONMSG CPF1023

NOTE:
ADDLIBLE- Add Library List Entry

job queue is an object(*JOBQ) where batch jobs wait in line for there
turn at batch processing.u can hold,release or assign higher priorities for
jobs in the JOBQ.
LIBRARY LIST provides the search path to locate the objects specified
in he job.

/* PGM FOR RETRIVING SYSDATE*/

PGM

DCL

VAR(&USER) TYPE(*CHAR) LEN(10)

DCL

VAR(&DATE) TYPE(*CHAR) LEN(6)

DCL

VAR(&TIME) TYPE(*CHAR) LEN(8)

RTVJOBA

RTVSYSVAL SYSVAL(QDATE) RTNVAR(&DATE)

RTVSYSVAL SYSVAL(QTIME) RTNVAR(&TIME)

SNDUSRMSG MSG(&DATE)

SNDUSRMSG MSG(&TIME)

SNDUSRMSG MSG(&USER)

USER(&USER)

ENDPGM

___________

5./*PGM USING DATA BASE FILES*/

**CAT(||)=CONCAT|*BCAT(|>)BLANK WITH TRUNCATE|*TCAT(<|)TRU


&BLKS**/

PGM

DCLF

FILE(MINDADB/READPHY) RCDFMT(RECFMT)

DCL

VAR(&SALC) TYPE(*CHAR) LEN(15)

DCL

VAR(&MSG) TYPE(*CHAR) LEN(55)

LOOP:

RCVF

RCDFMT(RECFMT)

MONMSG

CHGVAR
CHGVAR

MSGID(CPF0864) EXEC(GOTO CMDLBL(END))


VAR(&SALC) VALUE(&EMPSALARY)
VAR(&MSG) VALUE(&EMPNUMBER |> &EMPNAME |>

&SALC )

SNDUSRMSG MSG(&MSG)

GOTO

END:

ENDPGM

CMDLBL(LOOP)

You might also like