Вы находитесь на странице: 1из 12

1. How do you handle Inter process communication in AS/400?

• Parameters
• Data Queue
• Data Area

2. What is a data queue? What is a message queue?

Data queues are a type of system object that you can create, to which
one HLL
procedure or program can send data, and from which another HLL
procedure or
program can receive data. The receiving program can be already
waiting for the
data, or can receive the data later.

The advantages of using data queues are:

• Using data queues frees a job from performing some work. If


the job is an interactive job, this can provide better response time
and decrease the size of the interactive program and its process
access group (PAG). This, in turn, can help overall system
performance. For example, if several work station users enter a
transaction that involves updating and adding to several files, the
system can perform better if the interactive jobs submit the
request for the transaction to a single batch processing job.

• Data queues are the fastest means of asynchronous


communication between two jobs. Using a data queue to send and
receive data requires less overhead than using database files,
message queues, or data areas to send and receive data.

• You can send to, receive from, and retrieve a description of a


data queue in any HLL procedure or program by calling the
QSNDDTAQ, QRCVDTAQ, QMHRDQM, QCLRDTAQ, and QMHQRDQD
programs without exiting the HLL procedure or program or calling
a CL procedure or program to send, receive, clear, or retrieve the
description.

• When receiving data from a data queue, you can set a time out
such that the job waits until an entry arrives on the data queue.
This differs from using the EOFDLY parameter on the OVRDBF
command, which causes the job to be activated whenever the
delay time ends.

• More than one job can receive data from the same data queue.
This has an
advantage in certain applications where the number of entries to
be processed is greater than one job can handle within the desired
performance restraints. For example, if several printers are
available to print orders, several interactive jobs could send
requests to a single data queue. A separate job for each printer
could receive from the data queue, either in first-in-first-out
(FIFO), last-in-first-out (LIFO), or in keyed-queue order.

• Data queues have the ability to attach a sender ID to each


message being placed on the queue. The sender ID, an attribute of
the data queue which is established when the queue is created,
contains the qualified job name and current user profile.

3. How a data queue is different form a message queue?

Data queues are similar to message queues, in that procedures


and programs can send data to the queue that is received later by
another procedure or program. However, more than one program can
have a receive pending on a data queue at the same time, while only
one program can have a receive pending on a message queue at the
same time. (Only one program receives an entry from a data queue,
even if more than one program is waiting.) Entries on a data queue are
handled in either first-in-first-out, last-in-first-out, or keyed-queue
order. When an entry is received, it is removed from the data queue.

4. What is the difference between Data Queue and Database


Files ?

The following describes the differences between using data


queues and database files:

• Data queues have been improved to communicate between active


procedures and programs, not to store large volumes of data or
large numbers of entries. For these purposes, use database files
as queues.
• Data queues should not be used for long-term storage of data. For
this purpose, you should use database files.
• When using data queues, you should include abnormal end
routines in your programs to recover any entries not yet
completely processed before the system is ended.
• It is good practice to periodically (such as once a day) delete and
re-create a data queue at a safe point. Performance can be
affected if too many entries exist without being removed. Re-
creating the data queue periodically will return the data queue to
its optimal size.

5. What are the different types of messages?


• Informational
• Inquiry
• Completion
• Diagnostic
• Request
• Escape
• Status
• Notify
6. Explain Data Area? What are the different types of Data
Area available in AS/400?

A data area is an object used to hold data for access by any job
running on the system. A data area can be used whenever you need
to store information of limited size, independent of the existence of
procedures or files. Typical uses of data areas are:

• To provide an area (perhaps within each job’s QTEMP


library) to pass information within a job.
• To provide a field that is easily and frequently changed to
control references within a job, such as:
– Supplying the next order number to be assigned
– Supplying the next check number
– Supplying the next save/restore media volume to be
used
• To provide a constant field for use in several jobs, such as
a tax rate or distribution list.
• To provide limited access to a larger process that requires
the data area. A data area can be locked to a single user,
thus preventing other users from processing at the same
time.

Types of Data Area

1. Local Data Area :-

A local data area is created for each job in the system, including
autostart jobs, jobs started on the system by a reader, and
subsystem monitor jobs. The system creates a local data area,
which is initially filled with blanks, with a length of 1024 and type
*CHAR. When you submit a job using the SBMJOB command, the
value of the submitting job’s local data area is copied into the
submitted job’s local data area. You can refer to your job’s local
data area by specifying *LDA for the DTAARA keyword on the
CHGDTAARA, RTVDTAARA, and DSPDTAARA commands or *LDA for
the substring built-in function (%SST).
The following is true of a local data area:
• The local data area cannot be referred to from any other job.
• You cannot create, delete, or allocate a local data area.
• No library is associated with the local data area.
• You cannot change the local data area in a secondary thread.
• The ILE CL compiler generates code to ensure that a procedure
running in a secondary thread cannot access the local data
area while a procedure running in the initial thread is
changing it.

2. Group Data Area: -

The system creates a group data area when an interactive job


becomes a group job (using the Change Group Attributes
[CHGGRPA] command). Only one group data area can exist for a
group. The group data area is deleted when the last job in the
group is ended (with the ENDJOB, SIGNOFF, or ENDGRPJOB
command, or with an abnormal end), or when the job is no longer
part of the group job (using the CHGGRPA command with GRPJOB
*NONE) specified). A group data area, which is initially filled with
blanks, has a length of 512 and type *CHAR. You can use a group
data area from within a group job by specifying *GDA for the
DTAARA parameter on the CHGDTAARA, RTVDTAARA, and
DSPDTAARA commands. A group data area is accessible to all of the
jobs in the group.
The following are true for a group data area:
• You cannot use the group data area as a substitute for a
character variable on the sub string built-in function
(%SUBSTRING or %SST). (You can, however, move a 512-byte
character variable used by the sub string function into or out
of the group data area.)
• A group data area cannot be referred to by jobs outside the
group.
• You cannot create, delete, or allocate a group data area.
• No library is associated with a group data area.

3. Program Initialization Parameter (PIP) Data Area :-

A PIP data area (PDA) is created for each prestart job when the
job is started. The object sub-type of the PDA is different than a
regular data area. The PDA can only be referred to by the special
value name *PDA. The size of the PDA is 2000 bytes but the
number of parameters contained in it is not restricted. The
RTVDTAARA, CHGDTAARA, and DSPDTAARA CL commands and the
RTVDTAARA and CHGDTAARA macro instructions support the
special value *PDA for the data area name parameter.
4. Remote Data Area :-
You can access remote data areas by using Distributed Data
Management (DDM). You do not need to change or recompile an
application program that resides on one AS/400 when it retrieves
data that resides on a remote AS/400. To ensure that you are
accessing the correct data area, you may need to do one of the
following:
• Delete the standard data area and create a DDM data
area that has the same name as the original standard data
area
• Rename the standard data area
7. What is the difference between a batch job and interactive
job?

A batch job does not require constant interaction with the


computer. Once you have submitted a batch job, you are free to do
other work at your workstation without waiting for the job to run. Two
examples of jobs that are commonly run in batch are printing reports
and doing month-end data summaries.

When you are signed on the system, you type one request at a
time (such as selecting an option or typing a command) and the system
responds to each request as it is typed. This session, sometimes called
an interactive job, begins when you sign on a display station and ends
when you sign off. During the session, your interaction with the system
is similar to a conversation. The AS/400 system links together all of the
tasks you do from the time you sign on until you sign off. This makes it
easier for you to manage your work environment, find your output, and
keep track of what you have done.

8. What is Override ?

An override is a CL command that temporarily changes a file


name, a device name, or remote location name associated with the
file, or some of the other attributes of a file. You can enter override
commands interactively from a display station or submit them as
part of a batch job. You can include them in a control language (CL)
program, or issue them from other programs by calling the program
QCMDEXC. Regardless of how they are issued, overrides remain in
effect only for the job, program, or display station session in which
they are issued. Furthermore, they have no effect on other jobs
that may be running at the same time.
9. SNDNETF SNDNETMSG SNDPGMMSG SNDJRNE

The Send Network File (SNDNETF) command sends a save file or a


member of a physical database file to another user on the local system
or on a remote system through the SNADS network.
The Send Network Message (SNDNETMSG) command sends a
message to another user on the local or a remote system through the
SNADS network.

The Send Program Message (SNDPGMMSG) command sends a


message to a named message queue or to a call message queue. A call
message queue can be the *EXT external message queue or a message
queue associated with a call stack entry. Each time a program or
procedure is called a new message queue is associated with its call
stack entry. The message queue is identified by the name of its
associated program or procedure.

The Send Journal Entry (SNDJRNE) command is used to write a single


journal entry to a specific journal. The entry can contain any
information. The user may assign an entry type to the journal entry
and may also associate the journal entry with a specified journaled
object.

10. Can printer file be declared in cl program?


No . The file must either be a database file with only one record

format or be a display file.

11. Can we use Multi format logical file in a CL program ?


No . The file must either be a database file with only one record
format or be a display file.

12. How do u send and receive data to data Queue?

CALL QSNDDTAQ PARM(DTAQ1 QGPL &FLDLEN &FIELD)


CALL QRCVDTAQ PARM(DTAQ1 QGPL &FLDLEN &FIELD &WAIT)

13. How do u send data to data area using CL and RPG?

IN CL :- CHGDTAARA DTAARA((MYLIB/DA1)(5 4))VALUE('value')


IN RPG :-
*NAMVAR DEFN DATAAREA-NAME LOCAL VARIABLE NAME
IN LOCAL VARIABLE NAME
OUT LOCAL VARIABLE NAME
IN ILE RPG :-
*DTARA DEFINE DATAAREA-NAME LOCAL VARIABLE
NAME
IN LOCAL VARIABLE NAME
OUT LOCAL VARIABLE NAME

14. OPNQRYF?? Why do u go for this??

15. What is message queue and job queue?

16. If you are calling pgm PGMB from PGMA and the
command SNDPGMMSG is encountered in PGMB where will
the msg go? [*MSGQ]

17. Name 2 CL commands permitting to copy a file from a


library to other one?

18. How many types of MONMSG are there??


19. How many printer files can you declare in a CL pgm ?

20. Is PGM and ENDPGM mandatory key words in CL pgm ?

21. How many MONMSG commands can you declare in CL


Pgm??

22. What is the advantage open query file?

 Dynamic selection of records


 It will sort the records based on the field values.
 We can retrieve records based on Virtual fields.
 Can create join logical files

25. Various types of message available in CL?

Message is the interface between operating system and the programs or user and program. We can
classify the message into two types namely

 Immediate message
 Predefined message

 Immediate message
Which does the program or system user create when they are sent and are not
permanently stored in the system?
 Control language
 SNDUSRMSG
 SNDPGMMSG
 SNDMSG
 SNDBRKMSG
 Display files
 ERRMSG
 SFLMSG
 INQUIRY and INFORMATIONAL message:
Using SNDUSRMSG command to send type of message
 Predefined message
Which 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.

 Control language
 SNDUSRMSG
 SNDPGMMSG
 RTVMSG

 Display files
 ERRMSGID
 SFLMSGID
 MSGCON
 MSGID
 COMPLETION and DIAGNOSTIC message
 Using SNDPGMMSG command these of message can be sent to any message
queue.
 DIAGNOSTIC message tell the calling program about errors detected by the
program. Completion message tell the result of work done by the program.
 STATUS messages
Using SNDPGMMSG command status message can be sent to it’s caller’s
program message queue or to the external message queue for the job. These message tell
the receiving program the status of the work performed by the sending program.

 ESCAPE message
Using SNDPGMMSG command escape message from a CL program can be sent
to it’s calling program. An escape message tells the calling program ended abnormally
and why.

 NOTTFY message
Notify message from a CL program can be sent to the message queue of calling
program or to the external message queue. A notify message tells the calling program
about a condition under which processing can continue.
 Predefined message are stored in message file
 To create a message file
CRTMSGF MSGF (MFILE) SIZE () AUT() TEXT ()
 Create and maintain messages
ADDMSGD
CHGMSGD OR WRKMSGD
DSPMSGD
RMVMSGD
Message file QCPFMSG in library QSYS contain the system message

26. What will MONMSG command in do?


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.
 Types of monitor message
 Escape Message
 Status or Notify Message
 Escape Message
Escape message are send to tell your program of am error condition that forced the sender
to end. By monitoring for escape message, you can take corrective actions or clean up and end
your program.
 Status or Notify Message
Status and notify message are send to tell your program of an abnormal condition that is
not serious enough for sender to end. By monitoring for status or notify message, your
program can detect this condition and not allow the function to continue.

 Two levels of MONMSG command


 Program level
 Specific command level
 Program level
The MONMSG is specified immediately following the last declare command in your CL
program. You can use as many as 100 program-level MONMSG commands in a program.
 Specific command level
Here the MONMSG command immediately follows a CL command. You can use as
many as 100 commands-level MONMSG commands for a single command.

 Monitor message command syntax


MONMSG MSGID () CMPDTA () EXEC ()
 MSGID-Required
Ex: MSGID (MCH1211)
 CMPDTA –(Optional)
Ex: MONMSG MSGID (MCH1211) CMPDTA (LIB)
 EXEC - -(Optional)
CL command
27 What are the disadvantages of using CL over RPG?
 We can able to read only records but we cannot able to write or update or delete records.
 We can have only one file to be used in a CL program
 We cannot able to use printer files in CL
 We cannot able to use subfile in a CL program
30 How to send the message to the screen SNDPGMMSG?
 BY passing unique message ID message data and message file.
 SNDPGMMSG syntax
 SNDPGM MSG MSGID (MSG0001) MSGF (MSGSUB)
33. What are the various steps in creating OPNQRYF?
Totally five steps involve in creating OPNQRYF
 OVRDBF
 FILE (file PF) TOFILE (LIB/ PF) SHARE (*Yes)
 If a PF is having 100 records and if we want to override the PF so that it
continues only the specific number of records we are using OVRDBF
 OPNQRYF
 FILE (LIB / PF) QRYSLT (‘EMPNO *EQ ‘ *BCAT &A)
 If you want to perform any SQL operation we have to declare in OPNQRYF
command only.
 In case of OPNQRYF we can perform expression only based on characters but
not on numeric.
 *BCAT
If you want to perform any charter expression are using *BCAT
expression which will provide a blanks in between the 2 variables.
 %WLDCRD
 It is similar to %LIKE in SQL
 QRYSLT (‘EMPNAME *EQ %WLDCRD (“S* “)’)
It will fetch all the records whose empname starts from S.
 *CT
 It will fetch all the records, which conditions the particular charter.
 QRYSLT (‘EMPNAME *CT “S” ‘)

 %RANGE
 It will fetch the records within the specific range
 QRYSLT (‘EMPNO *Eq %RANGE (100 110)’)
 CALL PGM (LIB/NAME) PARM ()

 DLTOVR
 As we see early the main file logically overridden and after performing the
necessary operation, we have to delete the logical file so that the main file
contains the actual records for this DLTOVR will be used.
 DLTOVR FILE (OPNPF)
 CLOF
 We have to close the file, which has been opened
 CLOF OPNID (OPNPF)
You will copy overridden file records using CPYFRMQRYF
 CPYFRMQRYF
 Since OVRDBF is logical we cannot able to list the variables, which satisfy the
query condition. To see the records being selected we have to copy from the
source file to a temporary file for this CPYFRMQRYF will be used
 CPYFRMQRYF FROMOPNID (OPNPF) TOFILE (LIB/NAME) MBR
(*REPLACE) CRTFILE (*YES) FMTOPT (*NOCHK)
 RUNQRY
 We have copied the contents satisfy the query into a temporary file using
CPYFRMQRYF. If we run the destination file we got the actual records, which
satisfy the query.
 RUNQRY QRYFILE (LIN/NAME)

Вам также может понравиться