Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

25/09/2K14

EXTERNALLY DESCRIBED FILES.


COMPOSITE KEY RETREIVAL
F<FILE NAME> IF E DISK
*
C EVAL ITEMNO=100 /* SETGT – TO SET THE LIMIT AT THE
GREATER LIMIT*/
C KEYEMP KEYLIST
C KFLD ITEMNO
C KFLD ITEMDESC
C ITEMNO CHAIN ITEML /* TO READ THE ITEM NO WITH 100 USING THE
CHAIN KEYWORD*/
Chain is the random retrieval of record from the keyfields.

C IF %FOUND(ITEML)
C IDESC DSPLY
C ELSE
C ‘NOT FOUND’ DSPLY
C ENDIF
C EVAL *INLR=*ON

When two key fields are present it is possible to retrieve the records only by the first record
format or both the record formats but no only by the second key fields.

READ OPCODES:
E is an extender in that be used to store the error happened during reading the record. It
supports
%error-
%eof - end of file returns a logical value (1 or 0) .
SELECT AND WHEN OPCODES:
SYNTAX:
SELECT
WHEN<>
-
-
-
WHEN<>
-
-
OTHER
-
ENDSL /* END SELECT*/

The various opcodes and their built in functions:


Setll:
%found
%equal
%error
Setgt:
%found
%error
Reade:
%eof
%equal
%error
Chain:
%found

File and record locking


When two users access the file and try to make a update one of the user’s change might get
lost …. That is said to be Phantom update.
1. The usage of chain will lock the record automatically and the update command will unlock
the record automatically.
2. If no update is used then the lock has to be removed explicitly by using unlock <recfmt>.
3. To avoid locking happening use chain(n) where n is the extender of the opcode CHAIN.
The time interval between the users making the update is called the INTERVAL that can be
specified In the file pf level.
DISPLAY FILES
OPEN A NEW MEMBER
SAVE IT
USE OPTION 17
GIVE THE RECORD NAME
IN THE BUILD SCREEN GIVE THE VARIABLES AND CONSTANTS
FOR DATA TYPE DEFINITION
NUM-INPUT-3
NUM-OUTPUT-6
NUM-BOTH-9

CHARINPUTI
CHAROUTPUTO
CHARBOTHB
For example
Employee name  +o(5)/* it shows output mode with 5 characters*/
On enter
Employee name  *00000
(For giving attributes)
Employee name  ?00000
(For changing the default field names)
Save the entries
Go to work with display files screen
Use option 8 to work with keywords
Use indicator keywords
Keyword Response text
CF12 12 exit.
Exfmt will show the values. It will first write values ON the screen and read values from
keyboard.

RPGLE PROGRAM TO CALL THE DISPLAY FILE


SYNTAX
F<DISPLAY FILE NAME> CF E WORKSTN
C EXFMT <DISPLAY FILE RECORD FORMAT NAME>
C EVAL *INLR=*ON

PROGRAM
FEMPDSP CF E WORKSTN
C EXFMT DSPFMT
C EVAL *INLR=*ON

29/09/2K14
To find whether journaling is completed – DSPJRN
TO FIND THE COMMANDS ASSOCIATED WITH THE CST : GO CMDCST
CASCADE-
Allows deletion from the parent and child table
NO ACTION –
Doesn’t allow any deletion to me made in the parent and the child table.
For overflow any indicators above 26 can be used which is a user defined flag.
PRINTER FILE AND RPGLE PROG:
FPROD_PF IF E K DISK
FPROD_PRTF O E PRINTER OFLIND(*IN67)
F INCLUDE(<The Record Format
That Has To Be Read From The Printer File In Which It Is Assigned To The Database File>)
C*
C READ PROD_PF
LF
C IF NOT*INLR
C WRITE (<RECORD FORMAT>)
C ENDIF

ASSIGNMENT 1:
1. Add more than forty records to the PROD_PF physical file.
2. Modify the PROD_PRTF printer file to include a field
PRODCOSTOH R +2 +2REFFLD(ITMCOST) EDTCODE(K)
3. Increase the size of above field by two
4. Add a new record format in the name total
R TOTAL spaceb(1)
1’TOTAL COST OF INVENTORY ON
TOTCOSTOH 53REFFLD(PRODCOST) EDTCDE(k)

5. Include one field by the name TOTCOSTOH . This field should have similar attributes of
PRODCOST field with the additional integer portion increased by four. The value of this field
should be printed at the end of the report under the PRODCOSTOH field . The value of this
field should be the sum of all the values
Formula 1:PRODCOSTOH=PRODCOST*PRODQTYOH/* for every record*/
Formula 2:TOTCOSTOH=TOTCOSTOH+PRODCOSTOH/*Also include the text total cost of
inventory before on the same line before TOTCOSTOH*/

 Write an RPG program to print PRODCOSTOH and TOTCOSTOH
FPROD_PF IF E K DISK
FPROD_PRTF O E PRINTER OFLIND(*IN73)
F INCLUDE(DETAILS)
F INCLUDE(HEADINGS)
DFIRSTPAGE S N INZ(*ON)
**HEADINGS ON FIRST PAGE
C IF FIRSTPAGE
C WRITE HEADING
C EVAL FIRSTPAGE=*OFF
C ENDIF
C READ PROD_PF
LR
C IF NOT *INLR
C EVAL PRODCSTOH=PRODCOST*PRODQTYOH
C EVAL TOTCOSTOH=TOTCOSTOH+PRODCOSTOH
C IF %EOF(PROD_PF)
C EVAL *INLR=*ON
C ELSE
C IF *IN73
C WRITE HEADING /*these three lines are used for
describing the headings on every page*/

C EVAL *IN73=*OFF
C ENDIF
C WRITE DETAILS
C ENDIF
C if *inlr
C if *in73
C write headings
C eval *in73=*off
C endif
C write totcostoh
C endif
 assignment

PHYSICAL FILE:
UNIQUE
R ITCI_FMT
CSTNBR 5 0
CSTNAME 25
CSTSTREET 25
CSTCITY 23
CSTSTATE 2
CSTZIPCODE 5 0
CSTAREACD 3 0
CSTTELNO 7 0
K CSTNBR

Insert records with customer numbers starting with three zero zero zero one(five records).

DESIGN OF THE DISPLAY FILE:


Number of record formats :
PROMPT_FMT
DSPLY_FMT
FITCIDSPF CF E WORKSTN
FITCIPF IF E K DISK
FITCIPRTF 0 E PRINTER
DTODAYSDATE S D
C MOVE UDATE TODAYSDATE
C EXFMT PROMPT_FMT
C DOW NOT *IN03
C EVAL *IN99=*OFF
C CSTNBR CHAIN ITCIPF1
C IF %FOUND(ITCIPF1)
C EXFMT DSPLY_FMT
C IF *IN10
C WRITE CSTFMT <PRINTER FILE RECORD FORMAT>
C ENDIF
C ELSE
C EVAL *IN99=*ON
C ENDIF
C EXFMT PROMPT_FMT
C ENDDO
C EVAL *INLR=*ON

You might also like