15
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.

1. How Do You Handle Inter Process Communication in as/400?

Embed Size (px)

Citation preview

Page 1: 1. How Do You Handle Inter Process Communication in as/400?

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

Parameters Data Queue Data Area

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

Data queues are a type o f sys tem ob ject that you can create , to wh ich one HLLprocedure or program can send data , and f rom which another HLL procedure orprogram can rece ive data . The rece iv ing program can be a l ready wa i t ing for thedata , o r can rece ive the data la ter .

The advantages o f us ing data queues are :

Us ing data queues f rees a job f rom per forming some work . I f the job i s an in teract ive job , th is can prov ide bet ter response t ime and decrease the s i ze o f the in teract ive program and i t s process access group (PAG) . Th is , in turn , can he lp overa l l sys tem per formance. For example , i f severa l work s tat ion users enter a t ransact ion that invo lves updat ing and add ing to severa l f i les , the system can per form bet ter i f the in teract ive jobs submit the request fo r the t ransact ion to a s ing le batch process ing job .

Data queues are the fas test means o f asynchronous communicat ion between two jobs . Us ing a data queue to send and rece ive data requ i res less overhead than us ing database f i les , message queues , o r data areas to send and rece ive data .

You can send to , rece ive f rom, and ret r ieve a descr ip t ion o f a data queue in any HLL procedure or program by ca l l ing the QSNDDTAQ, QRCVDTAQ, QMHRDQM, QCLRDTAQ, and QMHQRDQD programs wi thout ex i t ing the HLL procedure or program or ca l l ing a CL procedure or program to send, rece ive , c lear , o r re t r ieve the descr ip t ion .

When rece iv ing data f rom a data queue, you can set a t ime out such that the job wa i ts unt i l an ent ry ar r ives on the data queue. Th is d i f fe rs f rom us ing the EOFDLY parameter on the OVRDBF command, wh ich causes the job to be act ivated whenever the de lay t ime ends .

More than one job can rece ive data f rom the same data queue. Th is has anadvantage in cer ta in app l icat ions where the number o f ent r ies to be processed i s greater than one job can hand le w i th in the des i red per formance rest ra ints . For example , i f severa l pr in ters are

Page 2: 1. How Do You Handle Inter Process Communication in as/400?

ava i lab le to pr in t orders , severa l in teract ive jobs cou ld send requests to a s ing le data queue. A separate job for each pr in ter cou ld rece ive f rom the data queue, e i ther in f i r s t - in - f i r s t -out (F IFO) , las t - in - f i r s t -out (L IFO) , o r in keyed-queue order .

Data queues have the ab i l i ty to a t tach a sender ID to each message be ing p laced on the queue. The sender ID , an at t r ibute o f the data queue which i s es tab l i shed when the queue i s c reated, conta ins the qua l i f ied job name and cur rent user pro f i le .

3. How a data queue is di f ferent form a message queue?

Data queues are s imi la r to message queues , in that procedures and programs can send data to the queue that i s rece ived la ter by another procedure or program. However , more than one program can have a rece ive pend ing on a data queue at the same t ime, wh i le on ly one program can have a rece ive pend ing on a message queue at the same t ime. (On ly one program rece ives an ent ry f rom a data queue, even i f more than one program is wa i t ing . ) Ent r ies on a data queue are hand led in e i ther f i r s t - in - f i r s t -out , las t - in - f i r s t -out , o r keyed-queue order . When an ent ry i s rece ived, i t i s removed f rom the data queue.

4. What is the dif ference between Data Queue and Database Fi les ?

The fo l lowing descr ibes the d i f fe rences between us ing data queues and database f i les :

Data queues have been improved to communicate between act ive procedures and programs, not to s tore la rge vo lumes o f data or la rge numbers o f ent r ies . For these purposes , use database f i les as queues .

Data queues shou ld not be used for long- term s torage o f data . For th is purpose , you shou ld use database f i les .

When us ing data queues , you shou ld inc lude abnormal end rout ines in your programs to recover any ent r ies not yet complete ly processed before the system is ended.

I t i s good pract ice to per iod ica l ly (such as once a day) de lete and re -create a data queue at a sa fe po int . Per formance can be a f fected i f too many ent r ies ex is t w i thout be ing removed. Re-creat ing the data queue per iod ica l ly w i l l re turn the data queue to i t s opt imal s i ze .

5. What are the dif ferent types of messages?

Page 3: 1. How Do You Handle Inter Process Communication in as/400?

In format iona l Inqu i ry Complet ion Diagnost ic Request Escape Status Not i fy

6. Explain Data Area? What are the dif ferent types of Data Area avai lable in AS/400?

A data area i s an ob ject used to ho ld data for access by any job runn ing on the system. A data area can be used whenever you need to s tore in format ion o f l imi ted s i ze , independent o f the ex is tence o f procedures or f i les . Typ ica l uses o f data areas are :

To prov ide an area (perhaps w i th in each job ’s QTEMP l ib rary) to pass in format ion w i th in a job .

To prov ide a f ie ld that i s eas i ly and f requent ly changed to cont ro l re ferences w i th in a job , such as :

– Supp ly ing the next order number to be ass igned– Supp ly ing the next check number– Supp ly ing the next save/ restore media vo lume to be

used To prov ide a constant f ie ld for use in severa l jobs , such as

a tax rate or d is t r ibut ion l i s t . To prov ide l imi ted access to a la rger process that requ i res

the data area . A data area can be locked to a s ing le user , thus prevent ing other users f rom process ing at the same t ime.

Types of Data Area

1. Loca l Data Area : -

A loca l data area i s c reated for each job in the system, inc lud ing autostar t jobs , jobs s tar ted on the system by a reader , and subsystem moni tor jobs . The system creates a loca l data area , wh ich i s in i t ia l ly f i l l ed w i th b lanks , w i th a length o f 1024 and type *CHAR. When you submit a job us ing the SBMJOB command, the va lue o f the submit t ing job ’s loca l data area i s cop ied in to the submit ted job ’s loca l data area . You can re fer to your job ’s loca l data area by spec i fy ing *LDA for the DTAARA keyword on the CHGDTAARA, RTVDTAARA, and DSPDTAARA commands or *LDA for the subst r ing bu i l t - in funct ion (%SST) . The fo l lowing i s t rue o f a loca l data area:

The loca l data area cannot be re fer red to f rom any other job . You cannot c reate , de lete , o r a l locate a loca l data area . No l ib rary i s assoc ia ted w i th the loca l data area . You cannot change the loca l data area in a secondary thread. The ILE CL compi ler generates code to ensure that a procedure

runn ing in a secondary thread cannot access the loca l data

Page 4: 1. How Do You Handle Inter Process Communication in as/400?

area whi le a procedure runn ing in the in i t ia l thread i s chang ing i t .

2 . Group Data Area: -

The system creates a group data area when an in teract ive job becomes a group job (us ing the Change Group At t r ibutes [CHGGRPA] command) . On ly one group data area can ex is t fo r a group. The group data area i s de leted when the las t job in the group i s ended (w i th the ENDJOB, S IGNOFF, or ENDGRPJOB command, or w i th an abnormal end) , o r when the job i s no longer par t o f the group job (us ing the CHGGRPA command wi th GRPJOB *NONE) spec i f ied) . A group data area , wh ich i s in i t ia l ly f i l l ed w i th b lanks , has a length o f 512 and type *CHAR. You can use a group data area f rom wi th in a group job by spec i fy ing *GDA for the DTAARA parameter on the CHGDTAARA, RTVDTAARA, and DSPDTAARA commands . A group data area i s access ib le to a l l o f the jobs in the group.The fo l lowing are t rue for a group data area:

You cannot use the group data area as a subst i tu te for a character var iab le on the sub s t r ing bu i l t - in funct ion (%SUBSTRING or %SST) . (You can, however , move a 512-byte character var iab le used by the sub s t r ing funct ion in to or out o f the group data area . )

A group data area cannot be re fer red to by jobs outs ide the group.

You cannot c reate , de lete , o r a l locate a group data area . No l ib rary i s assoc ia ted w i th a group data area .

3 . Program In i t ia l i zat ion Parameter (P IP ) Data Area : -

A P IP data area (PDA) i s c reated for each prestar t job when the job i s s tar ted . The ob ject sub- type o f the PDA i s d i f fe rent than a regu lar data area . The PDA can on ly be re fer red to by the spec ia l va lue name *PDA. The s i ze o f the PDA i s 2000 bytes but the number o f parameters conta ined in i t i s not res t r i c ted . The RTVDTAARA, CHGDTAARA, and DSPDTAARA CL commands and the RTVDTAARA and CHGDTAARA macro ins t ruct ions suppor t the spec ia l va lue *PDA for the data area name parameter .

4 . Remote Data Area : - You can access remote data areas by us ing D is t r ibuted Data

Management (DDM) . You do not need to change or recompi le an app l icat ion program that res ides on one AS/400 when i t re t r ieves data that res ides on a remote AS/400. To ensure that you are access ing the cor rect data area , you may need to do one o f the fo l lowing:

Delete the s tandard data area and create a DDM data area that has the same name as the or ig ina l s tandard data area

Rename the s tandard data area

Page 5: 1. How Do You Handle Inter Process Communication in as/400?

7. What is the dif ference between a batch job and interact ive job?

A batch job does not requ i re constant in teract ion w i th the

computer . Once you have submit ted a batch job , you are f ree to do

other work at your workstat ion w i thout wa i t ing for the job to run . Two

examples o f jobs that are commonly run in batch are pr in t ing repor ts

and do ing month-end data summar ies .

When you are s igned on the system, you type one request a t a

t ime (such as se lect ing an opt ion or typ ing a command) and the system

responds to each request as i t i s typed. Th is sess ion , somet imes ca l led

an interact ive job, beg ins when you s ign on a d isp lay s tat ion and ends

when you s ign o f f . Dur ing the sess ion , your in teract ion w i th the system

is s imi la r to a conversat ion . The AS/400 system l inks together a l l o f the

tasks you do f rom the t ime you s ign on unt i l you s ign o f f . Th is makes i t

eas ier fo r you to manage your work env i ronment , f ind your output , and

keep t rack o f what you have done.

8. What is Overr ide ?

An overr ide i s a CL command that temporar i ly changes a f i le name, a dev ice name, or remote locat ion name assoc iated w i th the f i le , o r some of the other a t t r ibutes o f a f i le . You can enter overr ide commands in teract ive ly f rom a d isp lay s tat ion or submit them as par t o f a batch job . You can inc lude them in a cont ro l language (CL) program, or i ssue them f rom other programs by ca l l ing the program QCMDEXC. Regard less o f how they are i ssued, overr ides remain in e f fect on ly for the job , program, or d isp lay s tat ion sess ion in wh ich they are i ssued. Fur thermore , they have no e f fect on other jobs that may be runn ing at the same t ime.

9. SNDNETF SNDNETMSG SNDPGMMSG SNDJRNE

The Send Network Fi le (SNDNETF) command sends a save f i le or a

member o f a phys ica l database f i le to another user on the loca l sys tem

or on a remote system through the SNADS network .

The Send Network Message (SNDNETMSG) command sends a

message to another user on the loca l o r a remote system through the

SNADS network .

Page 6: 1. How Do You Handle Inter Process Communication in as/400?

The Send Program Message (SNDPGMMSG) command sends a

message to a named message queue or to a ca l l message queue. A ca l l

message queue can be the *EXT externa l message queue or a message

queue assoc iated w i th a ca l l s tack ent ry . Each t ime a program or

procedure i s ca l led a new message queue i s assoc ia ted w i th i t s ca l l

s tack ent ry . The message queue i s ident i f ied by the name of i t s

assoc ia ted program or procedure .

The Send Journal Entry (SNDJRNE) command i s used to wr i te a s ing le

journa l ent ry to a spec i f i c journa l . The ent ry can conta in any

in format ion . The user may ass ign an ent ry type to the journa l ent ry

and may a lso assoc ia te the journa l ent ry w i th a spec i f ied journa led

ob ject .

10. Can pr inter f i le be declared in c l program? No . The f i le must e i ther be a database f i le w i th on ly one record

fo rmat or be a d isp lay f i le .

11. Can we use Mult i format logical f i le in a CL program ? No . The f i le must e i ther be a database f i le w i th on ly 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((MYL IB /DA1) (5 4) )VALUE( 'va lue ' )

IN RPG : - *NAMVAR DEFN DATAAREA-NAME LOCAL VARIABLE NAME

IN LOCAL VARIABLE NAME OUT LOCAL VARIABLE NAME IN ILE RPG : -

Page 7: 1. How Do You Handle Inter Process Communication in as/400?

*DTARA DEF INE 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. I f you are cal l ing pgm PGMB from PGMA and the command SNDPGMMSG is encountered in PGMB where wi l l the msg go? [*MSGQ]

17. Name 2 CL commands permitt ing to copy a f i le from a l ibrary to other one?

18. How many types of MONMSG are there??19. How many pr inter f i les 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

Page 8: 1. How Do You Handle Inter Process Communication in as/400?

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

Page 9: 1. How Do You Handle Inter Process Communication in as/400?

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.

Page 10: 1. How Do You Handle Inter Process Communication in as/400?

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

Page 11: 1. How Do You Handle Inter Process Communication in as/400?

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

Page 12: 1. How Do You Handle Inter Process Communication in as/400?

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)